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,216 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const SKIP = 'skip';
|
|
5
|
+
const CHECK = 'check';
|
|
6
|
+
const ONLY = 'only';
|
|
7
|
+
|
|
8
|
+
module.exports = function (options, callback) {
|
|
9
|
+
const source = options.source;
|
|
10
|
+
const target = options.target;
|
|
11
|
+
|
|
12
|
+
const skipComments = (options.comments) ? options.comments === SKIP : true;
|
|
13
|
+
const skipStrings = (options.strings) ? options.strings === SKIP : true;
|
|
14
|
+
const skipFunctionNames = (options.functionNames) ? options.functionNames === SKIP : true;
|
|
15
|
+
const skipFunctionArguments = options.functionArguments === SKIP;
|
|
16
|
+
const skipParentheticals = options.parentheticals === SKIP;
|
|
17
|
+
|
|
18
|
+
let onceOptionUsed = false;
|
|
19
|
+
for (const key of Object.keys(options)) {
|
|
20
|
+
if (options[key] !== ONLY) { continue; }
|
|
21
|
+
if (!onceOptionUsed) {
|
|
22
|
+
onceOptionUsed = true;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error('Only one syntax feature option can be the "only" one to check');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const onlyComments = options.comments === ONLY;
|
|
30
|
+
const onlyStrings = options.strings === ONLY;
|
|
31
|
+
const onlyFunctionNames = options.functionNames === ONLY;
|
|
32
|
+
const onlyFunctionArguments = options.functionArguments === ONLY;
|
|
33
|
+
const onlyParentheticals = options.parentheticals === ONLY;
|
|
34
|
+
|
|
35
|
+
let insideString = false;
|
|
36
|
+
let insideComment = false;
|
|
37
|
+
let insideSingleLineComment = false;
|
|
38
|
+
let insideParens = false;
|
|
39
|
+
let insideFunctionArguments = false;
|
|
40
|
+
let openingParenCount = 0;
|
|
41
|
+
let matchCount = 0;
|
|
42
|
+
let openingQuote;
|
|
43
|
+
|
|
44
|
+
const targetIsArray = Array.isArray(target);
|
|
45
|
+
|
|
46
|
+
// If the target is just a string, it is easy to check whether
|
|
47
|
+
// some index of the source matches it.
|
|
48
|
+
// If the target is an array of strings, though, we have to
|
|
49
|
+
// check whether some index of the source matches *any* of
|
|
50
|
+
// those target strings (stopping after the first match).
|
|
51
|
+
const getMatch = (function () {
|
|
52
|
+
if (!targetIsArray) {
|
|
53
|
+
return getMatchBase.bind(null, target);
|
|
54
|
+
}
|
|
55
|
+
return function (index) {
|
|
56
|
+
for (let ti = 0, tl = target.length; ti < tl; ti++) {
|
|
57
|
+
const checkResult = getMatchBase(target[ti], index);
|
|
58
|
+
if (checkResult) { return checkResult; }
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
62
|
+
}());
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param targetString
|
|
67
|
+
* @param index
|
|
68
|
+
*/
|
|
69
|
+
function getMatchBase (targetString, index) {
|
|
70
|
+
const targetStringLength = targetString.length;
|
|
71
|
+
|
|
72
|
+
// Target is a single character
|
|
73
|
+
if (targetStringLength === 1 && source[index] !== targetString) { return false; }
|
|
74
|
+
|
|
75
|
+
// Target is multiple characters
|
|
76
|
+
if (source.substr(index, targetStringLength) !== targetString) { return false; }
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
insideParens,
|
|
80
|
+
insideFunctionArguments,
|
|
81
|
+
insideComment,
|
|
82
|
+
insideString,
|
|
83
|
+
startIndex: index,
|
|
84
|
+
endIndex: index + targetStringLength,
|
|
85
|
+
target: targetString
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (let i = 0, l = source.length; i < l; i++) {
|
|
90
|
+
const currentChar = source[i];
|
|
91
|
+
|
|
92
|
+
// Register the beginning of a comment
|
|
93
|
+
if (
|
|
94
|
+
!insideString && !insideComment &&
|
|
95
|
+
currentChar === '/' &&
|
|
96
|
+
source[i - 1] !== '\\' // escaping
|
|
97
|
+
) {
|
|
98
|
+
// standard comments
|
|
99
|
+
if (source[i + 1] === '*') {
|
|
100
|
+
insideComment = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// single-line comments
|
|
104
|
+
if (source[i + 1] === '/') {
|
|
105
|
+
insideComment = true;
|
|
106
|
+
insideSingleLineComment = true;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (insideComment) {
|
|
112
|
+
// Register the end of a standard comment
|
|
113
|
+
if (
|
|
114
|
+
!insideSingleLineComment &&
|
|
115
|
+
currentChar === '*' &&
|
|
116
|
+
source[i - 1] !== '\\' && // escaping
|
|
117
|
+
source[i + 1] === '/' &&
|
|
118
|
+
source[i - 1] !== '/' // don't end if it's /*/
|
|
119
|
+
) {
|
|
120
|
+
insideComment = false;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Register the end of a single-line comment
|
|
125
|
+
if (
|
|
126
|
+
insideSingleLineComment &&
|
|
127
|
+
currentChar === '\n'
|
|
128
|
+
) {
|
|
129
|
+
insideComment = false;
|
|
130
|
+
insideSingleLineComment = false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (skipComments) { continue; }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Register the beginning of a string
|
|
137
|
+
if (!insideComment && !insideString && (currentChar === '"' || currentChar === "'")) {
|
|
138
|
+
if (source[i - 1] === '\\') { continue; } // escaping
|
|
139
|
+
|
|
140
|
+
openingQuote = currentChar;
|
|
141
|
+
insideString = true;
|
|
142
|
+
|
|
143
|
+
// For string-quotes rule
|
|
144
|
+
if (target === currentChar) { handleMatch(getMatch(i)); }
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (insideString) {
|
|
149
|
+
// Register the end of a string
|
|
150
|
+
if (currentChar === openingQuote) {
|
|
151
|
+
if (source[i - 1] === '\\') { continue; } // escaping
|
|
152
|
+
insideString = false;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (skipStrings) { continue; }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Register the beginning of parens/functions
|
|
160
|
+
if (!insideString && !insideComment && currentChar === '(') {
|
|
161
|
+
// Keep track of opening parentheticals so that we
|
|
162
|
+
// know when the outermost function (possibly
|
|
163
|
+
// containing nested functions) is closing
|
|
164
|
+
openingParenCount++;
|
|
165
|
+
|
|
166
|
+
insideParens = true;
|
|
167
|
+
// Only inside a function if there is a function name
|
|
168
|
+
// before the opening paren
|
|
169
|
+
if ((/[A-Za-z]/).test(source[i - 1])) {
|
|
170
|
+
insideFunctionArguments = true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (target === '(') { handleMatch(getMatch(i)); }
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (insideParens) {
|
|
178
|
+
// Register the end of a function
|
|
179
|
+
if (currentChar === ')') {
|
|
180
|
+
openingParenCount--;
|
|
181
|
+
// Do this here so the match is still technically inside a function
|
|
182
|
+
if (target === ')') { handleMatch(getMatch(i)); }
|
|
183
|
+
if (openingParenCount === 0) {
|
|
184
|
+
insideParens = false;
|
|
185
|
+
insideFunctionArguments = false;
|
|
186
|
+
}
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const isFunctionName = (/^[A-Za-z]*\(/).test(source.slice(i));
|
|
192
|
+
if (skipFunctionNames && isFunctionName) { continue; }
|
|
193
|
+
if (onlyFunctionNames && !isFunctionName) { continue; }
|
|
194
|
+
|
|
195
|
+
const match = getMatch(i);
|
|
196
|
+
|
|
197
|
+
if (!match) { continue; }
|
|
198
|
+
handleMatch(match);
|
|
199
|
+
if (options.once) { return; }
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
* @param match
|
|
205
|
+
*/
|
|
206
|
+
function handleMatch (match) {
|
|
207
|
+
if (onlyParentheticals && !insideParens) { return; }
|
|
208
|
+
if (skipParentheticals && insideParens) { return; }
|
|
209
|
+
if (onlyFunctionArguments && !insideFunctionArguments) { return; }
|
|
210
|
+
if (skipFunctionArguments && insideFunctionArguments) { return; }
|
|
211
|
+
if (onlyStrings && !insideString) { return; }
|
|
212
|
+
if (onlyComments && !insideComment) { return; }
|
|
213
|
+
matchCount++;
|
|
214
|
+
callback(match, matchCount);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add an empty line after a node. Mutates the node.
|
|
6
|
+
*
|
|
7
|
+
* @template {import('postcss').Rule | import('postcss').AtRule} T
|
|
8
|
+
* @param {T} node
|
|
9
|
+
* @param {string} newline
|
|
10
|
+
* @returns {T}
|
|
11
|
+
*/
|
|
12
|
+
module.exports = function addEmptyLineAfter (node, newline) {
|
|
13
|
+
const { raws } = node;
|
|
14
|
+
|
|
15
|
+
if (typeof raws.after !== 'string') {
|
|
16
|
+
return node;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const spaces = raws.after.split(';');
|
|
20
|
+
const after = spaces[spaces.length - 1] || '';
|
|
21
|
+
|
|
22
|
+
if (!(/\r?\n/).test(after)) {
|
|
23
|
+
raws.after += newline.repeat(2);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
raws.after = raws.after.replace(/(\r?\n)/, `${newline}$1`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return node;
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const hasBlock = require('stylelint/lib/utils/hasBlock.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check if a statement has an empty block.
|
|
8
|
+
*
|
|
9
|
+
* @param {import('postcss').Rule | import('postcss').AtRule} statement - postcss rule or at-rule node
|
|
10
|
+
* @returns {boolean} True if the statement has a block and it is empty
|
|
11
|
+
*/
|
|
12
|
+
module.exports = function hasEmptyBlock (statement) {
|
|
13
|
+
return hasBlock(statement) && statement.nodes.length === 0;
|
|
14
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('postcss').Node} PostcssNode */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the next non-comment node in a PostCSS AST
|
|
8
|
+
* at or after a given node.
|
|
9
|
+
*
|
|
10
|
+
* @param {PostcssNode | void} startNode
|
|
11
|
+
* @returns {PostcssNode | null}
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function nextNonCommentNode (startNode) {
|
|
14
|
+
if (!startNode || !startNode.next) { return null; }
|
|
15
|
+
|
|
16
|
+
if (startNode.type === 'comment') {
|
|
17
|
+
return nextNonCommentNode(startNode.next());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return startNode;
|
|
21
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Remove empty lines before a node. Mutates the node.
|
|
6
|
+
*
|
|
7
|
+
* @template {import('postcss').Rule | import('postcss').AtRule} T
|
|
8
|
+
* @param {T} node
|
|
9
|
+
* @param {string} newline
|
|
10
|
+
* @returns {T}
|
|
11
|
+
*/
|
|
12
|
+
module.exports = function removeEmptyLinesAfter (node, newline) {
|
|
13
|
+
node.raws.after = node.raws.after ? node.raws.after.replace(/(\r?\n\s*\n)+/g, newline) : '';
|
|
14
|
+
|
|
15
|
+
return node;
|
|
16
|
+
};
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const configurationError = require('stylelint/lib/utils/configurationError.cjs');
|
|
5
|
+
const isSingleLineString = require('stylelint/lib/utils/isSingleLineString.cjs');
|
|
6
|
+
const isWhitespace = require('stylelint/lib/utils/isWhitespace.cjs');
|
|
7
|
+
const { assertFunction, isNullish } = require('stylelint/lib/utils/validateTypes.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {(message: string) => string} MessageFunction
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {object} Messages
|
|
15
|
+
* @property {MessageFunction} [expectedBefore]
|
|
16
|
+
* @property {MessageFunction} [rejectedBefore]
|
|
17
|
+
* @property {MessageFunction} [expectedAfter]
|
|
18
|
+
* @property {MessageFunction} [rejectedAfter]
|
|
19
|
+
* @property {MessageFunction} [expectedBeforeSingleLine]
|
|
20
|
+
* @property {MessageFunction} [rejectedBeforeSingleLine]
|
|
21
|
+
* @property {MessageFunction} [expectedBeforeMultiLine]
|
|
22
|
+
* @property {MessageFunction} [rejectedBeforeMultiLine]
|
|
23
|
+
* @property {MessageFunction} [expectedAfterSingleLine]
|
|
24
|
+
* @property {MessageFunction} [rejectedAfterSingleLine]
|
|
25
|
+
* @property {MessageFunction} [expectedAfterMultiLine]
|
|
26
|
+
* @property {MessageFunction} [rejectedAfterMultiLine]
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {object} WhitespaceCheckerArgs
|
|
31
|
+
* @property {string} source - The source string
|
|
32
|
+
* @property {number} index - The index of the character to check before
|
|
33
|
+
* @property {(message: string) => void} err - If a problem is found, this callback
|
|
34
|
+
* will be invoked with the relevant warning message.
|
|
35
|
+
* Typically this callback will report() the problem.
|
|
36
|
+
* @property {string} [errTarget] - If a problem is found, this string
|
|
37
|
+
* will be sent to the relevant warning message.
|
|
38
|
+
* @property {string} [lineCheckStr] - Single- and multi-line checkers
|
|
39
|
+
* will use this string to determine whether they should proceed,
|
|
40
|
+
* i.e. if this string is one line only, single-line checkers will check,
|
|
41
|
+
* multi-line checkers will ignore.
|
|
42
|
+
* If none is passed, they will use `source`.
|
|
43
|
+
* @property {boolean} [onlyOneChar=false] - Only check *one* character before.
|
|
44
|
+
* By default, "always-*" checks will look for the `targetWhitespace` one
|
|
45
|
+
* before and then ensure there is no whitespace two before. This option
|
|
46
|
+
* bypasses that second check.
|
|
47
|
+
* @property {boolean} [allowIndentation=false] - Allow arbitrary indentation
|
|
48
|
+
* between the `targetWhitespace` (almost definitely a newline) and the `index`.
|
|
49
|
+
* With this option, the checker will see if a newline *begins* the whitespace before
|
|
50
|
+
* the `index`.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {(args: WhitespaceCheckerArgs) => void} WhitespaceChecker
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {{
|
|
59
|
+
* before: WhitespaceChecker,
|
|
60
|
+
* beforeAllowingIndentation: WhitespaceChecker,
|
|
61
|
+
* after: WhitespaceChecker,
|
|
62
|
+
* afterOneOnly: WhitespaceChecker,
|
|
63
|
+
* }} WhitespaceCheckers
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a whitespaceChecker, which exposes the following functions:
|
|
68
|
+
* - `before()`
|
|
69
|
+
* - `beforeAllowingIndentation()`
|
|
70
|
+
* - `after()`
|
|
71
|
+
* - `afterOneOnly()`
|
|
72
|
+
*
|
|
73
|
+
* @param {"space" | "newline"} targetWhitespace - This is a keyword instead
|
|
74
|
+
* of the actual character (e.g. " ") in order to accommodate
|
|
75
|
+
* different styles of newline ("\n" vs "\r\n")
|
|
76
|
+
* @param {"always" | "never" | "always-single-line" | "always-multi-line" | "never-single-line" | "never-multi-line"} expectation
|
|
77
|
+
* @param {Messages} messages - An object of message functions;
|
|
78
|
+
* calling `before*()` or `after*()` and the `expectation` that is passed
|
|
79
|
+
* determines which message functions are required
|
|
80
|
+
*
|
|
81
|
+
* @returns {WhitespaceCheckers} The checker, with its exposed checking functions
|
|
82
|
+
*/
|
|
83
|
+
module.exports = function whitespaceChecker (targetWhitespace, expectation, messages) {
|
|
84
|
+
// Keep track of active arguments in order to avoid passing
|
|
85
|
+
// too much stuff around, making signatures long and confusing.
|
|
86
|
+
// This variable gets reset anytime a checking function is called.
|
|
87
|
+
/** @type {WhitespaceCheckerArgs} */
|
|
88
|
+
let activeArgs;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Check for whitespace *before* a character.
|
|
92
|
+
* @type {WhitespaceChecker}
|
|
93
|
+
*/
|
|
94
|
+
function before ({
|
|
95
|
+
source,
|
|
96
|
+
index,
|
|
97
|
+
err,
|
|
98
|
+
errTarget,
|
|
99
|
+
lineCheckStr,
|
|
100
|
+
onlyOneChar = false,
|
|
101
|
+
allowIndentation = false
|
|
102
|
+
}) {
|
|
103
|
+
activeArgs = {
|
|
104
|
+
source,
|
|
105
|
+
index,
|
|
106
|
+
err,
|
|
107
|
+
errTarget,
|
|
108
|
+
onlyOneChar,
|
|
109
|
+
allowIndentation
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
switch (expectation) {
|
|
113
|
+
case 'always':
|
|
114
|
+
expectBefore();
|
|
115
|
+
break;
|
|
116
|
+
case 'never':
|
|
117
|
+
rejectBefore();
|
|
118
|
+
break;
|
|
119
|
+
case 'always-single-line':
|
|
120
|
+
if (!isSingleLineString(lineCheckStr || source)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
expectBefore(messages.expectedBeforeSingleLine);
|
|
125
|
+
break;
|
|
126
|
+
case 'never-single-line':
|
|
127
|
+
if (!isSingleLineString(lineCheckStr || source)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
rejectBefore(messages.rejectedBeforeSingleLine);
|
|
132
|
+
break;
|
|
133
|
+
case 'always-multi-line':
|
|
134
|
+
if (isSingleLineString(lineCheckStr || source)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
expectBefore(messages.expectedBeforeMultiLine);
|
|
139
|
+
break;
|
|
140
|
+
case 'never-multi-line':
|
|
141
|
+
if (isSingleLineString(lineCheckStr || source)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
rejectBefore(messages.rejectedBeforeMultiLine);
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
throw configurationError(`Unknown expectation "${expectation}"`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Check for whitespace *after* a character.
|
|
154
|
+
* @type {WhitespaceChecker}
|
|
155
|
+
*/
|
|
156
|
+
function after ({ source, index, err, errTarget, lineCheckStr, onlyOneChar = false }) {
|
|
157
|
+
activeArgs = { source, index, err, errTarget, onlyOneChar };
|
|
158
|
+
|
|
159
|
+
switch (expectation) {
|
|
160
|
+
case 'always':
|
|
161
|
+
expectAfter();
|
|
162
|
+
break;
|
|
163
|
+
case 'never':
|
|
164
|
+
rejectAfter();
|
|
165
|
+
break;
|
|
166
|
+
case 'always-single-line':
|
|
167
|
+
if (!isSingleLineString(lineCheckStr || source)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
expectAfter(messages.expectedAfterSingleLine);
|
|
172
|
+
break;
|
|
173
|
+
case 'never-single-line':
|
|
174
|
+
if (!isSingleLineString(lineCheckStr || source)) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
rejectAfter(messages.rejectedAfterSingleLine);
|
|
179
|
+
break;
|
|
180
|
+
case 'always-multi-line':
|
|
181
|
+
if (isSingleLineString(lineCheckStr || source)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
expectAfter(messages.expectedAfterMultiLine);
|
|
186
|
+
break;
|
|
187
|
+
case 'never-multi-line':
|
|
188
|
+
if (isSingleLineString(lineCheckStr || source)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
rejectAfter(messages.rejectedAfterMultiLine);
|
|
193
|
+
break;
|
|
194
|
+
default:
|
|
195
|
+
throw configurationError(`Unknown expectation "${expectation}"`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @type {WhitespaceChecker}
|
|
201
|
+
*/
|
|
202
|
+
function beforeAllowingIndentation (obj) {
|
|
203
|
+
before({ ...obj, allowIndentation: true });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* @param messageFunction
|
|
209
|
+
*/
|
|
210
|
+
function expectBefore (messageFunction = messages.expectedBefore) {
|
|
211
|
+
if (activeArgs.allowIndentation) {
|
|
212
|
+
expectBeforeAllowingIndentation(messageFunction);
|
|
213
|
+
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const _activeArgs = activeArgs;
|
|
218
|
+
const source = _activeArgs.source;
|
|
219
|
+
const index = _activeArgs.index;
|
|
220
|
+
|
|
221
|
+
const oneCharBefore = source[index - 1];
|
|
222
|
+
const twoCharsBefore = source[index - 2];
|
|
223
|
+
|
|
224
|
+
if (isNullish(oneCharBefore)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (
|
|
229
|
+
targetWhitespace === 'space' &&
|
|
230
|
+
oneCharBefore === ' ' &&
|
|
231
|
+
(activeArgs.onlyOneChar || isNullish(twoCharsBefore) || !isWhitespace(twoCharsBefore))
|
|
232
|
+
) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
assertFunction(messageFunction);
|
|
237
|
+
activeArgs.err(messageFunction(activeArgs.errTarget || source.charAt(index)));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
*
|
|
242
|
+
* @param messageFunction
|
|
243
|
+
*/
|
|
244
|
+
function expectBeforeAllowingIndentation (messageFunction = messages.expectedBefore) {
|
|
245
|
+
const _activeArgs2 = activeArgs;
|
|
246
|
+
const source = _activeArgs2.source;
|
|
247
|
+
const index = _activeArgs2.index;
|
|
248
|
+
const error = _activeArgs2.err;
|
|
249
|
+
|
|
250
|
+
const expectedChar = targetWhitespace === 'newline' ? '\n' : undefined;
|
|
251
|
+
let i = index - 1;
|
|
252
|
+
|
|
253
|
+
while (source[i] !== expectedChar) {
|
|
254
|
+
if (source[i] === '\t' || source[i] === ' ') {
|
|
255
|
+
i--;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
assertFunction(messageFunction);
|
|
260
|
+
error(messageFunction(activeArgs.errTarget || source.charAt(index)));
|
|
261
|
+
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* @param messageFunction
|
|
269
|
+
*/
|
|
270
|
+
function rejectBefore (messageFunction = messages.rejectedBefore) {
|
|
271
|
+
const _activeArgs3 = activeArgs;
|
|
272
|
+
const source = _activeArgs3.source;
|
|
273
|
+
const index = _activeArgs3.index;
|
|
274
|
+
|
|
275
|
+
const oneCharBefore = source[index - 1];
|
|
276
|
+
|
|
277
|
+
if (!isNullish(oneCharBefore) && isWhitespace(oneCharBefore)) {
|
|
278
|
+
assertFunction(messageFunction);
|
|
279
|
+
activeArgs.err(messageFunction(activeArgs.errTarget || source.charAt(index)));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @type {WhitespaceChecker}
|
|
285
|
+
*/
|
|
286
|
+
function afterOneOnly (obj) {
|
|
287
|
+
after({ ...obj, onlyOneChar: true });
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
*
|
|
292
|
+
* @param messageFunction
|
|
293
|
+
*/
|
|
294
|
+
function expectAfter (messageFunction = messages.expectedAfter) {
|
|
295
|
+
const _activeArgs4 = activeArgs;
|
|
296
|
+
const source = _activeArgs4.source;
|
|
297
|
+
const index = _activeArgs4.index;
|
|
298
|
+
|
|
299
|
+
const oneCharAfter = source[index + 1];
|
|
300
|
+
const twoCharsAfter = source[index + 2];
|
|
301
|
+
const threeCharsAfter = source[index + 3];
|
|
302
|
+
|
|
303
|
+
if (isNullish(oneCharAfter)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (targetWhitespace === 'newline') {
|
|
308
|
+
// If index is followed by a Windows CR-LF ...
|
|
309
|
+
if (
|
|
310
|
+
oneCharAfter === '\r' &&
|
|
311
|
+
twoCharsAfter === '\n' &&
|
|
312
|
+
(activeArgs.onlyOneChar || isNullish(threeCharsAfter) || !isWhitespace(threeCharsAfter))
|
|
313
|
+
) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// If index is followed by a Unix LF ...
|
|
318
|
+
if (
|
|
319
|
+
oneCharAfter === '\n' &&
|
|
320
|
+
(activeArgs.onlyOneChar || isNullish(twoCharsAfter) || !isWhitespace(twoCharsAfter))
|
|
321
|
+
) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (
|
|
327
|
+
targetWhitespace === 'space' &&
|
|
328
|
+
oneCharAfter === ' ' &&
|
|
329
|
+
(activeArgs.onlyOneChar || isNullish(twoCharsAfter) || !isWhitespace(twoCharsAfter))
|
|
330
|
+
) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
assertFunction(messageFunction);
|
|
335
|
+
activeArgs.err(messageFunction(activeArgs.errTarget || source.charAt(index)));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
*
|
|
340
|
+
* @param messageFunction
|
|
341
|
+
*/
|
|
342
|
+
function rejectAfter (messageFunction = messages.rejectedAfter) {
|
|
343
|
+
const _activeArgs5 = activeArgs;
|
|
344
|
+
const source = _activeArgs5.source;
|
|
345
|
+
const index = _activeArgs5.index;
|
|
346
|
+
|
|
347
|
+
const oneCharAfter = source[index + 1];
|
|
348
|
+
|
|
349
|
+
if (!isNullish(oneCharAfter) && isWhitespace(oneCharAfter)) {
|
|
350
|
+
assertFunction(messageFunction);
|
|
351
|
+
activeArgs.err(messageFunction(activeArgs.errTarget || source.charAt(index)));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
before,
|
|
357
|
+
beforeAllowingIndentation,
|
|
358
|
+
after,
|
|
359
|
+
afterOneOnly
|
|
360
|
+
};
|
|
361
|
+
};
|
|
@@ -53,9 +53,9 @@ export default stylelint.createPlugin(ruleName, (enabled) => {
|
|
|
53
53
|
/**
|
|
54
54
|
* Splits the selectors based on a specified delimiter and filters out empty selectors.
|
|
55
55
|
*
|
|
56
|
-
* @param {string[]} splittedSelectors - The selectors to be split
|
|
57
|
-
* @param {string} splitBy - The delimiter to split the selectors
|
|
58
|
-
* @returns {string[]} The split and filtered selectors
|
|
56
|
+
* @param {string[]} splittedSelectors - The selectors to be split
|
|
57
|
+
* @param {string} splitBy - The delimiter to split the selectors
|
|
58
|
+
* @returns {string[]} The split and filtered selectors
|
|
59
59
|
*/
|
|
60
60
|
function getSplittedSelectors (splittedSelectors, splitBy) {
|
|
61
61
|
const res = [];
|
|
@@ -77,9 +77,9 @@ function getSplittedSelectors (splittedSelectors, splitBy) {
|
|
|
77
77
|
/**
|
|
78
78
|
* Checks for empty selectors within the space-split selectors.
|
|
79
79
|
*
|
|
80
|
-
* @param {string[]} spaceSplittedSelectors - The space-split selectors
|
|
81
|
-
* @param {stylelint.PostcssResult} result - The result object
|
|
82
|
-
* @param {import('postcss').Rule} rule - The current rule
|
|
80
|
+
* @param {string[]} spaceSplittedSelectors - The space-split selectors
|
|
81
|
+
* @param {stylelint.PostcssResult} result - The result object
|
|
82
|
+
* @param {import('postcss').Rule} rule - The current rule
|
|
83
83
|
*/
|
|
84
84
|
function checkEmptySelector (spaceSplittedSelectors, result, rule) {
|
|
85
85
|
for (let sp of spaceSplittedSelectors) {
|
|
@@ -101,8 +101,8 @@ function checkEmptySelector (spaceSplittedSelectors, result, rule) {
|
|
|
101
101
|
/**
|
|
102
102
|
* Reports an error for an empty selector.
|
|
103
103
|
*
|
|
104
|
-
* @param {import('postcss').Rule} rule - The current rule
|
|
105
|
-
* @param {stylelint.PostcssResult} result - The result object
|
|
104
|
+
* @param {import('postcss').Rule} rule - The current rule
|
|
105
|
+
* @param {stylelint.PostcssResult} result - The result object
|
|
106
106
|
*/
|
|
107
107
|
function reportError (rule, result) {
|
|
108
108
|
stylelint.utils.report({
|