Skip to content

Commit 4835c57

Browse files
committed
feat: add StylelintConfig
1 parent 27b9482 commit 4835c57

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

src/config/index.d.ts

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
import type { CustomSyntax, Plugin, Rule, Severity } from 'stylelint'
2+
import type { Rules } from '../rules'
3+
import type { Plugins } from './plugins'
4+
import type { KnownCustomSyntax } from './customSyntax'
5+
import type { KnownExtends } from './extends'
6+
7+
export interface PluginFunctions {
8+
[pluginName: string]: Rule
9+
}
10+
11+
/**
12+
* specify what subset of files to apply a configuration to.
13+
*/
14+
export interface Override extends Omit<StylelintConfig, 'overrides'> {
15+
/**
16+
* Which is an array of glob patterns that specify which files
17+
* the configuration should be applied to
18+
*/
19+
files: string | string[]
20+
}
21+
22+
/**
23+
* Stylelint configuration
24+
* @see [Stylelint configuration](https://stylelint.io/user-guide/configure)
25+
*/
26+
export interface StylelintConfig {
27+
/**
28+
* Automatically fix, where possible, problems reported by rules.
29+
*
30+
* @see [Configure fix](https://stylelint.io/user-guide/configure#fix)
31+
*/
32+
fix?: boolean
33+
34+
/**
35+
* Store the results of processed files so that Stylelint only operates on the changed ones.
36+
*
37+
* @see [Configure cache](https://stylelint.io/user-guide/configure#cache)
38+
*
39+
*/
40+
cache?: boolean
41+
42+
/**
43+
* If `true`, Only register problems for rules with an "error"-level
44+
* severity (ignore "warning"-level).
45+
*/
46+
quiet?: boolean
47+
48+
/**
49+
* Stylelint does not throw an error when the glob pattern matches no files.
50+
*
51+
* @see [Configure allowEmptyInput](https://stylelint.io/user-guide/configure#allowemptyinput)
52+
*/
53+
allowEmptyInput?: boolean
54+
55+
/**
56+
* You can provide a glob or array of globs to ignore specific files.
57+
*
58+
* Stylelint ignores the `node_modules` directory by default.
59+
* However, this is overridden if ignoreFiles is set.
60+
*
61+
* If the globs are absolute paths, they are used as is.
62+
* If they are relative, they are analyzed relative to
63+
* - `configBasedir`, if it's provided;
64+
* - the config's filepath, if the config is a file that Stylelint found and loaded;
65+
* - or `process.cwd()`.
66+
*
67+
* @see [Configure ignoreFiles](https://stylelint.io/user-guide/configure#ignorefiles)
68+
*/
69+
ignoreFiles?: string | string[]
70+
71+
/**
72+
* Pattern of files to ignore (in addition to those in `.stylelintignore` ).
73+
*/
74+
ignorePatterns?: string
75+
76+
/**
77+
* Ignore stylelint-disable (e.g. `// stylelint-disable block-no-empty`) comments.
78+
*
79+
* You can use this option to see what your linting results would be like without those exceptions.
80+
*
81+
* @see [Configure ignoreDisables](https://stylelint.io/user-guide/configure#ignoredisables)
82+
*/
83+
ignoreDisables?: boolean
84+
85+
/**
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.
87+
*/
88+
configurationComment?: string
89+
90+
/**
91+
* Report `stylelint-disable` comments without a description.
92+
*
93+
* @see [Report descriptionless disables](https://stylelint.io/user-guide/options#reportdescriptionlessdisables)
94+
*/
95+
reportDescriptionlessDisables?: boolean
96+
97+
/**
98+
* Report `stylelint-disable` comments that don't match rules that are specified in the configuration object.
99+
*
100+
* @see [Report invalid scope disables](https://stylelint.io/user-guide/options#reportinvalidscopedisables)
101+
*/
102+
reportInvalidScopeDisables?: boolean
103+
104+
/**
105+
* Report stylelint-disable comments that don't match any lints that need to be disabled.
106+
*
107+
* @see [Report needless disables](https://stylelint.io/user-guide/options#reportneedlessdisables)
108+
*/
109+
reportNeedlessDisables?: boolean
110+
111+
/**
112+
* You can set the default severity level for all rules that do not have a severity specified in their secondary options.
113+
*
114+
* @see [Default Severity](https://stylelint.io/user-guide/configure#defaultseverity)
115+
* @example
116+
* ```json
117+
* {
118+
* "defaultSeverity": "warning",
119+
* }
120+
* ```
121+
*/
122+
defaultSeverity?: Severity
123+
124+
/**
125+
* You can extend an existing configuration (whether your own or a third-party one).
126+
* Configurations can bundle plugins, custom syntaxes, options, and configure rules.
127+
* They can also extend other configurations.
128+
*
129+
* For example, {@link https://github.com/stylelint/stylelint-config-standard stylelint-config-standard} is one of our official configs that you can extend.
130+
*
131+
* When one configuration extends another,
132+
* it starts with the other's properties and then adds to and overrides what's there.
133+
*
134+
* @see [Configure extends](https://stylelint.io/user-guide/configure#extends)
135+
* @example
136+
* ```json
137+
* {
138+
* "extends": "stylelint-config-standard",
139+
* }
140+
* ```
141+
*/
142+
extends?: KnownExtends | KnownExtends[]
143+
/**
144+
* Plugins are custom rules or sets of custom rules built to support methodologies,
145+
* toolsets, non-standard CSS features, or very specific use cases.
146+
*
147+
* @see [Configure plugins](https://stylelint.io/user-guide/configure#plugins)
148+
*/
149+
plugins?: Plugins
150+
151+
/**
152+
* plugin functions
153+
*/
154+
pluginFunctions?: PluginFunctions
155+
/**
156+
* Specify what subset of files to apply a configuration to.
157+
* - must contain a `files` property, which is an array of glob patterns that specify which files the configuration should be applied to
158+
* - should contain at least one other regular configuration property, such as `customSyntax`, `rules`, `extends`, etc.
159+
*
160+
* @see [Configure overrides](https://stylelint.io/user-guide/configure#overrides)
161+
*/
162+
overrides?: Override[]
163+
164+
/**
165+
* Specify a custom syntax to use on your code.
166+
*
167+
* This option allows Stylelint to transform these into something that resembles CSS,
168+
* which is the language that:
169+
* - underpins all the other styling languages
170+
* - is best understood by rules built into Stylelint
171+
*
172+
* This option should be a string that resolves to a JS module that exports a
173+
* {@link https://github.com/postcss/postcss#syntaxes PostCSS-compatible syntax}.
174+
* The string can be a module name (like `my-module`)
175+
* or a path to a JS file (like `path/to/my-module.js`).
176+
*
177+
* @see [Configure customSyntax](https://stylelint.io/user-guide/options#customsyntax)
178+
*/
179+
customSyntax?: KnownCustomSyntax | Exclude<CustomSyntax, string>
180+
181+
/**
182+
* Rules determine what the linter looks for and complains about.
183+
*
184+
* @see [Rules](https://stylelint.io/user-guide/rules)
185+
*/
186+
rules?: Partial<Rules>
187+
}
188+
189+
export { CustomSyntax, Severity }

0 commit comments

Comments
 (0)