@tcy/eslint-rules 1.9.0 → 1.9.1

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 (39) hide show
  1. package/README.md +4 -0
  2. package/coverage/clover.xml +63 -58
  3. package/coverage/coverage-final.json +1 -1
  4. package/coverage/lcov-report/index.html +19 -19
  5. package/coverage/lcov-report/src/array-elements-per-line.js.html +1 -1
  6. package/coverage/lcov-report/src/back/back.js.html +1 -1
  7. package/coverage/lcov-report/src/back/http.js.html +1 -1
  8. package/coverage/lcov-report/src/back/index.html +1 -1
  9. package/coverage/lcov-report/src/back/recommended.js.html +1 -1
  10. package/coverage/lcov-report/src/bin/eslint-cache-guard.js.html +1 -1
  11. package/coverage/lcov-report/src/bin/index.html +1 -1
  12. package/coverage/lcov-report/src/client/client.js.html +1 -1
  13. package/coverage/lcov-report/src/client/index.html +1 -1
  14. package/coverage/lcov-report/src/client/recommended.js.html +1 -1
  15. package/coverage/lcov-report/src/decorator-type-enforcement.js.html +1 -1
  16. package/coverage/lcov-report/src/enforce-tailwind-important.js.html +151 -16
  17. package/coverage/lcov-report/src/export-specifiers-per-line.js.html +1 -1
  18. package/coverage/lcov-report/src/import-specifiers-per-line.js.html +1 -1
  19. package/coverage/lcov-report/src/index.html +19 -19
  20. package/coverage/lcov-report/src/index.js.html +1 -1
  21. package/coverage/lcov-report/src/jsx-boolean-shorthand.js.html +1 -1
  22. package/coverage/lcov-report/src/jsx-expression-string-literals.js.html +1 -1
  23. package/coverage/lcov-report/src/jsx-ref-string-exists.js.html +1 -1
  24. package/coverage/lcov-report/src/no-static-key-in-map.js.html +1 -1
  25. package/coverage/lcov-report/src/plugin.js.html +1 -1
  26. package/coverage/lcov-report/src/recommended.js.html +1 -1
  27. package/coverage/lcov-report/src/require-fragment-key.js.html +1 -1
  28. package/coverage/lcov-report/src/route-dto-required.js.html +1 -1
  29. package/coverage/lcov-report/src/v-model-name-match.js.html +1 -1
  30. package/coverage/lcov-report/src/vuejs-define-component.js.html +1 -1
  31. package/coverage/lcov-report/src/vuejs-define-workspace.js.html +1 -1
  32. package/coverage/lcov.info +144 -128
  33. package/decl/back/back.d.ts +13 -1
  34. package/decl/client/client.d.ts +13 -1
  35. package/decl/enforce-tailwind-important.d.ts +30 -1
  36. package/decl/plugin.d.ts +13 -1
  37. package/package.json +1 -1
  38. package/src/enforce-tailwind-important.js +50 -5
  39. package/tests/enforce-tailwind-important.spec.js +42 -1
@@ -122,170 +122,186 @@ TN:
122
122
  SF:src/enforce-tailwind-important.js
123
123
  FN:4,(anonymous_0)
124
124
  FN:6,(anonymous_1)
125
- FN:17,(anonymous_2)
126
- FN:23,reportIfMissing
127
- FN:24,(anonymous_4)
128
- FN:32,(anonymous_5)
129
- FN:37,(anonymous_6)
130
- FN:46,buildFixedTemplateText
131
- FN:47,(anonymous_8)
132
- FN:54,(anonymous_9)
133
- FN:67,processExpression
134
- FN:77,(anonymous_11)
135
- FN:85,(anonymous_12)
136
- FN:94,(anonymous_13)
137
- FN:102,(anonymous_14)
138
- FN:114,(anonymous_15)
139
- FN:135,(anonymous_16)
140
- FN:150,(anonymous_17)
141
- FNF:18
142
- FNH:1
143
- FNDA:1,(anonymous_0)
125
+ FN:28,(anonymous_2)
126
+ FN:31,(anonymous_3)
127
+ FN:57,(anonymous_4)
128
+ FN:63,(anonymous_5)
129
+ FN:68,reportIfMissing
130
+ FN:69,(anonymous_7)
131
+ FN:77,(anonymous_8)
132
+ FN:82,(anonymous_9)
133
+ FN:91,buildFixedTemplateText
134
+ FN:92,(anonymous_11)
135
+ FN:99,(anonymous_12)
136
+ FN:112,processExpression
137
+ FN:122,(anonymous_14)
138
+ FN:130,(anonymous_15)
139
+ FN:139,(anonymous_16)
140
+ FN:147,(anonymous_17)
141
+ FN:159,(anonymous_18)
142
+ FN:180,(anonymous_19)
143
+ FN:195,(anonymous_20)
144
+ FNF:21
145
+ FNH:3
146
+ FNDA:9,(anonymous_0)
144
147
  FNDA:0,(anonymous_1)
