linter-bundle 7.2.0 → 7.4.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/README.md +11 -11
  3. package/eslint/react.mjs +2 -1
  4. package/eslint/rules/enforce-logical-expression-parens.mjs +1 -1
  5. package/eslint/rules/enforce-ternary-parens.mjs +1 -1
  6. package/eslint/rules/ensure-lucide-import-consistency.mjs +1 -1
  7. package/eslint/rules/no-extra-spaces-in-generics.mjs +1 -1
  8. package/eslint/rules/no-ternary-return.mjs +1 -1
  9. package/eslint/rules/no-unnecessary-typeof.mjs +1 -1
  10. package/eslint/rules/restricted-filenames.mjs +6 -2
  11. package/package.json +5 -5
  12. package/stylelint/index.mjs +0 -2
  13. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/index.mjs +5 -9
  14. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/index.mjs +1 -1
  15. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/index.mjs +12 -14
  16. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/atRuleNameSpaceChecker.mjs +2 -7
  17. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/index.mjs +13 -16
  18. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/index.mjs +22 -23
  19. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/index.mjs +29 -30
  20. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/index.mjs +19 -20
  21. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/index.mjs +40 -43
  22. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/index.mjs +19 -20
  23. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/index.mjs +14 -17
  24. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/index.mjs +6 -9
  25. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.mjs +1 -1
  26. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/index.mjs +42 -43
  27. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/index.mjs +19 -20
  28. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/index.mjs +15 -16
  29. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/index.mjs +27 -28
  30. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/index.mjs +6 -8
  31. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/index.mjs +17 -18
  32. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/index.mjs +17 -18
  33. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/index.mjs +17 -18
  34. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationBangSpaceChecker.mjs +2 -5
  35. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationColonSpaceChecker.mjs +2 -5
  36. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/index.mjs +8 -10
  37. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/index.mjs +8 -10
  38. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/index.mjs +9 -11
  39. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/index.mjs +9 -11
  40. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/index.mjs +23 -25
  41. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/index.mjs +72 -57
  42. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs +97 -72
  43. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs +10 -16
  44. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/functionCommaSpaceChecker.mjs +7 -9
  45. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/index.mjs +43 -49
  46. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs +13 -8
  47. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.mjs +2 -2
  48. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.mjs +9 -11
  49. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/index.mjs +9 -11
  50. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/index.mjs +6 -9
  51. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/index.mjs +68 -27
  52. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/index.mjs +23 -39
  53. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/index.mjs +6 -12
  54. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/index.mjs +8 -10
  55. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/index.mjs +9 -11
  56. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/index.mjs +9 -11
  57. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaFeatureColonSpaceChecker.mjs +2 -1
  58. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaQueryListCommaWhitespaceChecker.mjs +2 -5
  59. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/index.mjs +14 -17
  60. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/index.mjs +6 -7
  61. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/index.mjs +45 -43
  62. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/index.mjs +5 -9
  63. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/index.mjs +24 -58
  64. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/index.mjs +8 -11
  65. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/index.mjs +5 -8
  66. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/index.mjs +49 -45
  67. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/index.mjs +52 -54
  68. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/index.mjs +37 -39
  69. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/index.mjs +12 -14
  70. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/index.mjs +12 -14
  71. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/index.mjs +11 -14
  72. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/index.mjs +4 -7
  73. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/index.mjs +7 -9
  74. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/index.mjs +8 -10
  75. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/index.mjs +8 -10
  76. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/index.mjs +17 -17
  77. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/index.mjs +39 -40
  78. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/index.mjs +49 -44
  79. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.mjs +5 -8
  80. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorAttributeOperatorSpaceChecker.mjs +6 -7
  81. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorCombinatorSpaceChecker.mjs +6 -7
  82. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorListCommaWhitespaceChecker.mjs +2 -5
  83. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/index.mjs +51 -59
  84. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/index.mjs +19 -21
  85. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/index.mjs +11 -13
  86. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/index.mjs +12 -14
  87. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/index.mjs +12 -14
  88. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/index.mjs +12 -12
  89. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/valueListCommaWhitespaceChecker.mjs +2 -1
  90. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/README.md +0 -21
  91. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.mjs +0 -133
@@ -30,7 +30,7 @@ const meta = {
30
30
  };
31
31
 
32
32
  /** @type {import('stylelint').Rule} */
