1 | import type * as PostCSS from 'postcss';
|
2 | import type { GlobbyOptions } from 'globby';
|
3 | import type { cosmiconfig, TransformSync as CosmiconfigTransformSync } from 'cosmiconfig';
|
4 |
|
5 | type ConfigExtends = string | string[];
|
6 |
|
7 | type ConfigPlugins = string | stylelint.Plugin | (string | stylelint.Plugin)[];
|
8 |
|
9 | type ConfigIgnoreFiles = string | string[];
|
10 |
|
11 | type ConfigRules = {
|
12 | [ruleName: string]: stylelint.ConfigRuleSettings<any, Object>;
|
13 | };
|
14 |
|
15 | type ConfigOverride = Omit<stylelint.Config, 'overrides'> & {
|
16 | files: string | string[];
|
17 | name?: string;
|
18 | };
|
19 |
|
20 | type ConfigProcessors = string[];
|
21 |
|
22 | type DisableSettings = stylelint.ConfigRuleSettings<boolean, stylelint.DisableOptions>;
|
23 |
|
24 |
|
25 |
|
26 | type PropertyNamesOfType<T, U> = {
|
27 | [K in keyof T]-?: T[K] extends U ? K : never;
|
28 | }[keyof T];
|
29 |
|
30 | type FileCache = {
|
31 | calcHashOfConfig: (config: stylelint.Config) => void;
|
32 | hasFileChanged: (absoluteFilepath: string) => boolean;
|
33 | reconcile: () => void;
|
34 | destroy: () => void;
|
35 | removeEntry: (absoluteFilepath: string) => void;
|
36 | };
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | type RuleMessageFunc = {
|
45 | bivariance(...args: (string | number | boolean | RegExp)[]): string;
|
46 | }['bivariance'];
|
47 |
|
48 | type RuleSeverityFunc = {
|
49 | bivariance(...args: (string | number | boolean | RegExp)[]): stylelint.Severity | null;
|
50 | }['bivariance'];
|
51 |
|
52 | type RuleOptionsPossibleFunc = (value: unknown) => boolean;
|
53 |
|
54 | type DisableReportEntry = {
|
55 | source?: string;
|
56 | ranges: stylelint.DisableReportRange[];
|
57 | };
|
58 |
|
59 | declare namespace stylelint {
|
60 | |
61 |
|
62 |
|
63 | export type Severity = 'warning' | 'error';
|
64 |
|
65 | |
66 |
|
67 |
|
68 | export type Plugin =
|
69 | | { default?: { ruleName: string; rule: Rule } }
|
70 | | { ruleName: string; rule: Rule };
|
71 |
|
72 |
|
73 | export type ConfigRuleSettings<T, O extends Object> =
|
74 | | null
|
75 | | undefined
|
76 | | NonNullable<T>
|
77 | | [NonNullable<T>]
|
78 | | [NonNullable<T>, O];
|
79 |
|
80 |
|
81 | export type DisableOptions = {
|
82 | except?: Array<StringOrRegex>;
|
83 | severity?: Severity;
|
84 | };
|
85 |
|
86 | |
87 |
|
88 |
|
89 | export type Config = {
|
90 | extends?: ConfigExtends;
|
91 | plugins?: ConfigPlugins;
|
92 | pluginFunctions?: {
|
93 | [pluginName: string]: Rule;
|
94 | };
|
95 | ignoreFiles?: ConfigIgnoreFiles;
|
96 | ignorePatterns?: string;
|
97 | rules?: ConfigRules;
|
98 | quiet?: boolean;
|
99 | formatter?: FormatterType | Formatter;
|
100 | defaultSeverity?: Severity;
|
101 | ignoreDisables?: boolean;
|
102 | reportNeedlessDisables?: DisableSettings;
|
103 | reportInvalidScopeDisables?: DisableSettings;
|
104 | reportDescriptionlessDisables?: DisableSettings;
|
105 | reportUnscopedDisables?: DisableSettings;
|
106 | configurationComment?: string;
|
107 | overrides?: ConfigOverride[];
|
108 | customSyntax?: CustomSyntax;
|
109 | processors?: ConfigProcessors;
|
110 |
|
111 | _processorFunctions?: Map<string, ReturnType<Processor>['postprocess']>;
|
112 | allowEmptyInput?: boolean;
|
113 | cache?: boolean;
|
114 | fix?: boolean;
|
115 | validate?: boolean;
|
116 | };
|
117 |
|
118 |
|
119 | export type DisablePropertyName = PropertyNamesOfType<Config, DisableSettings>;
|
120 |
|
121 |
|
122 | export type CosmiconfigResult =
|
123 | | (ReturnType<CosmiconfigTransformSync> & { config: Config })
|
124 | | null;
|
125 |
|
126 |
|
127 | export type DisabledRange = {
|
128 | node: PostCSS.Node;
|
129 | start: number;
|
130 | strictStart: boolean;
|
131 | end?: number;
|
132 | strictEnd?: boolean;
|
133 | rules?: string[];
|
134 | description?: string;
|
135 | };
|
136 |
|
137 |
|
138 | export type DisabledRangeObject = {
|
139 | [ruleName: string]: DisabledRange[];
|
140 | };
|
141 |
|
142 |
|
143 | export type DisabledWarning = { line: number; rule: string };
|
144 |
|
145 |
|
146 | export type StylelintPostcssResult = {
|
147 | ruleSeverities: { [ruleName: string]: RuleSeverity };
|
148 | customMessages: { [ruleName: string]: RuleMessage };
|
149 | customUrls: { [ruleName: string]: string };
|
150 | ruleMetadata: { [ruleName: string]: Partial<RuleMeta> };
|
151 | fixersData: { [ruleName: string]: Array<FixerData> };
|
152 | quiet?: boolean;
|
153 | disabledRanges: DisabledRangeObject;
|
154 | disabledWarnings?: DisabledWarning[];
|
155 | ignored?: boolean;
|
156 | stylelintError?: boolean;
|
157 | stylelintWarning?: boolean;
|
158 | config?: Config;
|
159 | };
|
160 |
|
161 | type StylelintWarningType = 'deprecation' | 'invalidOption' | 'parseError';
|
162 |
|
163 |
|
164 | export type WarningOptions = PostCSS.WarningOptions & {
|
165 | stylelintType?: StylelintWarningType;
|
166 | severity?: Severity;
|
167 | url?: string;
|
168 | rule?: string;
|
169 | };
|
170 |
|
171 |
|
172 | export type PostcssResult = PostCSS.Result & {
|
173 | stylelint: StylelintPostcssResult;
|
174 | warn(message: string, options?: WarningOptions): void;
|
175 | };
|
176 |
|
177 |
|
178 | export type Formatter = (results: LintResult[], returnValue: LinterResult) => string;
|
179 |
|
180 | type Formatters = {
|
181 | readonly compact: Promise<Formatter>;
|
182 |
|
183 | readonly github: Promise<Formatter>;
|
184 | readonly json: Promise<Formatter>;
|
185 | readonly string: Promise<Formatter>;
|
186 | readonly tap: Promise<Formatter>;
|
187 | readonly unix: Promise<Formatter>;
|
188 | readonly verbose: Promise<Formatter>;
|
189 | };
|
190 |
|
191 |
|
192 | export type FormatterType = keyof Formatters;
|
193 |
|
194 |
|
195 | export type CustomSyntax = string | PostCSS.Syntax;
|
196 |
|
197 | |
198 |
|
199 |
|
200 | export type Processor = () => {
|
201 | name: string;
|
202 | postprocess: (result: LintResult, root?: PostCSS.Root) => void;
|
203 | };
|
204 |
|
205 |
|
206 | export type RuleMessage = string | RuleMessageFunc;
|
207 |
|
208 |
|
209 | export type RuleMessages = { [message: string]: RuleMessage };
|
210 |
|
211 |
|
212 | export type RuleOptionsPossible = boolean | number | string | RuleOptionsPossibleFunc;
|
213 |
|
214 |
|
215 | export type RuleOptions = {
|
216 | actual: unknown;
|
217 | possible?:
|
218 | | RuleOptionsPossibleFunc
|
219 | | RuleOptionsPossible[]
|
220 | | Record<string, RuleOptionsPossible[]>;
|
221 | optional?: boolean;
|
222 | };
|
223 |
|
224 |
|
225 | type RuleSeverity = Severity | RuleSeverityFunc;
|
226 |
|
227 | |
228 |
|
229 |
|
230 | export type RuleContext = {
|
231 | configurationComment?: string | undefined;
|
232 | fix?: boolean | undefined;
|
233 | newline?: string | undefined;
|
234 | };
|
235 |
|
236 |
|
237 | export type RuleBase<P = any, S = any> = (
|
238 | primaryOption: P,
|
239 | secondaryOptions: S,
|
240 | context: RuleContext,
|
241 | ) => (root: PostCSS.Root, result: PostcssResult) => Promise<void> | void;
|
242 |
|
243 |
|
244 | export type RuleMeta = {
|
245 | url: string;
|
246 | deprecated?: boolean;
|
247 | fixable?: boolean;
|
248 | };
|
249 |
|
250 |
|
251 | export type Range = {
|
252 | start: Position;
|
253 | end: Position;
|
254 | };
|
255 |
|
256 | type FixerData = {
|
257 | range?: Range;
|
258 | fixed: boolean;
|
259 | };
|
260 |
|
261 | |
262 |
|
263 |
|
264 | export type Rule<P = any, S = any> = RuleBase<P, S> & {
|
265 | ruleName: string;
|
266 | messages: RuleMessages;
|
267 | primaryOptionArray?: boolean;
|
268 | meta?: RuleMeta;
|
269 | };
|
270 |
|
271 | type StringOrRegex = string | RegExp;
|
272 | type OneOrMany<S> = S | S[];
|
273 | type Primary = number | true | OneOrMany<StringOrRegex> | Record<string, any>;
|
274 | type Secondary = Record<string, any>;
|
275 | type CoreRule<P extends Primary, S extends Secondary = any> = Rule<P, S>;
|
276 |
|
277 |
|
278 | export type CoreRules = {
|
279 | 'alpha-value-notation': CoreRule<
|
280 | 'number' | 'percentage',
|
281 | { exceptProperties: OneOrMany<StringOrRegex> }
|
282 | >;
|
283 | 'annotation-no-unknown': CoreRule<true, { ignoreAnnotations: OneOrMany<StringOrRegex> }>;
|
284 | 'at-rule-allowed-list': CoreRule<OneOrMany<string>>;
|
285 | 'at-rule-disallowed-list': CoreRule<OneOrMany<string>>;
|
286 | 'at-rule-empty-line-before': CoreRule<
|
287 | 'always' | 'never',
|
288 | {
|
289 | except: OneOrMany<
|
290 | | 'after-same-name'
|
291 | | 'inside-block'
|
292 | | 'blockless-after-same-name-blockless'
|
293 | | 'blockless-after-blockless'
|
294 | | 'first-nested'
|
295 | >;
|
296 | ignore: OneOrMany<
|
297 | | 'after-comment'
|
298 | | 'first-nested'
|
299 | | 'inside-block'
|
300 | | 'blockless-after-same-name-blockless'
|
301 | | 'blockless-after-blockless'
|
302 | >;
|
303 | ignoreAtRules: OneOrMany<string>;
|
304 | }
|
305 | >;
|
306 | 'at-rule-no-unknown': CoreRule<true, { ignoreAtRules: OneOrMany<StringOrRegex> }>;
|
307 | 'at-rule-no-vendor-prefix': CoreRule<true>;
|
308 | 'at-rule-property-required-list': CoreRule<Record<string, OneOrMany<string>>>;
|
309 | 'block-no-empty': CoreRule<true, { ignore: OneOrMany<'comments'> }>;
|
310 | 'color-function-notation': CoreRule<
|
311 | 'modern' | 'legacy',
|
312 | { ignore: OneOrMany<'with-var-inside'> }
|
313 | >;
|
314 | 'color-hex-alpha': CoreRule<'always' | 'never'>;
|
315 | 'color-hex-length': CoreRule<'short' | 'long'>;
|
316 | 'color-named': CoreRule<
|
317 | 'never' | 'always-where-possible',
|
318 | { ignoreProperties: OneOrMany<StringOrRegex>; ignore: OneOrMany<'inside-function'> }
|
319 | >;
|
320 | 'color-no-hex': CoreRule<true>;
|
321 | 'color-no-invalid-hex': CoreRule<true>;
|
322 | 'comment-empty-line-before': CoreRule<
|
323 | 'always' | 'never',
|
324 | {
|
325 | except: OneOrMany<'first-nested'>;
|
326 | ignore: OneOrMany<'stylelint-commands' | 'after-comment'>;
|
327 | ignoreComments: OneOrMany<StringOrRegex>;
|
328 | }
|
329 | >;
|
330 | 'comment-no-empty': CoreRule<true>;
|
331 | 'comment-pattern': CoreRule<StringOrRegex>;
|
332 | 'comment-whitespace-inside': CoreRule<'always' | 'never'>;
|
333 | 'comment-word-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
334 | 'custom-media-pattern': CoreRule<StringOrRegex>;
|
335 | 'custom-property-empty-line-before': CoreRule<
|
336 | 'always' | 'never',
|
337 | {
|
338 | except: OneOrMany<'first-nested' | 'after-comment' | 'after-custom-property'>;
|
339 | ignore: OneOrMany<'after-comment' | 'first-nested' | 'inside-single-line-block'>;
|
340 | }
|
341 | >;
|
342 | 'custom-property-no-missing-var-function': CoreRule<true>;
|
343 | 'custom-property-pattern': CoreRule<StringOrRegex>;
|
344 | 'declaration-block-no-duplicate-custom-properties': CoreRule<
|
345 | true,
|
346 | { ignoreProperties: OneOrMany<StringOrRegex> }
|
347 | >;
|
348 | 'declaration-block-no-duplicate-properties': CoreRule<
|
349 | true,
|
350 | {
|
351 | ignore: OneOrMany<
|
352 | | 'consecutive-duplicates'
|
353 | | 'consecutive-duplicates-with-different-values'
|
354 | | 'consecutive-duplicates-with-different-syntaxes'
|
355 | | 'consecutive-duplicates-with-same-prefixless-values'
|
356 | >;
|
357 | ignoreProperties: OneOrMany<StringOrRegex>;
|
358 | }
|
359 | >;
|
360 | 'declaration-block-no-redundant-longhand-properties': CoreRule<
|
361 | true,
|
362 | {
|
363 | ignoreShorthands: OneOrMany<StringOrRegex>;
|
364 | ignoreLonghands: OneOrMany<string>;
|
365 | }
|
366 | >;
|
367 | 'declaration-block-no-shorthand-property-overrides': CoreRule<true>;
|
368 | 'declaration-block-single-line-max-declarations': CoreRule<number>;
|
369 | 'declaration-empty-line-before': CoreRule<
|
370 | 'always' | 'never',
|
371 | {
|
372 | except: OneOrMany<'first-nested' | 'after-comment' | 'after-declaration'>;
|
373 | ignore: OneOrMany<
|
374 | 'after-comment' | 'after-declaration' | 'first-nested' | 'inside-single-line-block'
|
375 | >;
|
376 | }
|
377 | >;
|
378 | 'declaration-no-important': CoreRule<true>;
|
379 | 'declaration-property-max-values': CoreRule<Record<string, number>>;
|
380 | 'declaration-property-unit-allowed-list': CoreRule<
|
381 | Record<string, OneOrMany<string>>,
|
382 | { ignore: OneOrMany<'inside-function'> }
|
383 | >;
|
384 | 'declaration-property-unit-disallowed-list': CoreRule<Record<string, OneOrMany<string>>>;
|
385 | 'declaration-property-value-allowed-list': CoreRule<Record<string, OneOrMany<StringOrRegex>>>;
|
386 | 'declaration-property-value-disallowed-list': CoreRule<
|
387 | Record<string, OneOrMany<StringOrRegex>>
|
388 | >;
|
389 | 'declaration-property-value-no-unknown': CoreRule<
|
390 | true,
|
391 | {
|
392 | ignoreProperties: Record<string, OneOrMany<StringOrRegex>>;
|
393 | propertiesSyntax: Record<string, string>;
|
394 | typesSyntax: Record<string, string>;
|
395 | }
|
396 | >;
|
397 | 'font-family-name-quotes': CoreRule<
|
398 | 'always-where-required' | 'always-where-recommended' | 'always-unless-keyword'
|
399 | >;
|
400 | 'font-family-no-duplicate-names': CoreRule<
|
401 | true,
|
402 | { ignoreFontFamilyNames: OneOrMany<StringOrRegex> }
|
403 | >;
|
404 | 'font-family-no-missing-generic-family-keyword': CoreRule<
|
405 | true,
|
406 | { ignoreFontFamilies: OneOrMany<StringOrRegex> }
|
407 | >;
|
408 | 'font-weight-notation': CoreRule<
|
409 | 'numeric' | 'named-where-possible',
|
410 | { ignore: OneOrMany<'relative'> }
|
411 | >;
|
412 | 'function-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
413 | 'function-calc-no-unspaced-operator': CoreRule<true>;
|
414 | 'function-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
415 | 'function-linear-gradient-no-nonstandard-direction': CoreRule<true>;
|
416 | 'function-name-case': CoreRule<
|
417 | 'lower' | 'upper',
|
418 | { ignoreFunctions: OneOrMany<StringOrRegex> }
|
419 | >;
|
420 | 'function-no-unknown': CoreRule<true, { ignoreFunctions: OneOrMany<StringOrRegex> }>;
|
421 | 'function-url-no-scheme-relative': CoreRule<true>;
|
422 | 'function-url-quotes': CoreRule<'always' | 'never', { except: OneOrMany<'empty'> }>;
|
423 | 'function-url-scheme-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
424 | 'function-url-scheme-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
425 | 'hue-degree-notation': CoreRule<'angle' | 'number'>;
|
426 | 'import-notation': CoreRule<'string' | 'url'>;
|
427 | 'keyframe-block-no-duplicate-selectors': CoreRule<true>;
|
428 | 'keyframe-declaration-no-important': CoreRule<true>;
|
429 | 'keyframe-selector-notation': CoreRule<
|
430 | 'keyword' | 'percentage' | 'percentage-unless-within-keyword-only-block'
|
431 | >;
|
432 | 'keyframes-name-pattern': CoreRule<StringOrRegex>;
|
433 | 'length-zero-no-unit': CoreRule<
|
434 | true,
|
435 | {
|
436 | ignore: OneOrMany<'custom-properties'>;
|
437 | ignoreFunctions: OneOrMany<StringOrRegex>;
|
438 | }
|
439 | >;
|
440 | 'lightness-notation': CoreRule<'percentage' | 'number'>;
|
441 | 'max-nesting-depth': CoreRule<
|
442 | number,
|
443 | {
|
444 | ignore: OneOrMany<'blockless-at-rules' | 'pseudo-classes'>;
|
445 | ignoreAtRules: OneOrMany<StringOrRegex>;
|
446 | ignoreRules: OneOrMany<StringOrRegex>;
|
447 | ignorePseudoClasses: OneOrMany<StringOrRegex>;
|
448 | }
|
449 | >;
|
450 | 'media-feature-name-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
451 | 'media-feature-name-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
452 | 'media-feature-name-no-unknown': CoreRule<
|
453 | true,
|
454 | { ignoreMediaFeatureNames: OneOrMany<StringOrRegex> }
|
455 | >;
|
456 | 'media-feature-name-no-vendor-prefix': CoreRule<true>;
|
457 | 'media-feature-name-unit-allowed-list': CoreRule<Record<string, OneOrMany<string>>>;
|
458 | 'media-feature-name-value-allowed-list': CoreRule<Record<string, OneOrMany<StringOrRegex>>>;
|
459 | 'media-feature-name-value-no-unknown': CoreRule<true>;
|
460 | 'media-feature-range-notation': CoreRule<'prefix' | 'context'>;
|
461 | 'media-query-no-invalid': CoreRule<true, { ignoreFunctions: OneOrMany<StringOrRegex> }>;
|
462 | 'named-grid-areas-no-invalid': CoreRule<true>;
|
463 | 'no-descending-specificity': CoreRule<true, { ignore: OneOrMany<'selectors-within-list'> }>;
|
464 | 'no-duplicate-at-import-rules': CoreRule<true>;
|
465 | 'no-duplicate-selectors': CoreRule<true, { disallowInList: boolean }>;
|
466 | 'no-empty-source': CoreRule<true>;
|
467 | 'no-invalid-double-slash-comments': CoreRule<true>;
|
468 | 'no-invalid-position-at-import-rule': CoreRule<
|
469 | true,
|
470 | { ignoreAtRules: OneOrMany<StringOrRegex> }
|
471 | >;
|
472 | 'no-irregular-whitespace': CoreRule<true>;
|
473 | 'no-unknown-animations': CoreRule<true>;
|
474 | 'no-unknown-custom-media': CoreRule<true>;
|
475 | 'no-unknown-custom-properties': CoreRule<true>;
|
476 | 'number-max-precision': CoreRule<
|
477 | number,
|
478 | {
|
479 | ignoreProperties: OneOrMany<StringOrRegex>;
|
480 | ignoreUnits: OneOrMany<StringOrRegex>;
|
481 | insideFunctions: Record<string, number>;
|
482 | }
|
483 | >;
|
484 | 'property-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
485 | 'property-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
486 | 'property-no-unknown': CoreRule<
|
487 | true,
|
488 | {
|
489 | checkPrefixed: boolean;
|
490 | ignoreAtRules: OneOrMany<StringOrRegex>;
|
491 | ignoreProperties: OneOrMany<StringOrRegex>;
|
492 | ignoreSelectors: OneOrMany<StringOrRegex>;
|
493 | }
|
494 | >;
|
495 | 'property-no-vendor-prefix': CoreRule<true, { ignoreProperties: OneOrMany<StringOrRegex> }>;
|
496 | 'rule-empty-line-before': CoreRule<
|
497 | 'always' | 'never' | 'always-multi-line' | 'never-multi-line',
|
498 | {
|
499 | ignore: OneOrMany<'after-comment' | 'first-nested' | 'inside-block'>;
|
500 | except: OneOrMany<
|
501 | | 'after-rule'
|
502 | | 'after-single-line-comment'
|
503 | | 'first-nested'
|
504 | | 'inside-block-and-after-rule'
|
505 | | 'inside-block'
|
506 | >;
|
507 | }
|
508 | >;
|
509 | 'rule-selector-property-disallowed-list': CoreRule<
|
510 | Record<string, OneOrMany<StringOrRegex>>,
|
511 | {
|
512 | ignore: OneOrMany<'keyframe-selectors'>;
|
513 | }
|
514 | >;
|
515 | 'selector-anb-no-unmatchable': CoreRule<true>;
|
516 | 'selector-attribute-name-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
517 | 'selector-attribute-operator-allowed-list': CoreRule<OneOrMany<string>>;
|
518 | 'selector-attribute-operator-disallowed-list': CoreRule<OneOrMany<string>>;
|
519 | 'selector-attribute-quotes': CoreRule<'always' | 'never'>;
|
520 | 'selector-class-pattern': CoreRule<StringOrRegex, { resolveNestedSelectors: boolean }>;
|
521 | 'selector-combinator-allowed-list': CoreRule<OneOrMany<string>>;
|
522 | 'selector-combinator-disallowed-list': CoreRule<OneOrMany<string>>;
|
523 | 'selector-disallowed-list': CoreRule<
|
524 | OneOrMany<StringOrRegex>,
|
525 | { splitList: boolean; ignore: OneOrMany<'inside-block' | 'keyframe-selectors'> }
|
526 | >;
|
527 | 'selector-id-pattern': CoreRule<StringOrRegex>;
|
528 | 'selector-max-attribute': CoreRule<number, { ignoreAttributes: OneOrMany<StringOrRegex> }>;
|
529 | 'selector-max-class': CoreRule<number>;
|
530 | 'selector-max-combinators': CoreRule<number>;
|
531 | 'selector-max-compound-selectors': CoreRule<
|
532 | number,
|
533 | { ignoreSelectors: OneOrMany<StringOrRegex> }
|
534 | >;
|
535 | 'selector-max-id': CoreRule<
|
536 | number,
|
537 | {
|
538 | ignoreContextFunctionalPseudoClasses: OneOrMany<StringOrRegex>;
|
539 | checkContextFunctionalPseudoClasses: OneOrMany<StringOrRegex>;
|
540 | }
|
541 | >;
|
542 | 'selector-max-pseudo-class': CoreRule<number>;
|
543 | 'selector-max-specificity': CoreRule<string, { ignoreSelectors: OneOrMany<StringOrRegex> }>;
|
544 | 'selector-max-type': CoreRule<
|
545 | number,
|
546 | {
|
547 | ignore: OneOrMany<
|
548 | 'descendant' | 'child' | 'compounded' | 'next-sibling' | 'custom-elements'
|
549 | >;
|
550 | ignoreTypes: OneOrMany<StringOrRegex>;
|
551 | }
|
552 | >;
|
553 | 'selector-max-universal': CoreRule<number, { ignoreAfterCombinators: OneOrMany<string> }>;
|
554 | 'selector-nested-pattern': CoreRule<StringOrRegex, { splitList: boolean }>;
|
555 | 'selector-no-qualifying-type': CoreRule<
|
556 | true,
|
557 | { ignore: OneOrMany<'attribute' | 'class' | 'id'> }
|
558 | >;
|
559 | 'selector-no-vendor-prefix': CoreRule<true, { ignoreSelectors: OneOrMany<StringOrRegex> }>;
|
560 | 'selector-not-notation': CoreRule<'simple' | 'complex'>;
|
561 | 'selector-pseudo-class-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
562 | 'selector-pseudo-class-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
563 | 'selector-pseudo-class-no-unknown': CoreRule<
|
564 | true,
|
565 | { ignorePseudoClasses: OneOrMany<StringOrRegex> }
|
566 | >;
|
567 | 'selector-pseudo-element-allowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
568 | 'selector-pseudo-element-colon-notation': CoreRule<'single' | 'double'>;
|
569 | 'selector-pseudo-element-disallowed-list': CoreRule<OneOrMany<StringOrRegex>>;
|
570 | 'selector-pseudo-element-no-unknown': CoreRule<
|
571 | true,
|
572 | { ignorePseudoElements: OneOrMany<StringOrRegex> }
|
573 | >;
|
574 | 'selector-type-case': CoreRule<'lower' | 'upper', { ignoreTypes: OneOrMany<StringOrRegex> }>;
|
575 | 'selector-type-no-unknown': CoreRule<
|
576 | true,
|
577 | {
|
578 | ignore: OneOrMany<'custom-elements' | 'default-namespace'>;
|
579 | ignoreNamespaces: OneOrMany<StringOrRegex>;
|
580 | ignoreTypes: OneOrMany<StringOrRegex>;
|
581 | }
|
582 | >;
|
583 | 'shorthand-property-no-redundant-values': CoreRule<true>;
|
584 | 'string-no-newline': CoreRule<true>;
|
585 | 'time-min-milliseconds': CoreRule<number, { ignore: OneOrMany<'delay'> }>;
|
586 | 'unit-allowed-list': CoreRule<
|
587 | OneOrMany<string>,
|
588 | {
|
589 | ignoreFunctions: OneOrMany<StringOrRegex>;
|
590 | ignoreProperties: Record<string, OneOrMany<StringOrRegex>>;
|
591 | }
|
592 | >;
|
593 | 'unit-disallowed-list': CoreRule<
|
594 | OneOrMany<string>,
|
595 | {
|
596 | ignoreFunctions: OneOrMany<StringOrRegex>;
|
597 | ignoreProperties: Record<string, OneOrMany<StringOrRegex>>;
|
598 | ignoreMediaFeatureNames: Record<string, OneOrMany<StringOrRegex>>;
|
599 | }
|
600 | >;
|
601 | 'unit-no-unknown': CoreRule<
|
602 | true,
|
603 | {
|
604 | ignoreUnits: OneOrMany<StringOrRegex>;
|
605 | ignoreFunctions: OneOrMany<StringOrRegex>;
|
606 | }
|
607 | >;
|
608 | 'value-keyword-case': CoreRule<
|
609 | 'lower' | 'upper',
|
610 | {
|
611 | ignoreProperties: OneOrMany<StringOrRegex>;
|
612 | ignoreKeywords: OneOrMany<StringOrRegex>;
|
613 | ignoreFunctions: OneOrMany<StringOrRegex>;
|
614 | camelCaseSvgKeywords: boolean;
|
615 | }
|
616 | >;
|
617 | 'value-no-vendor-prefix': CoreRule<true, { ignoreValues: OneOrMany<StringOrRegex> }>;
|
618 | };
|
619 |
|
620 |
|
621 | export type GetPostcssOptions = {
|
622 | code?: string;
|
623 | codeFilename?: string;
|
624 | filePath?: string;
|
625 | customSyntax?: CustomSyntax;
|
626 | };
|
627 |
|
628 |
|
629 | export type GetLintSourceOptions = GetPostcssOptions & {
|
630 | existingPostcssResult?: PostCSS.Result;
|
631 | cache?: boolean;
|
632 | };
|
633 |
|
634 | |
635 |
|
636 |
|
637 | export type LinterOptions = {
|
638 | files?: OneOrMany<string>;
|
639 | globbyOptions?: GlobbyOptions;
|
640 | cache?: boolean;
|
641 | cacheLocation?: string;
|
642 | cacheStrategy?: string;
|
643 | code?: string;
|
644 | codeFilename?: string;
|
645 | config?: Config;
|
646 | configFile?: string;
|
647 | configBasedir?: string;
|
648 | |
649 |
|
650 |
|
651 |
|
652 | cwd?: string;
|
653 | ignoreDisables?: boolean;
|
654 | ignorePath?: OneOrMany<string>;
|
655 | ignorePattern?: string[];
|
656 | reportDescriptionlessDisables?: boolean;
|
657 | reportNeedlessDisables?: boolean;
|
658 | reportInvalidScopeDisables?: boolean;
|
659 | reportUnscopedDisables?: boolean;
|
660 | maxWarnings?: number;
|
661 | customSyntax?: CustomSyntax;
|
662 |
|
663 | _defaultFormatter?: FormatterType;
|
664 | formatter?: FormatterType | Formatter;
|
665 | disableDefaultIgnores?: boolean;
|
666 | fix?: boolean;
|
667 | allowEmptyInput?: boolean;
|
668 | quiet?: boolean;
|
669 | quietDeprecationWarnings?: boolean;
|
670 | validate?: boolean;
|
671 | };
|
672 |
|
673 | |
674 |
|
675 |
|
676 | export type CssSyntaxError = {
|
677 | file?: string;
|
678 | input: {
|
679 | column: number;
|
680 | file?: string;
|
681 | line: number;
|
682 | source: string;
|
683 | };
|
684 | |
685 |
|
686 |
|
687 | line: number;
|
688 | |
689 |
|
690 |
|
691 | column: number;
|
692 | |
693 |
|
694 |
|
695 | endLine?: number;
|
696 | |
697 |
|
698 |
|
699 | endColumn?: number;
|
700 | message: string;
|
701 | name: string;
|
702 | reason: string;
|
703 | source: string;
|
704 | };
|
705 |
|
706 | |
707 |
|
708 |
|
709 | export type Warning = {
|
710 | |
711 |
|
712 |
|
713 | line: number;
|
714 | |
715 |
|
716 |
|
717 | column: number;
|
718 | |
719 |
|
720 |
|
721 | endLine?: number;
|
722 | |
723 |
|
724 |
|
725 | endColumn?: number;
|
726 | rule: string;
|
727 | severity: Severity;
|
728 | text: string;
|
729 | url?: string;
|
730 | stylelintType?: StylelintWarningType;
|
731 | };
|
732 |
|
733 | |
734 |
|
735 |
|
736 | export type LintResult = {
|
737 | source?: string;
|
738 | deprecations: {
|
739 | text: string;
|
740 | reference?: string;
|
741 | }[];
|
742 | invalidOptionWarnings: {
|
743 | text: string;
|
744 | }[];
|
745 | parseErrors: (PostCSS.Warning & {
|
746 | stylelintType: Extract<StylelintWarningType, 'parseError'>;
|
747 | })[];
|
748 | errored?: boolean;
|
749 | warnings: Warning[];
|
750 | ignored?: boolean;
|
751 | |
752 |
|
753 |
|
754 |
|
755 |
|
756 | _postcssResult?: PostcssResult;
|
757 | };
|
758 |
|
759 |
|
760 | export type DisableReportRange = {
|
761 | rule: string;
|
762 | start: number;
|
763 | end?: number;
|
764 | };
|
765 |
|
766 | |
767 |
|
768 |
|
769 | export type LinterResult = {
|
770 | |
771 |
|
772 |
|
773 |
|
774 | cwd: string;
|
775 | results: LintResult[];
|
776 | errored: boolean;
|
777 | |
778 |
|
779 |
|
780 |
|
781 | output: string;
|
782 |
|
783 | _output?: string;
|
784 |
|
785 | _outputWarned?: boolean;
|
786 | |
787 |
|
788 |
|
789 | report: string;
|
790 | |
791 |
|
792 |
|
793 |
|
794 | code?: string;
|
795 | maxWarningsExceeded?: {
|
796 | maxWarnings: number;
|
797 | foundWarnings: number;
|
798 | };
|
799 | reportedDisables: DisableOptionsReport;
|
800 | descriptionlessDisables?: DisableOptionsReport;
|
801 | needlessDisables?: DisableOptionsReport;
|
802 | invalidScopeDisables?: DisableOptionsReport;
|
803 | |
804 |
|
805 |
|
806 | ruleMetadata: { [ruleName: string]: Partial<RuleMeta> };
|
807 | };
|
808 |
|
809 | type Position = {
|
810 | line: number;
|
811 | column: number;
|
812 | };
|
813 |
|
814 | |
815 |
|
816 |
|
817 | export type Problem = {
|
818 | ruleName: string;
|
819 | result: PostcssResult;
|
820 | message: RuleMessage;
|
821 | messageArgs?: Parameters<RuleMessageFunc> | undefined;
|
822 | node: PostCSS.Node;
|
823 | |
824 |
|
825 |
|
826 |
|
827 | index?: number;
|
828 | |
829 |
|
830 |
|
831 |
|
832 | endIndex?: number;
|
833 | |
834 |
|
835 |
|
836 |
|
837 |
|
838 | start?: Position;
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 | end?: Position;
|
845 | word?: string;
|
846 | line?: number;
|
847 | |
848 |
|
849 |
|
850 | severity?: RuleSeverity;
|
851 | fix?: () => void | undefined | never;
|
852 | };
|
853 |
|
854 |
|
855 | export type ShorthandProperties =
|
856 | | 'animation'
|
857 | | 'background'
|
858 | | 'border'
|
859 | | 'border-block'
|
860 | | 'border-block-end'
|
861 | | 'border-block-start'
|
862 | | 'border-inline'
|
863 | | 'border-inline-end'
|
864 | | 'border-inline-start'
|
865 | | 'border-bottom'
|
866 | | 'border-color'
|
867 | | 'border-image'
|
868 | | 'border-inline-end'
|
869 | | 'border-inline-start'
|
870 | | 'border-left'
|
871 | | 'border-radius'
|
872 | | 'border-right'
|
873 | | 'border-style'
|
874 | | 'border-top'
|
875 | | 'border-width'
|
876 | | 'column-rule'
|
877 | | 'columns'
|
878 | | 'flex'
|
879 | | 'flex-flow'
|
880 | | 'font'
|
881 | | 'font-synthesis'
|
882 | | 'font-variant'
|
883 | | 'gap'
|
884 | | 'grid'
|
885 | | 'grid-area'
|
886 | | 'grid-column'
|
887 | | 'grid-gap'
|
888 | | 'grid-row'
|
889 | | 'grid-template'
|
890 | | 'inset'
|
891 | | 'inset-block'
|
892 | | 'inset-inline'
|
893 | | 'list-style'
|
894 | | 'margin'
|
895 | | 'margin-block'
|
896 | | 'margin-inline'
|
897 | | 'mask'
|
898 | | 'outline'
|
899 | | 'overflow'
|
900 | | 'overscroll-behavior'
|
901 | | 'padding'
|
902 | | 'padding-block'
|
903 | | 'padding-inline'
|
904 | | 'place-content'
|
905 | | 'place-items'
|
906 | | 'place-self'
|
907 | | 'scroll-margin'
|
908 | | 'scroll-margin-block'
|
909 | | 'scroll-margin-inline'
|
910 | | 'scroll-padding'
|
911 | | 'scroll-padding-block'
|
912 | | 'scroll-padding-inline'
|
913 | | 'text-decoration'
|
914 | | 'text-emphasis'
|
915 | | 'transition';
|
916 |
|
917 |
|
918 | export type LonghandSubPropertiesOfShorthandProperties = ReadonlyMap<
|
919 | ShorthandProperties,
|
920 | ReadonlySet<string>
|
921 | >;
|
922 |
|
923 | |
924 |
|
925 |
|
926 | export type Utils = {
|
927 | |
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 | report: (problem: Problem) => void;
|
942 |
|
943 | |
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 | ruleMessages: <T extends RuleMessages, R extends { [K in keyof T]: T[K] }>(
|
954 | ruleName: string,
|
955 | messages: T,
|
956 | ) => R;
|
957 |
|
958 | |
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 | validateOptions: (
|
978 | result: PostcssResult,
|
979 | ruleName: string,
|
980 | ...optionDescriptions: RuleOptions[]
|
981 | ) => boolean;
|
982 |
|
983 | |
984 |
|
985 |
|
986 |
|
987 | checkAgainstRule: <T, O extends Object>(
|
988 | options: {
|
989 | ruleName: string;
|
990 | ruleSettings: ConfigRuleSettings<T, O>;
|
991 | root: PostCSS.Root;
|
992 | result?: PostcssResult;
|
993 | context?: RuleContext;
|
994 | },
|
995 | callback: (warning: PostCSS.Warning) => void,
|
996 | ) => Promise<void>;
|
997 | };
|
998 |
|
999 | |
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 | export type InternalApi = {
|
1005 | _options: LinterOptions & { cwd: string };
|
1006 | _extendExplorer: ReturnType<typeof cosmiconfig>;
|
1007 | _specifiedConfigCache: Map<Config, Map<string, CosmiconfigResult>>;
|
1008 | _postcssResultCache: Map<string, PostCSS.Result>;
|
1009 | _fileCache: FileCache;
|
1010 | };
|
1011 |
|
1012 |
|
1013 | export type DisableOptionsReport = DisableReportEntry[];
|
1014 |
|
1015 |
|
1016 | export type PostcssPluginOptions = Omit<LinterOptions, 'customSyntax'> | Config;
|
1017 |
|
1018 | |
1019 |
|
1020 |
|
1021 | export type PublicApi = PostCSS.PluginCreator<PostcssPluginOptions> & {
|
1022 | |
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 | lint: (options: LinterOptions) => Promise<LinterResult>;
|
1030 |
|
1031 | |
1032 |
|
1033 |
|
1034 | rules: { readonly [name in keyof CoreRules]: Promise<CoreRules[name]> };
|
1035 |
|
1036 | |
1037 |
|
1038 |
|
1039 | formatters: Formatters;
|
1040 |
|
1041 | |
1042 |
|
1043 |
|
1044 | createPlugin: (ruleName: string, rule: Rule) => Plugin;
|
1045 |
|
1046 | |
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 | _createLinter: (options: LinterOptions) => InternalApi;
|
1054 |
|
1055 | |
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | resolveConfig: (
|
1064 | filePath: string,
|
1065 | options?: Pick<LinterOptions, 'cwd' | 'config' | 'configBasedir' | 'configFile'>,
|
1066 | ) => Promise<Config | undefined>;
|
1067 |
|
1068 | |
1069 |
|
1070 |
|
1071 | utils: Utils;
|
1072 |
|
1073 | |
1074 |
|
1075 |
|
1076 | reference: {
|
1077 | longhandSubPropertiesOfShorthandProperties: LonghandSubPropertiesOfShorthandProperties;
|
1078 | };
|
1079 | };
|
1080 | }
|
1081 |
|
1082 | declare const stylelint: stylelint.PublicApi;
|
1083 |
|
1084 | export = stylelint;
|