145
- FNDA:0,(anonymous_2)
146
- FNDA:0,reportIfMissing
148
+ FNDA:8,(anonymous_2)
149
+ FNDA:4,(anonymous_3)
147
150
  FNDA:0,(anonymous_4)
148
151
  FNDA:0,(anonymous_5)
149
- FNDA:0,(anonymous_6)
150
- FNDA:0,buildFixedTemplateText
152
+ FNDA:0,reportIfMissing
153
+ FNDA:0,(anonymous_7)
151
154
  FNDA:0,(anonymous_8)
152
155
  FNDA:0,(anonymous_9)
153
- FNDA:0,processExpression
156
+ FNDA:0,buildFixedTemplateText
154
157
  FNDA:0,(anonymous_11)
155
158
  FNDA:0,(anonymous_12)
156
- FNDA:0,(anonymous_13)
159
+ FNDA:0,processExpression
157
160
  FNDA:0,(anonymous_14)
158
161
  FNDA:0,(anonymous_15)
159
162
  FNDA:0,(anonymous_16)
160
163
  FNDA:0,(anonymous_17)
161
- DA:4,1
164
+ FNDA:0,(anonymous_18)
165
+ FNDA:0,(anonymous_19)
166
+ FNDA:0,(anonymous_20)
167
+ DA:4,9
162
168
  DA:6,1
163
- DA:18,0
164
- DA:24,0
165
- DA:25,0
166
- DA:28,0
167
- DA:29,0
168
- DA:32,0
169
- DA:33,0
170
- DA:38,0
171
- DA:39,0
172
- DA:41,0
173
- DA:47,0
174
- DA:48,0
175
- DA:50,0
176
- DA:51,0
177
- DA:53,0
178
- DA:54,0
179
- DA:55,0
169
+ DA:16,1
170
+ DA:28,8
171
+ DA:31,4
180
172
  DA:58,0
181
- DA:59,0
182
173
  DA:60,0
183
174
  DA:63,0
184
- DA:64,0
185
- DA:68,0
186
175
  DA:69,0
187
- DA:72,0
176
+ DA:70,0
177
+ DA:73,0
188
178
  DA:74,0
189
- DA:75,0
190
179
  DA:77,0
191
180
  DA:78,0
192
- DA:79,0
193
- DA:82,0
194
181
  DA:83,0
195
182
  DA:84,0
196
- DA:85,0
197
183
  DA:86,0
198
- DA:87,0
199
184
  DA:92,0
200
- DA:94,0
185
+ DA:93,0
201
186
  DA:95,0
202
187
  DA:96,0
188
+ DA:98,0
203
189
  DA:99,0
204
- DA:101,0
205
- DA:102,0
206
- DA:107,0
190
+ DA:100,0
191
+ DA:103,0
192
+ DA:104,0
193
+ DA:105,0
207
194
  DA:108,0
208
- DA:111,0
209
- DA:115,0
195
+ DA:109,0
196
+ DA:113,0
197
+ DA:114,0
210
198
  DA:117,0
199
+ DA:119,0
211
200
  DA:120,0
201
+ DA:122,0
212
202
  DA:123,0
213
203
  DA:124,0
214
- DA:125,0
215
204
  DA:127,0
