@alexlit/lint-kit 182.1.0 → 182.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/config-eslint/package.json +3 -3
- package/packages/config-eslint/plugins/unocss.js +4 -6
- package/packages/config-stylelint/node_modules/ansi-regex/index.d.ts +33 -0
- package/packages/config-stylelint/node_modules/ansi-regex/index.js +14 -0
- package/packages/config-stylelint/node_modules/ansi-regex/license +9 -0
- package/packages/config-stylelint/node_modules/ansi-regex/package.json +61 -0
- package/packages/config-stylelint/node_modules/ansi-regex/readme.md +66 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/LICENSE +19 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/README.md +630 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.cjs +559 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.cts +304 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.ts +304 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.js +525 -0
- package/packages/config-stylelint/node_modules/file-entry-cache/package.json +62 -0
- package/packages/config-stylelint/node_modules/flat-cache/LICENSE +19 -0
- package/packages/config-stylelint/node_modules/flat-cache/README.md +235 -0
- package/packages/config-stylelint/node_modules/flat-cache/dist/index.cjs +495 -0
- package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.cts +255 -0
- package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.ts +255 -0
- package/packages/config-stylelint/node_modules/flat-cache/dist/index.js +455 -0
- package/packages/config-stylelint/node_modules/flat-cache/package.json +87 -0
- package/packages/config-stylelint/node_modules/globby/ignore.js +337 -0
- package/packages/config-stylelint/node_modules/globby/index.d.ts +394 -0
- package/packages/config-stylelint/node_modules/globby/index.js +488 -0
- package/packages/config-stylelint/node_modules/globby/license +9 -0
- package/packages/config-stylelint/node_modules/globby/package.json +94 -0
- package/packages/config-stylelint/node_modules/globby/readme.md +388 -0
- package/packages/config-stylelint/node_modules/globby/utilities.js +382 -0
- package/packages/config-stylelint/node_modules/meow/build/dependencies.js +7347 -0
- package/packages/config-stylelint/node_modules/meow/build/index.d.ts +2684 -0
- package/packages/config-stylelint/node_modules/meow/build/index.js +185 -0
- package/packages/config-stylelint/node_modules/meow/build/licenses.md +1254 -0
- package/packages/config-stylelint/node_modules/meow/build/options.js +147 -0
- package/packages/config-stylelint/node_modules/meow/build/parser.js +113 -0
- package/packages/config-stylelint/node_modules/meow/build/utils.js +7 -0
- package/packages/config-stylelint/node_modules/meow/build/validate.js +145 -0
- package/packages/config-stylelint/node_modules/meow/license +9 -0
- package/packages/config-stylelint/node_modules/meow/package.json +103 -0
- package/packages/config-stylelint/node_modules/meow/readme.md +387 -0
- package/packages/config-stylelint/node_modules/postcss-safe-parser/LICENSE +20 -0
- package/packages/config-stylelint/node_modules/postcss-safe-parser/README.md +25 -0
- package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parse.js +12 -0
- package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parser.js +100 -0
- package/packages/config-stylelint/node_modules/postcss-safe-parser/package.json +36 -0
- package/packages/config-stylelint/node_modules/slash/index.d.ts +23 -0
- package/packages/config-stylelint/node_modules/slash/index.js +9 -0
- package/packages/config-stylelint/node_modules/slash/license +9 -0
- package/packages/config-stylelint/node_modules/slash/package.json +39 -0
- package/packages/config-stylelint/node_modules/slash/readme.md +36 -0
- package/packages/config-stylelint/node_modules/string-width/index.d.ts +39 -0
- package/packages/config-stylelint/node_modules/string-width/index.js +119 -0
- package/packages/config-stylelint/node_modules/string-width/license +9 -0
- package/packages/config-stylelint/node_modules/string-width/package.json +65 -0
- package/packages/config-stylelint/node_modules/string-width/readme.md +66 -0
- package/packages/config-stylelint/node_modules/strip-ansi/index.d.ts +15 -0
- package/packages/config-stylelint/node_modules/strip-ansi/index.js +19 -0
- package/packages/config-stylelint/node_modules/strip-ansi/license +9 -0
- package/packages/config-stylelint/node_modules/strip-ansi/package.json +59 -0
- package/packages/config-stylelint/node_modules/strip-ansi/readme.md +37 -0
- package/packages/config-stylelint/node_modules/stylelint/LICENSE +20 -0
- package/packages/config-stylelint/node_modules/stylelint/README.md +113 -0
- package/packages/config-stylelint/node_modules/stylelint/bin/stylelint.mjs +7 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/assignDisabledRanges.mjs +483 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/augmentConfig.mjs +586 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/cli.mjs +746 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/constants.mjs +25 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/createPartialStylelintResult.mjs +114 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/createPlugin.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/createStylelint.mjs +37 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/descriptionlessDisables.mjs +51 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/calcSeverityCounts.mjs +21 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/compactFormatter.mjs +23 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/index.mjs +23 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/jsonFormatter.mjs +10 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/preprocessWarnings.mjs +74 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/stringFormatter.mjs +308 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/tapFormatter.mjs +85 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/terminalLink.mjs +21 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/unixFormatter.mjs +32 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/formatters/verboseFormatter.mjs +175 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/getConfigForFile.mjs +110 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/getPostcssResult.mjs +130 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/index.mjs +38 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/invalidScopeDisables.mjs +41 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/isPathIgnored.mjs +48 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/lintPostcssResult.mjs +172 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/lintSource.mjs +135 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/needlessDisables.mjs +91 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/normalizeAllRuleSettings.mjs +29 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/normalizeRuleSettings.mjs +56 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/postcssPlugin.mjs +50 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/prepareReturnValue.mjs +63 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/printConfig.mjs +44 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/atKeywords.mjs +83 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/functions.mjs +96 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/keywords.mjs +663 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaFeatures.mjs +115 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaTypes.mjs +14 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/prefixes.mjs +17 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/properties.mjs +1112 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/selectors.mjs +472 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reference/units.mjs +82 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reportDisables.mjs +48 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/reportUnknownRuleNames.mjs +76 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/resolveConfig.mjs +43 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/alpha-value-notation/index.mjs +207 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/annotation-no-unknown/index.mjs +88 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-allowed-list/index.mjs +62 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-no-unknown/index.mjs +108 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-value-no-unknown/index.mjs +64 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-disallowed-list/index.mjs +62 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-empty-line-before/index.mjs +178 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-deprecated/index.mjs +86 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-unknown/index.mjs +80 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-vendor-prefix/index.mjs +82 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-prelude-no-invalid/index.mjs +76 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-property-required-list/index.mjs +92 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-empty/index.mjs +116 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-redundant-nested-style-rules/index.mjs +52 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-alias-notation/index.mjs +87 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-notation/index.mjs +168 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-alpha/index.mjs +75 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-length/index.mjs +128 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/colordUtils.mjs +109 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/index.mjs +183 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-hex/index.mjs +69 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-invalid-hex/index.mjs +68 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-empty-line-before/index.mjs +131 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-no-empty/index.mjs +50 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-pattern/index.mjs +51 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-whitespace-inside/index.mjs +149 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-word-disallowed-list/index.mjs +63 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/container-name-pattern/index.mjs +107 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-media-pattern/index.mjs +61 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-empty-line-before/index.mjs +156 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-no-missing-var-function/index.mjs +148 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-pattern/index.mjs +100 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-custom-properties/index.mjs +82 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-properties/index.mjs +301 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-redundant-longhand-properties/index.mjs +411 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/index.mjs +74 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/index.mjs +62 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-empty-line-before/index.mjs +160 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-no-important/index.mjs +51 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-max-values/index.mjs +79 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-allowed-list/index.mjs +108 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-disallowed-list/index.mjs +94 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-allowed-list/index.mjs +66 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-disallowed-list/index.mjs +66 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-keyword-no-deprecated/index.mjs +203 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-no-unknown/index.mjs +424 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/display-notation/index.mjs +225 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-name-quotes/index.mjs +243 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-duplicate-names/index.mjs +122 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-missing-generic-family-keyword/index.mjs +122 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-weight-notation/index.mjs +221 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-allowed-list/index.mjs +114 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-calc-no-unspaced-operator/index.mjs +589 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-disallowed-list/index.mjs +73 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-linear-gradient-no-nonstandard-direction/index.mjs +145 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-name-case/index.mjs +120 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-no-unknown/index.mjs +83 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-no-scheme-relative/index.mjs +67 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-quotes/index.mjs +230 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-allowed-list/index.mjs +70 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-disallowed-list/index.mjs +70 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/hue-degree-notation/index.mjs +123 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/import-notation/index.mjs +104 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/index.mjs +180 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-block-no-duplicate-selectors/index.mjs +68 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-declaration-no-important/index.mjs +54 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-selector-notation/index.mjs +202 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframes-name-pattern/index.mjs +63 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/layer-name-pattern/index.mjs +91 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/length-zero-no-unit/index.mjs +221 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/lightness-notation/index.mjs +165 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/max-nesting-depth/index.mjs +195 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-allowed-list/index.mjs +67 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-disallowed-list/index.mjs +67 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-unknown/index.mjs +79 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-vendor-prefix/index.mjs +94 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-unit-allowed-list/index.mjs +110 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-allowed-list/index.mjs +100 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-no-unknown/index.mjs +277 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-range-notation/index.mjs +187 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-query-no-invalid/index.mjs +193 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-type-no-deprecated/index.mjs +82 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/index.mjs +117 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/utils/findNotContiguousOrRectangular.mjs +57 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/nesting-selector-no-missing-scoping-root/index.mjs +165 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-descending-specificity/index.mjs +200 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-at-import-rules/index.mjs +156 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-selectors/index.mjs +218 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-empty-source/index.mjs +61 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-double-slash-comments/index.mjs +77 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-at-import-rule/index.mjs +76 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-declaration/index.mjs +86 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-irregular-whitespace/index.mjs +236 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-animations/index.mjs +71 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-media/index.mjs +77 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-properties/index.mjs +72 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/number-max-precision/index.mjs +209 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-allowed-list/index.mjs +58 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-disallowed-list/index.mjs +58 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-deprecated/index.mjs +143 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-unknown/index.mjs +126 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-vendor-prefix/index.mjs +100 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-empty-line-before/index.mjs +156 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-nesting-at-rule-required-list/index.mjs +85 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-selector-property-disallowed-list/index.mjs +119 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-anb-no-unmatchable/index.mjs +121 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-name-disallowed-list/index.mjs +69 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-allowed-list/index.mjs +70 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-disallowed-list/index.mjs +70 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-quotes/index.mjs +107 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-class-pattern/index.mjs +71 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-allowed-list/index.mjs +81 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-disallowed-list/index.mjs +81 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-disallowed-list/index.mjs +115 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-id-pattern/index.mjs +66 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-attribute/index.mjs +92 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-class/index.mjs +75 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-combinators/index.mjs +77 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-compound-selectors/index.mjs +123 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-id/index.mjs +107 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-pseudo-class/index.mjs +85 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-specificity/index.mjs +146 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-type/index.mjs +219 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-universal/index.mjs +95 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-nested-pattern/index.mjs +95 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-qualifying-type/index.mjs +323 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-vendor-prefix/index.mjs +92 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-not-notation/index.mjs +217 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-allowed-list/index.mjs +84 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-disallowed-list/index.mjs +84 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-no-unknown/index.mjs +179 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-allowed-list/index.mjs +75 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/index.mjs +93 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-disallowed-list/index.mjs +74 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-no-unknown/index.mjs +91 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-case/index.mjs +118 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-no-unknown/index.mjs +148 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/shorthand-property-no-redundant-values/index.mjs +359 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/string-no-newline/index.mjs +120 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/syntax-string-no-invalid/index.mjs +80 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/time-min-milliseconds/index.mjs +167 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-allowed-list/index.mjs +116 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-disallowed-list/index.mjs +211 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-no-unknown/index.mjs +207 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-keyword-case/index.mjs +253 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.mjs +92 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/standalone.mjs +381 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/timing.mjs +134 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/unscopedDisables.mjs +66 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/FileCache.mjs +115 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/addEmptyLineBefore.mjs +21 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/addSemicolonForEditInfo.mjs +35 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/appendRuleName.mjs +13 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/arrayEqual.mjs +14 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/beforeBlockString.mjs +28 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/blockString.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/blurInterpolation.mjs +8 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/cachedImport.mjs +68 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkAgainstRule.mjs +71 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkInvalidCLIOptions.mjs +105 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/configurationComment.mjs +74 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/containsString.mjs +52 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/createMapWithSet.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/dynamicImport.mjs +13 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachDeclarationBlock.mjs +59 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachNodeUpToRoot.mjs +22 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/emitWarning.mjs +83 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/errors.mjs +55 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/filterFilePaths.mjs +17 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAnimationName.mjs +74 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAtRuleContext.mjs +27 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/findFontFamily.mjs +148 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/findMediaFeatureNames.mjs +151 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/findNodeUpToRoot.mjs +25 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/fixEmptyLinesBefore.mjs +26 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/functionArgumentsSearch.mjs +64 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getAtRuleParams.mjs +7 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDeclarationValue.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDimension.mjs +62 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFileIgnorer.mjs +41 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatter.mjs +43 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatterOptionsText.mjs +12 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getImportantPosition.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getLexer.mjs +39 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getModulePath.mjs +35 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getNextNonSharedLineCommentNode.mjs +34 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.mjs +36 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRelativePath.mjs +12 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRuleSelector.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSchemeFromUrl.mjs +36 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSelectorSourceIndex.mjs +12 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStrippedSelectorSource.mjs +47 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStylelintRule.mjs +22 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasBlock.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasEmptyLine.mjs +13 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasInterpolation.mjs +24 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasLessInterpolation.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasPsvInterpolation.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasScssInterpolation.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasTplInterpolation.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/hash.mjs +10 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterBlock.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterComment.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterSingleLineComment.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterStandardPropertyDeclaration.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAutoprefixable.mjs +364 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterBlocklessAtRule.mjs +21 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterSameNameBlocklessAtRule.mjs +21 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isContextFunctionalPseudoClass.mjs +24 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterIncrementCustomIdentValue.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterResetCustomIdentValue.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomElement.mjs +34 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomFunction.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomMediaQuery.mjs +8 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomProperty.mjs +8 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomSelector.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isDescriptorDeclaration.mjs +22 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNested.mjs +83 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNodeOfRoot.mjs +17 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isHexColor.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isInDocument.mjs +32 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeRule.mjs +17 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeSelector.mjs +29 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isMathFunction.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNonNegativeInteger.mjs +6 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNumbery.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isOnlyWhitespace.mjs +17 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isPathNotFoundError.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isScssVariable.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSharedLineComment.mjs +53 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSingleLineString.mjs +10 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxAtRule.mjs +32 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxColorFunction.mjs +24 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxCombinator.mjs +32 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxComment.mjs +13 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxDeclaration.mjs +57 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxFunction.mjs +28 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxHexColor.mjs +14 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxKeyframesName.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxProperty.mjs +32 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxRule.mjs +24 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxSelector.mjs +56 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxTypeSelector.mjs +56 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxUrl.mjs +49 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxValue.mjs +51 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeRangeDescriptor.mjs +24 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeSupported.mjs +26 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUrlFunction.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidFontSize.mjs +38 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidHex.mjs +11 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidIdentifier.mjs +39 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVarFunction.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVariable.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/isWhitespace.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/matchesStringOrRegExp.mjs +97 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/mergeSyntaxDefinitions.mjs +137 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/narrowFixRange.mjs +68 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeContextLookup.mjs +41 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeFieldIndices.mjs +119 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFilePath.mjs +26 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFixMode.mjs +22 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeSelector.mjs +166 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/optionsMatches.mjs +20 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseCustomMediaQuery.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseMediaQuery.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseSelector.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/pathExists.mjs +16 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/pluralize.mjs +10 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/putIfAbsent.mjs +20 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/rangesOverlap.mjs +19 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/rawNodeString.mjs +29 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/regexes.mjs +135 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/removeEmptyLinesBefore.mjs +13 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/report.mjs +321 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/reportCommentProblem.mjs +39 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveFilePath.mjs +38 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveNestedSelectorsForRule.mjs +108 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveOptionValue.mjs +30 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveSilent.mjs +144 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/ruleMessages.mjs +18 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/setAtRuleParams.mjs +18 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/setDeclarationValue.mjs +18 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/suppressionsService.mjs +317 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/toPath.mjs +23 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/typeGuards.mjs +90 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/uniteSets.mjs +9 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithArrayProps.mjs +29 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithProps.mjs +28 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateOptions.mjs +176 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateTypes.mjs +148 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/utils/vendor.mjs +43 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/validateDisableSettings.mjs +67 -0
- package/packages/config-stylelint/node_modules/stylelint/lib/writeOutputFile.mjs +15 -0
- package/packages/config-stylelint/node_modules/stylelint/package.json +212 -0
- package/packages/config-stylelint/node_modules/stylelint/types/stylelint/index.d.ts +1590 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/default.d.ts +13 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/default.js +14 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/license +9 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/node.d.ts +125 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/node.js +49 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/package.json +68 -0
- package/packages/config-stylelint/node_modules/unicorn-magic/readme.md +31 -0
- package/packages/config-stylelint/package.json +2 -2
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { EOL } from 'node:os';
|
|
2
|
+
|
|
3
|
+
import { DEFAULT_SEVERITY, RULE_NAME_ALL } from './constants.mjs';
|
|
4
|
+
import { DEFAULT_CONFIGURATION_COMMENT } from './utils/configurationComment.mjs';
|
|
5
|
+
import assignDisabledRanges from './assignDisabledRanges.mjs';
|
|
6
|
+
import { emitDeprecationWarning } from './utils/emitWarning.mjs';
|
|
7
|
+
import getStylelintRule from './utils/getStylelintRule.mjs';
|
|
8
|
+
import reportUnknownRuleNames from './reportUnknownRuleNames.mjs';
|
|
9
|
+
import rules from './rules/index.mjs';
|
|
10
|
+
import timing from './timing.mjs';
|
|
11
|
+
|
|
12
|
+
/** @import {Config, LinterOptions, PostcssResult} from 'stylelint' */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {LinterOptions} stylelintOptions
|
|
16
|
+
* @param {PostcssResult} postcssResult
|
|
17
|
+
* @param {Config} config
|
|
18
|
+
* @returns {Promise<any>}
|
|
19
|
+
*/
|
|
20
|
+
export default async function lintPostcssResult(stylelintOptions, postcssResult, config) {
|
|
21
|
+
postcssResult.stylelint.stylelintError = false;
|
|
22
|
+
postcssResult.stylelint.stylelintWarning = false;
|
|
23
|
+
postcssResult.stylelint.quiet = config.quiet;
|
|
24
|
+
postcssResult.stylelint.quietDeprecationWarnings = stylelintOptions.quietDeprecationWarnings;
|
|
25
|
+
postcssResult.stylelint.config = config;
|
|
26
|
+
|
|
27
|
+
const postcssDoc = postcssResult.root;
|
|
28
|
+
|
|
29
|
+
if (!('type' in postcssDoc)) {
|
|
30
|
+
throw new Error('Unexpected Postcss root object!');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const newlineMatch = postcssDoc.source?.input.css.match(/\r?\n/);
|
|
34
|
+
const newline = newlineMatch ? newlineMatch[0] : EOL;
|
|
35
|
+
const configurationComment = config.configurationComment || DEFAULT_CONFIGURATION_COMMENT;
|
|
36
|
+
const ctx = { configurationComment, newline };
|
|
37
|
+
|
|
38
|
+
assignDisabledRanges(postcssDoc, postcssResult);
|
|
39
|
+
|
|
40
|
+
const postcssRoots = /** @type {import('postcss').Root[]} */ (
|
|
41
|
+
postcssDoc && postcssDoc.constructor.name === 'Document' ? postcssDoc.nodes : [postcssDoc]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Promises for the rules. Although the rule code runs synchronously now,
|
|
45
|
+
// the use of Promises makes it compatible with the possibility of async
|
|
46
|
+
// rules down the line.
|
|
47
|
+
/** @type {Array<Promise<any>>} */
|
|
48
|
+
const performRules = [];
|
|
49
|
+
|
|
50
|
+
/** @type {string[]} */
|
|
51
|
+
let ruleNames;
|
|
52
|
+
|
|
53
|
+
if (config.rules) {
|
|
54
|
+
const rulesOrder = new Map(Object.keys(rules).map((ruleName, index) => [ruleName, index]));
|
|
55
|
+
|
|
56
|
+
ruleNames = Object.keys(config.rules).sort(
|
|
57
|
+
(a, b) => (rulesOrder.get(a) ?? -1) - (rulesOrder.get(b) ?? -1),
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
ruleNames = [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Load all rules in parallel.
|
|
64
|
+
/** @type {Array<[string, import('stylelint').Rule | undefined]>} */
|
|
65
|
+
const ruleEntries = await Promise.all(
|
|
66
|
+
ruleNames.map(async (ruleName) => {
|
|
67
|
+
const ruleFunction = await getStylelintRule(ruleName, config);
|
|
68
|
+
|
|
69
|
+
return [ruleName, ruleFunction];
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
for (const [ruleName, ruleFunction] of ruleEntries) {
|
|
74
|
+
if (ruleFunction === undefined) {
|
|
75
|
+
performRules.push(
|
|
76
|
+
Promise.all(
|
|
77
|
+
postcssRoots.map((postcssRoot) =>
|
|
78
|
+
reportUnknownRuleNames(ruleName, postcssRoot, postcssResult),
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const ruleSettings = config.rules?.[ruleName];
|
|
87
|
+
|
|
88
|
+
if (ruleSettings === null || ruleSettings[0] === null) continue;
|
|
89
|
+
|
|
90
|
+
if (ruleFunction.meta?.deprecated && !stylelintOptions.quietDeprecationWarnings) {
|
|
91
|
+
warnDeprecatedRule(postcssResult, ruleName);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const primaryOption = ruleSettings[0];
|
|
95
|
+
const secondaryOptions = ruleSettings[1];
|
|
96
|
+
|
|
97
|
+
// Log the rule's severity in the PostCSS result
|
|
98
|
+
const defaultSeverity = config.defaultSeverity || DEFAULT_SEVERITY;
|
|
99
|
+
|
|
100
|
+
postcssResult.stylelint.ruleSeverities[ruleName] =
|
|
101
|
+
(secondaryOptions && secondaryOptions.severity) || defaultSeverity;
|
|
102
|
+
postcssResult.stylelint.customMessages[ruleName] = secondaryOptions && secondaryOptions.message;
|
|
103
|
+
postcssResult.stylelint.customUrls[ruleName] = secondaryOptions && secondaryOptions.url;
|
|
104
|
+
postcssResult.stylelint.ruleMetadata[ruleName] = ruleFunction.meta || {};
|
|
105
|
+
|
|
106
|
+
const shouldWarn = ruleFunction.meta?.fixable && !stylelintOptions.quietDeprecationWarnings;
|
|
107
|
+
const disableFix = secondaryOptions?.disableFix === true;
|
|
108
|
+
const fix = !disableFix && config.fix && isFixCompatible(postcssResult, ruleName);
|
|
109
|
+
const context = {
|
|
110
|
+
...ctx,
|
|
111
|
+
// context.fix is unlikely to be removed in the foreseeable future
|
|
112
|
+
// due to the sheer number of rules in the wild that rely on it
|
|
113
|
+
get fix() {
|
|
114
|
+
if (shouldWarn) {
|
|
115
|
+
emitDeprecationWarning(
|
|
116
|
+
'`context.fix` is deprecated.',
|
|
117
|
+
'CONTEXT_FIX',
|
|
118
|
+
`Pass a \`fix\` callback to the \`report\` utility of "${ruleName}" instead.`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return fix;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const ruleFn = ruleFunction(primaryOption, secondaryOptions, context);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {import('postcss').Root} postcssRoot
|
|
130
|
+
*/
|
|
131
|
+
async function runRule(postcssRoot) {
|
|
132
|
+
if (timing.enabled) {
|
|
133
|
+
return timing.time(ruleName, () => ruleFn(postcssRoot, postcssResult))();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return ruleFn(postcssRoot, postcssResult);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
performRules.push(Promise.all(postcssRoots.map(runRule)));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return Promise.all(performRules);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* using context.fix instead of the fix callback has the drawback
|
|
147
|
+
* of not honouring the configuration comments in subtle ways
|
|
148
|
+
* @see file://./../docs/user-guide/options.md#fix for details
|
|
149
|
+
* @param {PostcssResult} postcssResult
|
|
150
|
+
* @param {string} name
|
|
151
|
+
* @returns {boolean}
|
|
152
|
+
*/
|
|
153
|
+
function isFixCompatible({ stylelint: { disabledRanges } }, name) {
|
|
154
|
+
return !disabledRanges[RULE_NAME_ALL]?.length && !disabledRanges[name];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {PostcssResult} result
|
|
159
|
+
* @param {string} ruleName
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
function warnDeprecatedRule(result, ruleName) {
|
|
163
|
+
const message = `The "${ruleName}" rule is deprecated.`;
|
|
164
|
+
|
|
165
|
+
emitDeprecationWarning(
|
|
166
|
+
message,
|
|
167
|
+
'RULE',
|
|
168
|
+
`Please be aware that the "${ruleName}" rule will soon be either removed or renamed.`,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
result.warn(message, { stylelintType: 'deprecation' });
|
|
172
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import postcss from 'postcss';
|
|
4
|
+
|
|
5
|
+
import descriptionlessDisables from './descriptionlessDisables.mjs';
|
|
6
|
+
import getConfigForFile from './getConfigForFile.mjs';
|
|
7
|
+
import getLexer from './utils/getLexer.mjs';
|
|
8
|
+
import getPostcssResult from './getPostcssResult.mjs';
|
|
9
|
+
import invalidScopeDisables from './invalidScopeDisables.mjs';
|
|
10
|
+
import isPathIgnored from './isPathIgnored.mjs';
|
|
11
|
+
import isPathNotFoundError from './utils/isPathNotFoundError.mjs';
|
|
12
|
+
import lintPostcssResult from './lintPostcssResult.mjs';
|
|
13
|
+
import needlessDisables from './needlessDisables.mjs';
|
|
14
|
+
import reportDisables from './reportDisables.mjs';
|
|
15
|
+
import reportUnscopedDisables from './unscopedDisables.mjs';
|
|
16
|
+
|
|
17
|
+
/** @import {GetLintSourceOptions as Options, InternalApi as StylelintInternalApi, PostcssResult, StylelintPostcssResult} from 'stylelint' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Run stylelint on a PostCSS Result, either one that is provided
|
|
21
|
+
* or one that we create
|
|
22
|
+
* @param {StylelintInternalApi} stylelint
|
|
23
|
+
* @param {Options} options
|
|
24
|
+
* @returns {Promise<PostcssResult>}
|
|
25
|
+
*/
|
|
26
|
+
export default async function lintSource(stylelint, options = {}) {
|
|
27
|
+
if (!options.filePath && options.code === undefined && !options.existingPostcssResult) {
|
|
28
|
+
return Promise.reject(new Error('You must provide filePath, code, or existingPostcssResult'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const isCodeNotFile = options.code !== undefined;
|
|
32
|
+
|
|
33
|
+
const inputFilePath = isCodeNotFile ? options.codeFilename : options.filePath;
|
|
34
|
+
|
|
35
|
+
if (inputFilePath !== undefined && !isAbsolute(inputFilePath)) {
|
|
36
|
+
if (isCodeNotFile) {
|
|
37
|
+
return Promise.reject(new Error('codeFilename must be an absolute path'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return Promise.reject(new Error('filePath must be an absolute path'));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isIgnored = await isPathIgnored(stylelint, inputFilePath).catch((err) => {
|
|
44
|
+
if (isCodeNotFile && isPathNotFoundError(err)) return false;
|
|
45
|
+
|
|
46
|
+
throw err;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (isIgnored) {
|
|
50
|
+
return createEmptyPostcssResult(inputFilePath, options.existingPostcssResult);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const configForFile = await getConfigForFile({
|
|
54
|
+
stylelint,
|
|
55
|
+
searchPath: inputFilePath,
|
|
56
|
+
filePath: inputFilePath,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!configForFile) {
|
|
60
|
+
return Promise.reject(new Error('Config file not found'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const config = configForFile.config;
|
|
64
|
+
const existingPostcssResult = options.existingPostcssResult;
|
|
65
|
+
|
|
66
|
+
if (options.cache) {
|
|
67
|
+
stylelint._fileCache.calcHashOfConfig(config);
|
|
68
|
+
|
|
69
|
+
if (options.filePath && !stylelint._fileCache.hasFileChanged(options.filePath)) {
|
|
70
|
+
return createEmptyPostcssResult(inputFilePath, existingPostcssResult);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const postcssResult =
|
|
75
|
+
existingPostcssResult ||
|
|
76
|
+
(await getPostcssResult(stylelint, {
|
|
77
|
+
code: options.code,
|
|
78
|
+
codeFilename: options.codeFilename,
|
|
79
|
+
filePath: inputFilePath,
|
|
80
|
+
customSyntax: config.customSyntax,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
const stylelintPostcssResult = Object.assign(postcssResult, {
|
|
84
|
+
stylelint: {
|
|
85
|
+
ruleSeverities: {},
|
|
86
|
+
customMessages: {},
|
|
87
|
+
customUrls: {},
|
|
88
|
+
ruleMetadata: {},
|
|
89
|
+
fixersData: {},
|
|
90
|
+
rangesOfComputedEditInfos: [],
|
|
91
|
+
disabledRanges: {},
|
|
92
|
+
lexer: getLexer(config),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
await lintPostcssResult(stylelint._options, stylelintPostcssResult, config);
|
|
97
|
+
|
|
98
|
+
reportDisables(stylelintPostcssResult);
|
|
99
|
+
needlessDisables(stylelintPostcssResult);
|
|
100
|
+
invalidScopeDisables(stylelintPostcssResult);
|
|
101
|
+
descriptionlessDisables(stylelintPostcssResult);
|
|
102
|
+
reportUnscopedDisables(stylelintPostcssResult);
|
|
103
|
+
|
|
104
|
+
return stylelintPostcssResult;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @returns {StylelintPostcssResult}
|
|
109
|
+
*/
|
|
110
|
+
function createEmptyStylelintPostcssResult() {
|
|
111
|
+
return {
|
|
112
|
+
ruleSeverities: {},
|
|
113
|
+
customMessages: {},
|
|
114
|
+
customUrls: {},
|
|
115
|
+
ruleMetadata: {},
|
|
116
|
+
fixersData: {},
|
|
117
|
+
rangesOfComputedEditInfos: [],
|
|
118
|
+
disabledRanges: {},
|
|
119
|
+
ignored: true,
|
|
120
|
+
stylelintError: false,
|
|
121
|
+
stylelintWarning: false,
|
|
122
|
+
lexer: getLexer({}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {string | undefined} filePath
|
|
128
|
+
* @param {Options['existingPostcssResult']} existingPostcssResult
|
|
129
|
+
* @returns {PostcssResult}
|
|
130
|
+
*/
|
|
131
|
+
function createEmptyPostcssResult(filePath, existingPostcssResult) {
|
|
132
|
+
return Object.assign(existingPostcssResult ?? postcss().process('', { from: filePath }).sync(), {
|
|
133
|
+
stylelint: createEmptyStylelintPostcssResult(),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { RULE_NAME_ALL } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
import optionsMatches from './utils/optionsMatches.mjs';
|
|
4
|
+
import putIfAbsent from './utils/putIfAbsent.mjs';
|
|
5
|
+
import reportCommentProblem from './utils/reportCommentProblem.mjs';
|
|
6
|
+
import validateDisableSettings from './validateDisableSettings.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('stylelint').PostcssResult} postcssResult
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
export default function needlessDisables(postcssResult) {
|
|
13
|
+
const [enabled, options] = validateDisableSettings(postcssResult, 'reportNeedlessDisables');
|
|
14
|
+
|
|
15
|
+
if (!options) return;
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
disabledRanges,
|
|
19
|
+
disabledRanges: { [RULE_NAME_ALL]: disabledRangesAll = [] },
|
|
20
|
+
disabledWarnings = [],
|
|
21
|
+
} = postcssResult.stylelint;
|
|
22
|
+
|
|
23
|
+
// A map from `stylelint-disable` comments to the set of rules that
|
|
24
|
+
// are usefully disabled by each comment. We track this
|
|
25
|
+
// comment-by-comment rather than range-by-range because ranges that
|
|
26
|
+
// disable *all* rules are duplicated for each rule they apply to in
|
|
27
|
+
// practice.
|
|
28
|
+
/** @type {Map<import('postcss').Node, Set<string>>}} */
|
|
29
|
+
const usefulDisables = new Map();
|
|
30
|
+
|
|
31
|
+
for (const warning of disabledWarnings) {
|
|
32
|
+
const rule = warning.rule;
|
|
33
|
+
const ruleRanges = disabledRanges[rule];
|
|
34
|
+
|
|
35
|
+
if (ruleRanges) {
|
|
36
|
+
for (const range of ruleRanges) {
|
|
37
|
+
if (isWarningInRange(warning, range)) {
|
|
38
|
+
putIfAbsent(usefulDisables, range.node, () => new Set()).add(rule);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const range of disabledRangesAll) {
|
|
44
|
+
if (isWarningInRange(warning, range)) {
|
|
45
|
+
putIfAbsent(usefulDisables, range.node, () => new Set()).add(rule);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const allRangeNodes = new Set(disabledRangesAll.map((range) => range.node));
|
|
51
|
+
|
|
52
|
+
for (const [rule, ranges] of Object.entries(disabledRanges)) {
|
|
53
|
+
for (const range of ranges) {
|
|
54
|
+
const node = range.node;
|
|
55
|
+
|
|
56
|
+
if (rule !== RULE_NAME_ALL && allRangeNodes.has(node)) continue;
|
|
57
|
+
|
|
58
|
+
if (enabled === optionsMatches(options, 'except', rule)) continue;
|
|
59
|
+
|
|
60
|
+
const useful = usefulDisables.get(node) || new Set();
|
|
61
|
+
|
|
62
|
+
// Only emit a warning if this range's comment isn't useful for this rule.
|
|
63
|
+
// For the special rule "all", only emit a warning if it's not useful for
|
|
64
|
+
// *any* rules, because it covers all of them.
|
|
65
|
+
if (rule === RULE_NAME_ALL ? useful.size !== 0 : useful.has(rule)) continue;
|
|
66
|
+
|
|
67
|
+
reportCommentProblem({
|
|
68
|
+
rule: '--report-needless-disables',
|
|
69
|
+
message: `Needless disable for "${rule}"`,
|
|
70
|
+
severity: options.severity,
|
|
71
|
+
node,
|
|
72
|
+
postcssResult,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {import('stylelint').DisabledWarning} warning
|
|
80
|
+
* @param {import('stylelint').DisabledRange} range
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
83
|
+
function isWarningInRange(warning, range) {
|
|
84
|
+
const line = warning.line;
|
|
85
|
+
|
|
86
|
+
// Need to check if range.end exist, because line number type cannot be compared to undefined
|
|
87
|
+
return (
|
|
88
|
+
range.start <= line &&
|
|
89
|
+
((range.end !== undefined && range.end >= line) || range.end === undefined)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import getStylelintRule from './utils/getStylelintRule.mjs';
|
|
2
|
+
import normalizeRuleSettings from './normalizeRuleSettings.mjs';
|
|
3
|
+
|
|
4
|
+
/** @import {Config as StylelintConfig} from 'stylelint' */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {StylelintConfig} config
|
|
8
|
+
* @returns {Promise<StylelintConfig>}
|
|
9
|
+
*/
|
|
10
|
+
export default async function normalizeAllRuleSettings(config) {
|
|
11
|
+
if (!config.rules) return config;
|
|
12
|
+
|
|
13
|
+
/** @type {StylelintConfig['rules']} */
|
|
14
|
+
const normalizedRules = {};
|
|
15
|
+
|
|
16
|
+
for (const [ruleName, rawRuleSettings] of Object.entries(config.rules)) {
|
|
17
|
+
const rule = await getStylelintRule(ruleName, config);
|
|
18
|
+
|
|
19
|
+
if (rule) {
|
|
20
|
+
normalizedRules[ruleName] = normalizeRuleSettings(rawRuleSettings, rule);
|
|
21
|
+
} else {
|
|
22
|
+
normalizedRules[ruleName] = [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
config.rules = normalizedRules;
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isPlainObject } from './utils/validateTypes.mjs';
|
|
2
|
+
|
|
3
|
+
// Rule settings can take a number of forms, e.g.
|
|
4
|
+
// a. "rule-name": null
|
|
5
|
+
// b. "rule-name": [null, ...]
|
|
6
|
+
// c. "rule-name": primaryOption
|
|
7
|
+
// d. "rule-name": [primaryOption]
|
|
8
|
+
// e. "rule-name": [primaryOption, secondaryOption]
|
|
9
|
+
// Where primaryOption can be anything: primitive, Object, or Array.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This function normalizes all the possibilities into the
|
|
13
|
+
* standard form: [primaryOption, secondaryOption]
|
|
14
|
+
* Except in the cases with null, a & b, in which case
|
|
15
|
+
* null is returned
|
|
16
|
+
* @template T
|
|
17
|
+
* @template {object} O
|
|
18
|
+
* @param {import('stylelint').ConfigRuleSettings<T, O>} rawSettings
|
|
19
|
+
* @param {import('stylelint').Rule<T, O>} [rule]
|
|
20
|
+
* @returns {[T] | [T, O] | null}
|
|
21
|
+
*/
|
|
22
|
+
export default function normalizeRuleSettings(rawSettings, rule) {
|
|
23
|
+
if (rawSettings === null || rawSettings === undefined) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!Array.isArray(rawSettings)) {
|
|
28
|
+
return [rawSettings];
|
|
29
|
+
}
|
|
30
|
+
// Everything below is an array ...
|
|
31
|
+
|
|
32
|
+
const [primary, secondary] = rawSettings;
|
|
33
|
+
|
|
34
|
+
if (rawSettings.length > 0 && (primary === null || primary === undefined)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (rule && !rule.primaryOptionArray) {
|
|
39
|
+
return rawSettings;
|
|
40
|
+
}
|
|
41
|
+
// Everything below is a rule that CAN have an array for a primary option ...
|
|
42
|
+
// (they might also have something else, e.g. rule-properties-order can
|
|
43
|
+
// have the string "alphabetical")
|
|
44
|
+
|
|
45
|
+
if (rawSettings.length === 1 && Array.isArray(primary)) {
|
|
46
|
+
return rawSettings;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (rawSettings.length === 2 && !isPlainObject(primary) && isPlainObject(secondary)) {
|
|
50
|
+
return rawSettings;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// `T` must be an array type, but TSC thinks it's probably invalid to
|
|
54
|
+
// cast `[T]` to `T` so we cast through `any` first.
|
|
55
|
+
return [/** @type {T} */ (/** @type {any} */ (rawSettings))];
|
|
56
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isAbsolute, join } from 'node:path';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
|
|
4
|
+
import createStylelint from './createStylelint.mjs';
|
|
5
|
+
import { isString } from './utils/validateTypes.mjs';
|
|
6
|
+
import lintSource from './lintSource.mjs';
|
|
7
|
+
|
|
8
|
+
/** @import {Config as StylelintConfig, PostcssPluginOptions} from 'stylelint' */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @type {import('postcss').PluginCreator<PostcssPluginOptions>}
|
|
12
|
+
*/
|
|
13
|
+
export default function postcssPlugin(options = {}) {
|
|
14
|
+
const [cwd, tailoredOptions] = isConfig(options)
|
|
15
|
+
? [process.cwd(), { config: options }]
|
|
16
|
+
: [('cwd' in options && isString(options.cwd) && options.cwd) || process.cwd(), options];
|
|
17
|
+
const stylelint = createStylelint(tailoredOptions);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
postcssPlugin: 'stylelint',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('postcss').Root} root
|
|
24
|
+
* @param {import('postcss').Helpers} helpers
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
*/
|
|
27
|
+
async Once(root, { result }) {
|
|
28
|
+
let filePath = root.source && root.source.input.file;
|
|
29
|
+
|
|
30
|
+
if (filePath && !isAbsolute(filePath)) {
|
|
31
|
+
filePath = join(cwd, filePath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
await lintSource(stylelint, {
|
|
35
|
+
filePath,
|
|
36
|
+
existingPostcssResult: result,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
postcssPlugin.postcss = true;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {PostcssPluginOptions} options
|
|
46
|
+
* @returns {options is StylelintConfig}
|
|
47
|
+
*/
|
|
48
|
+
function isConfig(options) {
|
|
49
|
+
return 'rules' in options;
|
|
50
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SEVERITY_ERROR } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
/** @import { Formatter, LinterOptions, LinterResult, LintResult } from 'stylelint' */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {object} args
|
|
7
|
+
* @param {LintResult[]} args.results
|
|
8
|
+
* @param {LinterOptions['maxWarnings']} args.maxWarnings
|
|
9
|
+
* @param {LinterOptions['quietDeprecationWarnings']} args.quietDeprecationWarnings
|
|
10
|
+
* @param {Formatter} args.formatter
|
|
11
|
+
* @param {string} args.cwd
|
|
12
|
+
* @returns {LinterResult}
|
|
13
|
+
*/
|
|
14
|
+
export default function prepareReturnValue({ results, maxWarnings, formatter, cwd }) {
|
|
15
|
+
let errored = false;
|
|
16
|
+
|
|
17
|
+
for (const result of results) {
|
|
18
|
+
if (
|
|
19
|
+
result.errored ||
|
|
20
|
+
result.parseErrors.length > 0 ||
|
|
21
|
+
result.warnings.some((warning) => warning.severity === SEVERITY_ERROR)
|
|
22
|
+
) {
|
|
23
|
+
errored = true;
|
|
24
|
+
result.errored = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @type {LinterResult} */
|
|
29
|
+
const returnValue = {
|
|
30
|
+
cwd,
|
|
31
|
+
errored,
|
|
32
|
+
results: [],
|
|
33
|
+
report: '',
|
|
34
|
+
reportedDisables: [],
|
|
35
|
+
ruleMetadata: getRuleMetadata(results),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (maxWarnings !== undefined) {
|
|
39
|
+
const foundWarnings = results.reduce((count, file) => count + file.warnings.length, 0);
|
|
40
|
+
|
|
41
|
+
if (foundWarnings > maxWarnings) {
|
|
42
|
+
returnValue.maxWarningsExceeded = { maxWarnings, foundWarnings };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
returnValue.report = formatter(results, returnValue);
|
|
47
|
+
returnValue.results = results;
|
|
48
|
+
|
|
49
|
+
return returnValue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {LintResult[]} lintResults
|
|
54
|
+
*/
|
|
55
|
+
function getRuleMetadata(lintResults) {
|
|
56
|
+
const [lintResult] = lintResults;
|
|
57
|
+
|
|
58
|
+
if (lintResult === undefined) return {};
|
|
59
|
+
|
|
60
|
+
if (lintResult._postcssResult === undefined) return {};
|
|
61
|
+
|
|
62
|
+
return lintResult._postcssResult.stylelint.ruleMetadata;
|
|
63
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
|
|
3
|
+
import { isDynamicPattern } from 'globby';
|
|
4
|
+
|
|
5
|
+
import resolveConfig from './resolveConfig.mjs';
|
|
6
|
+
import toPath from './utils/toPath.mjs';
|
|
7
|
+
|
|
8
|
+
/** @import {Config as StylelintConfig} from 'stylelint' */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('stylelint').LinterOptions} options
|
|
12
|
+
* @returns {Promise<StylelintConfig | null>}
|
|
13
|
+
*/
|
|
14
|
+
export default async function printConfig({
|
|
15
|
+
cwd = process.cwd(),
|
|
16
|
+
code,
|
|
17
|
+
config,
|
|
18
|
+
configBasedir,
|
|
19
|
+
configFile,
|
|
20
|
+
globbyOptions,
|
|
21
|
+
files,
|
|
22
|
+
}) {
|
|
23
|
+
const isCodeNotFile = code !== undefined;
|
|
24
|
+
const filePath = files && files[0];
|
|
25
|
+
|
|
26
|
+
if (!files || files.length !== 1 || !filePath || isCodeNotFile) {
|
|
27
|
+
return Promise.reject(
|
|
28
|
+
new Error('The --print-config option must be used with exactly one file path.'),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isDynamicPattern(filePath)) {
|
|
33
|
+
return Promise.reject(new Error('The --print-config option does not support globs.'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
(await resolveConfig(filePath, {
|
|
38
|
+
cwd: toPath(globbyOptions?.cwd) || cwd,
|
|
39
|
+
config,
|
|
40
|
+
configBasedir,
|
|
41
|
+
configFile,
|
|
42
|
+
})) || null
|
|
43
|
+
);
|
|
44
|
+
}
|