@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
package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-allowed-list/index.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import valueParser from 'postcss-value-parser';
|
|
2
|
+
|
|
3
|
+
import { isRegExp, isString } from '../../utils/validateTypes.mjs';
|
|
4
|
+
import { declarationValueIndex } from '../../utils/nodeFieldIndices.mjs';
|
|
5
|
+
import isCustomProperty from '../../utils/isCustomProperty.mjs';
|
|
6
|
+
import isStandardSyntaxFunction from '../../utils/isStandardSyntaxFunction.mjs';
|
|
7
|
+
import matchesStringOrRegExp from '../../utils/matchesStringOrRegExp.mjs';
|
|
8
|
+
import report from '../../utils/report.mjs';
|
|
9
|
+
import ruleMessages from '../../utils/ruleMessages.mjs';
|
|
10
|
+
import validateOptions from '../../utils/validateOptions.mjs';
|
|
11
|
+
|
|
12
|
+
const ruleName = 'function-allowed-list';
|
|
13
|
+
|
|
14
|
+
const messages = ruleMessages(ruleName, {
|
|
15
|
+
rejected: (name) => `Unexpected function "${name}"`,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const meta = {
|
|
19
|
+
url: 'https://stylelint.io/user-guide/rules/function-allowed-list',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** @type {import('stylelint').CoreRules[ruleName]} */
|
|
23
|
+
const rule = (primary, secondaryOptions) => {
|
|
24
|
+
return (root, result) => {
|
|
25
|
+
const validOptions = validateOptions(
|
|
26
|
+
result,
|
|
27
|
+
ruleName,
|
|
28
|
+
{
|
|
29
|
+
actual: primary,
|
|
30
|
+
possible: [isString, isRegExp],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
actual: secondaryOptions,
|
|
34
|
+
possible: {
|
|
35
|
+
exceptWithoutPropertyFallback: [isString, isRegExp],
|
|
36
|
+
},
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (!validOptions) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const exceptWithoutPropertyFallback = secondaryOptions?.exceptWithoutPropertyFallback ?? [];
|
|
46
|
+
|
|
47
|
+
root.walkDecls((decl) => {
|
|
48
|
+
if (!decl.value.includes('(')) return;
|
|
49
|
+
|
|
50
|
+
valueParser(decl.value).walk((node) => {
|
|
51
|
+
const { type, sourceIndex, value: funcName } = node;
|
|
52
|
+
|
|
53
|
+
if (type !== 'function') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!isStandardSyntaxFunction(node)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (matchesStringOrRegExp(funcName, primary)) {
|
|
62
|
+
// Check if function requires fallback
|
|
63
|
+
if (!matchesStringOrRegExp(funcName, exceptWithoutPropertyFallback)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (hasPrevPropertyDeclaration(decl)) return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const index = declarationValueIndex(decl) + sourceIndex;
|
|
71
|
+
const endIndex = index + funcName.length;
|
|
72
|
+
|
|
73
|
+
report({
|
|
74
|
+
message: messages.rejected,
|
|
75
|
+
messageArgs: [funcName],
|
|
76
|
+
node: decl,
|
|
77
|
+
index,
|
|
78
|
+
endIndex,
|
|
79
|
+
result,
|
|
80
|
+
ruleName,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {import('postcss').Declaration} decl
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*/
|
|
91
|
+
function hasPrevPropertyDeclaration(decl) {
|
|
92
|
+
const prop = decl.prop.toLowerCase();
|
|
93
|
+
|
|
94
|
+
if (isCustomProperty(prop)) return false;
|
|
95
|
+
|
|
96
|
+
let prev = decl.prev();
|
|
97
|
+
|
|
98
|
+
while (prev) {
|
|
99
|
+
if (prev.type === 'decl' && prev.prop.toLowerCase() === prop) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
prev = prev.prev();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
rule.primaryOptionArray = true;
|
|
110
|
+
|
|
111
|
+
rule.ruleName = ruleName;
|
|
112
|
+
rule.messages = messages;
|
|
113
|
+
rule.meta = meta;
|
|
114
|
+
export default rule;
|
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TokenNode,
|
|
3
|
+
WhitespaceNode,
|
|
4
|
+
isFunctionNode,
|
|
5
|
+
isSimpleBlockNode,
|
|
6
|
+
isTokenNode,
|
|
7
|
+
isWhiteSpaceOrCommentNode,
|
|
8
|
+
isWhitespaceNode,
|
|
9
|
+
parseListOfComponentValues,
|
|
10
|
+
stringify,
|
|
11
|
+
walk,
|
|
12
|
+
} from '@csstools/css-parser-algorithms';
|
|
13
|
+
import {
|
|
14
|
+
TokenType,
|
|
15
|
+
isTokenComma,
|
|
16
|
+
isTokenDelim,
|
|
17
|
+
isTokenDimension,
|
|
18
|
+
isTokenIdent,
|
|
19
|
+
isTokenNumeric,
|
|
20
|
+
isTokenOpenCurly,
|
|
21
|
+
isTokenOpenParen,
|
|
22
|
+
isTokenSemicolon,
|
|
23
|
+
mutateIdent,
|
|
24
|
+
mutateUnit,
|
|
25
|
+
tokenize,
|
|
26
|
+
} from '@csstools/css-tokenizer';
|
|
27
|
+
|
|
28
|
+
import { declarationValueIndex } from '../../utils/nodeFieldIndices.mjs';
|
|
29
|
+
import getDeclarationValue from '../../utils/getDeclarationValue.mjs';
|
|
30
|
+
import { mathFunctions } from '../../reference/functions.mjs';
|
|
31
|
+
import { mayIncludeRegexes } from '../../utils/regexes.mjs';
|
|
32
|
+
import report from '../../utils/report.mjs';
|
|
33
|
+
import ruleMessages from '../../utils/ruleMessages.mjs';
|
|
34
|
+
import setDeclarationValue from '../../utils/setDeclarationValue.mjs';
|
|
35
|
+
import validateOptions from '../../utils/validateOptions.mjs';
|
|
36
|
+
|
|
37
|
+
import { assert } from '../../utils/validateTypes.mjs';
|
|
38
|
+
|
|
39
|
+
const ruleName = 'function-calc-no-unspaced-operator';
|
|
40
|
+
|
|
41
|
+
const messages = ruleMessages(ruleName, {
|
|
42
|
+
expectedBefore: (operator) => `Expected single space before "${operator}" operator`,
|
|
43
|
+
expectedAfter: (operator) => `Expected single space after "${operator}" operator`,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const meta = {
|
|
47
|
+
url: 'https://stylelint.io/user-guide/rules/function-calc-no-unspaced-operator',
|
|
48
|
+
fixable: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const OPERATORS = new Set(['+', '-']);
|
|
52
|
+
|
|
53
|
+
const FUNC_NAMES_REGEX = new RegExp(`^(?:${[...mathFunctions].join('|')})$`, 'i');
|
|
54
|
+
|
|
55
|
+
const NEWLINE_REGEX = /\n|\r\n/;
|
|
56
|
+
|
|
57
|
+
/** @import { CommentNode, ComponentValue, ContainerNode } from '@csstools/css-parser-algorithms' */
|
|
58
|
+
|
|
59
|
+
/** @type {import('stylelint').CoreRules[ruleName]} */
|
|
60
|
+
const rule = (primary) => {
|
|
61
|
+
return (root, result) => {
|
|
62
|
+
const validOptions = validateOptions(result, ruleName, { actual: primary });
|
|
63
|
+
|
|
64
|
+
if (!validOptions) return;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {messages[keyof messages]} message
|
|
68
|
+
* @param {import('postcss').Node} node
|
|
69
|
+
* @param {number} index
|
|
70
|
+
* @param {string} operator
|
|
71
|
+
* @param {() => void} fix
|
|
72
|
+
*/
|
|
73
|
+
function complain(message, node, index, operator, fix) {
|
|
74
|
+
const endIndex = index + operator.length;
|
|
75
|
+
const messageArgs = [operator];
|
|
76
|
+
|
|
77
|
+
report({
|
|
78
|
+
message,
|
|
79
|
+
messageArgs,
|
|
80
|
+
node,
|
|
81
|
+
index,
|
|
82
|
+
endIndex,
|
|
83
|
+
result,
|
|
84
|
+
ruleName,
|
|
85
|
+
fix: { apply: fix, node },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
root.walkDecls((decl) => {
|
|
90
|
+
const value = getDeclarationValue(decl);
|
|
91
|
+
|
|
92
|
+
if (!mayIncludeRegexes.operator.test(value)) return;
|
|
93
|
+
|
|
94
|
+
if (!mayIncludeRegexes.mathFunction.test(value)) return;
|
|
95
|
+
|
|
96
|
+
const nodes = tokenizeDeclarationValue(value);
|
|
97
|
+
|
|
98
|
+
if (nodes.length === 0) return;
|
|
99
|
+
|
|
100
|
+
const valueIndex = declarationValueIndex(decl);
|
|
101
|
+
const fixDeclarationValue = () => setDeclarationValue(decl, stringify([nodes]));
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {ContainerNode} node
|
|
105
|
+
* @param {Operation} operation
|
|
106
|
+
* @param {'before' | 'after'} position
|
|
107
|
+
*/
|
|
108
|
+
function checkCompleteOperation(node, operation, position) {
|
|
109
|
+
if (operation[position].some(isWhitespaceNode)) return;
|
|
110
|
+
|
|
111
|
+
const messageKey = position === 'before' ? 'expectedBefore' : 'expectedAfter';
|
|
112
|
+
|
|
113
|
+
complain(
|
|
114
|
+
messages[messageKey],
|
|
115
|
+
decl,
|
|
116
|
+
valueIndex + operation.operatorCharPosition,
|
|
117
|
+
operation.operatorChar,
|
|
118
|
+
() => {
|
|
119
|
+
operation.insertWhitespace(node, position);
|
|
120
|
+
fixDeclarationValue();
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {ContainerNode} node
|
|
127
|
+
* @param {Operation} operation
|
|
128
|
+
*/
|
|
129
|
+
function checkOperationWithoutOperator(node, operation) {
|
|
130
|
+
if (isTokenNode(operation.firstOperand)) {
|
|
131
|
+
const token = operation.firstOperand.value;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {string | undefined} operatorChar
|
|
135
|
+
* @param {() => void} mutator
|
|
136
|
+
* @returns {boolean}
|
|
137
|
+
*/
|
|
138
|
+
const complainToFirstOperand = (operatorChar, mutator) => {
|
|
139
|
+
if (!(operatorChar && mayIncludeRegexes.operator.test(operatorChar))) return false;
|
|
140
|
+
|
|
141
|
+
const [, , , endPos] = token;
|
|
142
|
+
|
|
143
|
+
operation.completeMissingOperator(operatorChar, endPos, 'append');
|
|
144
|
+
|
|
145
|
+
complain(
|
|
146
|
+
messages.expectedBefore,
|
|
147
|
+
decl,
|
|
148
|
+
valueIndex + operation.operatorCharPosition,
|
|
149
|
+
operation.operatorChar,
|
|
150
|
+
() => {
|
|
151
|
+
operation.insertOperatorAfterFirstOperand(node);
|
|
152
|
+
mutator();
|
|
153
|
+
fixDeclarationValue();
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
return true;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
if (isTokenDimension(token)) {
|
|
161
|
+
// E.g. '2px+' → ['2px', '+']
|
|
162
|
+
const [, , , , { unit }] = token;
|
|
163
|
+
const operatorChar = unit.at(-1);
|
|
164
|
+
const newUnit = unit.slice(0, -1);
|
|
165
|
+
|
|
166
|
+
if (complainToFirstOperand(operatorChar, () => mutateUnit(token, newUnit))) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (isTokenIdent(token)) {
|
|
172
|
+
// E.g. 'id+' → ['id', '+']
|
|
173
|
+
const [, , , , { value: tokenValue }] = token;
|
|
174
|
+
const operatorChar = tokenValue.at(-1);
|
|
175
|
+
const newTokenValue = tokenValue.slice(0, -1);
|
|
176
|
+
|
|
177
|
+
if (complainToFirstOperand(operatorChar, () => mutateIdent(token, newTokenValue))) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (isTokenNode(operation.secondOperand) && isTokenNumeric(operation.secondOperand.value)) {
|
|
184
|
+
const token = operation.secondOperand.value;
|
|
185
|
+
const [, , startPos, , { signCharacter: operatorChar }] = token;
|
|
186
|
+
|
|
187
|
+
if (operatorChar && mayIncludeRegexes.operator.test(operatorChar)) {
|
|
188
|
+
operation.completeMissingOperator(operatorChar, startPos, 'prepend');
|
|
189
|
+
|
|
190
|
+
complain(
|
|
191
|
+
messages.expectedAfter,
|
|
192
|
+
decl,
|
|
193
|
+
valueIndex + operation.operatorCharPosition,
|
|
194
|
+
operation.operatorChar,
|
|
195
|
+
() => {
|
|
196
|
+
operation.insertOperatorBeforeSecondOperand(node);
|
|
197
|
+
|
|
198
|
+
// Remove an operator character from the second operand token
|
|
199
|
+
token[4].signCharacter = undefined;
|
|
200
|
+
token[1] = token[1].slice(1);
|
|
201
|
+
|
|
202
|
+
fixDeclarationValue();
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {Operation} operation
|
|
211
|
+
* @param {'before' | 'after'} position
|
|
212
|
+
*/
|
|
213
|
+
function checkOperandWhitespace(operation, position) {
|
|
214
|
+
operation[position].forEach((whitespaceNode) => {
|
|
215
|
+
if (!isWhitespaceNode(whitespaceNode)) return;
|
|
216
|
+
|
|
217
|
+
const whitespace = whitespaceNode.toString();
|
|
218
|
+
|
|
219
|
+
if (whitespace === ' ') return;
|
|
220
|
+
|
|
221
|
+
const indexOfFirstNewLine = whitespace.search(NEWLINE_REGEX);
|
|
222
|
+
|
|
223
|
+
if (indexOfFirstNewLine === 0) return;
|
|
224
|
+
|
|
225
|
+
const message = position === 'before' ? messages.expectedBefore : messages.expectedAfter;
|
|
226
|
+
|
|
227
|
+
complain(
|
|
228
|
+
message,
|
|
229
|
+
decl,
|
|
230
|
+
valueIndex + operation.operatorCharPosition,
|
|
231
|
+
operation.operatorChar,
|
|
232
|
+
() => {
|
|
233
|
+
whitespaceNode.value = newWhitespaceNode(
|
|
234
|
+
indexOfFirstNewLine === -1 ? ' ' : whitespace.slice(indexOfFirstNewLine),
|
|
235
|
+
).value;
|
|
236
|
+
fixDeclarationValue();
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
walk(
|
|
243
|
+
nodes,
|
|
244
|
+
({ node, state }) => {
|
|
245
|
+
if (!state) return;
|
|
246
|
+
|
|
247
|
+
// Step 2
|
|
248
|
+
// Make sure that we are in a math context.
|
|
249
|
+
// Once in a math context we remain in one until we encounter a non-math function.
|
|
250
|
+
// Simple blocks with parentheses are the same as `calc()`
|
|
251
|
+
if (isFunctionNode(node)) {
|
|
252
|
+
state.inMathFunction = FUNC_NAMES_REGEX.test(node.getName().toLowerCase());
|
|
253
|
+
} else if (!isSimpleBlockNode(node) || !isTokenOpenParen(node.startToken)) {
|
|
254
|
+
state.inMathFunction = false;
|
|
255
|
+
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (!state.inMathFunction) return;
|
|
260
|
+
|
|
261
|
+
let cursor = 0;
|
|
262
|
+
/** @type {Operation | undefined} */
|
|
263
|
+
let operation = undefined;
|
|
264
|
+
|
|
265
|
+
while (cursor !== -1 && cursor < node.value.length) {
|
|
266
|
+
// Step 3
|
|
267
|
+
// Parse into operations
|
|
268
|
+
// Each operation consumes as much whitespace before and after
|
|
269
|
+
// Each parse call tries to consume as much as possible up to the next comma or semicolon
|
|
270
|
+
// Operations consist of
|
|
271
|
+
// - first operand
|
|
272
|
+
// - operator
|
|
273
|
+
// - second operand
|
|
274
|
+
// - whitespace before and after
|
|
275
|
+
[operation, cursor] = parseOperation(node, cursor);
|
|
276
|
+
|
|
277
|
+
if (!operation) {
|
|
278
|
+
cursor++;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Step 4
|
|
283
|
+
// If there is no operator, try to find one
|
|
284
|
+
if (!operation.operator) {
|
|
285
|
+
checkOperationWithoutOperator(node, operation);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Step 5
|
|
289
|
+
// If the operation is complete, ensure there is whitespace around the operator
|
|
290
|
+
// The operation might have started without an operator and might have been repaired by Step 4
|
|
291
|
+
if (operation.operator) {
|
|
292
|
+
checkCompleteOperation(node, operation, 'before');
|
|
293
|
+
checkCompleteOperation(node, operation, 'after');
|
|
294
|
+
|
|
295
|
+
// Step 6
|
|
296
|
+
// Normalize the whitespace around the operands
|
|
297
|
+
checkOperandWhitespace(operation, 'before');
|
|
298
|
+
checkOperandWhitespace(operation, 'after');
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
cursor = node.value.indexOf(operation.secondOperand);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
inMathFunction: false,
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @param {string} value
|
|
314
|
+
* @returns {Array<ComponentValue>}
|
|
315
|
+
*/
|
|
316
|
+
function tokenizeDeclarationValue(value) {
|
|
317
|
+
const tokens = tokenize({ css: value });
|
|
318
|
+
|
|
319
|
+
// Step 1
|
|
320
|
+
// Step 1.1
|
|
321
|
+
// Re-tokenize dimensions with units containing dashes.
|
|
322
|
+
// These might be typo's.
|
|
323
|
+
// For example: `10px-20px` has a unit of `px-20px`
|
|
324
|
+
tokens.forEach((token, i) => {
|
|
325
|
+
if (!isTokenDimension(token)) return;
|
|
326
|
+
|
|
327
|
+
const { unit } = token[4];
|
|
328
|
+
|
|
329
|
+
if (unit.startsWith('--')) return;
|
|
330
|
+
|
|
331
|
+
const indexOfDash = unit.indexOf('-');
|
|
332
|
+
|
|
333
|
+
if (indexOfDash === -1) return;
|
|
334
|
+
|
|
335
|
+
const remainder = unit.slice(indexOfDash);
|
|
336
|
+
|
|
337
|
+
if (remainder.length === 1) return;
|
|
338
|
+
|
|
339
|
+
mutateUnit(token, unit.slice(0, indexOfDash));
|
|
340
|
+
token[3] = token[2] + token[1].length;
|
|
341
|
+
|
|
342
|
+
const remainderTokens = tokenize({ css: remainder }).slice(0, -1); // Trim EOF token
|
|
343
|
+
|
|
344
|
+
remainderTokens.forEach((remainderToken) => {
|
|
345
|
+
remainderToken[2] += token[3];
|
|
346
|
+
remainderToken[3] += token[3];
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
tokens.splice(i + 1, 0, ...remainderTokens);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// Step 1.2
|
|
353
|
+
// Re-tokenize scss interpolation blocks
|
|
354
|
+
// Grouping `#` and `{` into a single token allows us to parse these as simple blocks with curly braces.
|
|
355
|
+
// For example: `#{$foo}`
|
|
356
|
+
tokens.forEach((currentToken, i) => {
|
|
357
|
+
if (!isTokenDelim(currentToken) || currentToken[4].value !== '#') return;
|
|
358
|
+
|
|
359
|
+
const nextToken = tokens[i + 1];
|
|
360
|
+
|
|
361
|
+
if (!isTokenOpenCurly(nextToken)) return;
|
|
362
|
+
|
|
363
|
+
const nextNextToken = tokens[i + 2];
|
|
364
|
+
|
|
365
|
+
if (!isTokenDelim(nextNextToken) || nextNextToken[4].value !== '$') return;
|
|
366
|
+
|
|
367
|
+
// Set the string representation of the open curly to `#{`
|
|
368
|
+
nextToken[1] = '#{';
|
|
369
|
+
// Remove the `#` token
|
|
370
|
+
tokens.splice(i, 1);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
return parseListOfComponentValues(tokens);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** @see https://drafts.csswg.org/css-values/#typedef-calc-value */
|
|
377
|
+
const OPERAND_TOKEN_TYPES = new Set([
|
|
378
|
+
TokenType.Number,
|
|
379
|
+
TokenType.Dimension,
|
|
380
|
+
TokenType.Percentage,
|
|
381
|
+
TokenType.Ident,
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @param {ComponentValue | undefined} node
|
|
386
|
+
* @returns {boolean}
|
|
387
|
+
*/
|
|
388
|
+
function isOperandNode(node) {
|
|
389
|
+
if (isSimpleBlockNode(node)) return true;
|
|
390
|
+
|
|
391
|
+
if (isFunctionNode(node)) {
|
|
392
|
+
const name = node.getName().toLowerCase();
|
|
393
|
+
|
|
394
|
+
if (mathFunctions.has(name) || name === 'var') return true;
|
|
395
|
+
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!isTokenNode(node)) return false;
|
|
400
|
+
|
|
401
|
+
return OPERAND_TOKEN_TYPES.has(node.value[0]);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @param {string} whitespace
|
|
406
|
+
*/
|
|
407
|
+
function newWhitespaceNode(whitespace = ' ') {
|
|
408
|
+
return new WhitespaceNode([[TokenType.Whitespace, whitespace, -1, -1, undefined]]);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
class Operation {
|
|
412
|
+
/**
|
|
413
|
+
* @param {ComponentValue} firstOperand
|
|
414
|
+
* @param {Array<WhitespaceNode | CommentNode>} before
|
|
415
|
+
* @param {ComponentValue} secondOperand
|
|
416
|
+
* @param {Array<WhitespaceNode | CommentNode>} after
|
|
417
|
+
* @param {TokenNode | undefined} operator
|
|
418
|
+
*/
|
|
419
|
+
constructor(firstOperand, before, secondOperand, after, operator) {
|
|
420
|
+
/** @type {typeof firstOperand} */
|
|
421
|
+
this.firstOperand = firstOperand;
|
|
422
|
+
/** @type {typeof before} */
|
|
423
|
+
this.before = before;
|
|
424
|
+
/** @type {typeof secondOperand} */
|
|
425
|
+
this.secondOperand = secondOperand;
|
|
426
|
+
/** @type {typeof after} */
|
|
427
|
+
this.after = after;
|
|
428
|
+
/** @type {typeof operator} */
|
|
429
|
+
this.operator = operator;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
get #operatorToken() {
|
|
433
|
+
assert(isTokenDelim(this.operator?.value));
|
|
434
|
+
|
|
435
|
+
return this.operator.value;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** @returns {string} */
|
|
439
|
+
get operatorChar() {
|
|
440
|
+
return this.#operatorToken[4].value;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** @returns {number} */
|
|
444
|
+
get operatorCharPosition() {
|
|
445
|
+
return this.#operatorToken[2];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @param {ContainerNode} node
|
|
450
|
+
* @param {'before' | 'after'} position
|
|
451
|
+
*/
|
|
452
|
+
insertWhitespace(node, position) {
|
|
453
|
+
assert(this.operator);
|
|
454
|
+
node.value.splice(
|
|
455
|
+
node.value.indexOf(this.operator) + (position === 'before' ? 0 : 1),
|
|
456
|
+
0,
|
|
457
|
+
newWhitespaceNode(),
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @param {ContainerNode} node
|
|
463
|
+
*/
|
|
464
|
+
insertOperatorAfterFirstOperand(node) {
|
|
465
|
+
assert(this.operator);
|
|
466
|
+
node.value.splice(node.value.indexOf(this.firstOperand) + 1, 0, ...this.before, this.operator);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @param {ContainerNode} node
|
|
471
|
+
*/
|
|
472
|
+
insertOperatorBeforeSecondOperand(node) {
|
|
473
|
+
assert(this.operator);
|
|
474
|
+
node.value.splice(node.value.indexOf(this.secondOperand), 0, this.operator, ...this.after);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @param {string} operatorChar
|
|
479
|
+
* @param {number} operatorCharPosition
|
|
480
|
+
* @param {'append' | 'prepend'} type
|
|
481
|
+
*/
|
|
482
|
+
completeMissingOperator(operatorChar, operatorCharPosition, type) {
|
|
483
|
+
this.operator = new TokenNode([
|
|
484
|
+
TokenType.Delim,
|
|
485
|
+
operatorChar,
|
|
486
|
+
operatorCharPosition,
|
|
487
|
+
operatorCharPosition + operatorChar.length,
|
|
488
|
+
{ value: operatorChar },
|
|
489
|
+
]);
|
|
490
|
+
|
|
491
|
+
if (type === 'append') {
|
|
492
|
+
this.after = this.before;
|
|
493
|
+
this.before = [newWhitespaceNode()];
|
|
494
|
+
} else {
|
|
495
|
+
this.after = [newWhitespaceNode()];
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* @param {ContainerNode} container
|
|
502
|
+
* @param {number} cursor
|
|
503
|
+
* @returns {[Operation | undefined, number]}
|
|
504
|
+
*/
|
|
505
|
+
function parseOperation(container, cursor) {
|
|
506
|
+
let firstOperand = undefined;
|
|
507
|
+
let secondOperand = undefined;
|
|
508
|
+
const before = [];
|
|
509
|
+
const after = [];
|
|
510
|
+
let operator = undefined;
|
|
511
|
+
|
|
512
|
+
let currentNode = container.value[cursor];
|
|
513
|
+
|
|
514
|
+
// Consume as much whitespace and comments as possible
|
|
515
|
+
while (isWhiteSpaceOrCommentNode(currentNode)) {
|
|
516
|
+
currentNode = container.value[++cursor];
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// If the current node is an operand, consume it
|
|
520
|
+
if (isOperandNode(currentNode)) {
|
|
521
|
+
firstOperand = currentNode;
|
|
522
|
+
|
|
523
|
+
currentNode = container.value[++cursor];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// Consume as much whitespace and comments as possible
|
|
527
|
+
// Assign to `before`
|
|
528
|
+
while (isWhiteSpaceOrCommentNode(currentNode)) {
|
|
529
|
+
before.push(currentNode);
|
|
530
|
+
|
|
531
|
+
currentNode = container.value[++cursor];
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// If the current node is an operator, consume it
|
|
535
|
+
if (
|
|
536
|
+
isTokenNode(currentNode) &&
|
|
537
|
+
isTokenDelim(currentNode.value) &&
|
|
538
|
+
OPERATORS.has(currentNode.value[4].value)
|
|
539
|
+
) {
|
|
540
|
+
operator = currentNode;
|
|
541
|
+
|
|
542
|
+
currentNode = container.value[++cursor];
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// Consume as much whitespace and comments as possible
|
|
546
|
+
// Assign to `after`
|
|
547
|
+
while (isWhiteSpaceOrCommentNode(currentNode)) {
|
|
548
|
+
after.push(currentNode);
|
|
549
|
+
|
|
550
|
+
currentNode = container.value[++cursor];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// If the current node is an operand, consume it
|
|
554
|
+
if (isOperandNode(currentNode)) {
|
|
555
|
+
secondOperand = currentNode;
|
|
556
|
+
|
|
557
|
+
currentNode = container.value[++cursor];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Consume as much whitespace and comments as possible
|
|
561
|
+
while (isWhiteSpaceOrCommentNode(currentNode)) {
|
|
562
|
+
currentNode = container.value[++cursor];
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// If we have not consumed any operands, we are not in an operation
|
|
566
|
+
// Do error recovery by consuming until the next comma or semicolon
|
|
567
|
+
// If no comma or semicolon is found, consume until the end of the container
|
|
568
|
+
if (!firstOperand || !secondOperand) {
|
|
569
|
+
while (currentNode) {
|
|
570
|
+
if (
|
|
571
|
+
isTokenNode(currentNode) &&
|
|
572
|
+
(isTokenComma(currentNode.value) || isTokenSemicolon(currentNode.value))
|
|
573
|
+
) {
|
|
574
|
+
return [undefined, cursor];
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
currentNode = container.value[++cursor];
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return [undefined, container.value.length];
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
return [new Operation(firstOperand, before, secondOperand, after, operator), cursor];
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
rule.ruleName = ruleName;
|
|
587
|
+
rule.messages = messages;
|
|
588
|
+
rule.meta = meta;
|
|
589
|
+
export default rule;
|