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