216
- DA:134,0
217
- DA:136,0
205
+ DA:128,0
206
+ DA:129,0
207
+ DA:130,0
208
+ DA:131,0
209
+ DA:132,0
218
210
  DA:137,0
219
211
  DA:139,0
220
212
  DA:140,0
221
- DA:142,0
222
- DA:143,0
213
+ DA:141,0
223
214
  DA:144,0
224
- DA:145,0
225
- DA:151,0
226
- DA:159,0
227
- LF:66
228
- LH:2
229
- BRDA:28,0,0,0
230
- BRDA:28,0,1,0
231
- BRDA:32,1,0,0
232
- BRDA:32,1,1,0
233
- BRDA:39,2,0,0
234
- BRDA:39,2,1,0
235
- BRDA:54,3,0,0
236
- BRDA:54,3,1,0
237
- BRDA:58,4,0,0
238
- BRDA:58,4,1,0
239
- BRDA:59,5,0,0
240
- BRDA:59,5,1,0
241
- BRDA:59,6,0,0
242
- BRDA:59,6,1,0
243
- BRDA:68,7,0,0
244
- BRDA:68,7,1,0
245
- BRDA:72,8,0,0
246
- BRDA:72,8,1,0
247
- BRDA:72,8,2,0
248
- BRDA:72,8,3,0
249
- BRDA:72,8,4,0
250
- BRDA:72,8,5,0
251
- BRDA:78,9,0,0
252
- BRDA:78,9,1,0
253
- BRDA:82,10,0,0
254
- BRDA:82,10,1,0
255
- BRDA:84,11,0,0
256
- BRDA:84,11,1,0
257
- BRDA:86,12,0,0
258
- BRDA:86,12,1,0
259
- BRDA:86,13,0,0
260
- BRDA:86,13,1,0
261
- BRDA:95,14,0,0
262
- BRDA:95,14,1,0
263
- BRDA:95,15,0,0
264
- BRDA:95,15,1,0
265
- BRDA:107,16,0,0
266
- BRDA:107,16,1,0
267
- BRDA:136,17,0,0
268
- BRDA:136,17,1,0
269
- BRDA:137,18,0,0
270
- BRDA:137,18,1,0
271
- BRDA:140,19,0,0
272
- BRDA:140,19,1,0
273
- BRDA:142,20,0,0
274
- BRDA:142,20,1,0
275
- BRDA:142,21,0,0
276
- BRDA:142,21,1,0
277
- BRDA:144,22,0,0
278
- BRDA:144,22,1,0
279
- BRDA:151,23,0,0
280
- BRDA:151,23,1,0
281
- BRDA:152,24,0,0
282
- BRDA:152,24,1,0
283
- BRDA:152,24,2,0
284
- BRDA:152,24,3,0
285
- BRDA:152,24,4,0
286
- BRDA:152,24,5,0
287
- BRF:58
288
- BRH:0
215
+ DA:146,0
216
+ DA:147,0
217
+ DA:152,0
218
+ DA:153,0
219
+ DA:156,0
220
+ DA:160,0
221
+ DA:162,0
222
+ DA:165,0
223
+ DA:168,0
224
+ DA:169,0
225
+ DA:170,0
226
+ DA:172,0
227
+ DA:179,0
228
+ DA:181,0
229
+ DA:182,0
230
+ DA:184,0
231
+ DA:185,0
232
+ DA:187,0
233
+ DA:188,0
234
+ DA:189,0
235
+ DA:190,0
236
+ DA:196,0
237
+ DA:204,0
238
+ LF:71
239
+ LH:5
240
+ BRDA:28,0,0,8
241
+ BRDA:28,0,1,7
242
+ BRDA:33,1,0,4
243
+ BRDA:33,1,1,1
244
+ BRDA:33,1,2,3
245
+ BRDA:73,2,0,0
246
+ BRDA:73,2,1,0
247
+ BRDA:77,3,0,0
248
+ BRDA:77,3,1,0
249
+ BRDA:84,4,0,0
250
+ BRDA:84,4,1,0
251
+ BRDA:99,5,0,0
252
+ BRDA:99,5,1,0
253
+ BRDA:103,6,0,0
254
+ BRDA:103,6,1,0
255
+ BRDA:104,7,0,0
256
+ BRDA:104,7,1,0
257
+ BRDA:104,8,0,0
258
+ BRDA:104,8,1,0
259
+ BRDA:113,9,0,0
260
+ BRDA:113,9,1,0
261
+ BRDA:117,10,0,0
262
+ BRDA:117,10,1,0
263
+ BRDA:117,10,2,0
264
+ BRDA:117,10,3,0
265
+ BRDA:117,10,4,0
266
+ BRDA:117,10,5,0
267
+ BRDA:123,11,0,0
268
+ BRDA:123,11,1,0
269
+ BRDA:127,12,0,0
270
+ BRDA:127,12,1,0
271
+ BRDA:129,13,0,0
272
+ BRDA:129,13,1,0
273
+ BRDA:131,14,0,0
274
+ BRDA:131,14,1,0
275
+ BRDA:131,15,0,0
276
+ BRDA:131,15,1,0
277
+ BRDA:140,16,0,0
278
+ BRDA:140,16,1,0
279
+ BRDA:140,17,0,0
280
+ BRDA:140,17,1,0
281
+ BRDA:152,18,0,0
282
+ BRDA:152,18,1,0
283
+ BRDA:181,19,0,0
284
+ BRDA:181,19,1,0
285
+ BRDA:182,20,0,0
286
+ BRDA:182,20,1,0
287
+ BRDA:185,21,0,0
288
+ BRDA:185,21,1,0
289
+ BRDA:187,22,0,0
290
+ BRDA:187,22,1,0
291
+ BRDA:187,23,0,0
292
+ BRDA:187,23,1,0
293
+ BRDA:189,24,0,0
294
+ BRDA:189,24,1,0
295
+ BRDA:196,25,0,0
296
+ BRDA:196,25,1,0
297
+ BRDA:197,26,0,0
298
+ BRDA:197,26,1,0
299
+ BRDA:197,26,2,0
300
+ BRDA:197,26,3,0
301
+ BRDA:197,26,4,0
302
+ BRDA:197,26,5,0
303
+ BRF:63
304
+ BRH:5
289
305
  end_of_record
