linter-bundle 5.1.0 → 6.1.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/.linter-bundle.js +2 -0
- package/CHANGELOG.md +83 -9
- package/README.md +5 -3
- package/TODO.md +5 -0
- package/eslint/index.cjs +10 -4
- package/eslint/overrides-javascript.cjs +7 -1
- package/eslint/overrides-jest.cjs +1 -0
- package/eslint/overrides-jsdoc.cjs +1 -0
- package/eslint/rules/no-global-undefined-check.js +5 -3
- package/eslint/rules/no-unnecessary-typeof.js +26 -24
- package/eslint/rules/restricted-filenames.js +3 -1
- package/helper/ensure-type.cjs +2 -2
- package/helper/get-git-files.js +1 -1
- package/helper/get-outdated-dependencies.js +1 -1
- package/helper/get-outdated-overrides.js +1 -1
- package/helper/get-stylelint-path.js +1 -1
- package/helper/is-npm-or-yarn.js +1 -1
- package/helper/linter-bundle-config.js +22 -7
- package/helper/run-process.js +3 -3
- package/lint.js +31 -35
- package/package.json +27 -26
- package/stylelint/index.cjs +90 -5
- package/stylelint/plugins/stylelint-15.11.0-stylistic/LICENSE +20 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/html-tags/LICENSE +9 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/html-tags/index.cjs +122 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/reference/selectors.cjs +327 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/README.md +110 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/index.cjs +66 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/README.md +117 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/index.cjs +55 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/README.md +63 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/index.cjs +87 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/README.md +50 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/index.cjs +70 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/atRuleNameSpaceChecker.cjs +56 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/README.md +238 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/index.cjs +130 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/README.md +196 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/index.cjs +154 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/README.md +93 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/index.cjs +133 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/README.md +174 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/index.cjs +111 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/README.md +138 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/index.cjs +184 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/README.md +191 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/index.cjs +118 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/README.md +218 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/index.cjs +141 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/README.md +58 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/index.cjs +95 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.cjs +95 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/README.md +67 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/index.cjs +96 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/README.md +141 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/index.cjs +109 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-before/README.md +120 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-before/index.cjs +75 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/README.md +147 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/index.cjs +97 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/README.md +130 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/index.cjs +106 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/README.md +108 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/index.cjs +147 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/README.md +78 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/index.cjs +99 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/README.md +111 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/index.cjs +75 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/index.cjs +74 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationBangSpaceChecker.cjs +63 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationColonSpaceChecker.cjs +58 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/findMediaOperator.cjs +32 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/README.md +113 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/index.cjs +61 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/README.md +129 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/index.cjs +61 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/README.md +144 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/index.cjs +62 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/README.md +144 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/index.cjs +62 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/README.md +78 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/index.cjs +115 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/README.md +144 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/index.cjs +282 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/README.md +140 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.cjs +182 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/README.md +80 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.cjs +198 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/functionCommaSpaceChecker.cjs +125 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/functionCommaSpaceFix.cjs +51 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/README.md +339 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/index.cjs +743 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/README.md +21 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.cjs +132 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/README.md +116 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.cjs +225 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/README.md +151 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.cjs +200 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.cjs +91 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/index.cjs +91 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/README.md +108 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/index.cjs +93 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/README.md +62 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/index.cjs +112 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/index.cjs +109 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/README.md +72 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/index.cjs +109 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/README.md +113 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/index.cjs +97 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-before/README.md +111 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-before/index.cjs +49 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/README.md +136 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/index.cjs +93 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/README.md +136 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/index.cjs +93 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaFeatureColonSpaceChecker.cjs +54 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaQueryListCommaWhitespaceChecker.cjs +73 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/README.md +34 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/index.cjs +63 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/README.md +79 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/index.cjs +302 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/README.md +78 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/index.cjs +246 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/README.md +34 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/index.cjs +62 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/README.md +74 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/index.cjs +197 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/README.md +40 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/index.cjs +139 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/README.md +192 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/index.cjs +95 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/README.md +112 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/index.cjs +214 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/README.md +162 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/index.cjs +109 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/README.md +162 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/index.cjs +88 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/README.md +78 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/index.cjs +67 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/README.md +78 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/index.cjs +67 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/README.md +40 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/index.cjs +95 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/README.md +120 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/index.cjs +126 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/README.md +112 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/index.cjs +101 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/README.md +110 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/index.cjs +92 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/README.md +110 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/index.cjs +92 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/README.md +103 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/index.cjs +74 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/README.md +108 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/index.cjs +104 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/README.md +62 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/index.cjs +162 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/README.md +128 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.cjs +90 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorAttributeOperatorSpaceChecker.cjs +95 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorCombinatorSpaceChecker.cjs +113 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorListCommaWhitespaceChecker.cjs +64 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/README.md +130 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/index.cjs +256 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unicode-bom/README.md +41 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unicode-bom/index.cjs +67 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/README.md +126 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/index.cjs +133 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/README.md +102 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/index.cjs +107 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-before/README.md +100 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-before/index.cjs +49 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/README.md +136 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/index.cjs +94 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/README.md +136 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/index.cjs +94 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/README.md +121 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/index.cjs +68 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/valueListCommaWhitespaceChecker.cjs +74 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/style-search/LICENSE +13 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/style-search/index.cjs +216 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/addEmptyLineAfter.cjs +30 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/hasEmptyBlock.cjs +14 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/nextNonCommentNode.cjs +21 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/removeEmptyLinesAfter.cjs +16 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/whitespaceChecker.cjs +361 -0
- package/stylelint/plugins/stylelint-selector-no-empty.js +8 -8
- package/stylelint/plugins/stylelint-selector-tag-no-without-class.js +4 -4
- package/stylelint/plugins/stylelint-high-performance-animation.js +0 -276
- package/stylelint/plugins/stylelint-stylistic.js +0 -188
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const stylelint = require('stylelint');
|
|
5
|
+
const atRuleParamIndex = require('stylelint/lib/utils/atRuleParamIndex.cjs');
|
|
6
|
+
const findMediaFeatureNames = require('stylelint/lib/utils/findMediaFeatureNames.cjs');
|
|
7
|
+
const isCustomMediaQuery = require('stylelint/lib/utils/isCustomMediaQuery.cjs');
|
|
8
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
9
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
10
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
11
|
+
|
|
12
|
+
const { mutateIdent } = require('@csstools/css-tokenizer');
|
|
13
|
+
|
|
14
|
+
const ruleName = 'plugin/media-feature-name-case';
|
|
15
|
+
|
|
16
|
+
const messages = ruleMessages(ruleName, {
|
|
17
|
+
expected: (actual, expected) => `Expected "${actual}" to be "${expected}"`
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/README.md',
|
|
22
|
+
fixable: true
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @type {import('stylelint').Rule} */
|
|
26
|
+
const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
27
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
28
|
+
actual: primary,
|
|
29
|
+
possible: ['lower', 'upper']
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!validOptions) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
root.walkAtRules(/^media$/i, (atRule) => {
|
|
37
|
+
const hasComments = atRule.raws.params?.raw;
|
|
38
|
+
let mediaRule = hasComments ? hasComments : atRule.params;
|
|
39
|
+
|
|
40
|
+
let hasFixes = false;
|
|
41
|
+
|
|
42
|
+
mediaRule = findMediaFeatureNames(mediaRule, (mediaFeatureNameToken) => {
|
|
43
|
+
const [, , startIndex, endIndex, { value: featureName }] = mediaFeatureNameToken;
|
|
44
|
+
|
|
45
|
+
if (isCustomMediaQuery(featureName)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const expectedFeatureName =
|
|
50
|
+
primary === 'lower' ? featureName.toLowerCase() : featureName.toUpperCase();
|
|
51
|
+
|
|
52
|
+
if (featureName === expectedFeatureName) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (context.fix) {
|
|
57
|
+
mutateIdent(mediaFeatureNameToken, expectedFeatureName);
|
|
58
|
+
hasFixes = true;
|
|
59
|
+
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const atRuleIndex = atRuleParamIndex(atRule);
|
|
64
|
+
|
|
65
|
+
report({
|
|
66
|
+
message: messages.expected(featureName, expectedFeatureName),
|
|
67
|
+
node: atRule,
|
|
68
|
+
index: atRuleIndex + startIndex,
|
|
69
|
+
endIndex: atRuleIndex + endIndex + 1,
|
|
70
|
+
ruleName,
|
|
71
|
+
result
|
|
72
|
+
});
|
|
73
|
+
}).stringify();
|
|
74
|
+
|
|
75
|
+
if (hasFixes) {
|
|
76
|
+
if (hasComments) {
|
|
77
|
+
if (atRule.raws.params == null) {
|
|
78
|
+
throw new Error('The `AtRuleRaws` node must have a `params` property');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
atRule.raws.params.raw = mediaRule;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
atRule.params = mediaRule;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
rule.ruleName = ruleName;
|
|
91
|
+
rule.messages = messages;
|
|
92
|
+
rule.meta = meta;
|
|
93
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# media-feature-parentheses-space-inside
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace on the inside of the parentheses within media features.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
@media ( max-width: 300px ) {}
|
|
8
|
+
/** ↑ ↑
|
|
9
|
+
* The space inside these two parentheses */
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The [`fix` option](https://stylelint.io/user-guide/options/#fix) can automatically fix all of the problems reported by this rule.
|
|
13
|
+
|
|
14
|
+
## Options
|
|
15
|
+
|
|
16
|
+
`string`: `"always"|"never"`
|
|
17
|
+
|
|
18
|
+
### `"always"`
|
|
19
|
+
|
|
20
|
+
There _must always_ be a single space inside the parentheses.
|
|
21
|
+
|
|
22
|
+
The following patterns are considered problems:
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore -->
|
|
25
|
+
```css
|
|
26
|
+
@media (max-width: 300px) {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
@media (max-width: 300px ) {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The following patterns are _not_ considered problems:
|
|
35
|
+
|
|
36
|
+
<!-- prettier-ignore -->
|
|
37
|
+
```css
|
|
38
|
+
@media ( max-width: 300px ) {}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `"never"`
|
|
42
|
+
|
|
43
|
+
There _must never_ be whitespace on the inside the parentheses.
|
|
44
|
+
|
|
45
|
+
The following patterns are considered problems:
|
|
46
|
+
|
|
47
|
+
<!-- prettier-ignore -->
|
|
48
|
+
```css
|
|
49
|
+
@media ( max-width: 300px ) {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<!-- prettier-ignore -->
|
|
53
|
+
```css
|
|
54
|
+
@media ( max-width: 300px) {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The following patterns are _not_ considered problems:
|
|
58
|
+
|
|
59
|
+
<!-- prettier-ignore -->
|
|
60
|
+
```css
|
|
61
|
+
@media (max-width: 300px) {}
|
|
62
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const valueParser = require('postcss-value-parser');
|
|
5
|
+
const stylelint = require('stylelint');
|
|
6
|
+
const atRuleParamIndex = require('stylelint/lib/utils/atRuleParamIndex.cjs');
|
|
7
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
8
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
9
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
10
|
+
|
|
11
|
+
const ruleName = 'plugin/media-feature-parentheses-space-inside';
|
|
12
|
+
|
|
13
|
+
const messages = ruleMessages(ruleName, {
|
|
14
|
+
expectedOpening: 'Expected single space after "("',
|
|
15
|
+
rejectedOpening: 'Unexpected whitespace after "("',
|
|
16
|
+
expectedClosing: 'Expected single space before ")"',
|
|
17
|
+
rejectedClosing: 'Unexpected whitespace before ")"'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/README.md',
|
|
22
|
+
fixable: true
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @type {import('stylelint').Rule} */
|
|
26
|
+
const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
27
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
28
|
+
actual: primary,
|
|
29
|
+
possible: ['always', 'never']
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!validOptions) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
root.walkAtRules(/^media$/i, (atRule) => {
|
|
37
|
+
// If there are comments in the params, the complete string
|
|
38
|
+
// will be at atRule.raws.params.raw
|
|
39
|
+
const parameters = (atRule.raws.params?.raw) || atRule.params;
|
|
40
|
+
const indexBoost = atRuleParamIndex(atRule);
|
|
41
|
+
/** @type {Array<{ message: string, index: number }>} */
|
|
42
|
+
const problems = [];
|
|
43
|
+
|
|
44
|
+
const parsedParameters = valueParser(parameters).walk((node) => {
|
|
45
|
+
if (node.type === 'function') {
|
|
46
|
+
const length_ = valueParser.stringify(node).length;
|
|
47
|
+
|
|
48
|
+
if (primary === 'never') {
|
|
49
|
+
if ((/[\t ]/).test(node.before)) {
|
|
50
|
+
if (context.fix) { node.before = ''; }
|
|
51
|
+
|
|
52
|
+
problems.push({
|
|
53
|
+
message: messages.rejectedOpening,
|
|
54
|
+
index: node.sourceIndex + 1 + indexBoost
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ((/[\t ]/).test(node.after)) {
|
|
59
|
+
if (context.fix) { node.after = ''; }
|
|
60
|
+
|
|
61
|
+
problems.push({
|
|
62
|
+
message: messages.rejectedClosing,
|
|
63
|
+
index: node.sourceIndex - 2 + length_ + indexBoost
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (primary === 'always') {
|
|
68
|
+
if (node.before === '') {
|
|
69
|
+
if (context.fix) { node.before = ' '; }
|
|
70
|
+
|
|
71
|
+
problems.push({
|
|
72
|
+
message: messages.expectedOpening,
|
|
73
|
+
index: node.sourceIndex + 1 + indexBoost
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (node.after === '') {
|
|
78
|
+
if (context.fix) { node.after = ' '; }
|
|
79
|
+
|
|
80
|
+
problems.push({
|
|
81
|
+
message: messages.expectedClosing,
|
|
82
|
+
index: node.sourceIndex - 2 + length_ + indexBoost
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (problems.length > 0) {
|
|
90
|
+
if (context.fix) {
|
|
91
|
+
atRule.params = parsedParameters.toString();
|
|
92
|
+
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const error of problems) {
|
|
97
|
+
report({
|
|
98
|
+
message: error.message,
|
|
99
|
+
node: atRule,
|
|
100
|
+
index: error.index,
|
|
101
|
+
result,
|
|
102
|
+
ruleName
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
rule.ruleName = ruleName;
|
|
110
|
+
rule.messages = messages;
|
|
111
|
+
rule.meta = meta;
|
|
112
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# media-feature-range-operator-space-after
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace after the range operator in media features.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
@media (width >= 600px) {}
|
|
8
|
+
/** ↑
|
|
9
|
+
* The space after this operator */
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The [`fix` option](https://stylelint.io/user-guide/options/#fix) can automatically fix all of the problems reported by this rule.
|
|
13
|
+
|
|
14
|
+
## Options
|
|
15
|
+
|
|
16
|
+
`string`: `"always"|"never"`
|
|
17
|
+
|
|
18
|
+
### `"always"`
|
|
19
|
+
|
|
20
|
+
There _must always_ be a single space after the range operator.
|
|
21
|
+
|
|
22
|
+
The following patterns are considered problems:
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore -->
|
|
25
|
+
```css
|
|
26
|
+
@media (width>=600px) {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
@media (width >=600px) {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The following patterns are _not_ considered problems:
|
|
35
|
+
|
|
36
|
+
<!-- prettier-ignore -->
|
|
37
|
+
```css
|
|
38
|
+
@media (width>= 600px) {}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
<!-- prettier-ignore -->
|
|
42
|
+
```css
|
|
43
|
+
@media (width >= 600px) {}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `"never"`
|
|
47
|
+
|
|
48
|
+
There _must never_ be whitespace after the range operator.
|
|
49
|
+
|
|
50
|
+
The following patterns are considered problems:
|
|
51
|
+
|
|
52
|
+
<!-- prettier-ignore -->
|
|
53
|
+
```css
|
|
54
|
+
@media (width>= 600px) {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<!-- prettier-ignore -->
|
|
58
|
+
```css
|
|
59
|
+
@media (width >= 600px) {}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The following patterns are _not_ considered problems:
|
|
63
|
+
|
|
64
|
+
<!-- prettier-ignore -->
|
|
65
|
+
```css
|
|
66
|
+
@media (width>=600px) {}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<!-- prettier-ignore -->
|
|
70
|
+
```css
|
|
71
|
+
@media (width >=600px) {}
|
|
72
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const stylelint = require('stylelint');
|
|
5
|
+
const atRuleParamIndex = require('stylelint/lib/utils/atRuleParamIndex.cjs');
|
|
6
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
7
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
8
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
9
|
+
|
|
10
|
+
const whitespaceChecker = require('../../utils/whitespaceChecker.cjs');
|
|
11
|
+
const findMediaOperator = require('../findMediaOperator.cjs');
|
|
12
|
+
|
|
13
|
+
const ruleName = 'plugin/media-feature-range-operator-space-after';
|
|
14
|
+
|
|
15
|
+
const messages = ruleMessages(ruleName, {
|
|
16
|
+
expectedAfter: () => 'Expected single space after range operator',
|
|
17
|
+
rejectedAfter: () => 'Unexpected whitespace after range operator'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/README.md',
|
|
22
|
+
fixable: true
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @type {import('stylelint').Rule} */
|
|
26
|
+
const rule = (primary, _secondaryOptions, context) => {
|
|
27
|
+
const checker = whitespaceChecker('space', primary, messages);
|
|
28
|
+
|
|
29
|
+
return (root, result) => {
|
|
30
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
31
|
+
actual: primary,
|
|
32
|
+
possible: ['always', 'never']
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!validOptions) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
root.walkAtRules(/^media$/i, (atRule) => {
|
|
40
|
+
/** @type {number[]} */
|
|
41
|
+
const fixOperatorIndices = [];
|
|
42
|
+
/** @type {((index: number) => void) | null} */
|
|
43
|
+
const fix = context.fix ? (index) => fixOperatorIndices.push(index) : null;
|
|
44
|
+
|
|
45
|
+
findMediaOperator(atRule, (match, parameters, node) => {
|
|
46
|
+
checkAfterOperator(match, parameters, node, fix);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (fixOperatorIndices.length > 0) {
|
|
50
|
+
let parameters = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
|
|
51
|
+
|
|
52
|
+
for (const index of fixOperatorIndices.sort((a, b) => b - a)) {
|
|
53
|
+
const beforeOperator = parameters.slice(0, index + 1);
|
|
54
|
+
const afterOperator = parameters.slice(index + 1);
|
|
55
|
+
|
|
56
|
+
if (primary === 'always') {
|
|
57
|
+
parameters = beforeOperator + afterOperator.replace(/^\s*/, ' ');
|
|
58
|
+
}
|
|
59
|
+
else if (primary === 'never') {
|
|
60
|
+
parameters = beforeOperator + afterOperator.replace(/^\s*/, '');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (atRule.raws.params) {
|
|
65
|
+
atRule.raws.params.raw = parameters;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
atRule.params = parameters;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {import('style-search').StyleSearchMatch} match
|
|
75
|
+
* @param {string} params
|
|
76
|
+
* @param parameters
|
|
77
|
+
* @param {import('postcss').AtRule} node
|
|
78
|
+
* @param {((index: number) => void) | null} fix
|
|
79
|
+
*/
|
|
80
|
+
function checkAfterOperator (match, parameters, node, fix) {
|
|
81
|
+
const endIndex = match.startIndex + match.target.length - 1;
|
|
82
|
+
|
|
83
|
+
checker.after({
|
|
84
|
+
source: parameters,
|
|
85
|
+
index: endIndex,
|
|
86
|
+
err: (m) => {
|
|
87
|
+
if (fix) {
|
|
88
|
+
fix(endIndex);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
report({
|
|
94
|
+
message: m,
|
|
95
|
+
node,
|
|
96
|
+
index: endIndex + atRuleParamIndex(node) + 1,
|
|
97
|
+
result,
|
|
98
|
+
ruleName
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
rule.ruleName = ruleName;
|
|
107
|
+
rule.messages = messages;
|
|
108
|
+
rule.meta = meta;
|
|
109
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# media-feature-range-operator-space-before
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace before the range operator in media features.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
@media (width >= 600px) {}
|
|
8
|
+
/** ↑
|
|
9
|
+
* The space before this operator */
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The [`fix` option](https://stylelint.io/user-guide/options/#fix) can automatically fix all of the problems reported by this rule.
|
|
13
|
+
|
|
14
|
+
## Options
|
|
15
|
+
|
|
16
|
+
`string`: `"always"|"never"`
|
|
17
|
+
|
|
18
|
+
### `"always"`
|
|
19
|
+
|
|
20
|
+
There _must always_ be a single space before the range operator.
|
|
21
|
+
|
|
22
|
+
The following patterns are considered problems:
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore -->
|
|
25
|
+
```css
|
|
26
|
+
@media (width>=600px) {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
@media (width>= 600px) {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The following patterns are _not_ considered problems:
|
|
35
|
+
|
|
36
|
+
<!-- prettier-ignore -->
|
|
37
|
+
```css
|
|
38
|
+
@media (width >=600px) {}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
<!-- prettier-ignore -->
|
|
42
|
+
```css
|
|
43
|
+
@media (width >= 600px) {}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `"never"`
|
|
47
|
+
|
|
48
|
+
There _must never_ be whitespace before the range operator.
|
|
49
|
+
|
|
50
|
+
The following patterns are considered problems:
|
|
51
|
+
|
|
52
|
+
<!-- prettier-ignore -->
|
|
53
|
+
```css
|
|
54
|
+
@media (width >=600px) {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<!-- prettier-ignore -->
|
|
58
|
+
```css
|
|
59
|
+
@media (width >= 600px) {}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The following patterns are _not_ considered problems:
|
|
63
|
+
|
|
64
|
+
<!-- prettier-ignore -->
|
|
65
|
+
```css
|
|
66
|
+
@media (width>=600px) {}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<!-- prettier-ignore -->
|
|
70
|
+
```css
|
|
71
|
+
@media (width>= 600px) {}
|
|
72
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const stylelint = require('stylelint');
|
|
5
|
+
const atRuleParamIndex = require('stylelint/lib/utils/atRuleParamIndex.cjs');
|
|
6
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
7
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
8
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
9
|
+
|
|
10
|
+
const whitespaceChecker = require('../../utils/whitespaceChecker.cjs');
|
|
11
|
+
const findMediaOperator = require('../findMediaOperator.cjs');
|
|
12
|
+
|
|
13
|
+
const ruleName = 'plugin/media-feature-range-operator-space-before';
|
|
14
|
+
|
|
15
|
+
const messages = ruleMessages(ruleName, {
|
|
16
|
+
expectedBefore: () => 'Expected single space before range operator',
|
|
17
|
+
rejectedBefore: () => 'Unexpected whitespace before range operator'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/README.md',
|
|
22
|
+
fixable: true
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @type {import('stylelint').Rule} */
|
|
26
|
+
const rule = (primary, _secondaryOptions, context) => {
|
|
27
|
+
const checker = whitespaceChecker('space', primary, messages);
|
|
28
|
+
|
|
29
|
+
return (root, result) => {
|
|
30
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
31
|
+
actual: primary,
|
|
32
|
+
possible: ['always', 'never']
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!validOptions) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
root.walkAtRules(/^media$/i, (atRule) => {
|
|
40
|
+
/** @type {number[]} */
|
|
41
|
+
const fixOperatorIndices = [];
|
|
42
|
+
/** @type {((index: number) => void) | null} */
|
|
43
|
+
const fix = context.fix ? (index) => fixOperatorIndices.push(index) : null;
|
|
44
|
+
|
|
45
|
+
findMediaOperator(atRule, (match, parameters, node) => {
|
|
46
|
+
checkBeforeOperator(match, parameters, node, fix);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (fixOperatorIndices.length > 0) {
|
|
50
|
+
let parameters = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
|
|
51
|
+
|
|
52
|
+
for (const index of fixOperatorIndices.sort((a, b) => b - a)) {
|
|
53
|
+
const beforeOperator = parameters.slice(0, index);
|
|
54
|
+
const afterOperator = parameters.slice(index);
|
|
55
|
+
|
|
56
|
+
if (primary === 'always') {
|
|
57
|
+
parameters = beforeOperator.replace(/\s*$/, ' ') + afterOperator;
|
|
58
|
+
}
|
|
59
|
+
else if (primary === 'never') {
|
|
60
|
+
parameters = beforeOperator.replace(/\s*$/, '') + afterOperator;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (atRule.raws.params) {
|
|
65
|
+
atRule.raws.params.raw = parameters;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
atRule.params = parameters;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {import('style-search').StyleSearchMatch} match
|
|
75
|
+
* @param {string} params
|
|
76
|
+
* @param parameters
|
|
77
|
+
* @param {import('postcss').AtRule} node
|
|
78
|
+
* @param {((index: number) => void) | null} fix
|
|
79
|
+
*/
|
|
80
|
+
function checkBeforeOperator (match, parameters, node, fix) {
|
|
81
|
+
// The extra `+ 1` is because the match itself contains
|
|
82
|
+
// the character before the operator
|
|
83
|
+
checker.before({
|
|
84
|
+
source: parameters,
|
|
85
|
+
index: match.startIndex,
|
|
86
|
+
err: (m) => {
|
|
87
|
+
if (fix) {
|
|
88
|
+
fix(match.startIndex);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
report({
|
|
94
|
+
message: m,
|
|
95
|
+
node,
|
|
96
|
+
index: match.startIndex - 1 + atRuleParamIndex(node),
|
|
97
|
+
result,
|
|
98
|
+
ruleName
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
rule.ruleName = ruleName;
|
|
107
|
+
rule.messages = messages;
|
|
108
|
+
rule.meta = meta;
|
|
109
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|