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,63 @@
|
|
|
1
|
+
# at-rule-semicolon-newline-after
|
|
2
|
+
|
|
3
|
+
Require a newline after the semicolon of at-rules.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
@import url("x.css");
|
|
8
|
+
@import url("y.css");
|
|
9
|
+
/** ↑
|
|
10
|
+
* The newline after these semicolons */
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This rule allows an end-of-line comment followed by a newline. For example:
|
|
14
|
+
|
|
15
|
+
<!-- prettier-ignore -->
|
|
16
|
+
```css
|
|
17
|
+
@import url("x.css"); /* end-of-line comment */
|
|
18
|
+
|
|
19
|
+
a {}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The [`fix` option](https://stylelint.io/user-guide/options/#fix) can automatically fix all of the problems reported by this rule.
|
|
23
|
+
|
|
24
|
+
## Options
|
|
25
|
+
|
|
26
|
+
`string`: `"always"`
|
|
27
|
+
|
|
28
|
+
### `"always"`
|
|
29
|
+
|
|
30
|
+
There _must always_ be a newline after the semicolon.
|
|
31
|
+
|
|
32
|
+
The following patterns are considered problems:
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```css
|
|
36
|
+
@import url("x.css"); @import url("y.css");
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<!-- prettier-ignore -->
|
|
40
|
+
```css
|
|
41
|
+
@import url("x.css"); a {}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The following patterns are _not_ considered problems:
|
|
45
|
+
|
|
46
|
+
<!-- prettier-ignore -->
|
|
47
|
+
```css
|
|
48
|
+
@import url("x.css");
|
|
49
|
+
@import url("y.css");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<!-- prettier-ignore -->
|
|
53
|
+
```css
|
|
54
|
+
@import url("x.css"); /* end-of-line comment */
|
|
55
|
+
a {}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<!-- prettier-ignore -->
|
|
59
|
+
```css
|
|
60
|
+
@import url("x.css");
|
|
61
|
+
|
|
62
|
+
a {}
|
|
63
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
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 hasBlock = require('stylelint/lib/utils/hasBlock.cjs');
|
|
6
|
+
const isStandardSyntaxAtRule = require('stylelint/lib/utils/isStandardSyntaxAtRule.cjs');
|
|
7
|
+
const rawNodeString = require('stylelint/lib/utils/rawNodeString.cjs');
|
|
8
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
9
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
10
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
11
|
+
|
|
12
|
+
const nextNonCommentNode = require('../../utils/nextNonCommentNode.cjs');
|
|
13
|
+
const whitespaceChecker = require('../../utils/whitespaceChecker.cjs');
|
|
14
|
+
|
|
15
|
+
const ruleName = 'plugin/at-rule-semicolon-newline-after';
|
|
16
|
+
|
|
17
|
+
const messages = ruleMessages(ruleName, {
|
|
18
|
+
expectedAfter: () => 'Expected newline after ";"'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const meta = {
|
|
22
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/README.md',
|
|
23
|
+
fixable: true
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** @type {import('stylelint').Rule} */
|
|
27
|
+
const rule = (primary, _secondary, context) => {
|
|
28
|
+
const checker = whitespaceChecker('newline', primary, messages);
|
|
29
|
+
|
|
30
|
+
return (root, result) => {
|
|
31
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
32
|
+
actual: primary,
|
|
33
|
+
possible: ['always']
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (!validOptions) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
root.walkAtRules((atRule) => {
|
|
41
|
+
const nextNode = atRule.next();
|
|
42
|
+
|
|
43
|
+
if (!nextNode) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (hasBlock(atRule)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!isStandardSyntaxAtRule(atRule)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Allow an end-of-line comment
|
|
56
|
+
const nodeToCheck = nextNonCommentNode(nextNode);
|
|
57
|
+
|
|
58
|
+
if (!nodeToCheck) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
checker.afterOneOnly({
|
|
63
|
+
source: rawNodeString(nodeToCheck),
|
|
64
|
+
index: -1,
|
|
65
|
+
err: (message) => {
|
|
66
|
+
if (context.fix) {
|
|
67
|
+
nodeToCheck.raws.before = context.newline + nodeToCheck.raws.before;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
report({
|
|
71
|
+
message,
|
|
72
|
+
node: atRule,
|
|
73
|
+
index: atRule.toString().length + 1,
|
|
74
|
+
result,
|
|
75
|
+
ruleName
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
rule.ruleName = ruleName;
|
|
85
|
+
rule.messages = messages;
|
|
86
|
+
rule.meta = meta;
|
|
87
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# at-rule-semicolon-space-before
|
|
2
|
+
|
|
3
|
+
Require a single space or disallow whitespace before the semicolons of at-rules.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
@import "components/buttons";
|
|
8
|
+
/** ↑
|
|
9
|
+
* The space before this semicolon */
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Options
|
|
13
|
+
|
|
14
|
+
`string`: `"always"|"never"`
|
|
15
|
+
|
|
16
|
+
### `"always"`
|
|
17
|
+
|
|
18
|
+
There _must always_ be a single space before the semicolons.
|
|
19
|
+
|
|
20
|
+
The following pattern is considered a problem:
|
|
21
|
+
|
|
22
|
+
<!-- prettier-ignore -->
|
|
23
|
+
```css
|
|
24
|
+
@import "components/buttons";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The following pattern is _not_ considered a problem:
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```css
|
|
31
|
+
@import "components/buttons" ;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### `"never"`
|
|
35
|
+
|
|
36
|
+
There _must never_ be a single space before the semicolons.
|
|
37
|
+
|
|
38
|
+
The following pattern is considered a problem:
|
|
39
|
+
|
|
40
|
+
<!-- prettier-ignore -->
|
|
41
|
+
```css
|
|
42
|
+
@import "components/buttons" ;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The following pattern is _not_ considered a problem:
|
|
46
|
+
|
|
47
|
+
<!-- prettier-ignore -->
|
|
48
|
+
```css
|
|
49
|
+
@import "components/buttons";
|
|
50
|
+
```
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/index.cjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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 hasBlock = require('stylelint/lib/utils/hasBlock.cjs');
|
|
6
|
+
const isStandardSyntaxAtRule = require('stylelint/lib/utils/isStandardSyntaxAtRule.cjs');
|
|
7
|
+
const rawNodeString = require('stylelint/lib/utils/rawNodeString.cjs');
|
|
8
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
9
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
10
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
11
|
+
|
|
12
|
+
const whitespaceChecker = require('../../utils/whitespaceChecker.cjs');
|
|
13
|
+
|
|
14
|
+
const ruleName = 'plugin/at-rule-semicolon-space-before';
|
|
15
|
+
|
|
16
|
+
const messages = ruleMessages(ruleName, {
|
|
17
|
+
expectedBefore: () => 'Expected single space before ";"',
|
|
18
|
+
rejectedBefore: () => 'Unexpected whitespace before ";"'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const meta = {
|
|
22
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/README.md'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @type {import('stylelint').Rule} */
|
|
26
|
+
const rule = (primary) => {
|
|
27
|
+
const checker = whitespaceChecker('space', primary, messages);
|
|
28
|
+
|
|
29
|
+
return (root, result) => {
|
|
30
|
+
const validOptions = validateOptions(result, ruleName, {
|
|
31
|
+
actual: primary,
|
|
32
|
+
possible: ['always', 'never']
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!validOptions) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
root.walkAtRules((atRule) => {
|
|
40
|
+
if (hasBlock(atRule)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!isStandardSyntaxAtRule(atRule)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const nodeString = rawNodeString(atRule);
|
|
49
|
+
|
|
50
|
+
checker.before({
|
|
51
|
+
source: nodeString,
|
|
52
|
+
index: nodeString.length,
|
|
53
|
+
err: (m) => {
|
|
54
|
+
report({
|
|
55
|
+
message: m,
|
|
56
|
+
node: atRule,
|
|
57
|
+
index: nodeString.length - 1,
|
|
58
|
+
result,
|
|
59
|
+
ruleName
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
rule.ruleName = ruleName;
|
|
68
|
+
rule.messages = messages;
|
|
69
|
+
rule.meta = meta;
|
|
70
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable -- We want to keep as much of the original code as possible */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
const isStandardSyntaxAtRule = require('stylelint/lib/utils/isStandardSyntaxAtRule.cjs');
|
|
5
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {{
|
|
9
|
+
* root: import('postcss').Root,
|
|
10
|
+
* locationChecker: (opts: { source: string, index: number, err: (msg: string) => void, errTarget: string }) => void,
|
|
11
|
+
* result: import('stylelint').PostcssResult,
|
|
12
|
+
* checkedRuleName: string,
|
|
13
|
+
* fix?: ((atRule: import('postcss').AtRule) => void) | null,
|
|
14
|
+
* }} options
|
|
15
|
+
*/
|
|
16
|
+
module.exports = function atRuleNameSpaceChecker (options) {
|
|
17
|
+
options.root.walkAtRules((atRule) => {
|
|
18
|
+
if (!isStandardSyntaxAtRule(atRule)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
checkColon(
|
|
23
|
+
`@${atRule.name}${atRule.raws.afterName || ''}${atRule.params}`,
|
|
24
|
+
atRule.name.length,
|
|
25
|
+
atRule
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} source
|
|
31
|
+
* @param {number} index
|
|
32
|
+
* @param {import('postcss').AtRule} node
|
|
33
|
+
*/
|
|
34
|
+
function checkColon (source, index, node) {
|
|
35
|
+
options.locationChecker({
|
|
36
|
+
source,
|
|
37
|
+
index,
|
|
38
|
+
err: (m) => {
|
|
39
|
+
if (options.fix) {
|
|
40
|
+
options.fix(node);
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
report({
|
|
46
|
+
message: m,
|
|
47
|
+
node,
|
|
48
|
+
index,
|
|
49
|
+
result: options.result,
|
|
50
|
+
ruleName: options.checkedRuleName
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
errTarget: `@${node.name}`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# block-closing-brace-empty-line-before
|
|
2
|
+
|
|
3
|
+
Require or disallow an empty line before the closing brace of blocks.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```css
|
|
7
|
+
a {
|
|
8
|
+
color: pink;
|
|
9
|
+
/* ← */
|
|
10
|
+
} /* ↑ */
|
|
11
|
+
/** ↑
|
|
12
|
+
* This line */
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The [`fix` option](https://stylelint.io/user-guide/options/#fix) can automatically fix all of the problems reported by this rule.
|
|
16
|
+
|
|
17
|
+
## Options
|
|
18
|
+
|
|
19
|
+
`string`: `"always-multi-line"|"never"`
|
|
20
|
+
|
|
21
|
+
### `always-multi-line`
|
|
22
|
+
|
|
23
|
+
The following patterns are considered problems:
|
|
24
|
+
|
|
25
|
+
<!-- prettier-ignore -->
|
|
26
|
+
```css
|
|
27
|
+
a {
|
|
28
|
+
color: pink;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The following patterns are _not_ considered problems:
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```css
|
|
36
|
+
a {
|
|
37
|
+
color: pink;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<!-- prettier-ignore -->
|
|
43
|
+
```css
|
|
44
|
+
a { color: pink; }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### `never`
|
|
48
|
+
|
|
49
|
+
The following patterns are considered problems:
|
|
50
|
+
|
|
51
|
+
<!-- prettier-ignore -->
|
|
52
|
+
```css
|
|
53
|
+
a {
|
|
54
|
+
color: pink;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The following patterns are _not_ considered problems:
|
|
60
|
+
|
|
61
|
+
<!-- prettier-ignore -->
|
|
62
|
+
```css
|
|
63
|
+
a {
|
|
64
|
+
color: pink;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<!-- prettier-ignore -->
|
|
69
|
+
```css
|
|
70
|
+
a { color: pink; }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Optional secondary options
|
|
74
|
+
|
|
75
|
+
### `except: ["after-closing-brace"]`
|
|
76
|
+
|
|
77
|
+
When a rule is nested, `after-closing-brace` brace will reverse the primary option.
|
|
78
|
+
|
|
79
|
+
For example, with `"never"` and `except: ["after-closing-brace"]`:
|
|
80
|
+
|
|
81
|
+
The following patterns are considered problems:
|
|
82
|
+
|
|
83
|
+
<!-- prettier-ignore -->
|
|
84
|
+
```css
|
|
85
|
+
@media print {
|
|
86
|
+
|
|
87
|
+
a {
|
|
88
|
+
color: aquamarine;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<!-- prettier-ignore -->
|
|
94
|
+
```css
|
|
95
|
+
@supports (animation-name: test) {
|
|
96
|
+
|
|
97
|
+
a {
|
|
98
|
+
color: aquamarine;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- prettier-ignore -->
|
|
104
|
+
```css
|
|
105
|
+
@keyframes test {
|
|
106
|
+
|
|
107
|
+
100% {
|
|
108
|
+
color: aquamarine;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The following patterns are _not_ considered problems:
|
|
114
|
+
|
|
115
|
+
<!-- prettier-ignore -->
|
|
116
|
+
```css
|
|
117
|
+
@media print {
|
|
118
|
+
|
|
119
|
+
a {
|
|
120
|
+
color: aquamarine;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
<!-- prettier-ignore -->
|
|
127
|
+
```css
|
|
128
|
+
@font-face {
|
|
129
|
+
font-family: "MyFont";
|
|
130
|
+
src: url("myfont.woff2") format("woff2");
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<!-- prettier-ignore -->
|
|
135
|
+
```css
|
|
136
|
+
@supports (animation-name: test) {
|
|
137
|
+
|
|
138
|
+
a {
|
|
139
|
+
color: aquamarine;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
<!-- prettier-ignore -->
|
|
146
|
+
```css
|
|
147
|
+
@keyframes test {
|
|
148
|
+
|
|
149
|
+
100% {
|
|
150
|
+
color: aquamarine;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For example, with `"always-multi-line"` and `except: ["after-closing-brace"]`:
|
|
157
|
+
|
|
158
|
+
The following patterns are considered problems:
|
|
159
|
+
|
|
160
|
+
<!-- prettier-ignore -->
|
|
161
|
+
```css
|
|
162
|
+
@media print {
|
|
163
|
+
|
|
164
|
+
a {
|
|
165
|
+
color: aquamarine;
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
<!-- prettier-ignore -->
|
|
173
|
+
```css
|
|
174
|
+
@supports (animation-name: test) {
|
|
175
|
+
|
|
176
|
+
a {
|
|
177
|
+
color: aquamarine;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
<!-- prettier-ignore -->
|
|
185
|
+
```css
|
|
186
|
+
@keyframes test {
|
|
187
|
+
|
|
188
|
+
100% {
|
|
189
|
+
color: aquamarine;
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The following patterns are _not_ considered problems:
|
|
197
|
+
|
|
198
|
+
<!-- prettier-ignore -->
|
|
199
|
+
```css
|
|
200
|
+
@media print {
|
|
201
|
+
|
|
202
|
+
a {
|
|
203
|
+
color: aquamarine;
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
<!-- prettier-ignore -->
|
|
210
|
+
```css
|
|
211
|
+
@font-face {
|
|
212
|
+
font-family: "MyFont";
|
|
213
|
+
src: url("myfont.woff2") format("woff2");
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
<!-- prettier-ignore -->
|
|
219
|
+
```css
|
|
220
|
+
@supports (animation-name: test) {
|
|
221
|
+
|
|
222
|
+
a {
|
|
223
|
+
color: aquamarine;
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
<!-- prettier-ignore -->
|
|
230
|
+
```css
|
|
231
|
+
@keyframes test {
|
|
232
|
+
|
|
233
|
+
100% {
|
|
234
|
+
color: aquamarine;
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
@@ -0,0 +1,130 @@
|
|
|
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 blockString = require('stylelint/lib/utils/blockString.cjs');
|
|
6
|
+
const hasBlock = require('stylelint/lib/utils/hasBlock.cjs');
|
|
7
|
+
const hasEmptyLine = require('stylelint/lib/utils/hasEmptyLine.cjs');
|
|
8
|
+
const isSingleLineString = require('stylelint/lib/utils/isSingleLineString.cjs');
|
|
9
|
+
const optionsMatches = require('stylelint/lib/utils/optionsMatches.cjs');
|
|
10
|
+
const report = require('stylelint/lib/utils/report.cjs');
|
|
11
|
+
const ruleMessages = require('stylelint/lib/utils/ruleMessages.cjs');
|
|
12
|
+
const validateOptions = require('stylelint/lib/utils/validateOptions.cjs');
|
|
13
|
+
|
|
14
|
+
const addEmptyLineAfter = require('../../utils/addEmptyLineAfter.cjs');
|
|
15
|
+
const hasEmptyBlock = require('../../utils/hasEmptyBlock.cjs');
|
|
16
|
+
const removeEmptyLinesAfter = require('../../utils/removeEmptyLinesAfter.cjs');
|
|
17
|
+
|
|
18
|
+
const ruleName = 'plugin/block-closing-brace-empty-line-before';
|
|
19
|
+
|
|
20
|
+
const messages = ruleMessages(ruleName, {
|
|
21
|
+
expected: 'Expected empty line before closing brace',
|
|
22
|
+
rejected: 'Unexpected empty line before closing brace'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const meta = {
|
|
26
|
+
url: 'https://github.com/jens-duttke/linter-bundle/blob/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/README.md',
|
|
27
|
+
fixable: true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** @type {import('stylelint').Rule} */
|
|
31
|
+
const rule = (primary, secondaryOptions, context) => (root, result) => {
|
|
32
|
+
const validOptions = validateOptions(
|
|
33
|
+
result,
|
|
34
|
+
ruleName,
|
|
35
|
+
{
|
|
36
|
+
actual: primary,
|
|
37
|
+
possible: ['always-multi-line', 'never']
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
actual: secondaryOptions,
|
|
41
|
+
possible: {
|
|
42
|
+
except: ['after-closing-brace']
|
|
43
|
+
},
|
|
44
|
+
optional: true
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!validOptions) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check both kinds of statements: rules and at-rules
|
|
53
|
+
root.walkRules(check);
|
|
54
|
+
root.walkAtRules(check);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {import('postcss').Rule | import('postcss').AtRule} statement
|
|
58
|
+
*/
|
|
59
|
+
function check (statement) {
|
|
60
|
+
// Return early if blockless or has empty block
|
|
61
|
+
if (!hasBlock(statement) || hasEmptyBlock(statement)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Get whitespace after ""}", ignoring extra semicolon
|
|
66
|
+
const before = (statement.raws.after || '').replace(/;+/, '');
|
|
67
|
+
|
|
68
|
+
// Calculate index
|
|
69
|
+
const statementString = statement.toString();
|
|
70
|
+
let index = statementString.length - 1;
|
|
71
|
+
|
|
72
|
+
if (statementString[index - 1] === '\r') {
|
|
73
|
+
index -= 1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Set expectation
|
|
77
|
+
const expectEmptyLineBefore = (() => {
|
|
78
|
+
const childNodeTypes = statement.nodes.map((item) => item.type);
|
|
79
|
+
|
|
80
|
+
// Reverse the primary options if `after-closing-brace` is set
|
|
81
|
+
if (
|
|
82
|
+
optionsMatches(secondaryOptions, 'except', 'after-closing-brace') &&
|
|
83
|
+
statement.type === 'atrule' &&
|
|
84
|
+
!childNodeTypes.includes('decl')
|
|
85
|
+
) {
|
|
86
|
+
return primary === 'never';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return primary === 'always-multi-line' && !isSingleLineString(blockString(statement));
|
|
90
|
+
})();
|
|
91
|
+
|
|
92
|
+
// Check for at least one empty line
|
|
93
|
+
const hasEmptyLineBefore = hasEmptyLine(before);
|
|
94
|
+
|
|
95
|
+
// Return if the expectation is met
|
|
96
|
+
if (expectEmptyLineBefore === hasEmptyLineBefore) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (context.fix) {
|
|
101
|
+
const { newline } = context;
|
|
102
|
+
|
|
103
|
+
if (typeof newline !== 'string') { return; }
|
|
104
|
+
|
|
105
|
+
if (expectEmptyLineBefore) {
|
|
106
|
+
addEmptyLineAfter(statement, newline);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
removeEmptyLinesAfter(statement, newline);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const message = expectEmptyLineBefore ? messages.expected : messages.rejected;
|
|
116
|
+
|
|
117
|
+
report({
|
|
118
|
+
message,
|
|
119
|
+
result,
|
|
120
|
+
ruleName,
|
|
121
|
+
node: statement,
|
|
122
|
+
index
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
rule.ruleName = ruleName;
|
|
128
|
+
rule.messages = messages;
|
|
129
|
+
rule.meta = meta;
|
|
130
|
+
module.exports = stylelint.createPlugin(ruleName, rule);
|