290
306
  TN:
291
307
  SF:src/export-specifiers-per-line.js
@@ -106,7 +106,19 @@ declare const _default: {
106
106
  recommended: boolean;
107
107
  };
108
108
  fixable: string;
109
- schema: never[];
109
+ schema: {
110
+ type: string;
111
+ properties: {
112
+ ignore: {
113
+ type: string;
114
+ items: {
115
+ type: string;
116
+ };
117
+ default: never[];
118
+ };
119
+ };
120
+ additionalProperties: boolean;
121
+ }[];
110
122
  messages: {
111
123
  missingImportant: string;
112
124
  };
@@ -106,7 +106,19 @@ declare const _default: {
106
106
  recommended: boolean;
107
107
  };
108
108
  fixable: string;
109
- schema: never[];
109
+ schema: {
110
+ type: string;
111
+ properties: {
112
+ ignore: {
113
+ type: string;
114
+ items: {
115
+ type: string;
116
+ };
117
+ default: never[];
118
+ };
119
+ };
120
+ additionalProperties: boolean;
121
+ }[];
110
122
  messages: {
111
123
  missingImportant: string;
112
124
  };
@@ -3,6 +3,23 @@
3
3
  */
4
4
  export declare const isMissingImportant: (cls: any) => boolean;
5
5
  export declare const addImportant: (cls: any) => string;
