Skip to content

Commit afb544e

Browse files
committed
feat: add rule desc
1 parent 79f013c commit afb544e

File tree

8 files changed

+1413
-63
lines changed

8 files changed

+1413
-63
lines changed

src/config/customSyntax.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import type { LiteralUnion } from '../utils'
22

3+
/**
4+
* This is a special exported interface for other packages to declare
5+
* additional types that should bail out for stylelint postcss custom syntax. For example
6+
* `stylelint-scss` can declare it like so in its `d.ts`:
7+
*
8+
* ```ts
9+
* declare module 'stylelint-define-config' {
10+
* export interface CustomSyntax {
11+
* 'postcss-scss': void;
12+
*
13+
* // ... more syntax
14+
* }
15+
* }
16+
* ```
17+
*/
318
export interface CustomSyntax {}
419

520
export type KnownCustomSyntax = LiteralUnion<

src/config/extends.d.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
import type { LiteralUnion } from '../utils'
22

3+
/**
4+
* This is a special exported interface for other packages to declare
5+
* additional types that should bail out for stylelint extends. For example
6+
* `stylelint-scss` can declare it like so in its `d.ts`:
7+
*
8+
* ```ts
9+
* declare module 'stylelint-define-config' {
10+
* export interface CustomExtends {
11+
* 'stylelint-config-standard-scss': void;
12+
*
13+
* // ... more extends
14+
* }
15+
* }
16+
* ```
17+
*/
318
export interface CustomExtends {}
419

520
export type KnownExtends = LiteralUnion<
621
| 'stylelint-config-standard'
722
| 'stylelint-config-standard-scss'
8-
| 'stylelint-config-recess-order'
9-
| 'stylelint-config-rational-order'
1023
| 'stylelint-config-prettier'
1124
| 'stylelint-config-prettier-scss'
1225
| 'stylelint-config-recommended-vue'
13-
| 'stylelint-config-sass-guidelines'
14-
| 'stylelint-config-primer'
15-
| 'stylelint-config-wikimedia'
16-
| 'stylelint-config-wordpress'
1726
| keyof CustomExtends
1827
>

src/config/index.d.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface PluginFunctions {
88
[pluginName: string]: Rule
99
}
1010

11+
export type Extends = KnownExtends | StylelintConfig
12+
1113
/**
1214
* specify what subset of files to apply a configuration to.
1315
*/
@@ -70,6 +72,13 @@ export interface StylelintConfig {
7072

7173
/**
7274
* Pattern of files to ignore (in addition to those in `.stylelintignore` ).
75+
* @see [Configure ignorePatterns](https://stylelint.io/user-guide/configure#ignorefiles)
76+
* @example
77+
* ```json
78+
* {
79+
* "ignorePatterns": ["**\/*.js"]
80+
* }
81+
* ```
7382
*/
7483
ignorePatterns?: string
7584

@@ -83,7 +92,18 @@ export interface StylelintConfig {
8392
ignoreDisables?: boolean
8493

8594
/**
86-
* You can set what configuration comments like `\/* stylelint-disable *\/` start with.This can be useful if you use multiple instances of Stylelint with different configurations.
95+
* You can set what configuration comments like `\/* stylelint-disable *\/` start with.
96+
* This can be useful if you use multiple instances of Stylelint with different configurations.
97+
*
98+
* For example, to have an instance of Stylelint disable rules with \/* stylelint-foo-instance-disable *\/ instead of the default \/* stylelint-disable *\/:
99+
*
100+
* @see [configuration comment](https://stylelint.io/user-guide/configure#configurationcomment)
101+
* @example
102+
* ```json
103+
* {
104+
* "configurationComment": "stylelint-foo-instance"
105+
* }
106+
* ```
87107
*/
88108
configurationComment?: string
89109

@@ -139,12 +159,18 @@ export interface StylelintConfig {
139159
* }
140160
* ```
141161
*/
142-
extends?: KnownExtends | KnownExtends[]
162+
extends?: Extends | Extends[]
143163
/**
144164
* Plugins are custom rules or sets of custom rules built to support methodologies,
145165
* toolsets, non-standard CSS features, or very specific use cases.
146166
*
147167
* @see [Configure plugins](https://stylelint.io/user-guide/configure#plugins)
168+
* @example
169+
* ```json
170+
* {
171+
* "plugins": ["stylelint-scss"],
172+
* }
173+
* ```
148174
*/
149175
plugins?: Plugins
150176

src/config/plugins.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LiteralUnion } from '../utils'
33

44
/**
55
* This is a special exported interface for other packages to declare
6-
* additional plugins that should bail out for eslint plugins. For example
6+
* additional plugins that should bail out for stylelint plugins. For example
77
* `'stylelint-scss'` can declare it like so in its `d.ts`:
88
*
99
* ```ts
@@ -18,7 +18,7 @@ export interface CustomPlugins {}
1818

1919
type KnownPlugins = LiteralUnion<
2020
| 'stylelint-order' | 'stylelint-scss' | 'stylelint-stylistic' | 'stylelint-stylus'
21-
| 'stylelint-suitcss' | 'stylelint-react-native' | 'stylelint-selector-bem-pattern'
21+
| 'stylelint-suitcss' | 'stylelint-react-native' | 'stylelint-codeguide'
2222
| keyof CustomPlugins
2323
>
2424

src/rules/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StyleLintRules } from './stylelint'
33

44
/**
55
* This is a special exported interface for other packages to declare
6-
* additional types that should bail out for eslint rules. For example
6+
* additional types that should bail out for stylelint rules. For example
77
* `stylelint-scss` can declare it like so in its `d.ts`:
88
*
99
* ```ts

src/rules/rule-config.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export interface SecondaryOptions {
2828
message?: string | ((...args: any[]) => string)
2929
}
3030

31+
/**
32+
* declaration rule config.
33+
*
34+
* `RuleConfig<PrimaryOptions, SecondaryOptions>`
35+
*/
3136
export type RuleConfig<T, S extends Record<string, any> = Record<string, any>>
3237
= null
3338
| undefined

0 commit comments

Comments
 (0)