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,95 @@
|
|
|
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 isCustomProperty = require('stylelint/lib/utils/isCustomProperty.cjs');
|
|
6
|
+
const isStandardSyntaxProperty = require('stylelint/lib/utils/isStandardSyntaxProperty.cjs');
|
|
7
|
+
const optionsMatches = require('stylelint/lib/utils/optionsMatches.cjs');
|
|
8
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
9
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
10
|
+
const { isRule } = require('stylelint/lib/utils/typeGuards.cjs');
|
|
11
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
12
|
+
const { isRegExp, isString } = require('stylelint/lib/utils/validateTypes.cjs');
|
|
13
|
+
|
|
14
|
+
const ruleName = 'plugin/property-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/property-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(
|
|
28
|
+
result,
|
|
29
|
+
ruleName,
|
|
30
|
+
{
|
|
31
|
+
actual: primary,
|
|
32
|
+
possible: ['lower', 'upper']
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
actual: secondaryOptions,
|
|
36
|
+
possible: {
|
|
37
|
+
ignoreSelectors: [isString, isRegExp]
|
|
38
|
+
},
|
|
39
|
+
optional: true
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!validOptions) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
root.walkDecls((decl) => {
|
|
48
|
+
const property = decl.prop;
|
|
49
|
+
|
|
50
|
+
if (!isStandardSyntaxProperty(property)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (isCustomProperty(property)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { parent } = decl;
|
|
59
|
+
|
|
60
|
+
if (!parent) { throw new Error('A parent node must be present'); }
|
|
61
|
+
|
|
62
|
+
if (isRule(parent)) {
|
|
63
|
+
const { selector } = parent;
|
|
64
|
+
|
|
65
|
+
if (selector && optionsMatches(secondaryOptions, 'ignoreSelectors', selector)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const expectedProperty = primary === 'lower' ? property.toLowerCase() : property.toUpperCase();
|
|
71
|
+
|
|
72
|
+
if (property === expectedProperty) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (context.fix) {
|
|
77
|
+
decl.prop = expectedProperty;
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
report({
|
|
83
|
+
message: messages.expected(property, expectedProperty),
|
|
84
|
+
word: property,
|
|
85
|
+
node: decl,
|
|
86
|
+
ruleName,
|
|
87
|
+
result
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
rule.ruleName = ruleName;
|
|
93
|
+
rule.messages = messages;
|
|
94
|
+
rule.meta = meta;
|
|
95
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# selector-attribute-brackets-space-inside
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace on the inside of the brackets within attribute selectors.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
[ target=_blank ]
|
|
8
|
+
/** ↑ ↑
|
|
9
|
+
* The space inside these two brackets */
|
|
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 brackets.
|
|
21
|
+
|
|
22
|
+
The following patterns are considered problems:
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore -->
|
|
25
|
+
```css
|
|
26
|
+
[target] {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
[ target] {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```css
|
|
36
|
+
[target ] {}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<!-- prettier-ignore -->
|
|
40
|
+
```css
|
|
41
|
+
[target=_blank] {}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<!-- prettier-ignore -->
|
|
45
|
+
```css
|
|
46
|
+
[ target=_blank] {}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<!-- prettier-ignore -->
|
|
50
|
+
```css
|
|
51
|
+
[target=_blank ] {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The following patterns are _not_ considered problems:
|
|
55
|
+
|
|
56
|
+
<!-- prettier-ignore -->
|
|
57
|
+
```css
|
|
58
|
+
[ target ] {}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<!-- prettier-ignore -->
|
|
62
|
+
```css
|
|
63
|
+
[ target=_blank ] {}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `"never"`
|
|
67
|
+
|
|
68
|
+
There _must never_ be whitespace on the inside the brackets.
|
|
69
|
+
|
|
70
|
+
The following patterns are considered problems:
|
|
71
|
+
|
|
72
|
+
<!-- prettier-ignore -->
|
|
73
|
+
```css
|
|
74
|
+
[ target] {}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
<!-- prettier-ignore -->
|
|
78
|
+
```css
|
|
79
|
+
[target ] {}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
<!-- prettier-ignore -->
|
|
83
|
+
```css
|
|
84
|
+
[ target ] {}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
<!-- prettier-ignore -->
|
|
88
|
+
```css
|
|
89
|
+
[ target=_blank] {}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
<!-- prettier-ignore -->
|
|
93
|
+
```css
|
|
94
|
+
[target=_blank ] {}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
<!-- prettier-ignore -->
|
|
98
|
+
```css
|
|
99
|
+
[ target=_blank ] {}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The following patterns are _not_ considered problems:
|
|
103
|
+
|
|
104
|
+
<!-- prettier-ignore -->
|
|
105
|
+
```css
|
|
106
|
+
[target] {}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<!-- prettier-ignore -->
|
|
110
|
+
```css
|
|
111
|
+
[target=_blank] {}
|
|
112
|
+
```
|
|
@@ -0,0 +1,214 @@
|
|
|
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 styleSearch = require('../../style-search/index.cjs');
|
|
12
|
+
|
|
13
|
+
const ruleName = 'plugin/selector-attribute-brackets-space-inside';
|
|
14
|
+
|
|
15
|
+
const messages = ruleMessages(ruleName, {
|
|
16
|
+
expectedOpening: 'Expected single space after "["',
|
|
17
|
+
rejectedOpening: 'Unexpected whitespace after "["',
|
|
18
|
+
expectedClosing: 'Expected single space before "]"',
|
|
19
|
+
rejectedClosing: 'Unexpected whitespace before "]"'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const meta = {
|
|
23
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/README.md',
|
|
24
|
+
fixable: true
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** @type {import('stylelint').Rule} */
|
|
28
|
+
const rule = (primary, _secondaryOptions, context) => {
|
|
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.walkRules((ruleNode) => {
|
|
40
|
+
if (!isStandardSyntaxRule(ruleNode)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!ruleNode.selector.includes('[')) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const selector = ruleNode.raws.selector ? ruleNode.raws.selector.raw : ruleNode.selector;
|
|
49
|
+
|
|
50
|
+
let hasFixed;
|
|
51
|
+
const fixedSelector = parseSelector(selector, result, ruleNode, (selectorTree) => {
|
|
52
|
+
selectorTree.walkAttributes((attributeNode) => {
|
|
53
|
+
const attributeSelectorString = attributeNode.toString();
|
|
54
|
+
|
|
55
|
+
styleSearch({ source: attributeSelectorString, target: '[' }, (match) => {
|
|
56
|
+
const nextCharIsSpace = attributeSelectorString[match.startIndex + 1] === ' ';
|
|
57
|
+
const index = attributeNode.sourceIndex + match.startIndex + 1;
|
|
58
|
+
|
|
59
|
+
if (nextCharIsSpace && primary === 'never') {
|
|
60
|
+
if (context.fix) {
|
|
61
|
+
hasFixed = true;
|
|
62
|
+
fixBefore(attributeNode);
|
|
63
|
+
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
complain(messages.rejectedOpening, index);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!nextCharIsSpace && primary === 'always') {
|
|
71
|
+
if (context.fix) {
|
|
72
|
+
hasFixed = true;
|
|
73
|
+
fixBefore(attributeNode);
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
complain(messages.expectedOpening, index);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
styleSearch({ source: attributeSelectorString, target: ']' }, (match) => {
|
|
83
|
+
const previousCharIsSpace = attributeSelectorString[match.startIndex - 1] === ' ';
|
|
84
|
+
const index = attributeNode.sourceIndex + match.startIndex - 1;
|
|
85
|
+
|
|
86
|
+
if (previousCharIsSpace && primary === 'never') {
|
|
87
|
+
if (context.fix) {
|
|
88
|
+
hasFixed = true;
|
|
89
|
+
fixAfter(attributeNode);
|
|
90
|
+
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
complain(messages.rejectedClosing, index);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!previousCharIsSpace && primary === 'always') {
|
|
98
|
+
if (context.fix) {
|
|
99
|
+
hasFixed = true;
|
|
100
|
+
fixAfter(attributeNode);
|
|
101
|
+
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
complain(messages.expectedClosing, index);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (hasFixed && fixedSelector) {
|
|
112
|
+
if (!ruleNode.raws.selector) {
|
|
113
|
+
ruleNode.selector = fixedSelector;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
ruleNode.raws.selector.raw = fixedSelector;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @param {string} message
|
|
122
|
+
* @param {number} index
|
|
123
|
+
*/
|
|
124
|
+
function complain (message, index) {
|
|
125
|
+
report({
|
|
126
|
+
message,
|
|
127
|
+
index,
|
|
128
|
+
result,
|
|
129
|
+
ruleName,
|
|
130
|
+
node: ruleNode
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {import('postcss-selector-parser').Attribute} attributeNode
|
|
138
|
+
*/
|
|
139
|
+
function fixBefore (attributeNode) {
|
|
140
|
+
const spacesAttribute = attributeNode.raws.spaces?.attribute;
|
|
141
|
+
const rawAttributeBefore = spacesAttribute?.before;
|
|
142
|
+
|
|
143
|
+
/** @type {{ attrBefore: string, setAttrBefore: (fixed: string) => void }} */
|
|
144
|
+
const { attrBefore, setAttrBefore } = rawAttributeBefore ?
|
|
145
|
+
{
|
|
146
|
+
attrBefore: rawAttributeBefore,
|
|
147
|
+
setAttrBefore (fixed) {
|
|
148
|
+
spacesAttribute.before = fixed;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
: {
|
|
152
|
+
attrBefore:
|
|
153
|
+
(attributeNode.spaces.attribute?.before) || '',
|
|
154
|
+
setAttrBefore (fixed) {
|
|
155
|
+
if (!attributeNode.spaces.attribute) { attributeNode.spaces.attribute = {}; }
|
|
156
|
+
|
|
157
|
+
attributeNode.spaces.attribute.before = fixed;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (primary === 'always') {
|
|
162
|
+
setAttrBefore(attrBefore.replace(/^\s*/, ' '));
|
|
163
|
+
}
|
|
164
|
+
else if (primary === 'never') {
|
|
165
|
+
setAttrBefore(attrBefore.replace(/^\s*/, ''));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param {import('postcss-selector-parser').Attribute} attributeNode
|
|
171
|
+
*/
|
|
172
|
+
function fixAfter (attributeNode) {
|
|
173
|
+
const key = attributeNode.operator ?
|
|
174
|
+
attributeNode.insensitive ?
|
|
175
|
+
'insensitive'
|
|
176
|
+
: 'value'
|
|
177
|
+
: 'attribute';
|
|
178
|
+
|
|
179
|
+
const rawSpaces = attributeNode.raws.spaces?.[key];
|
|
180
|
+
const rawAfter = rawSpaces?.after;
|
|
181
|
+
|
|
182
|
+
const spaces = attributeNode.spaces[key];
|
|
183
|
+
|
|
184
|
+
/** @type {{ after: string, setAfter: (fixed: string) => void }} */
|
|
185
|
+
const { after, setAfter } = rawAfter ?
|
|
186
|
+
{
|
|
187
|
+
after: rawAfter,
|
|
188
|
+
setAfter (fixed) {
|
|
189
|
+
rawSpaces.after = fixed;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
: {
|
|
193
|
+
after: (spaces?.after) || '',
|
|
194
|
+
setAfter (fixed) {
|
|
195
|
+
if (!attributeNode.spaces[key]) { attributeNode.spaces[key] = {}; }
|
|
196
|
+
|
|
197
|
+
// @ts-expect-error -- TS2532: Object is possibly 'undefined'.
|
|
198
|
+
attributeNode.spaces[key].after = fixed;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
if (primary === 'always') {
|
|
203
|
+
setAfter(after.replace(/\s*$/, ' '));
|
|
204
|
+
}
|
|
205
|
+
else if (primary === 'never') {
|
|
206
|
+
setAfter(after.replace(/\s*$/, ''));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
rule.ruleName = ruleName;
|
|
212
|
+
rule.messages = messages;
|
|
213
|
+
rule.meta = meta;
|
|
214
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# selector-attribute-operator-space-after
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace after operators within attribute selectors.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
[target= _blank]
|
|
8
|
+
/** ↑
|
|
9
|
+
* The space after 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 operator.
|
|
21
|
+
|
|
22
|
+
The following patterns are considered problems:
|
|
23
|
+
|
|
24
|
+
<!-- prettier-ignore -->
|
|
25
|
+
```css
|
|
26
|
+
[target=_blank] {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
[target =_blank] {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```css
|
|
36
|
+
[target='_blank'] {}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<!-- prettier-ignore -->
|
|
40
|
+
```css
|
|
41
|
+
[target="_blank"] {}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<!-- prettier-ignore -->
|
|
45
|
+
```css
|
|
46
|
+
[target ='_blank'] {}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<!-- prettier-ignore -->
|
|
50
|
+
```css
|
|
51
|
+
[target ="_blank"] {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The following patterns are _not_ considered problems:
|
|
55
|
+
|
|
56
|
+
<!-- prettier-ignore -->
|
|
57
|
+
```css
|
|
58
|
+
[target] {}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<!-- prettier-ignore -->
|
|
62
|
+
```css
|
|
63
|
+
[target= _blank] {}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<!-- prettier-ignore -->
|
|
67
|
+
```css
|
|
68
|
+
[target= '_blank'] {}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
<!-- prettier-ignore -->
|
|
72
|
+
```css
|
|
73
|
+
[target= "_blank"] {}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<!-- prettier-ignore -->
|
|
77
|
+
```css
|
|
78
|
+
[target = _blank] {}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<!-- prettier-ignore -->
|
|
82
|
+
```css
|
|
83
|
+
[target = '_blank'] {}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<!-- prettier-ignore -->
|
|
87
|
+
```css
|
|
88
|
+
[target = "_blank"] {}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `"never"`
|
|
92
|
+
|
|
93
|
+
There _must never_ be a single space after the operator.
|
|
94
|
+
|
|
95
|
+
The following patterns are considered problems:
|
|
96
|
+
|
|
97
|
+
<!-- prettier-ignore -->
|
|
98
|
+
```css
|
|
99
|
+
[target= _blank] {}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
<!-- prettier-ignore -->
|
|
103
|
+
```css
|
|
104
|
+
[target = _blank] {}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
<!-- prettier-ignore -->
|
|
108
|
+
```css
|
|
109
|
+
[target= '_blank'] {}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
<!-- prettier-ignore -->
|
|
113
|
+
```css
|
|
114
|
+
[target= "_blank"] {}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
<!-- prettier-ignore -->
|
|
118
|
+
```css
|
|
119
|
+
[target = '_blank'] {}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
<!-- prettier-ignore -->
|
|
123
|
+
```css
|
|
124
|
+
[target = "_blank"] {}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The following patterns are _not_ considered problems:
|
|
128
|
+
|
|
129
|
+
<!-- prettier-ignore -->
|
|
130
|
+
```css
|
|
131
|
+
[target] {}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<!-- prettier-ignore -->
|
|
135
|
+
```css
|
|
136
|
+
[target=_blank] {}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
<!-- prettier-ignore -->
|
|
140
|
+
```css
|
|
141
|
+
[target='_blank'] {}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
<!-- prettier-ignore -->
|
|
145
|
+
```css
|
|
146
|
+
[target="_blank"] {}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
<!-- prettier-ignore -->
|
|
150
|
+
```css
|
|
151
|
+
[target =_blank] {}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
<!-- prettier-ignore -->
|
|
155
|
+
```css
|
|
156
|
+
[target ='_blank'] {}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
<!-- prettier-ignore -->
|
|
160
|
+
```css
|
|
161
|
+
[target ="_blank"] {}
|
|
162
|
+
```
|
|
@@ -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 ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
6
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
7
|
+
|
|
8
|
+
const whitespaceChecker = require('../../utils/whitespaceChecker.cjs');
|
|
9
|
+
const selectorAttributeOperatorSpaceChecker = require('../selectorAttributeOperatorSpaceChecker.cjs');
|
|
10
|
+
|
|
11
|
+
const ruleName = 'plugin/selector-attribute-operator-space-after';
|
|
12
|
+
|
|
13
|
+
const messages = ruleMessages(ruleName, {
|
|
14
|
+
expectedAfter: (operator) => `Expected single space after "${operator}"`,
|
|
15
|
+
rejectedAfter: (operator) => `Unexpected whitespace after "${operator}"`
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const meta = {
|
|
19
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/README.md',
|
|
20
|
+
fixable: true
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** @type {import('stylelint').Rule} */
|
|
24
|
+
const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
25
|
+
const checker = whitespaceChecker('space', primary, messages);
|
|
26
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
27
|
+
actual: primary,
|
|
28
|
+
possible: ['always', 'never']
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!validOptions) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
selectorAttributeOperatorSpaceChecker({
|
|
36
|
+
root,
|
|
37
|
+
result,
|
|
38
|
+
locationChecker: checker.after,
|
|
39
|
+
checkedRuleName: ruleName,
|
|
40
|
+
checkBeforeOperator: false,
|
|
41
|
+
fix: context.fix ?
|
|
42
|
+
(attributeNode) => {
|
|
43
|
+
/** @type {{ operatorAfter: string, setOperatorAfter: (fixed: string) => void }} */
|
|
44
|
+
const { operatorAfter, setOperatorAfter } = (() => {
|
|
45
|
+
const rawOperator = attributeNode.raws.operator;
|
|
46
|
+
|
|
47
|
+
if (rawOperator) {
|
|
48
|
+
return {
|
|
49
|
+
operatorAfter: rawOperator.slice(
|
|
50
|
+
attributeNode.operator ? attributeNode.operator.length : 0
|
|
51
|
+
),
|
|
52
|
+
setOperatorAfter (fixed) {
|
|
53
|
+
delete attributeNode.raws.operator;
|
|
54
|
+
|
|
55
|
+
if (!attributeNode.raws.spaces) { attributeNode.raws.spaces = {}; }
|
|
56
|
+
|
|
57
|
+
if (!attributeNode.raws.spaces.operator) { attributeNode.raws.spaces.operator = {}; }
|
|
58
|
+
|
|
59
|
+
attributeNode.raws.spaces.operator.after = fixed;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const rawSpacesOperator =
|
|
65
|
+
attributeNode.raws.spaces?.operator;
|
|
66
|
+
const rawOperatorAfter = rawSpacesOperator?.after;
|
|
67
|
+
|
|
68
|
+
if (rawOperatorAfter) {
|
|
69
|
+
return {
|
|
70
|
+
operatorAfter: rawOperatorAfter,
|
|
71
|
+
setOperatorAfter (fixed) {
|
|
72
|
+
rawSpacesOperator.after = fixed;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
operatorAfter:
|
|
79
|
+
(attributeNode.spaces.operator?.after) || '',
|
|
80
|
+
setOperatorAfter (fixed) {
|
|
81
|
+
if (!attributeNode.spaces.operator) { attributeNode.spaces.operator = {}; }
|
|
82
|
+
|
|
83
|
+
attributeNode.spaces.operator.after = fixed;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
87
|
+
|
|
88
|
+
if (primary === 'always') {
|
|
89
|
+
setOperatorAfter(operatorAfter.replace(/^\s*/, ' '));
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (primary === 'never') {
|
|
95
|
+
setOperatorAfter(operatorAfter.replace(/^\s*/, ''));
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
: null
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
rule.ruleName = ruleName;
|
|
107
|
+
rule.messages = messages;
|
|
108
|
+
rule.meta = meta;
|
|
109
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|