6
+ /**
7
+ * Plain (non-Tailwind) classes that must NOT receive the "!" modifier.
8
+ *
9
+ * These ship in the widgets' bundled Bootstrap-style grid CSS and are matched by
10
+ * a bare `.class` selector. Appending "!" turns the token into `class!`, which
11
+ * matches no rule at all (Tailwind does not emit anything for it, and `.class`
12
+ * does not match the `class!` token) - silently breaking the layout.
13
+ */
14
+ export declare const DEFAULT_IGNORED_CLASSES: string[];
15
+ /**
16
+ * Whether a class token must be flagged for a missing "!" modifier.
17
+ * @param {string} cls the class token
18
+ * @param {Set<string>} ignored classes that are allowed without "!"
19
+ */
20
+ export declare const shouldFlag: (cls: string, ignored: Set<string>) => boolean;
21
+ /** Build the set of ignored classes from the rule options. */
22
+ export declare const resolveIgnored: (options: any) => Set<any>;
6
23
  declare const _default: {
7
24
  meta: {
8
25
  type: string;
@@ -11,7 +28,19 @@ declare const _default: {
11
28
  recommended: boolean;
12
29
  };
13
30
  fixable: string;
14
- schema: never[];
31
+ schema: {
32
+ type: string;
33
+ properties: {
34
+ ignore: {
35
+ type: string;
36
+ items: {
37
+ type: string;
38
+ };
39
+ default: never[];
40
+ };
41
+ };
42
+ additionalProperties: boolean;
43
+ }[];
15
44
  messages: {
16
45
  missingImportant: string;
17
46
  };
package/decl/plugin.d.ts CHANGED
@@ -103,7 +103,19 @@ declare const _default: {
103
103
  recommended: boolean;
104
104
  };
105
105
  fixable: string;
106
- schema: never[];
106
+ schema: {
107
+ type: string;
108
+ properties: {
109
+ ignore: {
110
+ type: string;
111
+ items: {
112
+ type: string;
113
+ };
114
+ default: never[];
115
+ };
116
+ };
117
+ additionalProperties: boolean;
118
+ }[];
107
119
  messages: {
108
120
  missingImportant: string;
109
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tcy/eslint-rules",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "```typescript import { plugin as customRules } from 'tcy@eslint-rules/src/index.mjs';",
5
5
  "homepage": "https://github.com/tcastelly/eslint-rules#readme",
6
6
  "bugs": {
@@ -5,31 +5,76 @@ export const isMissingImportant = (cls) => !/^[a-zA-Z0-9-%&>*.:',/[\]()_@]+(:?!)
5
5
 
6
6
  export const addImportant = (cls) => `${cls}!`;
7
7
 
8
+ /**
9
+ * Plain (non-Tailwind) classes that must NOT receive the "!" modifier.
10
+ *
11
+ * These ship in the widgets' bundled Bootstrap-style grid CSS and are matched by
12
+ * a bare `.class` selector. Appending "!" turns the token into `class!`, which
13
+ * matches no rule at all (Tailwind does not emit anything for it, and `.class`
14
+ * does not match the `class!` token) - silently breaking the layout.
15
+ */
16
+ export const DEFAULT_IGNORED_CLASSES = [
17
+ 'row',
18
+ 'no-gutters',
19
+ 'container',
20
+ 'container-fluid',
21
+ ];
22
+
23
+ /**
24
+ * Whether a class token must be flagged for a missing "!" modifier.
25
+ * @param {string} cls the class token
26
+ * @param {Set<string>} ignored classes that are allowed without "!"
27
+ */
28
+ export const shouldFlag = (cls, ignored) => isMissingImportant(cls) && !ignored.has(cls);
29
+
30
+ /** Build the set of ignored classes from the rule options. */
31
+ export const resolveIgnored = (options) => new Set([
32
+ ...DEFAULT_IGNORED_CLASSES,
33
+ ...((options && options.ignore) || []),
34
+ ]);
35
+
8
36
  export default {
9
37
  meta: {
10
38
  type: 'layout',
11
39
  docs: { description: 'Enforce Tailwind classes end with "!"', recommended: false },
12
40
  fixable: 'code',
13
- schema: [],
41
+ schema: [
42
+ {
43
+ type: 'object',
44
+ properties: {
45
+ ignore: {
46
+ type: 'array',
47
+ items: { type: 'string' },
48
+ default: [],
49
+ },
50
+ },
51
+ additionalProperties: false,
52
+ },
53
+ ],
14
54
  messages: { missingImportant: 'Tailwind class "{{cls}}" should end with "!"' },
15
55
  },
16
56
 
17
57
  create(context) {
18
58
  const source = context.getSourceCode();
19
59
 
60
+ const ignored = resolveIgnored(context.options[0]);
61
+
62
+ // a class needs the "!" modifier unless it is explicitly ignored
63
+ const isFlagged = (cls) => shouldFlag(cls, ignored);
64
+
20
65
  //----------------------------------------------------------------------
21
66
  // Helpers
22
67
  //----------------------------------------------------------------------
23
68
  function reportIfMissing(node, value) {
24
69
  const classes = value.split(/\s+/).map((cls) => cls.trim()).filter(Boolean);
25
- const missing = classes.filter(isMissingImportant);
70
+ const missing = classes.filter(isFlagged);
26
71
 
27
72
  // nothing to fix
28
73
  if (!missing.length) {
29
74
  return;
30
75
  }
31
76
 
32
- const fixed = classes.map((c) => (isMissingImportant(c) ? addImportant(c) : c)).join(' ');
77
+ const fixed = classes.map((c) => (isFlagged(c) ? addImportant(c) : c)).join(' ');
33
78
  context.report({
34
79
  node,
35
80
  messageId: 'missingImportant',
@@ -51,7 +96,7 @@ export default {
51
96
  for (let i = 0; i < quasis.length; i += 1) {
52
97
  // fix literal part
53
98
  const parts = quasis[i].value.raw.split(/\s+/).filter(Boolean);
54
- const fixed = parts.map((p) => (isMissingImportant(p) ? addImportant(p) : p)).join(' ');
99
+ const fixed = parts.map((p) => (isFlagged(p) ? addImportant(p) : p)).join(' ');
55
100
  out += fixed;
56
101
 
57
102
  // add space before expression if needed
@@ -102,7 +147,7 @@ export default {
102
147
  .some((q) => q.value.raw
103
148
  .split(/\s+/)
104
149
  .filter(Boolean)
105
- .some(isMissingImportant));
150
+ .some(isFlagged));
106
151
 
107
152
  if (!hasMissing) {
108
153
  return;
@@ -1,4 +1,9 @@
1
- import { isMissingImportant } from '../src/enforce-tailwind-important';
1
+ import {
2
+ DEFAULT_IGNORED_CLASSES,
3
+ isMissingImportant,
4
+ resolveIgnored,
5
+ shouldFlag,
6
+ } from '../src/enforce-tailwind-important';
2
7
 
3
8
  describe('GIVEN "enforce-tailwind-important"', () => {
4
9
  describe('WHEN "test" important class', () => {
@@ -12,4 +17,40 @@ describe('GIVEN "enforce-tailwind-important"', () => {
12
17
  expect(isImportantClass).toBe(true);
13
18
  });
14
19
  });
20
+
21
+ describe('WHEN a class is in the ignore list', () => {
22
+ it('THEN "no-gutters" and "container-fluid" are ignored by default', () => {
23
+ expect(DEFAULT_IGNORED_CLASSES).toEqual(
24
+ expect.arrayContaining(['no-gutters', 'container-fluid']),
25
+ );
26
+ });
27
+
28
+ it('THEN a default-ignored class is not flagged', () => {
29
+ const ignored = resolveIgnored();
30
+
31
+ expect(shouldFlag('no-gutters', ignored)).toBe(false);
32
+ expect(shouldFlag('container-fluid', ignored)).toBe(false);
33
+ });
34
+
35
+ it('THEN a real Tailwind class is still flagged', () => {
36
+ const ignored = resolveIgnored();
37
+
38
+ expect(shouldFlag('w-full', ignored)).toBe(true);
39
+ expect(shouldFlag('max-w-[800px]', ignored)).toBe(true);
40
+ });
41
+
42
+ it('THEN an already-important class is never flagged', () => {
43
+ const ignored = resolveIgnored();
44
+
45
+ expect(shouldFlag('w-full!', ignored)).toBe(false);
46
+ });
47
+
48
+ it('THEN classes from the "ignore" option are merged with the defaults', () => {
49
+ const ignored = resolveIgnored({ ignore: ['my-legacy-class'] });
50
+
51
+ expect(shouldFlag('my-legacy-class', ignored)).toBe(false);
52
+ expect(shouldFlag('no-gutters', ignored)).toBe(false);
53
+ expect(shouldFlag('text-red-500', ignored)).toBe(true);
54
+ });
55
+ });
15
56
  });