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,162 @@
|
|
|
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 isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule.cjs');
|
|
6
|
+
const parseSelector = require('stylelint/lib/utils/parseSelector.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/selector-pseudo-class-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/selector-pseudo-class-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.walkRules((ruleNode) => {
|
|
37
|
+
if (!isStandardSyntaxRule(ruleNode)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!ruleNode.selector.includes('(')) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let hasFixed = false;
|
|
46
|
+
const selector = ruleNode.raws.selector ? ruleNode.raws.selector.raw : ruleNode.selector;
|
|
47
|
+
const fixedSelector = parseSelector(selector, result, ruleNode, (selectorTree) => {
|
|
48
|
+
selectorTree.walkPseudos((pseudoNode) => {
|
|
49
|
+
if (pseudoNode.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const paramString = pseudoNode.map((node) => String(node)).join(',');
|
|
54
|
+
const nextCharIsSpace = paramString.startsWith(' ');
|
|
55
|
+
const openIndex = pseudoNode.sourceIndex + pseudoNode.value.length + 1;
|
|
56
|
+
|
|
57
|
+
if (nextCharIsSpace && primary === 'never') {
|
|
58
|
+
if (context.fix) {
|
|
59
|
+
hasFixed = true;
|
|
60
|
+
setFirstNodeSpaceBefore(pseudoNode, '');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
complain(messages.rejectedOpening, openIndex);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!nextCharIsSpace && primary === 'always') {
|
|
68
|
+
if (context.fix) {
|
|
69
|
+
hasFixed = true;
|
|
70
|
+
setFirstNodeSpaceBefore(pseudoNode, ' ');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
complain(messages.expectedOpening, openIndex);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const previousCharIsSpace = paramString.endsWith(' ');
|
|
78
|
+
const closeIndex = openIndex + paramString.length - 1;
|
|
79
|
+
|
|
80
|
+
if (previousCharIsSpace && primary === 'never') {
|
|
81
|
+
if (context.fix) {
|
|
82
|
+
hasFixed = true;
|
|
83
|
+
setLastNodeSpaceAfter(pseudoNode, '');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
complain(messages.rejectedClosing, closeIndex);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!previousCharIsSpace && primary === 'always') {
|
|
91
|
+
if (context.fix) {
|
|
92
|
+
hasFixed = true;
|
|
93
|
+
setLastNodeSpaceAfter(pseudoNode, ' ');
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
complain(messages.expectedClosing, closeIndex);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (hasFixed && fixedSelector) {
|
|
103
|
+
if (!ruleNode.raws.selector) {
|
|
104
|
+
ruleNode.selector = fixedSelector;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
ruleNode.raws.selector.raw = fixedSelector;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {string} message
|
|
113
|
+
* @param {number} index
|
|
114
|
+
*/
|
|
115
|
+
function complain (message, index) {
|
|
116
|
+
report({
|
|
117
|
+
message,
|
|
118
|
+
index,
|
|
119
|
+
result,
|
|
120
|
+
ruleName,
|
|
121
|
+
node: ruleNode
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {import('postcss-selector-parser').Container} node
|
|
129
|
+
* @param {string} value
|
|
130
|
+
* @returns {void}
|
|
131
|
+
*/
|
|
132
|
+
function setFirstNodeSpaceBefore (node, value) {
|
|
133
|
+
const target = node.first;
|
|
134
|
+
|
|
135
|
+
if (target.type === 'selector') {
|
|
136
|
+
setFirstNodeSpaceBefore(target, value);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
target.spaces.before = value;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {import('postcss-selector-parser').Container} node
|
|
145
|
+
* @param {string} value
|
|
146
|
+
* @returns {void}
|
|
147
|
+
*/
|
|
148
|
+
function setLastNodeSpaceAfter (node, value) {
|
|
149
|
+
const target = node.last;
|
|
150
|
+
|
|
151
|
+
if (target.type === 'selector') {
|
|
152
|
+
setLastNodeSpaceAfter(target, value);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
target.spaces.after = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
rule.ruleName = ruleName;
|
|
160
|
+
rule.messages = messages;
|
|
161
|
+
rule.meta = meta;
|
|
162
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# selector-pseudo-element-case
|
|
2
|
+
|
|
3
|
+
Specify lowercase or uppercase for pseudo-element selectors.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
a::before {}
|
|
8
|
+
/** ↑
|
|
9
|
+
* This pseudo-element selector */
|
|
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`: `"lower"|"upper"`
|
|
17
|
+
|
|
18
|
+
### `"lower"`
|
|
19
|
+
|
|
20
|
+
The following patterns are considered problems:
|
|
21
|
+
|
|
22
|
+
<!-- prettier-ignore -->
|
|
23
|
+
```css
|
|
24
|
+
a:Before {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<!-- prettier-ignore -->
|
|
28
|
+
```css
|
|
29
|
+
a:bEfOrE {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<!-- prettier-ignore -->
|
|
33
|
+
```css
|
|
34
|
+
a:BEFORE {}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<!-- prettier-ignore -->
|
|
38
|
+
```css
|
|
39
|
+
a::Before {}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<!-- prettier-ignore -->
|
|
43
|
+
```css
|
|
44
|
+
a::bEfOrE {}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
<!-- prettier-ignore -->
|
|
48
|
+
```css
|
|
49
|
+
a::BEFORE {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<!-- prettier-ignore -->
|
|
53
|
+
```css
|
|
54
|
+
input::-MOZ-PLACEHOLDER {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The following patterns are _not_ considered problems:
|
|
58
|
+
|
|
59
|
+
<!-- prettier-ignore -->
|
|
60
|
+
```css
|
|
61
|
+
a:before {}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
<!-- prettier-ignore -->
|
|
65
|
+
```css
|
|
66
|
+
a::before {}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<!-- prettier-ignore -->
|
|
70
|
+
```css
|
|
71
|
+
input::-moz-placeholder {}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `"upper"`
|
|
75
|
+
|
|
76
|
+
The following patterns are considered problems:
|
|
77
|
+
|
|
78
|
+
<!-- prettier-ignore -->
|
|
79
|
+
```css
|
|
80
|
+
a:Before {}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
<!-- prettier-ignore -->
|
|
84
|
+
```css
|
|
85
|
+
a:bEfOrE {}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<!-- prettier-ignore -->
|
|
89
|
+
```css
|
|
90
|
+
a:BEFORE {}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<!-- prettier-ignore -->
|
|
94
|
+
```css
|
|
95
|
+
a::Before {}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
<!-- prettier-ignore -->
|
|
99
|
+
```css
|
|
100
|
+
a::bEfOrE {}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- prettier-ignore -->
|
|
104
|
+
```css
|
|
105
|
+
a::before {}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
<!-- prettier-ignore -->
|
|
109
|
+
```css
|
|
110
|
+
input::-moz-placeholder {}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The following patterns are _not_ considered problems:
|
|
114
|
+
|
|
115
|
+
<!-- prettier-ignore -->
|
|
116
|
+
```css
|
|
117
|
+
a:BEFORE {}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
<!-- prettier-ignore -->
|
|
121
|
+
```css
|
|
122
|
+
a::BEFORE {}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<!-- prettier-ignore -->
|
|
126
|
+
```css
|
|
127
|
+
input::-MOZ-PLACEHOLDER {}
|
|
128
|
+
```
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
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 isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule.cjs');
|
|
6
|
+
const isStandardSyntaxSelector = require('stylelint/lib/utils/isStandardSyntaxSelector.cjs');
|
|
7
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
8
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
9
|
+
const transformSelector = require('stylelint/lib/utils/transformSelector.cjs');
|
|
10
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
11
|
+
|
|
12
|
+
const { levelOneAndTwoPseudoElements } = require('../../reference/selectors.cjs');
|
|
13
|
+
|
|
14
|
+
const ruleName = 'plugin/selector-pseudo-element-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/selector-pseudo-element-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.walkRules((ruleNode) => {
|
|
37
|
+
if (!isStandardSyntaxRule(ruleNode)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const selector = ruleNode.selector;
|
|
42
|
+
|
|
43
|
+
if (!selector.includes(':')) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
transformSelector(result, ruleNode, (selectorTree) => {
|
|
48
|
+
selectorTree.walkPseudos((pseudoNode) => {
|
|
49
|
+
const pseudoElement = pseudoNode.value;
|
|
50
|
+
|
|
51
|
+
if (!isStandardSyntaxSelector(pseudoElement)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
!pseudoElement.includes('::') &&
|
|
57
|
+
!levelOneAndTwoPseudoElements.has(pseudoElement.toLowerCase().slice(1))
|
|
58
|
+
) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const expectedPseudoElement =
|
|
63
|
+
primary === 'lower' ? pseudoElement.toLowerCase() : pseudoElement.toUpperCase();
|
|
64
|
+
|
|
65
|
+
if (pseudoElement === expectedPseudoElement) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (context.fix) {
|
|
70
|
+
pseudoNode.value = expectedPseudoElement;
|
|
71
|
+
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
report({
|
|
76
|
+
message: messages.expected(pseudoElement, expectedPseudoElement),
|
|
77
|
+
node: ruleNode,
|
|
78
|
+
index: pseudoNode.sourceIndex,
|
|
79
|
+
ruleName,
|
|
80
|
+
result
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
rule.ruleName = ruleName;
|
|
88
|
+
rule.messages = messages;
|
|
89
|
+
rule.meta = meta;
|
|
90
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule.cjs');
|
|
5
|
+
const parseSelector = require('stylelint/lib/utils/parseSelector.cjs');
|
|
6
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
7
|
+
|
|
8
|
+
const styleSearch = require('../style-search/index.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {{
|
|
12
|
+
* root: import('postcss').Root,
|
|
13
|
+
* result: import('stylelint').PostcssResult,
|
|
14
|
+
* locationChecker: (opts: { source: string, index: number, err: (msg: string) => void }) => void,
|
|
15
|
+
* checkedRuleName: string,
|
|
16
|
+
* checkBeforeOperator: boolean,
|
|
17
|
+
* fix: ((attributeNode: import('postcss-selector-parser').Attribute) => boolean) | null,
|
|
18
|
+
* }} options
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
module.exports = function selectorAttributeOperatorSpaceChecker (options) {
|
|
22
|
+
options.root.walkRules((rule) => {
|
|
23
|
+
if (!isStandardSyntaxRule(rule)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!rule.selector.includes('[') || !rule.selector.includes('=')) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let hasFixed = false;
|
|
32
|
+
const selector = rule.raws.selector ? rule.raws.selector.raw : rule.selector;
|
|
33
|
+
|
|
34
|
+
const fixedSelector = parseSelector(selector, options.result, rule, (selectorTree) => {
|
|
35
|
+
selectorTree.walkAttributes((attributeNode) => {
|
|
36
|
+
const operator = attributeNode.operator;
|
|
37
|
+
|
|
38
|
+
if (!operator) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const attributeNodeString = attributeNode.toString();
|
|
43
|
+
|
|
44
|
+
styleSearch({ source: attributeNodeString, target: operator }, (match) => {
|
|
45
|
+
const index = options.checkBeforeOperator ? match.startIndex : match.endIndex - 1;
|
|
46
|
+
|
|
47
|
+
checkOperator(attributeNodeString, index, rule, attributeNode, operator);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (hasFixed && fixedSelector) {
|
|
53
|
+
if (!rule.raws.selector) {
|
|
54
|
+
rule.selector = fixedSelector;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
rule.raws.selector.raw = fixedSelector;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} source
|
|
63
|
+
* @param {number} index
|
|
64
|
+
* @param {import('postcss').Node} node
|
|
65
|
+
* @param {import('postcss-selector-parser').Attribute} attributeNode
|
|
66
|
+
* @param {string} operator
|
|
67
|
+
*/
|
|
68
|
+
function checkOperator (source, index, node, attributeNode, operator) {
|
|
69
|
+
options.locationChecker({
|
|
70
|
+
source,
|
|
71
|
+
index,
|
|
72
|
+
err: (message) => {
|
|
73
|
+
if (options.fix && options.fix(attributeNode)) {
|
|
74
|
+
hasFixed = true;
|
|
75
|
+
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
report({
|
|
80
|
+
message: message.replace(
|
|
81
|
+
options.checkBeforeOperator ?
|
|
82
|
+
operator.charAt(0)
|
|
83
|
+
: operator.charAt(operator.length - 1),
|
|
84
|
+
operator
|
|
85
|
+
),
|
|
86
|
+
node,
|
|
87
|
+
index: attributeNode.sourceIndex + index,
|
|
88
|
+
result: options.result,
|
|
89
|
+
ruleName: options.checkedRuleName
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorCombinatorSpaceChecker.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const isStandardSyntaxCombinator = require('stylelint/lib/utils/isStandardSyntaxCombinator.cjs');
|
|
5
|
+
const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule.cjs');
|
|
6
|
+
const parseSelector = require('stylelint/lib/utils/parseSelector.cjs');
|
|
7
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {(args: { source: string, index: number, errTarget: string, err: (message: string) => void }) => void} LocationChecker
|
|
11
|
+
* @param - - {{
|
|
12
|
+
* root: import('postcss').Root,
|
|
13
|
+
* result: import('stylelint').PostcssResult,
|
|
14
|
+
* locationChecker: LocationChecker,
|
|
15
|
+
* locationType: 'before' | 'after',
|
|
16
|
+
* checkedRuleName: string,
|
|
17
|
+
* fix: ((combinator: import('postcss-selector-parser').Combinator) => boolean) | null,
|
|
18
|
+
* @param options-
|
|
19
|
+
* @param options-
|
|
20
|
+
* @param options-
|
|
21
|
+
* @param options-
|
|
22
|
+
* @param options-
|
|
23
|
+
* @param options-
|
|
24
|
+
* @param options
|
|
25
|
+
* }} opts
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
module.exports = function selectorCombinatorSpaceChecker (options) {
|
|
29
|
+
let hasFixed;
|
|
30
|
+
|
|
31
|
+
options.root.walkRules((rule) => {
|
|
32
|
+
if (!isStandardSyntaxRule(rule)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
hasFixed = false;
|
|
37
|
+
const selector = rule.raws.selector ? rule.raws.selector.raw : rule.selector;
|
|
38
|
+
|
|
39
|
+
const fixedSelector = parseSelector(selector, options.result, rule, (selectorTree) => {
|
|
40
|
+
selectorTree.walkCombinators((node) => {
|
|
41
|
+
// Ignore non-standard combinators
|
|
42
|
+
if (!isStandardSyntaxCombinator(node)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Ignore spaced descendant combinator
|
|
47
|
+
if ((/\s/).test(node.value)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check the exist of node in prev of the combinator.
|
|
52
|
+
// in case some that aren't the first begin with combinators (nesting syntax)
|
|
53
|
+
if (options.locationType === 'before' && !node.prev()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const parentParentNode = node.parent?.parent;
|
|
58
|
+
|
|
59
|
+
// Ignore pseudo-classes selector like `.foo:nth-child(2n + 1) {}`
|
|
60
|
+
if (parentParentNode && parentParentNode.type === 'pseudo') {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const sourceIndex = node.sourceIndex;
|
|
65
|
+
const index =
|
|
66
|
+
node.value.length > 1 && options.locationType === 'before' ?
|
|
67
|
+
sourceIndex
|
|
68
|
+
: sourceIndex + node.value.length - 1;
|
|
69
|
+
|
|
70
|
+
check(selector, node, index, rule, sourceIndex);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (hasFixed && fixedSelector) {
|
|
75
|
+
if (!rule.raws.selector) {
|
|
76
|
+
rule.selector = fixedSelector;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
rule.raws.selector.raw = fixedSelector;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {string} source
|
|
86
|
+
* @param {import('postcss-selector-parser').Combinator} combinator
|
|
87
|
+
* @param {number} index
|
|
88
|
+
* @param {import('postcss').Node} node
|
|
89
|
+
* @param {number} sourceIndex
|
|
90
|
+
*/
|
|
91
|
+
function check (source, combinator, index, node, sourceIndex) {
|
|
92
|
+
options.locationChecker({
|
|
93
|
+
source,
|
|
94
|
+
index,
|
|
95
|
+
errTarget: combinator.value,
|
|
96
|
+
err: (message) => {
|
|
97
|
+
if (options.fix?.(combinator)) {
|
|
98
|
+
hasFixed = true;
|
|
99
|
+
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
report({
|
|
104
|
+
message,
|
|
105
|
+
node,
|
|
106
|
+
index: sourceIndex,
|
|
107
|
+
result: options.result,
|
|
108
|
+
ruleName: options.checkedRuleName
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorListCommaWhitespaceChecker.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule.cjs');
|
|
5
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
6
|
+
|
|
7
|
+
const styleSearch = require('../style-search/index.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {{
|
|
11
|
+
* root: import('postcss').Root,
|
|
12
|
+
* result: import('stylelint').PostcssResult,
|
|
13
|
+
* locationChecker: (opts: { source: string, index: number, err: (msg: string) => void }) => void,
|
|
14
|
+
* checkedRuleName: string,
|
|
15
|
+
* fix: ((rule: import('postcss').Rule, index: number) => boolean) | null,
|
|
16
|
+
* }} opts
|
|
17
|
+
* @param options
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
module.exports = function selectorListCommaWhitespaceChecker (options) {
|
|
21
|
+
options.root.walkRules((rule) => {
|
|
22
|
+
if (!isStandardSyntaxRule(rule)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const selector = rule.raws.selector ? rule.raws.selector.raw : rule.selector;
|
|
27
|
+
|
|
28
|
+
styleSearch(
|
|
29
|
+
{
|
|
30
|
+
source: selector,
|
|
31
|
+
target: ',',
|
|
32
|
+
functionArguments: 'skip'
|
|
33
|
+
},
|
|
34
|
+
(match) => {
|
|
35
|
+
checkDelimiter(selector, match.startIndex, rule);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} source
|
|
42
|
+
* @param {number} index
|
|
43
|
+
* @param {import('postcss').Rule} node
|
|
44
|
+
*/
|
|
45
|
+
function checkDelimiter (source, index, node) {
|
|
46
|
+
options.locationChecker({
|
|
47
|
+
source,
|
|
48
|
+
index,
|
|
49
|
+
err: (message) => {
|
|
50
|
+
if (options.fix?.(node, index)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
report({
|
|
55
|
+
message,
|
|
56
|
+
node,
|
|
57
|
+
index,
|
|
58
|
+
result: options.result,
|
|
59
|
+
ruleName: options.checkedRuleName
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|