33
- const rule = (primary, secondaryOptions, context) => {
33
+ const rule = (primary, secondaryOptions) => {
34
34
  const checker = whitespaceChecker('space', primary, messages);
35
35
 
36
36
  return (root, result) => {
@@ -81,31 +81,30 @@ const rule = (primary, secondaryOptions, context) => {
81
81
  source: blockString(statement),
82
82
  index: 0,
83
83
  err: (m) => {
84
- if (context.fix) {
85
- const statementFirst = statement.first;
86
-
87
- if (statementFirst == null) { return; }
88
-
89
- if (primary.startsWith('always')) {
90
- statementFirst.raws.before = ' ';
91
-
92
- return;
93
- }
94
-
95
- if (primary.startsWith('never')) {
96
- statementFirst.raws.before = '';
97
-
98
- return;
99
- }
100
- }
101
-
102
84
  report({
103
85
  message: m,
104
86
  node: statement,
105
87
  index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
106
88
  endIndex: beforeBlockString(statement, { noRawBefore: true }).length + 1,
107
89
  result,
108
- ruleName
90
+ ruleName,
91
+ fix: () => {
92
+ const statementFirst = statement.first;
93
+
94
+ if (statementFirst == null) { return; }
95
+
96
+ if (primary.startsWith('always')) {
97
+ statementFirst.raws.before = ' ';
98
+
99
+ return;
100
+ }
101
+
102
+ if (primary.startsWith('never')) {
103
+ statementFirst.raws.before = '';
104
+
105
+ return;
106
+ }
107
+ }
109
108
  });
110
109
  }
111
110
  });
@@ -9,7 +9,7 @@ import optionsMatches from 'stylelint/lib/utils/optionsMatches.mjs';
9
9
  import report from 'stylelint/lib/utils/report.mjs';
10
10
  import ruleMessages from 'stylelint/lib/utils/ruleMessages.mjs';
11
11
  import validateOptions from 'stylelint/lib/utils/validateOptions.mjs';
12
- import { isRegExp, isString } from 'stylelint/lib/utils/validateTypes.mjs';
12
+ import { isRegExp, isString } from 'stylelint/lib/utils/validateTypes.mjs';
13
13
 
14
14
  import hasEmptyBlock from '../../utils/hasEmptyBlock.mjs';
15
15
  import whitespaceChecker from '../../utils/whitespaceChecker.mjs';
@@ -31,7 +31,7 @@ const meta = {
31
31
  };
32
32
 
33
33
  /** @type {import('stylelint').Rule} */
34
- const rule = (primary, secondaryOptions, context) => {
34
+ const rule = (primary, secondaryOptions) => {
35
35
  const checker = whitespaceChecker('space', primary, messages);
36
36
 
37
37
  return (root, result) => {
@@ -108,27 +108,24 @@ const rule = (primary, secondaryOptions, context) => {
108
108
  index: source.length,
109
109
  lineCheckStr: blockString(statement),
110
110
  err: (m) => {
111
- if (context.fix) {
112
- if (primary.startsWith('always')) {
113
- statement.raws.between = ' ';
114
-
115
- return;
116
- }
117
-
118
- if (primary.startsWith('never')) {
119
- statement.raws.between = '';
120
-
121
- return;
122
- }
123
- }
124
-
125
111
  report({
126
112
  message: m,
127
113
  node: statement,
128
114
  index,
129
115
  endIndex: index,
130
116
  result,
131
- ruleName
117
+ ruleName,
118
+ fix: () => {
119
+ if (primary.startsWith('always')) {
120
+ statement.raws.between = ' ';
121
+ return;
122
+ }
123
+
124
+ if (primary.startsWith('never')) {
125
+ statement.raws.between = '';
126
+ return;
127
+ }
128
+ }
132
129
  });
133
130
  }
134
131
  });
@@ -26,7 +26,7 @@ const CONTAINS_HEX = /#[\da-z]+/i;
26
26
  const IGNORED_FUNCTIONS = new Set(['url']);
27
27
 
28
28
  /** @type {import('stylelint').Rule} */
29
- const rule = (primary, _secondaryOptions, context) => (root, result) => {
29
+ const rule = (primary, _secondaryOptions) => (root, result) => {
30
30
  const validOptions = validateOptions(result, ruleName, {
31
31
  actual: primary,
32
32
  possible: ['lower', 'upper']
@@ -53,20 +53,17 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
53
53
 
54
54
  if (value === expected) { return; }
55
55
 
56
- if (context.fix) {
57
- node.value = expected;
58
- needsFix = true;
59
-
60
- return;
61
- }
62
-
63
56
  report({
64
57
  message: messages.expected(value, expected),
65
58
  node: decl,
66
59
  index: declarationValueIndex(decl) + node.sourceIndex,
67
60
  endIndex: declarationValueIndex(decl) + node.sourceIndex,
68
61
  result,
69
- ruleName
62
+ ruleName,
63
+ fix: () => {
64
+ node.value = expected;
65
+ needsFix = true;
66
+ }
70
67
  });
71
68
  });
72
69
 
@@ -24,7 +24,7 @@ const meta = {
24
24
  };
25
25
 
26
26
  /** @type {import('stylelint').Rule} */
27
- const rule = (primary, _secondaryOptions, context) => {
27
+ const rule = (primary, _secondaryOptions) => {
28
28
  const checker = whitespaceChecker('space', primary, messages);
29
29
 
30
30
  return (root, result) => {
@@ -24,7 +24,7 @@ const meta = {
24
24
  };
25
25
 
26
26
  /** @type {import('stylelint').Rule} */
27
- const rule = (primary, _secondaryOptions, context) => {
27
+ const rule = (primary, _secondaryOptions) => {
28
28
  const checker = whitespaceChecker('space', primary, messages);
29
29
 
30
30
  return (root, result) => {
@@ -42,48 +42,47 @@ const rule = (primary, _secondaryOptions, context) => {
42
42
  result,
43
43
  locationChecker: checker.before,
44
44
  checkedRuleName: ruleName,
45
- fix:
46
- context.fix ? (decl, index) => {
47
- let bangIndex = index - declarationValueIndex(decl);
48
- const value = getDeclarationValue(decl);
49
- let target;
50
- /** @type {(val: string) => void} */
51
- let setFixed;
52
-
53
- if (bangIndex < value.length) {
54
- target = value;
55
- setFixed = (value_) => {
56
- setDeclarationValue(decl, value_);
57
- };
58
- }
59
- else if (decl.important) {
60
- target = (decl.raws.important ? decl.raws.important : ' !important');
61
- bangIndex -= value.length;
62
- setFixed = (value_) => {
63
- decl.raws.important = value_;
64
- };
65
- }
66
- else {
67
- return false; // not standard
68
- }
69
-
70
- const targetBefore = target.slice(0, bangIndex);
71
- const targetAfter = target.slice(bangIndex);
72
-
73
- if (primary === 'always') {
74
- setFixed(targetBefore.replace(/\s*$/, '') + ' ' + targetAfter);
75
-
76
- return true;
77
- }
78
-
79
- if (primary === 'never') {
80
- setFixed(targetBefore.replace(/\s*$/, '') + targetAfter);
81
-
82
- return true;
83
- }
84
-
85
- return false;
86
- } : null
45
+ fix: (decl, index) => {
46
+ let bangIndex = index - declarationValueIndex(decl);
47
+ const value = getDeclarationValue(decl);
48
+ let target;
49
+ /** @type {(val: string) => void} */
50
+ let setFixed;
51
+
52
+ if (bangIndex < value.length) {
53
+ target = value;
54
+ setFixed = (value_) => {
55
+ setDeclarationValue(decl, value_);
56
+ };
57
+ }
58
+ else if (decl.important) {
59
+ target = (decl.raws.important ? decl.raws.important : ' !important');
60
+ bangIndex -= value.length;
61
+ setFixed = (value_) => {
62
+ decl.raws.important = value_;
63
+ };
64
+ }
65
+ else {
66
+ return false; // not standard
67
+ }
68
+
69
+ const targetBefore = target.slice(0, bangIndex);
70
+ const targetAfter = target.slice(bangIndex);
71
+
72
+ if (primary === 'always') {
73
+ setFixed(targetBefore.replace(/\s*$/, '') + ' ' + targetAfter);
74
+
75
+ return true;
76
+ }
77
+
78
+ if (primary === 'never') {
79
+ setFixed(targetBefore.replace(/\s*$/, '') + targetAfter);
80
+
81
+ return true;
82
+ }
83
+
84
+ return false;
85
+ }
87
86
  });
88
87
  };
89
88
  };
@@ -71,32 +71,31 @@ const rule = (primary, _secondaryOptions, context) => {
71
71
  index: -1,
72
72
  lineCheckStr: blockString(parentRule),
73
73
  err: (m) => {
74
- if (context.fix) {
75
- if (primary.startsWith('always')) {
76
- const index = nodeToCheck.raws.before.search(/\r?\n/);
77
-
78
- nodeToCheck.raws.before =
79
- index >= 0 ?
80
- nodeToCheck.raws.before.slice(index)
81
- : context.newline + nodeToCheck.raws.before;
82
-
83
- return;
84
- }
85
-
86
- if (primary === 'never-multi-line') {
87
- nodeToCheck.raws.before = '';
88
-
89
- return;
90
- }
91
- }
92
-
93
74
  report({
94
75
  message: m,
95
76
  node: decl,
96
77
  index: decl.toString().length + 1,
97
78
  endIndex: decl.toString().length + 1,
98
79
  result,
99
- ruleName
80
+ ruleName,
81
+ fix: () => {
82
+ if (primary.startsWith('always')) {
83
+ const index = nodeToCheck.raws.before.search(/\r?\n/);
84
+
85
+ nodeToCheck.raws.before =
86
+ index >= 0 ?
87
+ nodeToCheck.raws.before.slice(index)
88
+ : context.newline + nodeToCheck.raws.before;
89
+
90
+ return;
91
+ }
92
+
93
+ if (primary === 'never-multi-line') {
94
+ nodeToCheck.raws.before = '';
95
+
96
+ return;
97
+ }
98
+ }
100
99
  });
101
100
  }
102
101
  });
@@ -26,7 +26,7 @@ const meta = {
26
26
  };
27
27
 
28
28
  /** @type {import('stylelint').Rule} */
29
- const rule = (primary, _secondaryOptions, context) => {
29
+ const rule = (primary, _secondaryOptions) => {
30
30
  const checker = whitespaceChecker('space', primary, messages);
31
31
 
32
32
  return (root, result) => {
@@ -64,27 +64,26 @@ const rule = (primary, _secondaryOptions, context) => {
64
64
  index: -1,
65
65
  lineCheckStr: blockString(parentRule),
66
66
  err: (m) => {
67
- if (context.fix) {
68
- if (primary.startsWith('always')) {
69
- nextDecl.raws.before = ' ';
70
-
71
- return;
72
- }
73
-
74
- if (primary.startsWith('never')) {
75
- nextDecl.raws.before = '';
76
-
77
- return;
78
- }
79
- }
80
-
81
67
  report({
82
68
  message: m,
83
69
  node: decl,
84
70
  index: decl.toString().length + 1,
85
71
  endIndex: decl.toString().length + 1,
86
72
  result,
87
- ruleName
73
+ ruleName,
74
+ fix: () => {
75
+ if (primary.startsWith('always')) {
76
+ nextDecl.raws.before = ' ';
77
+
78
+ return;
79
+ }
80
+
81
+ if (primary.startsWith('never')) {
82
+ nextDecl.raws.before = '';
83
+
84
+ return;
85
+ }
86
+ }
88
87
  });
89
88
  }
90
89
  });
@@ -27,7 +27,7 @@ const meta = {
27
27
  };
28
28
 
29
29
  /** @type {import('stylelint').Rule} */
30
- const rule = (primary, _secondaryOptions, context) => {
30
+ const rule = (primary, _secondaryOptions) => {
31
31
  const checker = whitespaceChecker('space', primary, messages);
32
32
 
33
33
  return (root, result) => {
@@ -61,39 +61,38 @@ const rule = (primary, _secondaryOptions, context) => {
61
61
  index: declString.length,
62
62
  lineCheckStr: blockString(parentRule),
63
63
  err: (m) => {
64
- if (context.fix) {
65
- const value = getDeclarationValue(decl);
66
-
67
- if (primary.startsWith('always')) {
68
- if (decl.important) {
69
- decl.raws.important = ' !important ';
70
- }
71
- else {
72
- setDeclarationValue(decl, value.replace(/\s*$/, ' '));
73
- }
74
-
75
- return;
76
- }
77
-
78
- if (primary.startsWith('never')) {
79
- if (decl.raws.important) {
80
- decl.raws.important = decl.raws.important.replace(/\s*$/, '');
81
- }
82
- else {
83
- setDeclarationValue(decl, value.replace(/\s*$/, ''));
84
- }
85
-
86
- return;
87
- }
88
- }
89
-
90
64
  report({
91
65
  message: m,
92
66
  node: decl,
93
67
  index: decl.toString().length - 1,
94
68
  endIndex: decl.toString().length - 1,
95
69
  result,
96
- ruleName
70
+ ruleName,
71
+ fix: () => {
72
+ const value = getDeclarationValue(decl);
73
+
74
+ if (primary.startsWith('always')) {
75
+ if (decl.important) {
76
+ decl.raws.important = ' !important ';
77
+ }
78
+ else {
79
+ setDeclarationValue(decl, value.replace(/\s*$/, ' '));
80
+ }
81
+
82
+ return;
83
+ }
84
+
85
+ if (primary.startsWith('never')) {
86
+ if (decl.raws.important) {
87
+ decl.raws.important = decl.raws.important.replace(/\s*$/, '');
88
+ }
89
+ else {
90
+ setDeclarationValue(decl, value.replace(/\s*$/, ''));
91
+ }
92
+
93
+ return;
94
+ }
95
+ }
97
96
  });
98
97
  }
99
98
  });
@@ -92,6 +92,7 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
92
92
  return;
93
93
  }
94
94
 
95
+ let fix;
95
96
  let message;
96
97
 
97
98
  if (primary === 'always') {
@@ -100,15 +101,13 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
100
101
  }
101
102
 
102
103
  // auto-fix
103
- if (context.fix) {
104
+ fix = () => {
104
105
  node.parent.raws.semicolon = true;
105
106
 
106
107
  if (isAtRule(node)) {
107
108
  node.raws.between = '';
108
109
  node.parent.raws.after = ' ';
109
110
  }
110
-
111
- return;
112
111
  }
113
112
 
114
113
  message = messages.expected;
@@ -119,11 +118,9 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
119
118
  }
120
119
 
121
120
  // auto-fix
122
- if (context.fix) {
121
+ fix = () => {
123
122
  node.parent.raws.semicolon = false;
124
-
125
- return;
126
- }
123
+ };
127
124
 
128
125
  message = messages.rejected;
129
126
  }
@@ -137,7 +134,8 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
137
134
  index: node.toString().trim().length - 1,
138
135
  endIndex: node.toString().trim().length - 1,
139
136
  result,
140
- ruleName
137
+ ruleName,
138
+ fix
141
139
  });
142
140
  }
143
141
  };
@@ -62,30 +62,29 @@ const rule = (primary, _secondaryOptions, context) => {
62
62
  index: indexToCheck,
63
63
  lineCheckStr: decl.value,
64
64
  err: (m) => {
65
- if (context.fix) {
66
- const between = decl.raws.between;
67
-
68
- if (between == null) { throw new Error('`between` must be present'); }
69
-
70
- const betweenStart = declarationValueIndex(decl) - between.length;
71
- const sliceIndex = indexToCheck - betweenStart + 1;
72
- const betweenBefore = between.slice(0, sliceIndex);
73
- const betweenAfter = between.slice(sliceIndex);
74
-
75
- decl.raws.between = (/^\s*\n/).test(betweenAfter) ?
76
- betweenBefore + betweenAfter.replace(/^[^\S\n\r]*/, '')
77
- : betweenBefore + context.newline + betweenAfter;
78
-
79
- return;
80
- }
81
-
82
65
  report({
83
66
  message: m,
84
67
  node: decl,
85
68
  index: indexToCheck,
86
69
  endIndex: indexToCheck,
87
70
  result,
88
- ruleName
71
+ ruleName,
72
+ fix: () => {
73
+ const between = decl.raws.between;
74
+
75
+ if (between == null) { throw new Error('`between` must be present'); }
76
+
77
+ const betweenStart = declarationValueIndex(decl) - between.length;
78
+ const sliceIndex = indexToCheck - betweenStart + 1;
79
+ const betweenBefore = between.slice(0, sliceIndex);
80
+ const betweenAfter = between.slice(sliceIndex);
81
+
82
+ decl.raws.between = (/^\s*\n/).test(betweenAfter) ?
83
+ betweenBefore + betweenAfter.replace(/^[^\S\n\r]*/, '')
84
+ : betweenBefore + context.newline + betweenAfter;
85
+
86
+ return;
87
+ }
89
88
  });
90
89
  }
91
90
  });
@@ -23,7 +23,7 @@ const meta = {
23
23
  };
24
24
 
25
25
  /** @type {import('stylelint').Rule} */
26
- const rule = (primary, _secondaryOptions, context) => {
26
+ const rule = (primary, _secondaryOptions) => {
27
27
  const checker = whitespaceChecker('space', primary, messages);
28
28
 
29
29
  return (root, result) => {
@@ -41,29 +41,28 @@ const rule = (primary, _secondaryOptions, context) => {
41
41
  result,
42
42
  locationChecker: checker.after,
43
43
  checkedRuleName: ruleName,
44
- fix:
45
- context.fix ? (decl, index) => {
46
- const colonIndex = index - declarationValueIndex(decl);
47
- const between = decl.raws.between;
44
+ fix: (decl, index) => {
45
+ const colonIndex = index - declarationValueIndex(decl);
46
+ const between = decl.raws.between;
48
47
 
49
- if (between == null) { throw new Error('`between` must be present'); }
48
+ if (between == null) { throw new Error('`between` must be present'); }
50
49
 
51
- if (primary.startsWith('always')) {
52
- decl.raws.between =
53
- between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ': ');
50
+ if (primary.startsWith('always')) {
51
+ decl.raws.between =
52
+ between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ': ');
54
53
 
55
- return true;
56
- }
54
+ return true;
55
+ }
57
56
 
58
- if (primary === 'never') {
59
- decl.raws.between =
60
- between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ':');
57
+ if (primary === 'never') {
58
+ decl.raws.between =
59
+ between.slice(0, colonIndex) + between.slice(colonIndex).replace(/^:\s*/, ':');
61
60
 
62
- return true;
63
- }
61
+ return true;
62
+ }
64
63
 
65
- return false;
66
- } : null
64
+ return false;
65
+ }
67
66
  });
68
67
  };
69
68
  };
@@ -22,7 +22,7 @@ const meta = {
22
22
  };
23
23
 
24
24
  /** @type {import('stylelint').Rule} */
25
- const rule = (primary, _secondaryOptions, context) => {
25
+ const rule = (primary, _secondaryOptions) => {
26
26
  const checker = whitespaceChecker('space', primary, messages);
27
27
 
28
28
  return (root, result) => {
@@ -40,29 +40,28 @@ const rule = (primary, _secondaryOptions, context) => {
40
40
  result,
41
41
  locationChecker: checker.before,
42
42
  checkedRuleName: ruleName,
43
- fix: context.fix ?
44
- (decl, index) => {
45
- const colonIndex = index - declarationValueIndex(decl);
46
- const between = decl.raws.between;
43
+ fix: (decl, index) => {
44
+ const colonIndex = index - declarationValueIndex(decl);
45
+ const between = decl.raws.between;
47
46
 
48
- if (between == null) { throw new Error('`between` must be present'); }
47
+ if (between == null) { throw new Error('`between` must be present'); }
49
48
 
50
- if (primary === 'always') {
51
- decl.raws.between =
52
- between.slice(0, colonIndex).replace(/\s*$/, ' ') + between.slice(colonIndex);
49
+ if (primary === 'always') {
50
+ decl.raws.between =
51
+ between.slice(0, colonIndex).replace(/\s*$/, ' ') + between.slice(colonIndex);
53
52
 
54
- return true;
55
- }
53
+ return true;
54
+ }
56
55
 
57
- if (primary === 'never') {
58
- decl.raws.between =
59
- between.slice(0, colonIndex).replace(/\s*$/, '') + between.slice(colonIndex);
56
+ if (primary === 'never') {
57
+ decl.raws.between =
58
+ between.slice(0, colonIndex).replace(/\s*$/, '') + between.slice(colonIndex);
60
59
 
61
- return true;
62
- }
60
+ return true;
61
+ }
63
62
 
64
- return false;
65
- } : null
63
+ return false;
64
+ }
66
65
  });
67
66
  };
68
67
  };
@@ -46,17 +46,14 @@ export default function declarationBangSpaceChecker (options) {
46
46
  source,
47
47
  index,
48
48
  err: (message) => {
49
- if (options.fix?.(decl, index)) {
50
- return;
51
- }
52
-
53
49
  report({
54
50
  message,
55
51
  node: decl,
56
52
  index,
57
53
  endIndex: index,
58
54
  result: options.result,
59
- ruleName: options.checkedRuleName
55
+ ruleName: options.checkedRuleName,
56
+ fix: (options.fix ? () => options.fix(decl, index) : undefined)
60
57
  });
61
58
  }
62
59
  });