linter-bundle 7.2.0 → 7.3.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/CHANGELOG.md +18 -2
- package/README.md +11 -11
- package/eslint/rules/enforce-logical-expression-parens.mjs +1 -1
- package/eslint/rules/enforce-ternary-parens.mjs +1 -1
- package/eslint/rules/ensure-lucide-import-consistency.mjs +1 -1
- package/eslint/rules/no-extra-spaces-in-generics.mjs +1 -1
- package/eslint/rules/no-ternary-return.mjs +1 -1
- package/eslint/rules/no-unnecessary-typeof.mjs +1 -1
- package/eslint/rules/restricted-filenames.mjs +1 -1
- package/package.json +3 -3
- package/stylelint/index.mjs +0 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/index.mjs +5 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/index.mjs +1 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/index.mjs +12 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/atRuleNameSpaceChecker.mjs +2 -7
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/index.mjs +13 -16
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/index.mjs +22 -23
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/index.mjs +29 -30
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/index.mjs +19 -20
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/index.mjs +40 -43
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/index.mjs +19 -20
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/index.mjs +14 -17
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/index.mjs +6 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.mjs +1 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/index.mjs +42 -43
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/index.mjs +19 -20
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/index.mjs +15 -16
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/index.mjs +27 -28
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/index.mjs +6 -8
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/index.mjs +17 -18
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/index.mjs +17 -18
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/index.mjs +17 -18
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationBangSpaceChecker.mjs +2 -5
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationColonSpaceChecker.mjs +2 -5
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/index.mjs +8 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/index.mjs +8 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/index.mjs +23 -25
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/index.mjs +72 -57
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs +97 -72
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs +10 -16
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/functionCommaSpaceChecker.mjs +7 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/index.mjs +43 -49
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs +13 -8
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.mjs +2 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/index.mjs +6 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/index.mjs +68 -27
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/index.mjs +23 -39
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/index.mjs +6 -12
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/index.mjs +8 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/index.mjs +9 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaFeatureColonSpaceChecker.mjs +2 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaQueryListCommaWhitespaceChecker.mjs +2 -5
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/index.mjs +14 -17
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/index.mjs +6 -7
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/index.mjs +45 -43
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/index.mjs +5 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/index.mjs +24 -58
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/index.mjs +8 -11
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/index.mjs +5 -8
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/index.mjs +49 -45
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/index.mjs +52 -54
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/index.mjs +37 -39
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/index.mjs +12 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/index.mjs +12 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/index.mjs +11 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/index.mjs +4 -7
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/index.mjs +7 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/index.mjs +8 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/index.mjs +8 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/index.mjs +17 -17
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/index.mjs +39 -40
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/index.mjs +49 -44
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.mjs +5 -8
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorAttributeOperatorSpaceChecker.mjs +6 -7
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorCombinatorSpaceChecker.mjs +6 -7
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorListCommaWhitespaceChecker.mjs +2 -5
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/index.mjs +51 -59
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/index.mjs +19 -21
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/index.mjs +11 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/index.mjs +12 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/index.mjs +12 -14
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/index.mjs +12 -12
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/valueListCommaWhitespaceChecker.mjs +2 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/README.md +0 -21
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.mjs +0 -133
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.
|
|
9
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.3.0...HEAD)
|
|
10
|
+
|
|
11
|
+
## [7.3.0] - 2025-03-20
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- [eslint] Updated `eslint-import-resolver-typescript` from `4.2.0` to `4.2.2`
|
|
16
|
+
- [eslint] Updated `typescript-eslint` from `8.26.1` to `8.27.0`
|
|
17
|
+
- [stylelint] Refactored all mocked stylistic Stylelint rule, to get rid of the deprecated `context.fix`
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
|
|
21
|
+
- [stylelint] Removed the stylistic `linebreaks` plugin, as this can be achieved using the `.editorconfig` file
|
|
22
|
+
|
|
23
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.2.0...v7.3.0)
|
|
10
24
|
|
|
11
25
|
## [7.2.0] - 2025-03-18
|
|
12
26
|
|
|
@@ -21,7 +35,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
21
35
|
|
|
22
36
|
### Added
|
|
23
37
|
|
|
24
|
-
- Re-added fixers of the mocked stylistic Stylelint rule.
|
|
38
|
+
- [stylelint] Re-added fixers of the mocked stylistic Stylelint rule.
|
|
39
|
+
|
|
40
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.1.2...v7.2.0)
|
|
25
41
|
|
|
26
42
|
## [7.1.2] - 2025-03-15
|
|
27
43
|
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ Beside that, the following additional rules are part of this bundle:
|
|
|
58
58
|
- [stylelint-selector-tag-no-without-class](https://www.npmjs.com/package/stylelint-selector-tag-no-without-class) (Forked version)
|
|
59
59
|
- [stylelint-use-logical-spec](https://www.npmjs.com/package/stylelint-use-logical-spec)
|
|
60
60
|
|
|
61
|
-
Beside that [
|
|
61
|
+
Beside that [72 stylistic rules](https://github.com/jens-duttke/linter-bundle/tree/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules) has been forked from `stylelint@15.11.0`, which have been removed in `stylelint@16.0.0`, are part of this bundle.
|
|
62
62
|
|
|
63
63
|
### Previously used, but now unmaintained plugins
|
|
64
64
|
|
|
@@ -93,16 +93,16 @@ npm install linter-bundle --save-dev
|
|
|
93
93
|
#### eslint.config.mjs
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
|
-
import gatsbyConfig from '
|
|
97
|
-
import javascriptConfig from '
|
|
98
|
-
// import javascriptLazyConfig from '
|
|
99
|
-
import jestConfig from '
|
|
100
|
-
import jsdocConfig from '
|
|
101
|
-
import reactConfig from '
|
|
102
|
-
import storybookConfig from '
|
|
103
|
-
import typeDeclarationsConfig from '
|
|
104
|
-
import workerConfig from '
|
|
105
|
-
import eslintConfig from '
|
|
96
|
+
import gatsbyConfig from 'linter-bundle/eslint/gatsby.mjs';
|
|
97
|
+
import javascriptConfig from 'linter-bundle/eslint/javascript.mjs';
|
|
98
|
+
// import javascriptLazyConfig from 'linter-bundle/eslint/javascript-lazy.mjs';
|
|
99
|
+
import jestConfig from 'linter-bundle/eslint/jest.mjs';
|
|
100
|
+
import jsdocConfig from 'linter-bundle/eslint/jsdoc.mjs';
|
|
101
|
+
import reactConfig from 'linter-bundle/eslint/react.mjs';
|
|
102
|
+
import storybookConfig from 'linter-bundle/eslint/storybook.mjs';
|
|
103
|
+
import typeDeclarationsConfig from 'linter-bundle/eslint/type-declarations.mjs';
|
|
104
|
+
import workerConfig from 'linter-bundle/eslint/worker.mjs';
|
|
105
|
+
import eslintConfig from 'linter-bundle/eslint.mjs';
|
|
106
106
|
|
|
107
107
|
export default [
|
|
108
108
|
...eslintConfig,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file ESLint rule
|
|
2
|
+
* @file ESLint rule that ensures that a `typeof` operant has more than one type in TypeScript, to prevent unnecessary checks of types at runtime.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/** @typedef {ts.Type & { intrinsicName?: string; types?: ts.Type[]; objectFlags?: ts.ObjectFlags; }} Type */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linter-bundle",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
|
|
6
6
|
"keywords": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@stylistic/eslint-plugin-jsx": "4.2.0",
|
|
46
46
|
"eslint": "9.22.0",
|
|
47
47
|
"eslint-formatter-unix": "8.40.0",
|
|
48
|
-
"eslint-import-resolver-typescript": "4.2.
|
|
48
|
+
"eslint-import-resolver-typescript": "4.2.2",
|
|
49
49
|
"eslint-import-resolver-webpack": "0.13.10",
|
|
50
50
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
51
51
|
"eslint-plugin-functional": "9.0.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"stylelint-order": "6.0.4",
|
|
69
69
|
"stylelint-scss": "6.11.1",
|
|
70
70
|
"stylelint-use-logical-spec": "5.0.1",
|
|
71
|
-
"typescript-eslint": "8.
|
|
71
|
+
"typescript-eslint": "8.27.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@typescript-eslint/utils": "*",
|
package/stylelint/index.mjs
CHANGED
|
@@ -49,7 +49,6 @@ export default {
|
|
|
49
49
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs'),
|
|
50
50
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs'),
|
|
51
51
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/indentation/index.mjs'),
|
|
52
|
-
await import('./plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.mjs'),
|
|
53
52
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs'),
|
|
54
53
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.mjs'),
|
|
55
54
|
await import('./plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.mjs'),
|
|
@@ -395,7 +394,6 @@ export default {
|
|
|
395
394
|
'plugin/function-parentheses-space-inside': 'never-single-line',
|
|
396
395
|
'plugin/function-whitespace-after': 'always',
|
|
397
396
|
'plugin/indentation': 'tab',
|
|
398
|
-
'plugin/linebreaks': 'unix',
|
|
399
397
|
'plugin/max-empty-lines': 1,
|
|
400
398
|
'plugin/max-line-length': 160,
|
|
401
399
|
'plugin/media-feature-colon-space-after': 'always',
|
|
@@ -19,7 +19,7 @@ const meta = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** @type {import('stylelint').Rule} */
|
|
22
|
-
const rule = (primary, _secondary
|
|
22
|
+
const rule = (primary, _secondary) => (root, result) => {
|
|
23
23
|
const validOptions = validateOptions(result, ruleName, {
|
|
24
24
|
actual: primary,
|
|
25
25
|
possible: ['lower', 'upper']
|
|
@@ -38,24 +38,20 @@ const rule = (primary, _secondary, context) => (root, result) => {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const name = atRule.name;
|
|
41
|
-
|
|
42
41
|
const expectedName = expectation === 'lower' ? name.toLowerCase() : name.toUpperCase();
|
|
43
42
|
|
|
44
43
|
if (name === expectedName) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
if (context.fix) {
|
|
49
|
-
atRule.name = expectedName;
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
47
|
report({
|
|
55
48
|
message: messages.expected(name, expectedName),
|
|
56
49
|
node: atRule,
|
|
57
50
|
ruleName,
|
|
58
|
-
result
|
|
51
|
+
result,
|
|
52
|
+
fix: () => {
|
|
53
|
+
atRule.name = expectedName;
|
|
54
|
+
}
|
|
59
55
|
});
|
|
60
56
|
});
|
|
61
57
|
};
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const meta = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
/** @type {import('stylelint').Rule} */
|
|
23
|
-
const rule = (primary, _secondary
|
|
23
|
+
const rule = (primary, _secondary) => {
|
|
24
24
|
const checker = whitespaceChecker('space', primary, messages);
|
|
25
25
|
|
|
26
26
|
return (root, result) => {
|
|
@@ -24,7 +24,7 @@ const meta = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/** @type {import('stylelint').Rule} */
|
|
27
|
-
const rule = (primary, _secondary
|
|
27
|
+
const rule = (primary, _secondary) => {
|
|
28
28
|
const checker = whitespaceChecker('newline', primary, messages);
|
|
29
29
|
|
|
30
30
|
return (root, result) => {
|
|
@@ -63,19 +63,17 @@ const rule = (primary, _secondary, context) => {
|
|
|
63
63
|
source: rawNodeString(nodeToCheck),
|
|
64
64
|
index: -1,
|
|
65
65
|
err: (message) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
}
|
|
66
|
+
report({
|
|
67
|
+
message,
|
|
68
|
+
node: atRule,
|
|
69
|
+
index: atRule.toString().length + 1,
|
|
70
|
+
endIndex: atRule.toString().length + 1,
|
|
71
|
+
result,
|
|
72
|
+
ruleName,
|
|
73
|
+
fix: () => {
|
|
74
|
+
nodeToCheck.raws.before = '\n' + nodeToCheck.raws.before;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
});
|
|
@@ -36,19 +36,14 @@ export default function atRuleNameSpaceChecker (options) {
|
|
|
36
36
|
source,
|
|
37
37
|
index,
|
|
38
38
|
err: (m) => {
|
|
39
|
-
if (options.fix) {
|
|
40
|
-
options.fix(node);
|
|
41
|
-
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
report({
|
|
46
40
|
message: m,
|
|
47
41
|
node,
|
|
48
42
|
index,
|
|
49
43
|
endIndex: index,
|
|
50
44
|
result: options.result,
|
|
51
|
-
ruleName: options.checkedRuleName
|
|
45
|
+
ruleName: options.checkedRuleName,
|
|
46
|
+
fix: (options.fix ? () => options.fix(node) : undefined)
|
|
52
47
|
});
|
|
53
48
|
},
|
|
54
49
|
errTarget: `@${node.name}`
|
|
@@ -97,21 +97,6 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
|
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
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
100
|
const message = expectEmptyLineBefore ? messages.expected : messages.rejected;
|
|
116
101
|
|
|
117
102
|
report({
|
|
@@ -120,7 +105,19 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
|
|
|
120
105
|
ruleName,
|
|
121
106
|
node: statement,
|
|
122
107
|
index,
|
|
123
|
-
endIndex: index
|
|
108
|
+
endIndex: index,
|
|
109
|
+
fix: () => {
|
|
110
|
+
const { newline } = context;
|
|
111
|
+
|
|
112
|
+
if (typeof newline !== 'string') { return; }
|
|
113
|
+
|
|
114
|
+
if (expectEmptyLineBefore) {
|
|
115
|
+
addEmptyLineAfter(statement, newline);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
removeEmptyLinesAfter(statement, newline);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
124
121
|
});
|
|
125
122
|
}
|
|
126
123
|
};
|
|
@@ -112,36 +112,35 @@ const rule = (primary, secondaryOptions, context) => {
|
|
|
112
112
|
index: -1,
|
|
113
113
|
lineCheckStr: blockString(statement),
|
|
114
114
|
err: (message) => {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
report({
|
|
116
|
+
message,
|
|
117
|
+
node: statement,
|
|
118
|
+
index: reportIndex,
|
|
119
|
+
endIndex: reportIndex,
|
|
120
|
+
result,
|
|
121
|
+
ruleName,
|
|
122
|
+
fix: () => {
|
|
123
|
+
const nodeToCheckRaws = nodeToCheck.raws;
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
if (typeof nodeToCheckRaws.before !== 'string') { return; }
|
|
119
126
|
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
if (primary.startsWith('always')) {
|
|
128
|
+
const index = nodeToCheckRaws.before.search(/\r?\n/);
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
nodeToCheckRaws.before =
|
|
131
|
+
index >= 0 ?
|
|
132
|
+
nodeToCheckRaws.before.slice(index)
|
|
133
|
+
: context.newline + nodeToCheckRaws.before;
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
130
137
|
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
if (primary.startsWith('never')) {
|
|
139
|
+
nodeToCheckRaws.before = '';
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
135
143
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
report({
|
|
139
|
-
message,
|
|
140
|
-
node: statement,
|
|
141
|
-
index: reportIndex,
|
|
142
|
-
endIndex: reportIndex,
|
|
143
|
-
result,
|
|
144
|
-
ruleName
|
|
145
144
|
});
|
|
146
145
|
}
|
|
147
146
|
});
|
|
@@ -86,36 +86,6 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
86
86
|
* @param {string} message
|
|
87
87
|
*/
|
|
88
88
|
function complain (message) {
|
|
89
|
-
if (context.fix) {
|
|
90
|
-
const statementRaws = statement.raws;
|
|
91
|
-
|
|
92
|
-
if (typeof statementRaws.after !== 'string') { return; }
|
|
93
|
-
|
|
94
|
-
if (primary.startsWith('always')) {
|
|
95
|
-
const firstWhitespaceIndex = statementRaws.after.search(/\s/);
|
|
96
|
-
const newlineBefore =
|
|
97
|
-
firstWhitespaceIndex >= 0 ?
|
|
98
|
-
statementRaws.after.slice(0, firstWhitespaceIndex)
|
|
99
|
-
: statementRaws.after;
|
|
100
|
-
const newlineAfter =
|
|
101
|
-
firstWhitespaceIndex >= 0 ? statementRaws.after.slice(firstWhitespaceIndex) : '';
|
|
102
|
-
const newlineIndex = newlineAfter.search(/\r?\n/);
|
|
103
|
-
|
|
104
|
-
statementRaws.after =
|
|
105
|
-
newlineIndex >= 0 ?
|
|
106
|
-
newlineBefore + newlineAfter.slice(newlineIndex)
|
|
107
|
-
: newlineBefore + context.newline + newlineAfter;
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (primary === 'never-multi-line') {
|
|
113
|
-
statementRaws.after = statementRaws.after.replace(/\s/g, '');
|
|
114
|
-
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
89
|
report({
|
|
120
90
|
message,
|
|
121
91
|
result,
|
|
@@ -123,6 +93,35 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
123
93
|
node: statement,
|
|
124
94
|
index,
|
|
125
95
|
endIndex: index,
|
|
96
|
+
fix: () => {
|
|
97
|
+
const statementRaws = statement.raws;
|
|
98
|
+
|
|
99
|
+
if (typeof statementRaws.after !== 'string') { return; }
|
|
100
|
+
|
|
101
|
+
if (primary.startsWith('always')) {
|
|
102
|
+
const firstWhitespaceIndex = statementRaws.after.search(/\s/);
|
|
103
|
+
const newlineBefore =
|
|
104
|
+
firstWhitespaceIndex >= 0 ?
|
|
105
|
+
statementRaws.after.slice(0, firstWhitespaceIndex)
|
|
106
|
+
: statementRaws.after;
|
|
107
|
+
const newlineAfter =
|
|
108
|
+
firstWhitespaceIndex >= 0 ? statementRaws.after.slice(firstWhitespaceIndex) : '';
|
|
109
|
+
const newlineIndex = newlineAfter.search(/\r?\n/);
|
|
110
|
+
|
|
111
|
+
statementRaws.after =
|
|
112
|
+
newlineIndex >= 0 ?
|
|
113
|
+
newlineBefore + newlineAfter.slice(newlineIndex)
|
|
114
|
+
: newlineBefore + context.newline + newlineAfter;
|
|
115
|
+
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (primary === 'never-multi-line') {
|
|
120
|
+
statementRaws.after = statementRaws.after.replace(/\s/g, '');
|
|
121
|
+
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
126
125
|
});
|
|
127
126
|
}
|
|
128
127
|
}
|
|
@@ -28,7 +28,7 @@ const meta = {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/** @type {import('stylelint').Rule} */
|
|
31
|
-
const rule = (primary, _secondaryOptions
|
|
31
|
+
const rule = (primary, _secondaryOptions) => {
|
|
32
32
|
const checker = whitespaceChecker('space', primary, messages);
|
|
33
33
|
|
|
34
34
|
return (root, result) => {
|
|
@@ -74,31 +74,30 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
74
74
|
source,
|
|
75
75
|
index: source.length - 1,
|
|
76
76
|
err: (message) => {
|
|
77
|
-
if (context.fix) {
|
|
78
|
-
const statementRaws = statement.raws;
|
|
79
|
-
|
|
80
|
-
if (typeof statementRaws.after !== 'string') { return; }
|
|
81
|
-
|
|
82
|
-
if (primary.startsWith('always')) {
|
|
83
|
-
statementRaws.after = statementRaws.after.replace(/\s*$/, ' ');
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (primary.startsWith('never')) {
|
|
89
|
-
statementRaws.after = statementRaws.after.replace(/\s*$/, '');
|
|
90
|
-
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
77
|
report({
|
|
96
78
|
message,
|
|
97
79
|
node: statement,
|
|
98
80
|
index,
|
|
99
81
|
endIndex: index,
|
|
100
82
|
result,
|
|
101
|
-
ruleName
|
|
83
|
+
ruleName,
|
|
84
|
+
fix: () => {
|
|
85
|
+
const statementRaws = statement.raws;
|
|
86
|
+
|
|
87
|
+
if (typeof statementRaws.after !== 'string') { return; }
|
|
88
|
+
|
|
89
|
+
if (primary.startsWith('always')) {
|
|
90
|
+
statementRaws.after = statementRaws.after.replace(/\s*$/, ' ');
|
|
91
|
+
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (primary.startsWith('never')) {
|
|
96
|
+
statementRaws.after = statementRaws.after.replace(/\s*$/, '');
|
|
97
|
+
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
102
101
|
});
|
|
103
102
|
}
|
|
104
103
|
});
|
|
@@ -108,65 +108,62 @@ const rule = (primary, secondaryOptions, context) => {
|
|
|
108
108
|
index: -1,
|
|
109
109
|
lineCheckStr: blockString(statement),
|
|
110
110
|
err: (m) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
report({
|
|
112
|
+
message: m,
|
|
113
|
+
node: statement,
|
|
114
|
+
index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
|
|
115
|
+
endIndex: beforeBlockString(statement, { noRawBefore: true }).length + 1,
|
|
116
|
+
result,
|
|
117
|
+
ruleName,
|
|
118
|
+
fix: () => {
|
|
119
|
+
const nodeToCheckRaws = nodeToCheck.raws;
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
const index = nodeToCheckRaws.before.search(/\r?\n/);
|
|
121
|
+
if (typeof nodeToCheckRaws.before !== 'string') { return; }
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
index
|
|
121
|
-
nodeToCheckRaws.before.slice(index)
|
|
122
|
-
: context.newline + nodeToCheckRaws.before;
|
|
123
|
+
if (primary.startsWith('always')) {
|
|
124
|
+
const index = nodeToCheckRaws.before.search(/\r?\n/);
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
nodeToCheckRaws.before =
|
|
127
|
+
index >= 0 ?
|
|
128
|
+
nodeToCheckRaws.before.slice(index)
|
|
129
|
+
: context.newline + nodeToCheckRaws.before;
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
}
|
|
131
|
+
backupCommentNextBefores.delete(nodeToCheck);
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
// Restore the `before` of the node next to the comment node.
|
|
131
|
-
for (const [node, before] of backupCommentNextBefores.entries()) {
|
|
132
|
-
node.raws.before = before;
|
|
133
|
+
return;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
if (primary === 'never-multi-line') {
|
|
137
|
+
// Restore the `before` of the node next to the comment node.
|
|
138
|
+
for (const [node, before] of backupCommentNextBefores.entries()) {
|
|
139
|
+
node.raws.before = before;
|
|
140
|
+
}
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
const reNewLine = /\r?\n/;
|
|
139
|
-
let fixTarget = statement.first;
|
|
142
|
+
backupCommentNextBefores.clear();
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
const
|
|
144
|
+
// Fix
|
|
145
|
+
const reNewLine = /\r?\n/;
|
|
146
|
+
let fixTarget = statement.first;
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
while (fixTarget) {
|
|
149
|
+
const fixTargetRaws = fixTarget.raws;
|
|
145
150
|
|
|
146
|
-
|
|
147
|
-
fixTargetRaws.before = fixTargetRaws.before.replace(/\r?\n/g, '');
|
|
148
|
-
}
|
|
151
|
+
if (typeof fixTargetRaws.before !== 'string') { continue; }
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
if (reNewLine.test(fixTargetRaws.before || '')) {
|
|
154
|
+
fixTargetRaws.before = fixTargetRaws.before.replace(/\r?\n/g, '');
|
|
155
|
+
}
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
if (fixTarget.type !== 'comment') {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
fixTarget = fixTarget.next();
|
|
162
|
+
}
|
|
158
163
|
|
|
159
|
-
|
|
164
|
+
nodeToCheckRaws.before = '';
|
|
165
|
+
}
|
|
160
166
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
report({
|
|
164
|
-
message: m,
|
|
165
|
-
node: statement,
|
|
166
|
-
index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
|
|
167
|
-
endIndex: beforeBlockString(statement, { noRawBefore: true }).length + 1,
|
|
168
|
-
result,
|
|
169
|
-
ruleName
|
|
170
167
|
});
|
|
171
168
|
}
|
|
172
169
|
});
|