linter-bundle 7.1.2 → 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 +32 -1
- package/README.md +11 -11
- package/eslint/index.mjs +17 -3
- package/eslint/jest.mjs +1 -0
- package/eslint/react.mjs +3 -0
- package/eslint/rules/enforce-logical-expression-parens.mjs +3 -3
- package/eslint/rules/enforce-ternary-parens.mjs +3 -3
- package/eslint/rules/ensure-lucide-import-consistency.mjs +1 -1
- package/eslint/rules/no-extra-spaces-in-generics.mjs +2 -2
- 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/lint.js +0 -1
- package/package.json +4 -4
- package/stylelint/index.mjs +0 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/index.mjs +5 -3
- 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 +5 -2
- 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 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/index.mjs +23 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/index.mjs +29 -0
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/index.mjs +19 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/index.mjs +50 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/index.mjs +19 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/index.mjs +14 -3
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/index.mjs +6 -2
- 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 -44
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/index.mjs +19 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/index.mjs +15 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/index.mjs +27 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/index.mjs +18 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/index.mjs +17 -1
- 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 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/index.mjs +8 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/index.mjs +9 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/index.mjs +9 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/index.mjs +23 -4
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/index.mjs +72 -21
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs +97 -24
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs +26 -17
- 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 +25 -4
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs +47 -1
- 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 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/index.mjs +9 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/index.mjs +6 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/index.mjs +68 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/index.mjs +23 -37
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/index.mjs +6 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/index.mjs +8 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/index.mjs +9 -10
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/index.mjs +9 -10
- 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 -3
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/index.mjs +6 -3
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/index.mjs +45 -19
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/index.mjs +5 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/index.mjs +24 -41
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/index.mjs +8 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/index.mjs +5 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/index.mjs +52 -20
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/index.mjs +52 -53
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/index.mjs +37 -38
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/index.mjs +12 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/index.mjs +12 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/index.mjs +11 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/index.mjs +4 -1
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/index.mjs +7 -8
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/index.mjs +8 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/index.mjs +8 -9
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/index.mjs +16 -4
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/index.mjs +48 -34
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/index.mjs +49 -20
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.mjs +5 -2
- 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 +23 -6
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/index.mjs +16 -2
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/index.mjs +11 -12
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/index.mjs +12 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/index.mjs +12 -13
- package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/index.mjs +11 -4
- 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 -103
|
@@ -23,7 +23,7 @@ const meta = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/** @type {import('stylelint').Rule} */
|
|
26
|
-
const rule = (primary, _secondaryOptions
|
|
26
|
+
const rule = (primary, _secondaryOptions) => (root, result) => {
|
|
27
27
|
const validOptions = validateOptions(result, ruleName, {
|
|
28
28
|
actual: primary,
|
|
29
29
|
possible: ['always', 'never']
|
|
@@ -38,10 +38,14 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
38
38
|
// will be at atRule.raws.params.raw
|
|
39
39
|
const parameters = (atRule.raws.params?.raw) || atRule.params;
|
|
40
40
|
const indexBoost = atRuleParamIndex(atRule);
|
|
41
|
-
/** @type {Array<{ message: string, index: number }>} */
|
|
42
|
-
const problems = [];
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
// Parse the parameters once, and create a static copy for reporting
|
|
43
|
+
const originalParsedParams = valueParser(parameters);
|
|
44
|
+
let fixCount = 0;
|
|
45
|
+
|
|
46
|
+
// First pass - only detect problems
|
|
47
|
+
const problems = [];
|
|
48
|
+
originalParsedParams.walk((node) => {
|
|
45
49
|
if (node.type === 'function') {
|
|
46
50
|
const length_ = valueParser.stringify(node).length;
|
|
47
51
|
|
|
@@ -49,14 +53,18 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
49
53
|
if ((/[\t ]/).test(node.before)) {
|
|
50
54
|
problems.push({
|
|
51
55
|
message: messages.rejectedOpening,
|
|
52
|
-
index: node.sourceIndex + 1 + indexBoost
|
|
56
|
+
index: node.sourceIndex + 1 + indexBoost,
|
|
57
|
+
functionIndex: node.sourceIndex,
|
|
58
|
+
type: 'opening'
|
|
53
59
|
});
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
if ((/[\t ]/).test(node.after)) {
|
|
57
63
|
problems.push({
|
|
58
64
|
message: messages.rejectedClosing,
|
|
59
|
-
index: node.sourceIndex - 2 + length_ + indexBoost
|
|
65
|
+
index: node.sourceIndex - 2 + length_ + indexBoost,
|
|
66
|
+
functionIndex: node.sourceIndex,
|
|
67
|
+
type: 'closing'
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
}
|
|
@@ -64,29 +72,76 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
64
72
|
if (node.before === '') {
|
|
65
73
|
problems.push({
|
|
66
74
|
message: messages.expectedOpening,
|
|
67
|
-
index: node.sourceIndex + 1 + indexBoost
|
|
75
|
+
index: node.sourceIndex + 1 + indexBoost,
|
|
76
|
+
functionIndex: node.sourceIndex,
|
|
77
|
+
type: 'opening'
|
|
68
78
|
});
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
if (node.after === '') {
|
|
72
82
|
problems.push({
|
|
73
83
|
message: messages.expectedClosing,
|
|
74
|
-
index: node.sourceIndex - 2 + length_ + indexBoost
|
|
84
|
+
index: node.sourceIndex - 2 + length_ + indexBoost,
|
|
85
|
+
functionIndex: node.sourceIndex,
|
|
86
|
+
type: 'closing'
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
91
|
});
|
|
80
92
|
|
|
93
|
+
// Report each problem with a fix function
|
|
81
94
|
if (problems.length > 0) {
|
|
82
|
-
for (const
|
|
95
|
+
for (const problem of problems) {
|
|
83
96
|
report({
|
|
84
|
-
message:
|
|
97
|
+
message: problem.message,
|
|
85
98
|
node: atRule,
|
|
86
|
-
index:
|
|
87
|
-
endIndex:
|
|
99
|
+
index: problem.index,
|
|
100
|
+
endIndex: problem.index,
|
|
88
101
|
result,
|
|
89
|
-
ruleName
|
|
102
|
+
ruleName,
|
|
103
|
+
fix: () => {
|
|
104
|
+
// Create a fresh copy for fixing each time to avoid mixing fixes
|
|
105
|
+
const parsedParams = valueParser(parameters);
|
|
106
|
+
let fixed = false;
|
|
107
|
+
|
|
108
|
+
parsedParams.walk((node) => {
|
|
109
|
+
if (node.type === 'function' && node.sourceIndex === problem.functionIndex) {
|
|
110
|
+
if (problem.type === 'opening') {
|
|
111
|
+
if (primary === 'never' && (/[\t ]/).test(node.before)) {
|
|
112
|
+
node.before = '';
|
|
113
|
+
fixed = true;
|
|
114
|
+
}
|
|
115
|
+
else if (primary === 'always' && node.before === '') {
|
|
116
|
+
node.before = ' ';
|
|
117
|
+
fixed = true;
|
|
118
|
+
}
|
|
119
|
+
} else if (problem.type === 'closing') {
|
|
120
|
+
if (primary === 'never' && (/[\t ]/).test(node.after)) {
|
|
121
|
+
node.after = '';
|
|
122
|
+
fixed = true;
|
|
123
|
+
}
|
|
124
|
+
else if (primary === 'always' && node.after === '') {
|
|
125
|
+
node.after = ' ';
|
|
126
|
+
fixed = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (fixed) {
|
|
133
|
+
const fixedParams = parsedParams.toString();
|
|
134
|
+
|
|
135
|
+
if (atRule.raws.params?.raw) {
|
|
136
|
+
atRule.raws.params.raw = fixedParams;
|
|
137
|
+
} else {
|
|
138
|
+
atRule.params = fixedParams;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
90
145
|
});
|
|
91
146
|
}
|
|
92
147
|
}
|
|
@@ -23,7 +23,7 @@ const meta = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/** @type {import('stylelint').Rule} */
|
|
26
|
-
const rule = (primary, _secondaryOptions
|
|
26
|
+
const rule = (primary, _secondaryOptions) => {
|
|
27
27
|
const checker = whitespaceChecker('space', primary, messages);
|
|
28
28
|
|
|
29
29
|
return (root, result) => {
|
|
@@ -37,35 +37,9 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
root.walkAtRules(/^media$/i, (atRule) => {
|
|
40
|
-
/** @type {number[]} */
|
|
41
|
-
const fixOperatorIndices = [];
|
|
42
|
-
|
|
43
40
|
findMediaOperator(atRule, (match, parameters, node) => {
|
|
44
|
-
checkAfterOperator(match, parameters, node
|
|
41
|
+
checkAfterOperator(match, parameters, node);
|
|
45
42
|
});
|
|
46
|
-
|
|
47
|
-
if (fixOperatorIndices.length > 0) {
|
|
48
|
-
let parameters = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
|
|
49
|
-
|
|
50
|
-
for (const index of fixOperatorIndices.sort((a, b) => b - a)) {
|
|
51
|
-
const beforeOperator = parameters.slice(0, index + 1);
|
|
52
|
-
const afterOperator = parameters.slice(index + 1);
|
|
53
|
-
|
|
54
|
-
if (primary === 'always') {
|
|
55
|
-
parameters = beforeOperator + afterOperator.replace(/^\s*/, ' ');
|
|
56
|
-
}
|
|
57
|
-
else if (primary === 'never') {
|
|
58
|
-
parameters = beforeOperator + afterOperator.replace(/^\s*/, '');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (atRule.raws.params) {
|
|
63
|
-
atRule.raws.params.raw = parameters;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
atRule.params = parameters;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
43
|
});
|
|
70
44
|
|
|
71
45
|
/**
|
|
@@ -73,28 +47,40 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
73
47
|
* @param {string} params
|
|
74
48
|
* @param parameters
|
|
75
49
|
* @param {import('postcss').AtRule} node
|
|
76
|
-
* @param {((index: number) => void) | null} fix
|
|
77
50
|
*/
|
|
78
|
-
function checkAfterOperator
|
|
51
|
+
function checkAfterOperator(match, parameters, node) {
|
|
79
52
|
const endIndex = match.startIndex + match.target.length - 1;
|
|
80
53
|
|
|
81
54
|
checker.after({
|
|
82
55
|
source: parameters,
|
|
83
56
|
index: endIndex,
|
|
84
57
|
err: (m) => {
|
|
85
|
-
if (fix) {
|
|
86
|
-
fix(endIndex);
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
58
|
report({
|
|
92
59
|
message: m,
|
|
93
60
|
node,
|
|
94
61
|
index: endIndex + atRuleParamIndex(node) + 1,
|
|
95
62
|
endIndex: endIndex + atRuleParamIndex(node) + 1,
|
|
96
63
|
result,
|
|
97
|
-
ruleName
|
|
64
|
+
ruleName,
|
|
65
|
+
fix: (fixer) => {
|
|
66
|
+
let parameters = node.raws.params ? node.raws.params.raw : node.params;
|
|
67
|
+
const beforeOperator = parameters.slice(0, endIndex + 1);
|
|
68
|
+
const afterOperator = parameters.slice(endIndex + 1);
|
|
69
|
+
|
|
70
|
+
if (primary === 'always') {
|
|
71
|
+
parameters = beforeOperator + afterOperator.replace(/^\s*/, ' ');
|
|
72
|
+
} else if (primary === 'never') {
|
|
73
|
+
parameters = beforeOperator + afterOperator.replace(/^\s*/, '');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (node.raws.params) {
|
|
77
|
+
node.raws.params.raw = parameters;
|
|
78
|
+
} else {
|
|
79
|
+
node.params = parameters;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return fixer;
|
|
83
|
+
}
|
|
98
84
|
});
|
|
99
85
|
}
|
|
100
86
|
});
|
|
@@ -23,7 +23,7 @@ const meta = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/** @type {import('stylelint').Rule} */
|
|
26
|
-
const rule = (primary, _secondaryOptions
|
|
26
|
+
const rule = (primary, _secondaryOptions) => {
|
|
27
27
|
const checker = whitespaceChecker('space', primary, messages);
|
|
28
28
|
|
|
29
29
|
return (root, result) => {
|
|
@@ -39,9 +39,8 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
39
39
|
root.walkAtRules(/^media$/i, (atRule) => {
|
|
40
40
|
/** @type {number[]} */
|
|
41
41
|
const fixOperatorIndices = [];
|
|
42
|
-
|
|
43
42
|
findMediaOperator(atRule, (match, parameters, node) => {
|
|
44
|
-
checkBeforeOperator(match, parameters, node,
|
|
43
|
+
checkBeforeOperator(match, parameters, node, (index) => fixOperatorIndices.push(index));
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
if (fixOperatorIndices.length > 0) {
|
|
@@ -82,19 +81,16 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
82
81
|
source: parameters,
|
|
83
82
|
index: match.startIndex,
|
|
84
83
|
err: (m) => {
|
|
85
|
-
if (fix) {
|
|
86
|
-
fix(match.startIndex);
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
84
|
report({
|
|
92
85
|
message: m,
|
|
93
86
|
node,
|
|
94
87
|
index: match.startIndex - 1 + atRuleParamIndex(node),
|
|
95
88
|
endIndex: match.startIndex - 1 + atRuleParamIndex(node),
|
|
96
89
|
result,
|
|
97
|
-
ruleName
|
|
90
|
+
ruleName,
|
|
91
|
+
fix: (fix ? () => {
|
|
92
|
+
fix(match.startIndex);
|
|
93
|
+
}: undefined)
|
|
98
94
|
});
|
|
99
95
|
}
|
|
100
96
|
});
|
|
@@ -47,18 +47,17 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
47
47
|
locationChecker: checker.afterOneOnly,
|
|
48
48
|
checkedRuleName: ruleName,
|
|
49
49
|
allowTrailingComments: primary.startsWith('always'),
|
|
50
|
-
fix:
|
|
51
|
-
|
|
52
|
-
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
50
|
+
fix: (atRule, index) => {
|
|
51
|
+
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
fixData ||= new Map();
|
|
54
|
+
const commaIndices = fixData.get(atRule) || [];
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
commaIndices.push(parameterCommaIndex);
|
|
57
|
+
fixData.set(atRule, commaIndices);
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
if (fixData) {
|
|
@@ -24,7 +24,7 @@ const meta = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/** @type {import('stylelint').Rule} */
|
|
27
|
-
const rule = (primary, _secondaryOptions
|
|
27
|
+
const rule = (primary, _secondaryOptions) => {
|
|
28
28
|
const checker = whitespaceChecker('space', primary, messages);
|
|
29
29
|
|
|
30
30
|
return (root, result) => {
|
|
@@ -45,18 +45,17 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
45
45
|
result,
|
|
46
46
|
locationChecker: checker.after,
|
|
47
47
|
checkedRuleName: ruleName,
|
|
48
|
-
fix:
|
|
49
|
-
|
|
50
|
-
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
48
|
+
fix: (atRule, index) => {
|
|
49
|
+
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
fixData ||= new Map();
|
|
52
|
+
const commaIndices = fixData.get(atRule) || [];
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
commaIndices.push(parameterCommaIndex);
|
|
55
|
+
fixData.set(atRule, commaIndices);
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
if (fixData) {
|
|
@@ -24,7 +24,7 @@ const meta = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/** @type {import('stylelint').Rule} */
|
|
27
|
-
const rule = (primary, _secondaryOptions
|
|
27
|
+
const rule = (primary, _secondaryOptions) => {
|
|
28
28
|
const checker = whitespaceChecker('space', primary, messages);
|
|
29
29
|
|
|
30
30
|
return (root, result) => {
|
|
@@ -45,18 +45,17 @@ const rule = (primary, _secondaryOptions, context) => {
|
|
|
45
45
|
result,
|
|
46
46
|
locationChecker: checker.before,
|
|
47
47
|
checkedRuleName: ruleName,
|
|
48
|
-
fix:
|
|
49
|
-
|
|
50
|
-
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
48
|
+
fix: (atRule, index) => {
|
|
49
|
+
const parameterCommaIndex = index - atRuleParamIndex(atRule);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
fixData ||= new Map();
|
|
52
|
+
const commaIndices = fixData.get(atRule) || [];
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
commaIndices.push(parameterCommaIndex);
|
|
55
|
+
fixData.set(atRule, commaIndices);
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
if (fixData) {
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaFeatureColonSpaceChecker.mjs
CHANGED
|
@@ -47,7 +47,8 @@ export default function mediaFeatureColonSpaceChecker (options) {
|
|
|
47
47
|
index: colonIndex,
|
|
48
48
|
endIndex: colonIndex,
|
|
49
49
|
result: options.result,
|
|
50
|
-
ruleName: options.checkedRuleName
|
|
50
|
+
ruleName: options.checkedRuleName,
|
|
51
|
+
fix: (options.fix ? () => options.fix(node, colonIndex) : undefined)
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
});
|
package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaQueryListCommaWhitespaceChecker.mjs
CHANGED
|
@@ -56,17 +56,14 @@ export default function mediaQueryListCommaWhitespaceChecker (options) {
|
|
|
56
56
|
err: (message) => {
|
|
57
57
|
const commaIndex = index + atRuleParamIndex(node);
|
|
58
58
|
|
|
59
|
-
if (options.fix?.(node, commaIndex)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
59
|
report({
|
|
64
60
|
message,
|
|
65
61
|
node,
|
|
66
62
|
index: commaIndex,
|
|
67
63
|
endIndex: commaIndex,
|
|
68
64
|
result: options.result,
|
|
69
|
-
ruleName: options.checkedRuleName
|
|
65
|
+
ruleName: options.checkedRuleName,
|
|
66
|
+
fix: (options.fix ? () => options.fix(node, commaIndex) : undefined)
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
69
|
});
|
|
@@ -19,7 +19,7 @@ const meta = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** @type {import('stylelint').Rule} */
|
|
22
|
-
const rule = (primary, _secondaryOptions
|
|
22
|
+
const rule = (primary, _secondaryOptions) => (root, result) => {
|
|
23
23
|
const validOptions = validateOptions(result, ruleName, { actual: primary });
|
|
24
24
|
|
|
25
25
|
// @ts-expect-error -- TS2339: Property 'inline' does not exist on type 'Source'. Property 'lang' does not exist on type 'Source'.
|
|
@@ -27,7 +27,7 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const rootString =
|
|
30
|
+
const rootString = root.toString();
|
|
31
31
|
|
|
32
32
|
if (!rootString.trim()) {
|
|
33
33
|
return;
|
|
@@ -38,7 +38,18 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
38
38
|
message: messages.rejected,
|
|
39
39
|
node: root,
|
|
40
40
|
result,
|
|
41
|
-
ruleName
|
|
41
|
+
ruleName,
|
|
42
|
+
fix: () => {
|
|
43
|
+
if (root.first == null) {
|
|
44
|
+
throw new Error('The root node must have the first node.');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (root.first.raws.before == null) {
|
|
48
|
+
throw new Error('The first node must have spaces before.');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
root.first.raws.before = root.first.raws.before.trimStart();
|
|
52
|
+
}
|
|
42
53
|
});
|
|
43
54
|
}
|
|
44
55
|
};
|
|
@@ -66,7 +66,7 @@ function findErrorStartIndex (lastEOLIndex, string, { ignoreEmptyLines, isRootFi
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** @type {import('stylelint').Rule} */
|
|
69
|
-
const rule = (primary, secondaryOptions
|
|
69
|
+
const rule = (primary, secondaryOptions) => (root, result) => {
|
|
70
70
|
const validOptions = validateOptions(
|
|
71
71
|
result,
|
|
72
72
|
ruleName,
|
|
@@ -88,7 +88,7 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
|
|
|
88
88
|
|
|
89
89
|
const ignoreEmptyLines = optionsMatches(secondaryOptions, 'ignore', 'empty-lines');
|
|
90
90
|
|
|
91
|
-
const rootString =
|
|
91
|
+
const rootString = root.toString();
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* @param {number} index
|
|
@@ -100,7 +100,10 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
|
|
|
100
100
|
index,
|
|
101
101
|
endIndex: index,
|
|
102
102
|
result,
|
|
103
|
-
ruleName
|
|
103
|
+
ruleName,
|
|
104
|
+
fix: () => {
|
|
105
|
+
fix(root);
|
|
106
|
+
}
|
|
104
107
|
});
|
|
105
108
|
};
|
|
106
109
|
|
|
@@ -66,7 +66,7 @@ function getOffsetByNode (node) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** @type {import('stylelint').Rule} */
|
|
69
|
-
const rule = (primary, _secondaryOptions
|
|
69
|
+
const rule = (primary, _secondaryOptions) => (root, result) => {
|
|
70
70
|
const validOptions = validateOptions(result, ruleName, { actual: primary });
|
|
71
71
|
|
|
72
72
|
if (!validOptions) {
|
|
@@ -82,7 +82,17 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
82
82
|
styleSearch({ source: rawAfterRoot, target: ';' }, (match) => {
|
|
83
83
|
if (!root.source) { throw new Error('The root node must have a source'); }
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
report({
|
|
86
|
+
message: messages.rejected,
|
|
87
|
+
node: root,
|
|
88
|
+
index: root.source.input.css.length - rawAfterRoot.length + match.startIndex,
|
|
89
|
+
endIndex: root.source.input.css.length - rawAfterRoot.length + match.startIndex,
|
|
90
|
+
result,
|
|
91
|
+
ruleName,
|
|
92
|
+
fix: () => {
|
|
93
|
+
fixSemiIndices.push(match.startIndex);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
86
96
|
});
|
|
87
97
|
|
|
88
98
|
// fix
|
|
@@ -114,7 +124,17 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
114
124
|
return;
|
|
115
125
|
}
|
|
116
126
|
|
|
117
|
-
|
|
127
|
+
report({
|
|
128
|
+
message: messages.rejected,
|
|
129
|
+
node: root,
|
|
130
|
+
index: getOffsetByNode(node) - rawBeforeNode.length + match.startIndex,
|
|
131
|
+
endIndex: getOffsetByNode(node) - rawBeforeNode.length + match.startIndex,
|
|
132
|
+
result,
|
|
133
|
+
ruleName,
|
|
134
|
+
fix: () => {
|
|
135
|
+
fixSemiIndices.push(match.startIndex - rawBeforeIndexStart);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
118
138
|
});
|
|
119
139
|
|
|
120
140
|
// fix
|
|
@@ -151,7 +171,17 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
151
171
|
rawAfterNode.length +
|
|
152
172
|
match.startIndex;
|
|
153
173
|
|
|
154
|
-
|
|
174
|
+
report({
|
|
175
|
+
message: messages.rejected,
|
|
176
|
+
node: root,
|
|
177
|
+
index,
|
|
178
|
+
endIndex: index,
|
|
179
|
+
result,
|
|
180
|
+
ruleName,
|
|
181
|
+
fix: () => {
|
|
182
|
+
fixSemiIndices.push(match.startIndex);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
155
185
|
});
|
|
156
186
|
|
|
157
187
|
// fix
|
|
@@ -178,7 +208,17 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
178
208
|
rawOwnSemicolon.length +
|
|
179
209
|
match.startIndex;
|
|
180
210
|
|
|
181
|
-
|
|
211
|
+
report({
|
|
212
|
+
message: messages.rejected,
|
|
213
|
+
node: root,
|
|
214
|
+
index,
|
|
215
|
+
endIndex: index,
|
|
216
|
+
result,
|
|
217
|
+
ruleName,
|
|
218
|
+
fix: () => {
|
|
219
|
+
fixSemiIndices.push(match.startIndex);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
182
222
|
});
|
|
183
223
|
|
|
184
224
|
// fix
|
|
@@ -188,20 +228,6 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
188
228
|
}
|
|
189
229
|
});
|
|
190
230
|
|
|
191
|
-
/**
|
|
192
|
-
* @param {number} index
|
|
193
|
-
*/
|
|
194
|
-
function complain (index) {
|
|
195
|
-
report({
|
|
196
|
-
message: messages.rejected,
|
|
197
|
-
node: root,
|
|
198
|
-
index,
|
|
199
|
-
endIndex: index,
|
|
200
|
-
result,
|
|
201
|
-
ruleName
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
231
|
/**
|
|
206
232
|
* @param {string} str
|
|
207
233
|
* @param string_
|
|
@@ -34,7 +34,7 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const rootString = root.
|
|
37
|
+
const rootString = root.toString();
|
|
38
38
|
|
|
39
39
|
if (!rootString.trim() || rootString.endsWith('\n')) {
|
|
40
40
|
return;
|
|
@@ -46,7 +46,10 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
|
|
|
46
46
|
index: rootString.length - 1,
|
|
47
47
|
endIndex: rootString.length - 1,
|
|
48
48
|
result,
|
|
49
|
-
ruleName
|
|
49
|
+
ruleName,
|
|
50
|
+
fix: () => {
|
|
51
|
+
root.raws.after = context.newline;
|
|
52
|
+
}
|
|
50
53
|
});
|
|
51
54
|
};
|
|
52
55
|
|