UNPKG

stylelint-define-config

Version:

Provide a defineConfig function for stylelint.config.js files

1,804 lines (1,590 loc) 142 kB
import { Severity, Plugin, Rule, Formatter, FormatterType, ConfigRuleSettings, DisableOptions, CustomSyntax as CustomSyntax$1 } from 'stylelint'; export { Severity } from 'stylelint'; import * as CSS from 'csstype'; interface SecondaryOptions { /** * You can set the `disableFix` secondary option to disable autofix on a per-rule basis. * @see [configure disable fix](https://stylelint.io/user-guide/configure#disablefix) */ disableFix?: boolean /** * You can set the reportDisables secondary option to report any stylelint-disable comments * for this rule, effectively disallowing authors to opt-out of it. * @see [configure report disables](https://stylelint.io/user-guide/configure#reportdisables) */ reportDisables?: boolean /** * You can use the severity secondary option to adjust any specific rule's severity. * * The available values for severity are: * - "warning" * - "error" (default) * @see [configure severity](https://stylelint.io/user-guide/configure#severity) */ severity?: Severity /** * You can use the message secondary option to deliver a custom message when a rule is violated. * @see [configure message](https://stylelint.io/user-guide/configure#message) */ message?: string | ((...args: any[]) => string) /** * You can use the url secondary option to provide a custom link to external docs. * These urls can then be displayed in custom formatters. * @see [configure url](https://stylelint.io/user-guide/configure#url) */ url?: string } /** * declaration rule config. * * `RuleConfig<PrimaryOptions, SecondaryOptions>` */ type RuleConfig<T, S extends Record<string, any> = Record<string, any>> = null | undefined | NonNullable<T> | readonly [NonNullable<T>] | readonly [NonNullable<T>, Omit<SecondaryOptions, keyof S> & S] type Unprefix<T extends Record<string, any>, Pre extends string> = { [K in keyof T as K extends `${Pre}${infer U}` ? U : never]: T[K]; }; type Prefix<T extends Record<string, any>, Pre extends string> = { [K in keyof T as `${Pre}${K}`]: T[K]; }; type RenamePrefix<T extends Record<string, any>, Old extends string, New extends string> = Prefix<Unprefix<T, Old>, New>; /** * A literal type that supports custom further strings but preserves autocompletion in IDEs. * * @see [copied from issue](https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609) */ type LiteralUnion<Union extends Base, Base = string> = Union | (Base & { zz_IGNORE_ME?: never; }); type RegExpLike = RegExp | `/${string}/` | string; type KebabCase<S extends string, B extends boolean = true> = S extends `${infer F}${infer O}` ? F extends Uncapitalize<F> ? `${F}${KebabCase<O, false>}` : B extends true ? `${Uncapitalize<F>}${KebabCase<O, false>}` : `-${Uncapitalize<F>}${KebabCase<O, false>}` : S; type AtRules = LiteralUnion<CSS.AtRules extends `@${infer T}` ? T : never> type CSSFunction = LiteralUnion< | 'abs' | 'acos' | 'asin' | 'atan' | 'atan2' | 'attr' | 'calc' | 'clamp' | 'cos' | 'counter' | 'counters' | 'cross-fade' | 'env' | 'exp' | 'fix-content' | 'hypot' | 'log' | 'max' | 'min' | 'minmax' | 'pow' | 'rem' | 'repeat' | 'round' | 'sign' | 'sin' | 'sqrt' | 'symbols' | 'tan' | 'url' | 'var' > type MediaFeature = MediaFeatureNormal | MediaFeaturePrefix type MediaFeatureNormal = LiteralUnion< // level 3 | 'width' | 'height' | 'device-width' | 'device-height' | 'orientation' | 'aspect-ratio' | 'device-aspect-ratio' | 'color' | 'color-index' | 'monochrome' | 'resolution' | 'scan' | 'grid' // level 4 | 'update' | 'overflow-block' | 'overflow-inline' | 'color-gamut' | 'pointer' | 'hover' | 'any-pointer' | 'any-hover' > type MediaFeaturePrefix = LiteralUnion< | 'max-width' | 'max-height' | 'max-device-width' | 'max-device-height' | 'max-aspect-ratio' | 'max-device-aspect-ratio' | 'max-color-index' | 'max-monochrome' | 'max-resolution' | 'max-color' | 'min-width' | 'min-height' | 'min-device-width' | 'min-device-height' | 'min-aspect-ratio' | 'min-device-aspect-ratio' | 'min-color' | 'min-color-index' | 'min-monochrome' | 'min-resolution' > type MediaFeatureLevel5 = LiteralUnion< | 'horizontal-viewport-segments' | 'vertical-viewport-segments' | 'display-mode' | 'environment-blending' | 'dynamic-range' | 'inverted-colors' | 'nav-controls' | 'video-color-gamut' | 'video-dynamic-range' | 'scripting' | 'prefers-reduced-motion' | 'prefers-reduced-transparency' | 'prefers-contrast' | 'forced-colors' | 'prefers-color-scheme' | 'prefers-reduced-data' > type MediaType = LiteralUnion<'all' | 'screen' | 'print'> type CSSPropertiesMap = keyof CSS.Properties type StandardPropertiesMap = keyof CSS.StandardProperties type KebabCaseStandardPropertiesMap = LiteralUnion<KebabCase<StandardPropertiesMap>> type SelectorAttributeOperator = LiteralUnion<'=' | '~=' | '|=' | '^=' | '$=' | '*='> type SelectorCombinator = LiteralUnion<' ' | '>' | '+' | '~' | '||' | '|' | ','> type SelectorPseudoClass = LiteralUnion< | 'active' | 'any-link' | 'autofill' | 'buffering' | 'blank' | 'checked' | 'current' | 'default' | 'defined' | 'dir' | 'disabled' | 'empty' | 'enabled' | 'first' | 'first-child' | 'first-of-type' | 'focus' | 'focus-visible' | 'focus-within' | 'fullscreen' | 'hover' | 'future' | 'has' | 'host' | 'host-context' | 'hover' | 'indeterminate' | 'in-range' | 'invalid' | 'is' | 'lang' | 'last-child' | 'last-of-type' | 'left' | 'link' | 'local-link' | 'modal' | 'muted' | 'not' | 'nth-child' | 'nth-last-child' | 'nth-last-of-type' | 'not-of-type' | 'only-child' | 'only-of-type' | 'optional' | 'out-of-range' | 'past' | 'paused' | 'picture-in-picture' | 'placeholder-shown' | 'playing' | 'popover-open' | 'ready-only' | 'read-write' | 'required' | 'right' | 'root' | 'scope' | 'seeking' | 'stalled' | 'target' | 'target-within' | 'user-invalid' | 'user-valid' | 'valid' | 'visited' | 'volume-locked' | 'where' > type SelectorPseudoElement = LiteralUnion< | 'before' | 'after' | 'backdrop' | 'cue' | 'cue-region' | 'file-selector-button' | 'first-letter' | 'first-line' | 'highlight' | 'marker' | 'part' | 'placeholder' | 'selection' | 'slotted' > type RelativeUnit = 'em' | 'rem' | 'vw' | 'vh' | 'vmin' | 'vmax' | 'ex' | 'cap' | 'ch' | 'ic' | 'lh' | 'rlh' | 'vi' | 'vb' | 'svw' | 'svh' | 'lvw' | 'lvh' | 'dvw' | 'dvh' type AbsoluteUnit = 'px' | 'pt' | 'cm' | 'mm' | 'Q' | 'in' | 'pc' type AngleUnit = 'deg' | 'grad' | 'rad' | 'turn' type PercentUnit = '%' type TimeUnit = 'ms' | 's' type FrequencyUnit = 'Hz' | 'kHz' type ResolutionUnit = 'dpi' | 'dpcm' | 'dppx' type CustomUnit = 'rpx' type Unit = LiteralUnion<RelativeUnit | AbsoluteUnit | AngleUnit | PercentUnit | TimeUnit | FrequencyUnit | ResolutionUnit | CustomUnit> type AlphaValueNotationPrimaryOptions = 'number' | 'percentage' interface AlphaValueNotationSecondaryOptions { /** * Reverse the primary option for matching properties. * @see [optional secondary options](https://stylelint.io/user-guide/rules/alpha-value-notation#optional-secondary-options) */ exceptProperties?: (CSSPropertiesMap | RegExpLike)[] message?: string | ((unfixed: string, fixed: string) => string) } type AlphaValueNotationOptions = RuleConfig< AlphaValueNotationPrimaryOptions, AlphaValueNotationSecondaryOptions > type AnnotationNoUnknownOptions = RuleConfig< true, { /** * Specify which annotations to ignore. */ ignoreAnnotations?: RegExpLike[] message?: string | ((annotation: string) => string) } > type AtRuleAllowedListOptions = RuleConfig< AtRules[] | string[], { message?: string | ((atRule: string) => string) } > type AtRuleDescriptorNoUnknownOptions = RuleConfig<true, { message?: string | ((atRule: string, descriptor: string) => string) }> type AtRuleDescriptorValueNoUnknownOptions = RuleConfig<true, { message?: string | ((descriptor: string, value: string) => string) }> type AtRuleDisallowedListOptions = RuleConfig< AtRules[] | string[], { message?: string | ((atRule: string) => string) } > type AtRuleEmptyLineBeforeOptions = RuleConfig< 'always' | 'never', { except?: LiteralUnion<'after-same-name' | 'inside-block' | 'blockless-after-same-name-blockless' | 'blockless-after-blockless' | 'first-nested'>[] ignore?: LiteralUnion<'after-comment' | 'first-nested' | 'inside-block' | 'blockless-after-same-name-blockless' | 'blockless-after-blockless'>[] ignoreAtRules?: (AtRules | RegExp | `/${string}/`)[] message?: string | ((atRule: string) => string) } > type AtRuleNoDeprecatedOptions = RuleConfig<true, { ignoreAtRules?: (RegExp | AtRules)[] message?: string | ((atRule: string) => string) }> type AtRuleNoUnknownOptions = RuleConfig< true, { ignoreAtRules?: (string | RegExp)[] message?: string | ((atRule: string) => string) } > type AtRuleNoVendorPrefixOptions = RuleConfig< true, { message: string | ((atRule: string) => string) } > type AtRulePreludeNoInvalidOptions = RuleConfig<true, { ignoreAtRules?: (RegExp | AtRules)[] message?: string | ((atRule: string, prelude: string) => string) }> type AtRulePropertyRequiredListOptions = RuleConfig< Record<AtRules, CSSPropertiesMap | CSSPropertiesMap[]>, { message?: string | ((atRule: string, property: string) => string) } > type BlockNoEmptyOptions = RuleConfig< true, { ignore?: ('comments')[] message?: string | ((block: string) => string) } > type ColorFunctionAliasNatationOptions = RuleConfig< 'without-alpha' | 'with-alpha', { message?: string | ((unfixed: string, fixed: string) => string) } > type ColorFunctionNatationOptions = RuleConfig< 'modern' | 'legacy', { ignore?: ('with-var-inside')[] message?: string | ((primary: string) => string) } > type ColorHexAlphaOptions = RuleConfig< 'always' | 'never', { message?: string | ((hex: string) => string) } > type ColorHexLengthOptions = RuleConfig< 'short' | 'long', { message?: string | ((actual: string, expected: string) => string) } > type ColorNamedOptions = RuleConfig< 'always-where-possible' | 'never', { ignoreProperties?: RegExpLike[] ignore?: ('inside-function')[] message?: string | ((named: string) => string) } > type ColorNoHexOptions = RuleConfig< true, { message?: string | ((hex: string, expected: string) => string) } > type ColorNoInvalidHexOptions = RuleConfig< true, { message?: string | ((hex: string, expected: string) => string) } > type CommentEmptyLineBeforeOptions = RuleConfig< 'always' | 'never', { except?: ('first-nested')[] ignore?: ('stylelint-commands' | 'after-comment')[] ignoreComments?: RegExpLike[] } > type CommentNoEmptyOptions = RuleConfig< true > type CommentPatternOptions = RuleConfig< RegExpLike > type CommentWhitespaceInsideOptions = RuleConfig< 'always' | 'never' > type CommentWordDisallowedListOptions = RuleConfig< RegExpLike | RegExpLike[], { message?: string | ((pattern: string) => string) } > type ContainerNamePatternOptions = RuleConfig< RegExpLike, { message?: string | ((containerName: string, pattern: string) => string) } > type CustomMediaPatternOptions = RuleConfig< RegExpLike, { message?: string | ((mediaName: string, pattern: string) => string) } > type CustomPropertyEmptyLineBeforeOptions = RuleConfig< 'always' | 'never', { except?: LiteralUnion<'after-comment' | 'after-custom-property' | 'first-nested'>[] ignore?: LiteralUnion<'after-comment' | 'first-nested' | 'inside-single-line-block'>[] message?: string | (() => string) } > type CustomPropertyNoMissingVarFunctionOptions = RuleConfig< true, { message?: string | ((customProperty: string) => string) } > type CustomPropertyPatternOptions = RuleConfig< RegExpLike, { message?: string | ((propName: string, pattern: string) => string) } > type DeclarationBlockNoDuplicateCustomPropertiesOptions = RuleConfig< true, { ignoreProperties?: (string | RegExp)[] message?: string | ((property: string) => string) } > type DeclarationBlockNoDuplicatePropertiesIgnore = LiteralUnion< | 'consecutive-duplicates' | 'consecutive-duplicates-with-different-values' | 'consecutive-duplicates-with-different-syntaxes' | 'consecutive-duplicates-with-same-prefixless-values' > type DeclarationBlockNoDuplicatePropertiesOptions = RuleConfig< true, { ignore?: [DeclarationBlockNoDuplicatePropertiesIgnore] ignoreProperties?: (string | RegExp)[] message?: string | ((property: string) => string) } > type DeclarationBlockNoRedundantLonghandPropertiesOptions = RuleConfig< true, { ignoreLonghands?: string | string[] ignoreShorthands?: (string | RegExp)[] message?: string | ((props: string) => string) } > type DeclarationBlockNoShorthandPropertyOverridesOptions = RuleConfig< true, { message?: string | ((shorthand: string, original: string) => string) } > type DeclarationBlockSingleLineMaxDeclarationsOptions = RuleConfig< number, { message?: string | ((max: number) => string) } > type DeclarationEmptyLineBeforeOptions = RuleConfig< 'always' | 'never', { except?: LiteralUnion<'after-comment' | 'after-declaration' | 'first-nested'>[] ignore?: LiteralUnion<'after-comment' | 'after-declaration' | 'first-nested' | 'inside-single-line-block'>[] ignoreProperties?: RegExpLike[] } > type DeclarationNoImportantOptions = RuleConfig< true > type DeclarationPropertyMaxValuesOptions = RuleConfig< Record<KebabCaseStandardPropertiesMap | `/${string}/`, number> | Record<string, number>, { message?: string | ((property: string, max: number) => string) } > type DeclarationPropertyUnitAllowedListOptions = RuleConfig< Record<KebabCaseStandardPropertiesMap | `/${string}/`, Unit | Unit[]>, { ignore?: ['inside-function'] message?: string | ((property: string, unit: string) => string) } > type DeclarationPropertyUnitDisallowedListOptions = RuleConfig< Record<KebabCaseStandardPropertiesMap | `/${string}/`, Unit | Unit[]>, { message?: string | ((property: string, unit: string) => string) } > type DeclarationPropertyValueAllowedListOptions = RuleConfig< Record<KebabCaseStandardPropertiesMap | `/${string}/`, RegExpLike | RegExpLike[]> | Record<string, RegExpLike | RegExpLike[]>, { message?: string | ((property: string, value: string) => string) } > type DeclarationPropertyValueDisallowedListOptions = RuleConfig< Record<KebabCaseStandardPropertiesMap | `/${string}/`, RegExpLike | RegExpLike[]> | Record<string, RegExpLike | RegExpLike[]>, { message?: string | ((property: string, value: string) => string) } > type DeclarationPropertyValueKeywordNoDeprecatedOptions = RuleConfig<true, { ignoreKeywords?: (RegExp | string)[] message?: string | ((property: string, keyword: string) => string) }> type DeclarationPropertyValueNoUnknownOptions = RuleConfig<true, { ignoreProperties?: Record<KebabCaseStandardPropertiesMap, RegExpLike | RegExpLike[]> | Record<string, RegExpLike | RegExpLike[]> /** * Extend or alter the properties syntax dictionary. * {@link https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md CSS Value Definition Syntax} is used to define a value's syntax. * If a definition starts with `|` it is added to the {@link https://csstree.github.io/docs/syntax/ existing definition value} if any. */ propertiesSyntax?: Record<KebabCaseStandardPropertiesMap, string> | Record<string, string> /** * Extend or alter the types syntax dictionary. * {@link https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md CSS Value Definition Syntax} is used to define a value's syntax. * If a definition starts with `|` it is added to the {@link https://csstree.github.io/docs/syntax/ existing definition value} if any. */ typesSyntax?: Record<string, string> message?: string | ((property: string, value: string) => string) }> type FontFamilyNameQuotesOptions = RuleConfig< 'always-where-required' | 'always-where-recommended' | 'always-unless-keyword', { message?: string | ((familyName: string) => string) } > type FontFamilyNoDuplicateNamesOptions = RuleConfig< true, { ignoreFontFamilyNames?: (string | RegExp)[] message?: string | ((name: string) => string) } > type FontFamilyNoMissingGenericFamilyKeywordOptions = RuleConfig< true, { ignoreFontFamilies?: (string | RegExp)[] message?: string | (() => string) } > type FontWeightNotationIgnore = 'relative' type FontWeightNotationOptions = RuleConfig< 'numeric' | 'named-where-possible', { ignore?: [FontWeightNotationIgnore] message?: string | ((type: string) => string) } > type FunctionAllowedListOptions = RuleConfig< CSSFunction | RegExpLike | (CSSFunction | RegExpLike)[], { message?: string | ((name: string) => string) /** * Disallow the matching functions when they are without a property fallback in the same declaration block. */ exceptWithoutPropertyFallback?: CSSFunction | RegExpLike | (CSSFunction | RegExpLike)[] } > type FunctionCalcNoUnspacedOperatorOptions = RuleConfig< true, { message?: string | ((operator: string) => string) } > type FunctionDisallowedListOptions = RuleConfig< CSSFunction | RegExpLike | (CSSFunction | RegExpLike)[], { message?: string | ((name: string) => string) } > type FunctionLinearGradientNoNonstandardDirectionOptions = RuleConfig< true > type FunctionNameCaseOptions = RuleConfig< 'lower' | 'upper', { ignoreFunctions?: (string | RegExp)[] message?: string | ((actual: string, expected: string) => string) } > type FunctionNoUnknownOptions = RuleConfig< true, { ignoreFunctions?: (string | RegExp)[] message?: string | ((name: string) => string) } > type FunctionUrlNoSchemeRelativeOptions = RuleConfig< true, { ignoreFunctions?: RegExpLike[] } > type FunctionUrlQuotesExcept = 'empty' type FunctionUrlQuotesOptions = RuleConfig< 'always' | 'never', { except?: [FunctionUrlQuotesExcept] message?: string | ((functionName: string) => string) } > type FunctionUrlSchemeAllowedListOptions = RuleConfig< RegExp | string | (RegExp | string)[], { message?: string | ((scheme: string) => string) } > type FunctionUrlSchemeDisallowedListOptions = RuleConfig< string | RegExp | (string | RegExp)[], { message?: string | ((scheme: string) => string) } > type HueDegreeNotationOptions = RuleConfig< 'angle' | 'number', { message?: string | ((unfixed: string, fixed: string) => string) } > type ImportNotationOptions = RuleConfig< 'string' | 'url', { message?: string | ((unfixed: string, fixed: string) => string) } > type KeyframeBlockNoDuplicateSelectorsOptions = RuleConfig< true, { message?: string | ((selector: string) => string) } > type KeyframeDeclarationNoImportantOptions = RuleConfig< true > type KeyframeSelectorNotationOptions = RuleConfig< 'keyword' | 'percentage' | 'percentage-unless-within-keyword-only-block', { message?: string | ((selector: string, fixedSelector: string) => string) } > type KeyframesNamePatternOptions = RuleConfig< string | RegExp, { message?: string | ((keyframeName: string, pattern: string) => string) } > type LayerNamePatternOptions = RuleConfig<string | RegExp> type LengthZeroNoUnitOptions = RuleConfig< true, { /** * Ignore units for zero length in custom properties. */ ignore?: ('custom-properties')[] ignoreFunctions?: (CSSFunction | RegExpLike)[] /** * Ignore units for zero lengths within the preludes of the specified at-rules. */ ignorePreludeOfAtRules?: RegExpLike[] message?: string | (() => string) } > type LightnessNotationOptions = RuleConfig<'percentage' | 'number', { message?: string | ((unfixed: string, fixed: string) => string); }>; type MaxNestingDepthOptions = RuleConfig< number, { ignore?: ('blockless-at-rules' | 'pseudo-classes')[] ignoreAtRules?: (AtRules | RegExp)[] message?: string | ((depth: string) => string) } > type MediaFeatureNameAllowed = MediaFeatureNormal | MediaFeatureLevel5 | RegExpLike type MediaFeatureNameAllowedListOptions = RuleConfig< MediaFeatureNameAllowed | (MediaFeatureNameAllowed)[], { message?: string | ((name: string) => string) } > type MediaFeatureNameDisallowed = MediaFeatureNormal | MediaFeatureLevel5 | RegExpLike type MediaFeatureNameDisallowedListOptions = RuleConfig< MediaFeatureNameDisallowed | (MediaFeatureNameDisallowed)[], { message?: string | ((name: string) => string) } > type MediaFeatureNameNoUnknownOptions = RuleConfig< true, { ignoreMediaFeatureNames?: (string | RegExp)[] message?: string | ((mediaFeatureName: string) => string) } > type MediaFeatureNameNoVendorPrefixOptions = RuleConfig< true > type MediaFeatureNameUnitAllowedListOptions = RuleConfig< Partial<Record<MediaFeatureNormal | MediaFeatureLevel5 | `/${string}/`, Unit | Unit[]>>, { message?: string | ((unit: string, name: string) => string) } > type MediaFeatureNameValueAllowedListOptions = RuleConfig< Partial<Record< MediaFeatureNormal | MediaFeatureLevel5 | `/${string}/`, string | RegExp | (string | RegExp)[] >>, { message?: string | ((name: string, value: string) => string) } > type MediaFeatureNameValueNoUnknownOptions = RuleConfig< true, { message?: string | ((name: string, value: string) => string) } > type MediaFeatureRangeNotationOptions = RuleConfig< 'context' | 'prefix', { message?: string | ((primary: string) => string) } > type MediaQueryNoInvalidOptions = RuleConfig< true, { message?: string | ((query: string, reason: string) => string) ignoreFunctions?: string | RegExp | (string | RegExp)[] } > type NamedGridAreasNoInvalidOptions = RuleConfig< true, { message?: string | ((name: string) => string) } > type NoDescendingSpecificityIgnore = 'selectors-within-list' type NoDescendingSpecificityOptions = RuleConfig< true, { ignore?: [NoDescendingSpecificityIgnore] message?: string | ((selectorA: string, selectorB: string) => string) } > type NoDuplicateAtImportRulesOptions = RuleConfig< true, { message?: string | ((atImport: string) => string) } > type NoDuplicateSelectorsOptions = RuleConfig< true, { /** * This option will also disallow duplicate selectors within selector lists. * @default false */ disallowInList?: boolean message?: string | ((selector: string, firstDuplicateLine: number | string) => string) } > type NoEmptySourceOptions = RuleConfig< true > type NoInvalidDoubleSlashCommentsOptions = RuleConfig< true > type NoInvalidPositionAtImportRuleOptions = RuleConfig< true, { ignoreAtRules?: (AtRules | RegExp)[] message?: string | (() => string) } > type NoIrregularWhitespaceOptions = RuleConfig< true > type NoUnknownAnimationsOptions = RuleConfig< true > type NoUnknownCustomMediaOptions = RuleConfig< true > type NoUnknownCustomPropertiesOptions = RuleConfig< true > type NumberMaxPrecisionOptions = RuleConfig< number, { /** * Ignore the precision of numbers for values with the specified units. */ ignoreUnits?: (Unit | RegExp)[] /** * Change a primary option value for specified functions. */ insideFunctions?: Record<string, number> message?: string | ((actual: string, expected: string) => string) } > type PropertyAllowed = CSSPropertiesMap | RegExpLike type PropertyAllowedListOptions = RuleConfig< PropertyAllowed | PropertyAllowed[], { message?: string | ((property: string) => string) } > type PropertyDisallowed = CSSPropertiesMap | RegExpLike type PropertyDisallowedListOptions = RuleConfig< PropertyDisallowed | PropertyDisallowed[], { message?: string | ((property: string) => string) } > type PropertyNoUnknownOptions = RuleConfig< true, { ignoreProperties?: (string | RegExp)[] /** * Skips checking properties of the given selectors against this rule. */ ignoreSelectors?: (string | RegExp)[] /** * Ignores properties nested within specified at-rules. */ ignoreAtRules?: (AtRules | RegExp)[] /** * If true, this rule will check vendor-prefixed properties. * @default false */ checkPrefixed?: boolean message?: string | ((property: string) => string) } > type PropertyNoVendorPrefixOptions = RuleConfig< true, { ignoreProperties?: (CSSPropertiesMap | RegExp)[] | (string | RegExp)[] message?: string | ((property: string) => string) } > type RuleEmptyLineBeforeOptions = RuleConfig< 'always' | 'never' | 'always-multi-line' | 'never-multi-line', { except?: LiteralUnion<'after-rule' | 'after-single-line-comment' | 'inside-block-and-after-rule' | 'inside-block' | 'first-nested'>[] ignore?: LiteralUnion<'after-comment' | 'first-nested' | 'inside-block'>[] message?: string | ((property: string) => string) } > type RuleSelectorPropertyDisallowed = CSSPropertiesMap | RegExpLike type RuleSelectorPropertyDisallowedListOptions = RuleConfig< Record<string, RuleSelectorPropertyDisallowed | RuleSelectorPropertyDisallowed[]>, { message?: string | ((selector: string, property: string) => string) ignore?: ['keyframe-selectors'] } > type SectorAnbNoUnmatchableOptions = RuleConfig< true, { message?: string | ((pseudoClass: string) => string) } > type SelectorAttributeNameDisallowedListOptions = RuleConfig< string | RegExp | (string | RegExp)[], { message?: string | ((name: string) => string) } > type SelectorAttributeOperatorAllowedListOptions = RuleConfig< SelectorAttributeOperator | RegExp | (SelectorAttributeOperator | RegExp)[], { message?: string | ((operator: string) => string) } > type SelectorAttributeOperatorDisallowedListOptions = RuleConfig< SelectorAttributeOperator | RegExp | (SelectorAttributeOperator | RegExp)[], { message?: string | ((operator: string) => string) } > type SelectorAttributeQuotesOptions = RuleConfig< 'always' | 'never', { message?: string | ((value: string) => string) } > type SelectorClassPatternOptions = RuleConfig< string | RegExp, { /** * This option will resolve nested selectors with `&` interpolation. * @default false */ resolveNestedSelectors?: boolean message?: string | ((selector: string, pattern: string) => string) } > type SelectorCombinatorAllowedListOptions = RuleConfig< SelectorCombinator | SelectorCombinator[], { message?: string | ((combinator: string) => string) } > type SelectorCombinatorDisallowedListOptions = RuleConfig< SelectorCombinator | SelectorCombinator[], { message?: string | ((combinator: string) => string) } > type SelectorDisallowedListIgnore = 'inside-block' | 'keyframe-selectors' type SelectorDisallowedListOptions = RuleConfig< string | RegExp | (string | RegExp)[], { /** * Split selector lists into individual selectors. * @default false */ splitList?: boolean /** * Ignore selectors that are inside a block. */ ignore?: [SelectorDisallowedListIgnore] message?: string | ((selector: string) => string) } > type SelectorIdPatternOptions = RuleConfig< string | RegExp, { message?: string | ((selector: string, pattern: string) => string) } > type SelectorMaxAttributeOptions = RuleConfig< number, { ignoreAttributes?: (string | RegExp)[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxClassOptions = RuleConfig< number, { message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxCombinatorsOptions = RuleConfig< number, { message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxCompoundSelectorsOptions = RuleConfig< number, { ignoreSelectors?: (string | RegExp)[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxIdOptions = RuleConfig< number, { checkContextFunctionalPseudoClasses?: (string | RegExp)[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxPseudoClassOptions = RuleConfig< number, { message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxSpecificityOptions = RuleConfig< `${string},${string},${string}`, { ignoreSelectors?: (string | RegExp)[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxTypeOptions = RuleConfig< number, { /** * Discount child type selectors. */ Ignore?: LiteralUnion<'child' | 'compounded' | 'custom-elements' | 'descendant' | 'next-sibling'>[] ignoreTypes?: (string | RegExp)[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorMaxUniversalOptions = RuleConfig< number, { /** * Ignore universal selectors that come after one of the specified combinators. */ ignoreAfterCombinators?: SelectorCombinator[] message?: string | ((selector: string, max: number | string) => string) } > type SelectorNestedPatternOptions = RuleConfig< string | RegExp, { /** * Split selector lists into individual selectors. * @default false */ splitList?: boolean message?: string | ((selector: string) => string) } > type SelectorNoQualifyingTypeIgnore = 'attribute' | 'class' | 'id' type SelectorNoQualifyingTypeOptions = RuleConfig< true, { ignore?: SelectorNoQualifyingTypeIgnore[] message?: string | ((selector: string) => string) } > type SelectorNoVendorPrefixOptions = RuleConfig< true, { ignoreSelectors?: (string | RegExp)[] message?: string | ((selector: string) => string) } > type SelectorNotNotationOptions = RuleConfig< 'simple' | 'complex', { message?: string | ((selector: string) => string) } > type SelectorPseudoClassAllowedListOptions = RuleConfig< SelectorPseudoClass | RegExpLike | (SelectorPseudoClass | RegExpLike)[], { message?: string | ((selector: string) => string) } > type SelectorPseudoClassDisallowedListOptions = RuleConfig< SelectorPseudoClass | RegExpLike | (SelectorPseudoClass | RegExpLike)[], { message?: string | ((selector: string) => string) } > type SelectorPseudoClassNoUnknownOptions = RuleConfig< true, { ignorePseudoClasses?: (string | RegExp)[] message?: string | ((selector: string) => string) } > type PseudoElement = SelectorPseudoElement | RegExp | `/${string}/` type SelectorPseudoElementAllowedListOptions = RuleConfig< PseudoElement | PseudoElement[], { message?: string | ((selector: string) => string) } > type SelectorPseudoElementColonNotationOptions = RuleConfig< 'single' | 'double', { message?: string | ((selector: string) => string) } > type SelectorPseudoElementDisallowed = SelectorPseudoElement | RegExpLike type SelectorPseudoElementDisallowedListOptions = RuleConfig< SelectorPseudoElementDisallowed | SelectorPseudoElementDisallowed[], { message?: string | ((selector: string) => string) } > type SelectorPseudoElementNoUnknownOptions = RuleConfig< true, { ignorePseudoElements?: (string | RegExp)[] message?: string | ((selector: string) => string) } > type SelectorTypeCaseOptions = RuleConfig< 'lower' | 'upper', { ignoreTypes?: (string | RegExp)[] message?: string | ((selector: string) => string) } > type SelectorTypeNoUnknownIgnore = LiteralUnion<'custom-elements' | 'default-namespace'> type SelectorTypeNoUnknownOptions = RuleConfig< true, { ignore?: SelectorTypeNoUnknownIgnore[] ignoreNamespaces?: (string | RegExp)[] ignoreTypes?: (string | RegExp)[] message?: string | ((selector: string) => string) } > type ShorthandPropertyNoRedundantValuesOptions = RuleConfig< true, { message?: string | ((unexpected: string, expected: string) => string) /** * Ignore four-value shorthand declarations that could be shortened to three values when applied to edges. */ ignore?: readonly ['four-into-three-edge-values'] } > type StringNoNewlineOptions = RuleConfig<true, { ignore?: ('at-rule-preludes' | 'declaration-values')[] message?: string | (() => string) }> type SyntaxStringNoInvalidOptions = RuleConfig<true, { message?: string | ((syntaxString: string) => string) }> type TimeMinMillisecondsIgnore = 'delay' type TimeMinMillisecondsOptions = RuleConfig< number, { /** * Ignore time values for an animation or transition delay. */ ignore?: TimeMinMillisecondsIgnore[] message?: string | ((time: number) => string) } > type UnitAllowedListIgnoreProperties = Partial< Record< Unit, CSSPropertiesMap | RegExp | (CSSPropertiesMap | RegExp)[] > > type UnitAllowedListIgnoreFunctions = | CSSFunction | RegExpLike | (CSSFunction | RegExpLike)[] type UnitAllowedListOptions = RuleConfig< Unit | Unit[], { ignoreProperties?: UnitAllowedListIgnoreProperties ignoreFunctions?: UnitAllowedListIgnoreFunctions message?: string | ((unit: number) => string) } > type UnitDisallowedListIgnoreProperties = Partial< Record< Unit, CSSPropertiesMap | RegExp | (CSSPropertiesMap | RegExp)[] > > type UnitDisallowedListIgnoreFunctions = | CSSFunction | RegExpLike | (CSSFunction | RegExpLike)[] type UnitDisallowedListIgnoreMediaFeatureNames = Partial< Record< Unit, MediaFeature | RegExpLike | (MediaFeature | RegExpLike)[] > > type UnitDisallowedListOptions = RuleConfig< Unit | Unit[], { /** * Ignore units in the values of declarations with the specified properties. */ ignoreProperties?: UnitDisallowedListIgnoreProperties /** * Ignore units for specific feature names. */ ignoreFunctions?: UnitDisallowedListIgnoreFunctions /** * Ignore units that are inside of the specified functions. */ ignoreMediaFeatureNames?: UnitDisallowedListIgnoreMediaFeatureNames message?: string | ((unit: number) => string) } > type UnitNoUnknownOptions = RuleConfig< true, { ignoreUnits?: (RegExp | string)[] ignoreFunctions?: (MediaFeature | RegExpLike)[] message?: string | ((unit: number) => string) } > type ValueKeywordCaseOptions = RuleConfig< 'lower' | 'upper', { /** * Ignore case of keywords values. */ ignoreKeywords?: (string | RegExp)[] /** * Ignore case of the values of the listed properties. */ ignoreProperties?: (CSSPropertiesMap | RegExpLike)[] /** * Ignore case of the values inside the listed functions. */ ignoreFunctions?: (CSSFunction | RegExpLike)[] /** * If `true`, this rule expects SVG keywords to be camel case when the primary option is "lower". * @default false */ camelCaseSvgKeywords?: boolean message?: string | ((actual: number, expected: string) => string) } > type ValueNoVendorPrefixOptions = RuleConfig< true, { ignoreValues: string | RegExp | (string | RegExp)[] message?: string | ((actual: number, expected: string) => string) } > /** * Rules determine what the linter looks for and complains about. * There are {@link https://stylelint.io/user-guide/rules over 100 rules} built into Stylelint. No rules are turned on by default. */ interface StyleLintRules { /** * Specify percentage or number notation for alpha-values. * * ```scss * a { color: rgb(0 0 0 / 0.5) } * // ^^^ * // This notation * ``` * * ### Primary Options: * - `"number"`: Alpha-values must always use the number notation. * - `"percentage"`: Alpha-values must always use percentage notation. * * ### Optional Secondary Options: * * - `exceptProperties`: Reverse the primary option for matching properties. * * @see [alpha-value-notation](https://stylelint.io/user-guide/rules/alpha-value-notation) * @example * ```json * { * "alpha-value-notation": ["number", { "exceptProperties": ["opacity"] }] * } * ``` */ 'alpha-value-notation': AlphaValueNotationOptions /** * Disallow unknown annotations. * * * ```scss * a { color: green !important; } * // ^^^^^^^^^^ * // This annotation * ``` * * This rule considers annotations defined in the CSS Specifications, up to and including Editor's Drafts, to be known. * * ### Primary Options: * * `true` * * ### Optional Secondary Options: * - `ignoreAnnotations` * * @see [annotation-no-unknown](https://stylelint.io/user-guide/rules/annotation-no-unknown) */ 'annotation-no-unknown': AnnotationNoUnknownOptions /** * Specify a list of allowed at-rules. * * >```scss * >@keyframes name {} * >//^^^^^^^^ * >//At-rules like this * >``` * * ### Primary Options: * - `array | string` * * @see [at-rule-allowed-list](https://stylelint.io/user-guide/rules/at-rule-allowed-list) */ 'at-rule-allowed-list': AtRuleAllowedListOptions /** * Disallow unknown descriptors for at-rules. * * >```scss * >@counter-style foo { * > unknown-descriptor: cyclic; * >// ^^^^^^^^^^^^^^^^^^ * >// Descriptors like this * >} * >``` * This rule considers descriptors defined in the CSS Specifications, up to and including Editor's Drafts, to be known. * * @see [at-rule-descriptor-no-unknown](https://stylelint.io/user-guide/rules/at-rule-descriptor-no-unknown) */ 'at-rule-descriptor-no-unknown': AtRuleDescriptorNoUnknownOptions /** * Disallow unknown values for descriptors within at-rules. * * >``` scss * >@counter-style foo { * > system: unknown; * >// ^^^^^^^ * >// Values like this * >} * >``` * * This rule considers descriptors and values defined in the CSS Specifications, up to and including Editor's Drafts, to be known. * * @see [at-rule-descriptor-value-no-unknown](https://stylelint.io/user-guide/rules/at-rule-descriptor-value-no-unknown) */ 'at-rule-descriptor-value-no-unknown': AtRuleDescriptorValueNoUnknownOptions /** * Specify a list of disallowed at-rules. * * >```scss * >@keyframes name {} * >//^^^^^^^^ * >//At-rules like this * >``` * ### Primary Options: * - `array | string` * * @see [at-rule-disallowed-list](https://stylelint.io/user-guide/rules/at-rule-disallowed-list) */ 'at-rule-disallowed-list': AtRuleDisallowedListOptions /** * Require or disallow an empty line before at-rules. * * >```scss * >a {} * > // ← This line * >@media {} * >``` * * This rule ignores: * - at-rules that are the very first node in the source * - `@import` in Less. * * ### Primary Options: * - `"always"`: There must always be an empty line before at-rules. * - `"never"`: There must never be an empty line before at-rules. * * ### Optional Secondary Options: * - `except` * - `ignore` * - `ignoreAtRules` * * @see [at-rule-empty-line-before](https://stylelint.io/user-guide/rules/at-rule-empty-line-before) */ 'at-rule-empty-line-before': AtRuleEmptyLineBeforeOptions /** * Disallow deprecated at-rules. * * >``` scss * >@viewport {} * >//^^^^^^^ * >//At-rules like this * >``` * * This rule flags at-rules that were removed or deprecated after being in the CSS specifications, including editor drafts, and were subsequently either: * * - shipped in a stable version of a browser * - shipped by a developer channel/edition browser * - shipped but behind experimental flags * - polyfilled with some adoption before any browser actually shipped * - had an MDN page at one point in time * * @see [at-rule-no-deprecated](https://stylelint.io/user-guide/rules/at-rule-no-deprecated) */ 'at-rule-no-deprecated': AtRuleNoDeprecatedOptions /** * Disallow unknown at-rules. * * >```scss * >@unknown (max-width: 960px) {} * >//^^^^^^ * >//At-rules like this * >``` * * This rule considers at-rules defined in the CSS Specifications, * up to and including Editor's Drafts, to be known. * * ### Primary Options: * `true` * * ### Optional Secondary Options: * - `ignoreAtRules` * * @see [at-rule-no-unknown](https://stylelint.io/user-guide/rules/at-rule-no-unknown) */ 'at-rule-no-unknown': AtRuleNoUnknownOptions /** * Disallow vendor prefixes for at-rules. * * >```scss * >@-webkit-keyframes { 0% { top: 0; } } * >//^^^^^^ * >//This prefix * >``` * * ### Primary Options: * `true` * * This rule ignores non-standard vendor-prefixed at-rules that aren't handled by * {@link https://github.com/postcss/autoprefixer Autoprefixer}. * * @see [at-rule-no-vendor-prefix](https://stylelint.io/user-guide/rules/at-rule-no-vendor-prefix) */ 'at-rule-no-vendor-prefix': AtRuleNoVendorPrefixOptions /** * Disallow invalid preludes for at-rules. * * >```scss * >@property --foo {} * >// ^^^^^ * >// Preludes like this * >``` * * This rule considers preludes for at-rules defined within the CSS specifications, up to and including Editor's Drafts, to be valid. * * @see [at-rule-prelude-no-invalid](https://stylelint.io/user-guide/rules/at-rule-prelude-no-invalid) */ 'at-rule-prelude-no-invalid': AtRulePreludeNoInvalidOptions /** * Specify a list of required properties for an at-rule. * * ### Primary Options * `object`: `{ "at-rule-name": ["array", "of", "properties"] |"property" }` * * @see [at-rule-property-required-list](https://stylelint.io/user-guide/rules/at-rule-property-required-list) */ 'at-rule-property-required-list': AtRulePropertyRequiredListOptions /** * Disallow empty blocks. * * ```scss * a { } * // ^^ * // Blocks like this * ``` * * ### Primary Options: * `true` * * @see [block-no-empty](https://stylelint.io/user-guide/rules/block-no-empty) */ 'block-no-empty': BlockNoEmptyOptions /** * Specify alias notation for color-functions * * ```scss * a { color: rgb(0 0 0 / 0.2) } * // ^^^ * // This notation * ``` * * Color functions `rgb()` and `hsl()` have aliases `rgba()` and `hsla()`. Those are exactly equivalent, and [it's preferable](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb) to use the first variant without `a`. * * ### Primary Options * - `'without-alpha'`: Applicable color-functions must always use the without alpha notation. * - `'with-alpha'`: Applicable color-functions must always use with alpha notation. * * @see [color-function-alias-notation](https://stylelint.io/user-guide/rules/color-function-alias-notation) */ 'color-function-alias-notation': ColorFunctionAliasNatationOptions /** * Specify modern or legacy notation for color-functions. * * ```scss * a { color: rgb(0 0 0 / 0.2) } * // ^^^ * // This notation * ``` * * Modern color-functions use a comma-free syntax because functions in CSS are used to group/name a syntax chunk. * They should work by the same rules that CSS grammar does in general: * values are optional and re-orderable when possible, space-separated, and commas are used to separate repetitions only. * * For legacy reasons, `rgb()` and `hsl()` also supports an alternate syntax that separates all of its arguments with commas. * Also for legacy reasons, the `rgba()` and `hsla()` functions exist using the same comma-based syntax. * * ### Primary Options * - `"modern"`: Applicable color-functions must always use modern notation. * - `"legacy"`: Applicable color-functions must always use the legacy notation. * * ### Optional Secondary Options * - `ignore` * * @see [color-function-notation](https://stylelint.io/user-guide/rules/color-function-notation) */ 'color-function-notation': ColorFunctionNatationOptions /** * Require or disallow alpha channel for hex colors. * * ```scss * a { color: #fffa } * // ^ * // This alpha channel * ``` * * ### Primary Options * - `"always"` * - `"never"` * * @see [color-hex-alpha](https://stylelint.io/user-guide/rules/color-hex-alpha) */ 'color-hex-alpha': ColorHexAlphaOptions /** * Specify short or long notation for hex colors. * * ```scss * a { color: #fff } * // ^^^^ * // This hex color * ``` * * ### Primary Options * - `"short"` * - `"long"` * * @see [color-hex-length](https://stylelint.io/user-guide/rules/color-hex-length) */ 'color-hex-length': ColorHexLengthOptions /** * Require (where possible) or disallow named colors. * * ```scss * a { color: black } * // ^^^^^ * // This named color * ``` * * This rule ignores `$sass` and `@less` variable syntaxes. * * ### Primary Options * - `"always-where-possible"`: Colors must always, where possible, be named. * This will complain if a hex (3, 4, 6 and 8 digit), `rgb()`, `rgba()`, `hsl()`, * `hsla()`, `hwb()` or `gray()` color can be represented as a named color. * - `"never"`: Colors must never be named. * * ### Optional Secondary Options * - `ignore` * - `ignoreProperties` * * @see [color-named](https://stylelint.io/user-guide/rules/color-named) */ 'color-named': ColorNamedOptions /** * Disallow hex colors. * * ```scss * a { color: #333 } * // ^^^^ * // This hex color * ``` * * ### Primary Options * `true` * * @see [color-no-hex](https://stylelint.io/user-guide/rules/color-no-hex) */ 'color-no-hex': ColorNoHexOptions /** * Disallow invalid hex colors. * * ```scss * a { color: #y3 } * // ^^^ * // This hex color * ``` * * ### Primary Options * `true` * * Longhand hex colors can be either 6 or 8 (with alpha channel) hexadecimal characters. * And their shorthand variants are 3 and 4 characters respectively. * * @see [color-no-invalid-hex](https://stylelint.io/user-guide/rules/color-no-invalid-hex) */ 'color-no-invalid-hex': ColorNoInvalidHexOptions /** * Require or disallow an empty line before comments. * * ```scss * a {} * // ← * \/* comment *\/ // ↑ * // ↑ * // This line * ``` * * This rule ignores: * - comments that are the very first node in the source * - shared-line comments * - single-line comments with `//` (when you're using a custom syntax that supports them) * - comments within selector and value lists * * ### Primary Options * - `"always"`: There must always be an empty line before comments. * - `"never"`: There must never be an empty line before comments. * * ### Optional Secondary Options * * - `except` * - `ignore` * - `ignoreComments` * * @see [comment-empty-line-before](https://stylelint.io/user-guide/rules/comment-empty-line-before) */ 'comment-empty-line-before': CommentEmptyLineBeforeOptions /** * Disallow empty comments. * * ```scss * \/* *\/ * // ^^^ * // Comments like this * ``` * * This rule ignores SCSS-like comments. * * ### Primary Options * `true` * * @see [comment-no-empty](https://stylelint.io/user-guide/rules/comment-no-empty) */ 'comment-no-empty': CommentNoEmptyOptions /** * Specify a pattern for comments. * * ```scss * \/* comment *\/ * ^^^^^^^ * The pattern of this * ``` * * ### Primary Options * * `RegExp | string` * * A string will be translated into a RegExp like so `new RegExp(yourString)` — so be sure to escape properly. * * @see [comment-pattern](https://stylelint.io/user-guide/rules/comment-pattern) */ 'comment-pattern': CommentPatternOptions /** * Require or disallow whitespace on the inside of comment markers. * * ```scss * \/* comment *\/ * ^ ^ * The space inside these two markers * ``` * * Any number of asterisks are allowed at the beginning or end of the comment. * * ### Primary Options * - `"always"`: There must always be whitespace inside the markers. * - `"never"`: There must never be whitespace on the inside the markers. * * @see [comment-whitespace-inside](https://stylelint.io/user-guide/rules/comment-whitespace-inside) */ 'comment-whitespace-inside': CommentWhitespaceInsideOptions /** * Specify a list of disallowed words within comments. * * ```scss * \/* words within comments *\/ * // ^^^^^ ^^^^^^ ^^^^^^^^ * // These three words * ``` * * ### Primary Option * `(string | RegExp)[]` * * @see [comment-word-disallowed-list](https://stylelint.io/user-guide/rules/comment-word-disallowed-list) */ 'comment-word-disallowed-list': CommentWordDisallowedListOptions /** * Specify a pattern for container names. * * >```scss * >@container foo (width > 400px) {} * >// ^^^ * >// The pattern of this * >``` * * ### Primary Options * `RegExp | string`: A string will be translated into a `RegExp` like so `new RegExp(yourString)` — so be sure to escape properly. * * @se