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