@allxsmith/eslint-plugin-bestax 1.2.0 → 1.3.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.
- package/README.md +21 -10
- package/dist/generated/metadata.d.ts +31 -1
- package/dist/generated/metadata.d.ts.map +1 -1
- package/dist/generated/metadata.js +538 -87
- package/dist/rules/no-bulma-component-class.d.ts +19 -7
- package/dist/rules/no-bulma-component-class.d.ts.map +1 -1
- package/dist/rules/no-bulma-component-class.js +85 -10
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -112,16 +112,16 @@ In `recommended` — each reports code that does not do what it says:
|
|
|
112
112
|
|
|
113
113
|
Opt-in — these report code that works, and buy explicitness instead:
|
|
114
114
|
|
|
115
|
-
| Rule | Fixable | What it asks for
|
|
116
|
-
| -------------------------- | ------- |
|
|
117
|
-
| `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface
|
|
118
|
-
| `no-bulma-component-class` | — | The bestax component instead of a plain element
|
|
115
|
+
| Rule | Fixable | What it asks for |
|
|
116
|
+
| -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |
|
|
118
|
+
| `no-bulma-component-class` | — | The bestax component instead of its Bulma class, on a plain element (`<button className="button">`) or on another component (`<Columns className="box">`) |
|
|
119
119
|
|
|
120
120
|
The rules that judge bestax elements resolve them through the import and
|
|
121
121
|
through scope, so neither your own `<Box>` nor a local shadowing the imported
|
|
122
122
|
one is linted against Bulma's rules, and each skips a value it cannot read as a
|
|
123
|
-
literal. `no-bulma-component-class` reads plain HTML elements
|
|
124
|
-
leaves
|
|
123
|
+
literal. `no-bulma-component-class` reads plain HTML elements as well, and
|
|
124
|
+
leaves custom elements and anything inside `<svg>` alone.
|
|
125
125
|
|
|
126
126
|
A spread is handled by what it can change: `no-color-as-surface` and
|
|
127
127
|
`no-inert-flex-props` go silent, since a spread may carry the prop that makes
|
|
@@ -195,21 +195,32 @@ code.
|
|
|
195
195
|
### no-bulma-component-class
|
|
196
196
|
|
|
197
197
|
Off by default. It reports a plain element styled with a Bulma class that
|
|
198
|
-
bestax has a component for, and names the component.
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
bestax has a component for, and names the component. It also reports that
|
|
199
|
+
class in the `className` of a bestax component that renders another one, which
|
|
200
|
+
is where `bestax-migrate bulma-classes` leaves the second of two such classes
|
|
201
|
+
(`columns box`). Turn it on in an app that has moved onto bestax, with the
|
|
202
|
+
codemod or by hand, to keep raw Bulma markup from coming back.
|
|
201
203
|
|
|
202
204
|
```jsx
|
|
203
205
|
<button className="button is-primary" /> // ✗ bestax renders .button as Button
|
|
204
206
|
<div className="dropdown" /> // ✗ bestax has Dropdown, converted by hand
|
|
207
|
+
<Columns className="box" /> // ✗ bestax renders .box as Box
|
|
205
208
|
<div className="has-text-centered mt-4" /> // ✓ helper classes are left alone
|
|
206
209
|
<p className="help" /> // ✓ bestax renders .help inside its form controls
|
|
210
|
+
<Columns className="columns is-mobile" /> // ✓ its own classes
|
|
207
211
|
```
|
|
208
212
|
|
|
209
213
|
It reads the classes a `className` spells out, including the strings in a
|
|
210
214
|
ternary, a template, or a call to `clsx`, `classnames` or `tailwind-merge`
|
|
211
215
|
(however the file imports or requires it), and reports one class per element:
|
|
212
|
-
the one the codemod would decide by
|
|
216
|
+
the one the codemod would decide by, a family's first and then, on a plain
|
|
217
|
+
element, the one whose component fits its tag best, a tag it renders with no
|
|
218
|
+
`as` before one it reaches through `as`. That tag is the one the element's
|
|
219
|
+
classes give it, so an `.image` ratio, which puts `Image` on a `<figure>`, fits
|
|
220
|
+
a `<div>` only through `as`. On a component, whose tag can come from `as`, the
|
|
221
|
+
table's order decides. It reads `className` only on the components
|
|
222
|
+
the codemod writes, whose own classes it knows, so `<Input className="box">` is
|
|
223
|
+
left alone. A function your app defines, a `cn` in `lib/utils`
|
|
213
224
|
included, is one it cannot see into, so it reads nothing there. It only reports. Whether an element converts
|
|
214
225
|
depends on its tag, attributes and children, and `bestax-migrate bulma-classes`
|
|
215
226
|
is the one place that judges that.
|
|
@@ -32,11 +32,41 @@ export interface BulmaComponentClass {
|
|
|
32
32
|
* family whose component renders its own parts, converted by hand.
|
|
33
33
|
*/
|
|
34
34
|
readonly converts: boolean;
|
|
35
|
+
/** For a class that converts: the tag its component renders by itself. */
|
|
36
|
+
readonly tag?: string;
|
|
37
|
+
/**
|
|
38
|
+
* For a class that converts: the tags its component renders, its own and
|
|
39
|
+
* the ones `as` reaches, or `'any'`. Of the classes an element carries,
|
|
40
|
+
* the codemod decides by the one whose component fits its tag best: the
|
|
41
|
+
* tag it renders with no `as`, then one of these, then none.
|
|
42
|
+
*/
|
|
43
|
+
readonly tags?: readonly string[] | 'any';
|
|
44
|
+
/**
|
|
45
|
+
* For a class that converts: the classes beside it that decide the tag its
|
|
46
|
+
* component renders with no `as` (`Image`'s ratios a <figure>, `Title`'s
|
|
47
|
+
* sizes their heading), each with that tag, null for its own, and the tags
|
|
48
|
+
* it converts on when not all. The first the element carries that converts
|
|
49
|
+
* on its tag decides.
|
|
50
|
+
*/
|
|
51
|
+
readonly retags?: Readonly<Record<string, BulmaRetag>>;
|
|
52
|
+
/**
|
|
53
|
+
* How to keep the class on an element another component renders, where an
|
|
54
|
+
* element of its own is not the answer.
|
|
55
|
+
*/
|
|
56
|
+
readonly onAnother?: string;
|
|
57
|
+
}
|
|
58
|
+
/** A class that decides the tag a component renders with no `as`. */
|
|
59
|
+
export interface BulmaRetag {
|
|
60
|
+
/** The tag it renders, or null for the component's own. */
|
|
61
|
+
readonly tag: string | null;
|
|
62
|
+
/** The tags it converts on, when not all. */
|
|
63
|
+
readonly on?: readonly string[];
|
|
35
64
|
}
|
|
36
65
|
/**
|
|
37
66
|
* Bulma classes that name a bestax component, from bestax-migrate's
|
|
38
67
|
* bulma-classes table. In the order the codemod decides an element's
|
|
39
|
-
* component when it carries several: a family first, then by precedence
|
|
68
|
+
* component when it carries several: a family first, then by precedence,
|
|
69
|
+
* among the ones whose component fits the element's tag best.
|
|
40
70
|
*/
|
|
41
71
|
export declare const BULMA_COMPONENT_CLASSES: ReadonlyMap<string, BulmaComponentClass>;
|
|
42
72
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/generated/metadata.ts"],"names":[],"mappings":"AAIA,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/generated/metadata.ts"],"names":[],"mappings":"AAIA,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CA6JtD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EActD,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAC1C;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACvD;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAihBzE,CAAC"}
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* part is `"Navbar.Brand"`.
|
|
7
7
|
*/
|
|
8
8
|
export const DEPRECATED_PROPS = {
|
|
9
|
+
Autocomplete: {
|
|
10
|
+
dropdown: {
|
|
11
|
+
replacement: null,
|
|
12
|
+
note: 'It will be removed in the next major version, with nothing in its place.',
|
|
13
|
+
},
|
|
14
|
+
selected: {
|
|
15
|
+
replacement: null,
|
|
16
|
+
note: 'Nothing reads it, and `onSelect` is what reports a pick. It will be removed in the next major version.',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
9
19
|
Button: {
|
|
10
20
|
isFullWidth: {
|
|
11
21
|
replacement: 'isFullwidth',
|
|
@@ -24,6 +34,12 @@ export const DEPRECATED_PROPS = {
|
|
|
24
34
|
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
25
35
|
},
|
|
26
36
|
},
|
|
37
|
+
'Buttons.ToggleButton': {
|
|
38
|
+
isFullWidth: {
|
|
39
|
+
replacement: 'isFullwidth',
|
|
40
|
+
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
27
43
|
Columns: {
|
|
28
44
|
gapSize: {
|
|
29
45
|
replacement: 'gap',
|
|
@@ -139,6 +155,12 @@ export const DEPRECATED_PROPS = {
|
|
|
139
155
|
note: "Bulma's `.tags` wraps by default (no shipped `are-multiline` CSS exists for it) — this prop has never had a visual effect and will be removed in the next major version.",
|
|
140
156
|
},
|
|
141
157
|
},
|
|
158
|
+
ToggleButton: {
|
|
159
|
+
isFullWidth: {
|
|
160
|
+
replacement: 'isFullwidth',
|
|
161
|
+
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
142
164
|
};
|
|
143
165
|
/**
|
|
144
166
|
* Elements whose `color` prop is a text-colour alias, NOT a filled surface
|
|
@@ -160,13 +182,18 @@ export const TEXT_ALIAS_COLOR_ELEMENTS = [
|
|
|
160
182
|
'Container',
|
|
161
183
|
'Content',
|
|
162
184
|
'Delete',
|
|
185
|
+
'EmptyState.Actions',
|
|
186
|
+
'Icon',
|
|
163
187
|
'IconText',
|
|
188
|
+
'IconText.Icon',
|
|
164
189
|
'Image',
|
|
190
|
+
'Panel.Icon',
|
|
165
191
|
];
|
|
166
192
|
/**
|
|
167
193
|
* Bulma classes that name a bestax component, from bestax-migrate's
|
|
168
194
|
* bulma-classes table. In the order the codemod decides an element's
|
|
169
|
-
* component when it carries several: a family first, then by precedence
|
|
195
|
+
* component when it carries several: a family first, then by precedence,
|
|
196
|
+
* among the ones whose component fits the element's tag best.
|
|
170
197
|
*/
|
|
171
198
|
export const BULMA_COMPONENT_CLASSES = new Map([
|
|
172
199
|
['checkbox', { component: 'Checkbox', converts: false }],
|
|
@@ -180,95 +207,519 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
180
207
|
['navbar-burger', { component: 'Navbar.Burger', converts: false }],
|
|
181
208
|
['navbar-link', { component: 'Navbar.Link', converts: false }],
|
|
182
209
|
['panel-icon', { component: 'Panel.Icon', converts: false }],
|
|
183
|
-
[
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
[
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
['
|
|
192
|
-
['
|
|
193
|
-
[
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
[
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
[
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
[
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
[
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
[
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
210
|
+
[
|
|
211
|
+
'columns',
|
|
212
|
+
{ component: 'Columns', converts: true, tag: 'div', tags: ['div'] },
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
'column',
|
|
216
|
+
{ component: 'Column', converts: true, tag: 'div', tags: ['div'] },
|
|
217
|
+
],
|
|
218
|
+
['grid', { component: 'Grid', converts: true, tag: 'div', tags: ['div'] }],
|
|
219
|
+
['cell', { component: 'Cell', converts: true, tag: 'div', tags: ['div'] }],
|
|
220
|
+
[
|
|
221
|
+
'container',
|
|
222
|
+
{
|
|
223
|
+
component: 'Container',
|
|
224
|
+
converts: true,
|
|
225
|
+
tag: 'div',
|
|
226
|
+
tags: [
|
|
227
|
+
'div',
|
|
228
|
+
'main',
|
|
229
|
+
'section',
|
|
230
|
+
'article',
|
|
231
|
+
'aside',
|
|
232
|
+
'header',
|
|
233
|
+
'footer',
|
|
234
|
+
'nav',
|
|
235
|
+
],
|
|
236
|
+
onAnother: 'where it is only there to center this element, `mx="auto"` centers it, and otherwise wrap the element in a `Container`; either way drop the class, then check the layout',
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
[
|
|
240
|
+
'section',
|
|
241
|
+
{
|
|
242
|
+
component: 'Section',
|
|
243
|
+
converts: true,
|
|
244
|
+
tag: 'section',
|
|
245
|
+
tags: ['section'],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
'hero',
|
|
250
|
+
{
|
|
251
|
+
component: 'Hero',
|
|
252
|
+
converts: true,
|
|
253
|
+
tag: 'section',
|
|
254
|
+
tags: [
|
|
255
|
+
'section',
|
|
256
|
+
'div',
|
|
257
|
+
'main',
|
|
258
|
+
'header',
|
|
259
|
+
'footer',
|
|
260
|
+
'article',
|
|
261
|
+
'aside',
|
|
262
|
+
],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
'hero-head',
|
|
267
|
+
{
|
|
268
|
+
component: 'Hero.Head',
|
|
269
|
+
converts: true,
|
|
270
|
+
tag: 'div',
|
|
271
|
+
tags: ['div', 'header', 'nav'],
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
'hero-body',
|
|
276
|
+
{ component: 'Hero.Body', converts: true, tag: 'div', tags: ['div'] },
|
|
277
|
+
],
|
|
278
|
+
[
|
|
279
|
+
'hero-foot',
|
|
280
|
+
{
|
|
281
|
+
component: 'Hero.Foot',
|
|
282
|
+
converts: true,
|
|
283
|
+
tag: 'div',
|
|
284
|
+
tags: ['div', 'footer', 'nav'],
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
'footer',
|
|
289
|
+
{
|
|
290
|
+
component: 'Footer',
|
|
291
|
+
converts: true,
|
|
292
|
+
tag: 'footer',
|
|
293
|
+
tags: ['footer', 'div'],
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
[
|
|
297
|
+
'level',
|
|
298
|
+
{ component: 'Level', converts: true, tag: 'nav', tags: ['nav'] },
|
|
299
|
+
],
|
|
300
|
+
[
|
|
301
|
+
'level-left',
|
|
302
|
+
{ component: 'Level.Left', converts: true, tag: 'div', tags: ['div'] },
|
|
303
|
+
],
|
|
304
|
+
[
|
|
305
|
+
'level-right',
|
|
306
|
+
{ component: 'Level.Right', converts: true, tag: 'div', tags: ['div'] },
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
'level-item',
|
|
310
|
+
{
|
|
311
|
+
component: 'Level.Item',
|
|
312
|
+
converts: true,
|
|
313
|
+
tag: 'div',
|
|
314
|
+
tags: ['div', 'p', 'a'],
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
[
|
|
318
|
+
'media',
|
|
319
|
+
{
|
|
320
|
+
component: 'Media',
|
|
321
|
+
converts: true,
|
|
322
|
+
tag: 'article',
|
|
323
|
+
tags: ['article', 'div'],
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
[
|
|
327
|
+
'media-left',
|
|
328
|
+
{
|
|
329
|
+
component: 'Media.Left',
|
|
330
|
+
converts: true,
|
|
331
|
+
tag: 'figure',
|
|
332
|
+
tags: ['figure', 'div'],
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
[
|
|
336
|
+
'media-content',
|
|
337
|
+
{ component: 'Media.Content', converts: true, tag: 'div', tags: ['div'] },
|
|
338
|
+
],
|
|
339
|
+
[
|
|
340
|
+
'media-right',
|
|
341
|
+
{ component: 'Media.Right', converts: true, tag: 'div', tags: ['div'] },
|
|
342
|
+
],
|
|
343
|
+
['card', { component: 'Card', converts: true, tag: 'div', tags: ['div'] }],
|
|
344
|
+
[
|
|
345
|
+
'card-header',
|
|
346
|
+
{
|
|
347
|
+
component: 'Card.Header',
|
|
348
|
+
converts: true,
|
|
349
|
+
tag: 'header',
|
|
350
|
+
tags: ['header'],
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
[
|
|
354
|
+
'card-header-title',
|
|
355
|
+
{
|
|
356
|
+
component: 'Card.Header.Title',
|
|
357
|
+
converts: true,
|
|
358
|
+
tag: 'div',
|
|
359
|
+
tags: ['div', 'p', 'h2', 'h3', 'h4'],
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
'card-header-icon',
|
|
364
|
+
{
|
|
365
|
+
component: 'Card.Header.Icon',
|
|
366
|
+
converts: true,
|
|
367
|
+
tag: 'button',
|
|
368
|
+
tags: ['button'],
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
[
|
|
372
|
+
'card-image',
|
|
373
|
+
{ component: 'Card.Image', converts: true, tag: 'div', tags: ['div'] },
|
|
374
|
+
],
|
|
375
|
+
[
|
|
376
|
+
'card-content',
|
|
377
|
+
{ component: 'Card.Content', converts: true, tag: 'div', tags: ['div'] },
|
|
378
|
+
],
|
|
379
|
+
[
|
|
380
|
+
'card-footer',
|
|
381
|
+
{
|
|
382
|
+
component: 'Card.Footer',
|
|
383
|
+
converts: true,
|
|
384
|
+
tag: 'footer',
|
|
385
|
+
tags: ['footer'],
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
[
|
|
389
|
+
'card-footer-item',
|
|
390
|
+
{
|
|
391
|
+
component: 'Card.FooterItem',
|
|
392
|
+
converts: true,
|
|
393
|
+
tag: 'span',
|
|
394
|
+
tags: ['span', 'a', 'button'],
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
[
|
|
398
|
+
'navbar',
|
|
399
|
+
{ component: 'Navbar', converts: true, tag: 'nav', tags: ['nav'] },
|
|
400
|
+
],
|
|
401
|
+
[
|
|
402
|
+
'navbar-brand',
|
|
403
|
+
{ component: 'Navbar.Brand', converts: true, tag: 'div', tags: ['div'] },
|
|
404
|
+
],
|
|
405
|
+
[
|
|
406
|
+
'navbar-menu',
|
|
407
|
+
{ component: 'Navbar.Menu', converts: true, tag: 'div', tags: ['div'] },
|
|
408
|
+
],
|
|
409
|
+
[
|
|
410
|
+
'navbar-start',
|
|
411
|
+
{ component: 'Navbar.Start', converts: true, tag: 'div', tags: ['div'] },
|
|
412
|
+
],
|
|
413
|
+
[
|
|
414
|
+
'navbar-end',
|
|
415
|
+
{ component: 'Navbar.End', converts: true, tag: 'div', tags: ['div'] },
|
|
416
|
+
],
|
|
417
|
+
[
|
|
418
|
+
'navbar-item',
|
|
419
|
+
{ component: 'Navbar.Item', converts: true, tag: 'a', tags: 'any' },
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
'navbar-dropdown',
|
|
423
|
+
{
|
|
424
|
+
component: 'Navbar.DropdownMenu',
|
|
425
|
+
converts: true,
|
|
426
|
+
tag: 'div',
|
|
427
|
+
tags: ['div'],
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
[
|
|
431
|
+
'navbar-divider',
|
|
432
|
+
{ component: 'Navbar.Divider', converts: true, tag: 'hr', tags: ['hr'] },
|
|
433
|
+
],
|
|
434
|
+
[
|
|
435
|
+
'field',
|
|
436
|
+
{ component: 'Field', converts: true, tag: 'div', tags: ['div'] },
|
|
437
|
+
],
|
|
438
|
+
[
|
|
439
|
+
'field-label',
|
|
440
|
+
{ component: 'Field.Label', converts: true, tag: 'div', tags: ['div'] },
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
'field-body',
|
|
444
|
+
{ component: 'Field.Body', converts: true, tag: 'div', tags: ['div'] },
|
|
445
|
+
],
|
|
446
|
+
[
|
|
447
|
+
'control',
|
|
448
|
+
{ component: 'Control', converts: true, tag: 'div', tags: ['div', 'p'] },
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
'input',
|
|
452
|
+
{ component: 'InputBase', converts: true, tag: 'input', tags: ['input'] },
|
|
453
|
+
],
|
|
454
|
+
[
|
|
455
|
+
'textarea',
|
|
456
|
+
{
|
|
457
|
+
component: 'TextAreaBase',
|
|
458
|
+
converts: true,
|
|
459
|
+
tag: 'textarea',
|
|
460
|
+
tags: ['textarea'],
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
'buttons',
|
|
465
|
+
{ component: 'Buttons', converts: true, tag: 'div', tags: ['div'] },
|
|
466
|
+
],
|
|
467
|
+
['tags', { component: 'Tags', converts: true, tag: 'div', tags: ['div'] }],
|
|
468
|
+
[
|
|
469
|
+
'button',
|
|
470
|
+
{ component: 'Button', converts: true, tag: 'button', tags: 'any' },
|
|
471
|
+
],
|
|
472
|
+
['tag', { component: 'Tag', converts: true, tag: 'span', tags: ['span'] }],
|
|
473
|
+
[
|
|
474
|
+
'delete',
|
|
475
|
+
{ component: 'Delete', converts: true, tag: 'button', tags: ['button'] },
|
|
476
|
+
],
|
|
477
|
+
[
|
|
478
|
+
'progress',
|
|
479
|
+
{
|
|
480
|
+
component: 'Progress',
|
|
481
|
+
converts: true,
|
|
482
|
+
tag: 'progress',
|
|
483
|
+
tags: ['progress'],
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
[
|
|
487
|
+
'table',
|
|
488
|
+
{ component: 'Table', converts: true, tag: 'table', tags: ['table'] },
|
|
489
|
+
],
|
|
490
|
+
[
|
|
491
|
+
'title',
|
|
492
|
+
{
|
|
493
|
+
component: 'Title',
|
|
494
|
+
converts: true,
|
|
495
|
+
tag: 'h1',
|
|
496
|
+
tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'],
|
|
497
|
+
retags: {
|
|
498
|
+
'is-1': { tag: 'h1', on: ['h1', 'p'] },
|
|
499
|
+
'is-2': { tag: 'h2', on: ['h2', 'p'] },
|
|
500
|
+
'is-3': { tag: 'h3', on: ['h3', 'p'] },
|
|
501
|
+
'is-4': { tag: 'h4', on: ['h4', 'p'] },
|
|
502
|
+
'is-5': { tag: 'h5', on: ['h5', 'p'] },
|
|
503
|
+
'is-6': { tag: 'h6', on: ['h6', 'p'] },
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
[
|
|
508
|
+
'subtitle',
|
|
509
|
+
{
|
|
510
|
+
component: 'SubTitle',
|
|
511
|
+
converts: true,
|
|
512
|
+
tag: 'h1',
|
|
513
|
+
tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'],
|
|
514
|
+
retags: {
|
|
515
|
+
'is-1': { tag: 'h1', on: ['h1', 'p'] },
|
|
516
|
+
'is-2': { tag: 'h2', on: ['h2', 'p'] },
|
|
517
|
+
'is-3': { tag: 'h3', on: ['h3', 'p'] },
|
|
518
|
+
'is-4': { tag: 'h4', on: ['h4', 'p'] },
|
|
519
|
+
'is-5': { tag: 'h5', on: ['h5', 'p'] },
|
|
520
|
+
'is-6': { tag: 'h6', on: ['h6', 'p'] },
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
],
|
|
524
|
+
[
|
|
525
|
+
'notification',
|
|
526
|
+
{ component: 'Notification', converts: true, tag: 'div', tags: ['div'] },
|
|
527
|
+
],
|
|
528
|
+
['box', { component: 'Box', converts: true, tag: 'div', tags: ['div'] }],
|
|
529
|
+
[
|
|
530
|
+
'content',
|
|
531
|
+
{ component: 'Content', converts: true, tag: 'div', tags: ['div'] },
|
|
532
|
+
],
|
|
533
|
+
[
|
|
534
|
+
'block',
|
|
535
|
+
{ component: 'Block', converts: true, tag: 'div', tags: ['div'] },
|
|
536
|
+
],
|
|
537
|
+
[
|
|
538
|
+
'select',
|
|
539
|
+
{ component: 'SelectBase', converts: true, tag: 'div', tags: ['div'] },
|
|
540
|
+
],
|
|
541
|
+
[
|
|
542
|
+
'breadcrumb',
|
|
543
|
+
{ component: 'Breadcrumb', converts: true, tag: 'nav', tags: ['nav'] },
|
|
544
|
+
],
|
|
545
|
+
[
|
|
546
|
+
'skeleton-block',
|
|
547
|
+
{ component: 'Skeleton', converts: true, tag: 'div', tags: ['div'] },
|
|
548
|
+
],
|
|
549
|
+
[
|
|
550
|
+
'skeleton-lines',
|
|
551
|
+
{ component: 'Skeleton', converts: true, tag: 'div', tags: ['div'] },
|
|
552
|
+
],
|
|
553
|
+
['file', { component: 'File', converts: true, tag: 'div', tags: ['div'] }],
|
|
554
|
+
[
|
|
555
|
+
'icon',
|
|
556
|
+
{ component: 'Icon', converts: true, tag: 'span', tags: ['span'] },
|
|
557
|
+
],
|
|
558
|
+
[
|
|
559
|
+
'icon-text',
|
|
560
|
+
{ component: 'IconText', converts: true, tag: 'span', tags: ['span'] },
|
|
561
|
+
],
|
|
562
|
+
[
|
|
563
|
+
'image',
|
|
564
|
+
{
|
|
565
|
+
component: 'Image',
|
|
566
|
+
converts: true,
|
|
567
|
+
tag: 'div',
|
|
568
|
+
tags: ['div', 'figure', 'p'],
|
|
569
|
+
retags: {
|
|
570
|
+
'is-16x16': { tag: null },
|
|
571
|
+
'is-24x24': { tag: null },
|
|
572
|
+
'is-32x32': { tag: null },
|
|
573
|
+
'is-48x48': { tag: null },
|
|
574
|
+
'is-64x64': { tag: null },
|
|
575
|
+
'is-96x96': { tag: null },
|
|
576
|
+
'is-128x128': { tag: null },
|
|
577
|
+
'is-square': { tag: null },
|
|
578
|
+
'is-1by1': { tag: 'figure' },
|
|
579
|
+
'is-5by4': { tag: 'figure' },
|
|
580
|
+
'is-4by3': { tag: 'figure' },
|
|
581
|
+
'is-3by2': { tag: 'figure' },
|
|
582
|
+
'is-5by3': { tag: 'figure' },
|
|
583
|
+
'is-16by9': { tag: 'figure' },
|
|
584
|
+
'is-2by1': { tag: 'figure' },
|
|
585
|
+
'is-3by1': { tag: 'figure' },
|
|
586
|
+
'is-4by5': { tag: 'figure' },
|
|
587
|
+
'is-3by4': { tag: 'figure' },
|
|
588
|
+
'is-2by3': { tag: 'figure' },
|
|
589
|
+
'is-3by5': { tag: 'figure' },
|
|
590
|
+
'is-9by16': { tag: 'figure' },
|
|
591
|
+
'is-1by2': { tag: 'figure' },
|
|
592
|
+
'is-1by3': { tag: 'figure' },
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
],
|
|
596
|
+
[
|
|
597
|
+
'menu',
|
|
598
|
+
{ component: 'Menu', converts: true, tag: 'aside', tags: ['aside'] },
|
|
599
|
+
],
|
|
600
|
+
[
|
|
601
|
+
'menu-label',
|
|
602
|
+
{ component: 'Menu.Label', converts: true, tag: 'p', tags: ['p'] },
|
|
603
|
+
],
|
|
604
|
+
[
|
|
605
|
+
'menu-list',
|
|
606
|
+
{ component: 'Menu.List', converts: true, tag: 'ul', tags: ['ul'] },
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
'modal-background',
|
|
610
|
+
{
|
|
611
|
+
component: 'Modal.Background',
|
|
612
|
+
converts: true,
|
|
613
|
+
tag: 'div',
|
|
614
|
+
tags: ['div'],
|
|
615
|
+
},
|
|
616
|
+
],
|
|
617
|
+
[
|
|
618
|
+
'modal-content',
|
|
619
|
+
{ component: 'Modal.Content', converts: true, tag: 'div', tags: ['div'] },
|
|
620
|
+
],
|
|
621
|
+
[
|
|
622
|
+
'modal-card',
|
|
623
|
+
{ component: 'Modal.Card', converts: true, tag: 'div', tags: ['div'] },
|
|
624
|
+
],
|
|
625
|
+
[
|
|
626
|
+
'modal-card-head',
|
|
627
|
+
{
|
|
628
|
+
component: 'Modal.Card.Head',
|
|
629
|
+
converts: true,
|
|
630
|
+
tag: 'header',
|
|
631
|
+
tags: ['header'],
|
|
632
|
+
},
|
|
633
|
+
],
|
|
634
|
+
[
|
|
635
|
+
'modal-card-title',
|
|
636
|
+
{ component: 'Modal.Card.Title', converts: true, tag: 'p', tags: ['p'] },
|
|
637
|
+
],
|
|
638
|
+
[
|
|
639
|
+
'modal-card-body',
|
|
640
|
+
{
|
|
641
|
+
component: 'Modal.Card.Body',
|
|
642
|
+
converts: true,
|
|
643
|
+
tag: 'section',
|
|
644
|
+
tags: ['section'],
|
|
645
|
+
},
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
'modal-card-foot',
|
|
649
|
+
{
|
|
650
|
+
component: 'Modal.Card.Foot',
|
|
651
|
+
converts: true,
|
|
652
|
+
tag: 'footer',
|
|
653
|
+
tags: ['footer'],
|
|
654
|
+
},
|
|
655
|
+
],
|
|
656
|
+
[
|
|
657
|
+
'pagination',
|
|
658
|
+
{ component: 'Pagination', converts: true, tag: 'nav', tags: ['nav'] },
|
|
659
|
+
],
|
|
660
|
+
[
|
|
661
|
+
'pagination-list',
|
|
662
|
+
{ component: 'Pagination.List', converts: true, tag: 'ul', tags: ['ul'] },
|
|
663
|
+
],
|
|
257
664
|
[
|
|
258
665
|
'pagination-previous',
|
|
259
|
-
{
|
|
666
|
+
{
|
|
667
|
+
component: 'Pagination.Previous',
|
|
668
|
+
converts: true,
|
|
669
|
+
tag: 'a',
|
|
670
|
+
tags: ['a'],
|
|
671
|
+
},
|
|
672
|
+
],
|
|
673
|
+
[
|
|
674
|
+
'pagination-next',
|
|
675
|
+
{ component: 'Pagination.Next', converts: true, tag: 'a', tags: ['a'] },
|
|
676
|
+
],
|
|
677
|
+
[
|
|
678
|
+
'pagination-link',
|
|
679
|
+
{ component: 'Pagination.Link', converts: true, tag: 'a', tags: ['a'] },
|
|
260
680
|
],
|
|
261
|
-
['pagination-next', { component: 'Pagination.Next', converts: true }],
|
|
262
|
-
['pagination-link', { component: 'Pagination.Link', converts: true }],
|
|
263
681
|
[
|
|
264
682
|
'pagination-ellipsis',
|
|
265
|
-
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
[
|
|
273
|
-
|
|
683
|
+
{
|
|
684
|
+
component: 'Pagination.Ellipsis',
|
|
685
|
+
converts: true,
|
|
686
|
+
tag: 'span',
|
|
687
|
+
tags: ['span'],
|
|
688
|
+
},
|
|
689
|
+
],
|
|
690
|
+
[
|
|
691
|
+
'panel',
|
|
692
|
+
{
|
|
693
|
+
component: 'Panel',
|
|
694
|
+
converts: true,
|
|
695
|
+
tag: 'nav',
|
|
696
|
+
tags: ['nav', 'article', 'section', 'aside', 'div'],
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
[
|
|
700
|
+
'panel-heading',
|
|
701
|
+
{ component: 'Panel.Heading', converts: true, tag: 'p', tags: ['p'] },
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
'panel-tabs',
|
|
705
|
+
{ component: 'Panel.Tabs', converts: true, tag: 'p', tags: ['p'] },
|
|
706
|
+
],
|
|
707
|
+
[
|
|
708
|
+
'panel-block',
|
|
709
|
+
{
|
|
710
|
+
component: 'Panel.Block',
|
|
711
|
+
converts: true,
|
|
712
|
+
tag: 'a',
|
|
713
|
+
tags: ['a', 'div', 'label'],
|
|
714
|
+
},
|
|
715
|
+
],
|
|
716
|
+
['tabs', { component: 'Tabs', converts: true, tag: 'div', tags: ['div'] }],
|
|
717
|
+
[
|
|
718
|
+
'table-container',
|
|
719
|
+
{ component: 'Table', converts: true, tag: 'div', tags: ['div'] },
|
|
720
|
+
],
|
|
721
|
+
[
|
|
722
|
+
'fixed-grid',
|
|
723
|
+
{ component: 'Grid', converts: true, tag: 'div', tags: ['div'] },
|
|
724
|
+
],
|
|
274
725
|
]);
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Report a plain element styled with a Bulma class bestax has a component
|
|
3
|
-
* for: `<button className="button is-primary">` is bestax `Button`.
|
|
3
|
+
* for: `<button className="button is-primary">` is bestax `Button`. And
|
|
4
|
+
* report that class in the `className` of a bestax component that renders
|
|
5
|
+
* another one: `<Columns className="box">` keeps a raw `.box` that bestax
|
|
6
|
+
* renders as `Box`.
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Plain elements are read whatever the file imports: a lowercase tag is
|
|
9
|
+
* plain HTML. A custom element (`<my-card>`) and anything inside `<svg>` or
|
|
10
|
+
* `<math>` are not HTML, so both are left alone. A capitalised tag is read
|
|
11
|
+
* only when it resolves, through the import and through scope, to a bestax
|
|
12
|
+
* component the class table names, which are the ones the codemod writes and
|
|
13
|
+
* whose own classes the table knows. A class that is that component's own
|
|
14
|
+
* (`<Box className="box">`) is not reported. Any other component is left
|
|
15
|
+
* alone, since the table can't say which classes it renders itself.
|
|
10
16
|
*
|
|
11
17
|
* OPT-IN, like `no-color-as-surface`: the markup works, and this rule is a
|
|
12
18
|
* preference for the component over the class. It is for an app that has
|
|
@@ -23,7 +29,13 @@
|
|
|
23
29
|
* bestax renders only inside a component (`.label`, `.help`), nor the parts
|
|
24
30
|
* of a family, since the family's own class is reported where it sits. An
|
|
25
31
|
* element carrying several is reported once, for the class the codemod
|
|
26
|
-
* would decide by
|
|
32
|
+
* would decide by: a family first, else, on a plain element, the one whose
|
|
33
|
+
* component fits its tag best (the tag it renders with the element's classes
|
|
34
|
+
* and no `as`, then one `as` reaches), the first in the table's order among
|
|
35
|
+
* equals. A class beside a root can pick that tag (`retags`): an `.image`
|
|
36
|
+
* ratio puts `Image` on a <figure>, so on a <div> it fits only through `as`.
|
|
37
|
+
* On a bestax component, whose tag can come from `as`, the table's order
|
|
38
|
+
* decides.
|
|
27
39
|
*
|
|
28
40
|
* A spread does not silence it: the report is about the class the author
|
|
29
41
|
* wrote, which is there whether or not a spread later replaces it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-bulma-component-class.d.ts","sourceRoot":"","sources":["../../src/rules/no-bulma-component-class.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"no-bulma-component-class.d.ts","sourceRoot":"","sources":["../../src/rules/no-bulma-component-class.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AA8GnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAyEhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { BULMA_COMPONENT_CLASSES } from '../generated/metadata.js';
|
|
2
|
-
import { attributesOf, classJoinerAt, classNameTokens, namedAttr, } from '../lib/elements.js';
|
|
1
|
+
import { BULMA_COMPONENT_CLASSES, } from '../generated/metadata.js';
|
|
2
|
+
import { attributesOf, classJoinerAt, classNameTokens, elementOf, namedAttr, withImports, } from '../lib/elements.js';
|
|
3
3
|
/** A lowercase HTML tag: not a component, not a custom element. */
|
|
4
4
|
const INTRINSIC = /^[a-z][a-z0-9]*$/;
|
|
5
5
|
/** Subtrees whose tags are not HTML. */
|
|
6
6
|
const FOREIGN = new Set(['svg', 'math']);
|
|
7
|
+
/** The components the table names, whose own classes it knows. */
|
|
8
|
+
const COMPONENTS = new Set([...BULMA_COMPONENT_CLASSES.values()].map(entry => entry.component));
|
|
7
9
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
10
|
function tagOf(opening) {
|
|
9
11
|
const name = opening?.name;
|
|
@@ -17,6 +19,54 @@ function insideForeign(ancestors) {
|
|
|
17
19
|
FOREIGN.has(tagOf(ancestor.openingElement) ?? ''));
|
|
18
20
|
}
|
|
19
21
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
22
|
+
/**
|
|
23
|
+
* The tag the class's component renders on `tag` with these classes and no
|
|
24
|
+
* `as`: the one the first class beside it that decides it picks, on a tag it
|
|
25
|
+
* converts on (`.image.is-16by9` a <figure>), else its own.
|
|
26
|
+
*/
|
|
27
|
+
function rendersWith(entry, tag, tokens) {
|
|
28
|
+
for (const token of tokens) {
|
|
29
|
+
const retag = entry.retags && Object.hasOwn(entry.retags, token)
|
|
30
|
+
? entry.retags[token]
|
|
31
|
+
: undefined;
|
|
32
|
+
if (retag && (!retag.on || retag.on.includes(tag))) {
|
|
33
|
+
return retag.tag ?? entry.tag;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return entry.tag;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How well the class's component fits this tag: 2 for the tag it renders
|
|
40
|
+
* with these classes and no `as`, 1 for one it renders through `as`, 0 for
|
|
41
|
+
* neither.
|
|
42
|
+
*/
|
|
43
|
+
function fit(entry, tag, tokens) {
|
|
44
|
+
if (tag === null)
|
|
45
|
+
return 0;
|
|
46
|
+
if (rendersWith(entry, tag, tokens) === tag)
|
|
47
|
+
return 2;
|
|
48
|
+
return entry.tags === 'any' || entry.tags?.includes(tag) ? 1 : 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The class the codemod decides by, among the ones in `tokens` that `keep`
|
|
52
|
+
* allows: the first family class in the order the element carries them, else
|
|
53
|
+
* the one whose component fits `tag` best, the first in the table's order
|
|
54
|
+
* among equals.
|
|
55
|
+
*/
|
|
56
|
+
function decidingClass(tokens, tag, keep = () => true) {
|
|
57
|
+
const family = tokens.find(token => {
|
|
58
|
+
const entry = BULMA_COMPONENT_CLASSES.get(token);
|
|
59
|
+
return entry?.converts === false && keep(entry);
|
|
60
|
+
});
|
|
61
|
+
if (family !== undefined)
|
|
62
|
+
return family;
|
|
63
|
+
const carried = [...BULMA_COMPONENT_CLASSES].filter(([key, entry]) => tokens.includes(key) && keep(entry));
|
|
64
|
+
const best = carried.reduce((found, candidate) => found === undefined ||
|
|
65
|
+
fit(candidate[1], tag, tokens) > fit(found[1], tag, tokens)
|
|
66
|
+
? candidate
|
|
67
|
+
: found, undefined);
|
|
68
|
+
return best?.[0];
|
|
69
|
+
}
|
|
20
70
|
const rule = {
|
|
21
71
|
meta: {
|
|
22
72
|
type: 'suggestion',
|
|
@@ -28,28 +78,53 @@ const rule = {
|
|
|
28
78
|
messages: {
|
|
29
79
|
converts: "`<{{tag}}>` is styled with Bulma's `.{{cls}}`, which bestax renders as `{{component}}`. `bestax-migrate bulma-classes` converts elements like this one where the markup allows.",
|
|
30
80
|
family: "`<{{tag}}>` is styled with Bulma's `.{{cls}}`, and bestax has `{{component}}` for it. `bestax-migrate bulma-classes` leaves this markup for you to convert by hand.",
|
|
81
|
+
alsoConverts: "`<{{element}}>` also carries Bulma's `.{{cls}}`, which bestax renders as `{{component}}`, and an element renders one component. {{advice}}.",
|
|
82
|
+
alsoFamily: "`<{{element}}>` also carries Bulma's `.{{cls}}`, and bestax has `{{component}}` for it, which renders markup of its own. Convert that markup to `{{component}}` by hand, and drop the class.",
|
|
31
83
|
},
|
|
32
84
|
},
|
|
33
85
|
create(context) {
|
|
86
|
+
const { imports, visitor } = withImports();
|
|
34
87
|
return {
|
|
88
|
+
...visitor,
|
|
35
89
|
JSXOpeningElement(node) {
|
|
36
90
|
const tag = tagOf(node);
|
|
37
|
-
if (tag === null || FOREIGN.has(tag))
|
|
38
|
-
return;
|
|
39
91
|
// The cheap check first: most elements carry no className at all.
|
|
40
92
|
const attr = namedAttr(attributesOf(node), 'className');
|
|
41
93
|
if (!attr)
|
|
42
94
|
return;
|
|
95
|
+
// Nothing inside <svg> or <math> is HTML, a component's element
|
|
96
|
+
// included.
|
|
97
|
+
if (tag !== null && FOREIGN.has(tag))
|
|
98
|
+
return;
|
|
43
99
|
if (insideForeign(context.sourceCode.getAncestors(node))) {
|
|
44
100
|
return;
|
|
45
101
|
}
|
|
102
|
+
if (tag === null) {
|
|
103
|
+
const name = elementOf(context, node, imports);
|
|
104
|
+
if (name === null || !COMPONENTS.has(name))
|
|
105
|
+
return;
|
|
106
|
+
const tokens = [
|
|
107
|
+
...classNameTokens(attr, classJoinerAt(context, node)),
|
|
108
|
+
];
|
|
109
|
+
const cls = decidingClass(tokens,
|
|
110
|
+
// No tag to fit: a component's can come from `as`, so the
|
|
111
|
+
// table's order decides here.
|
|
112
|
+
null, entry => entry.component !== name);
|
|
113
|
+
if (cls === undefined)
|
|
114
|
+
return;
|
|
115
|
+
const entry = BULMA_COMPONENT_CLASSES.get(cls);
|
|
116
|
+
const advice = entry.onAnother
|
|
117
|
+
? entry.onAnother.charAt(0).toUpperCase() + entry.onAnother.slice(1)
|
|
118
|
+
: `Give \`${entry.component}\` an element of its own around or inside this one and drop the class, then check the layout`;
|
|
119
|
+
context.report({
|
|
120
|
+
node: attr,
|
|
121
|
+
messageId: entry.converts ? 'alsoConverts' : 'alsoFamily',
|
|
122
|
+
data: { element: name, cls, component: entry.component, advice },
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
46
126
|
const tokens = [...classNameTokens(attr, classJoinerAt(context, node))];
|
|
47
|
-
|
|
48
|
-
// order the element carries them, else the converted root it ranks
|
|
49
|
-
// first, which is the table's own order.
|
|
50
|
-
const family = tokens.find(token => BULMA_COMPONENT_CLASSES.get(token)?.converts === false);
|
|
51
|
-
const cls = family ??
|
|
52
|
-
[...BULMA_COMPONENT_CLASSES.keys()].find(key => tokens.includes(key));
|
|
127
|
+
const cls = decidingClass(tokens, tag);
|
|
53
128
|
if (cls === undefined)
|
|
54
129
|
return;
|
|
55
130
|
const entry = BULMA_COMPONENT_CLASSES.get(cls);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allxsmith/eslint-plugin-bestax",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "ESLint rules for @allxsmith/bestax-bulma — catches helper-prop values the library silently drops, deprecated props, and the color-as-surface mistake",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"url": "https://github.com/allxsmith/bestax/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@allxsmith/bestax-bulma": "^5.
|
|
44
|
+
"@allxsmith/bestax-bulma": "^5.41.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"eslint": "^10.0.0"
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@jest/globals": "^30.0.0",
|
|
51
51
|
"@types/jest": "^30.0.0",
|
|
52
|
-
"@types/node": "^26.
|
|
53
|
-
"@typescript-eslint/parser": "^8.
|
|
54
|
-
"eslint": "^10.
|
|
52
|
+
"@types/node": "^26.6.4",
|
|
53
|
+
"@typescript-eslint/parser": "^8.71.1",
|
|
54
|
+
"eslint": "^10.12.0",
|
|
55
55
|
"jest": "^30.2.0",
|
|
56
|
-
"ts-jest": "^29.4.
|
|
56
|
+
"ts-jest": "^29.4.14",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"clean": "rimraf dist",
|
|
73
73
|
"release": "npx semantic-release"
|
|
74
74
|
},
|
|
75
|
-
"readme": "# @allxsmith/eslint-plugin-bestax\n\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)\n[](https://opensource.org/licenses/MIT)\n[](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)\n[](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)\n[](https://www.bestpractices.dev/projects/14361)\n[](https://github.com/allxsmith/bestax/blob/main/SECURITY.md)\n\nESLint rules for [`@allxsmith/bestax-bulma`](https://www.npmjs.com/package/@allxsmith/bestax-bulma).\n\nEvery rule here reports code that does not do what it looks like it does. The\nlibrary's helper props validate by membership and emit nothing for a value they\ndo not recognise, with no throw and no warning, so `textColor=\"blue\"` renders\nnothing and says nothing.\n\n**Scope, up front:** the helper props are typed as literal unions, so if you\nwrite bestax in `.tsx` and run `tsc`, it already catches a wrong literal. This\nplugin is for the places that check does not reach: JavaScript and JSX\nprojects, and lint stages that run before or instead of typechecking. The deprecation and flex rules are additive everywhere, since\nno type error marks a deprecated prop or a flex prop that emits nothing.\n\n## Requirements\n\nESLint 10, using [flat config](https://eslint.org/docs/latest/use/configure/configuration-files).\nThe plugin is ESM-only, which does not rule out a CommonJS config. An\n`eslint.config.cjs` can `require()` it on a Node that supports `require(esm)`,\nand `configs.recommended` reads straight off the result with no interop hop,\nbecause `rules` and `configs` are named exports alongside the default. On a\nNode without that support it throws `ERR_REQUIRE_ESM`, and an `import` from\n`eslint.config.mjs` works either way.\n\n## Setup\n\n```bash\nnpm install --save-dev @allxsmith/eslint-plugin-bestax\n```\n\n### TypeScript\n\nThe preset sets no `parser`, so a TypeScript parser has to come from a config\nobject of your own. Put it first; the preset after:\n\n```js\n// eslint.config.js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\nimport parser from '@typescript-eslint/parser';\n\nexport default [\n { files: ['**/*.{ts,tsx}'], languageOptions: { parser } },\n bestax.configs.recommended,\n];\n```\n\nAny TypeScript setup that sets a parser works the same way, `typescript-eslint`\nincluded, precisely because the preset does not set one of its own.\n\nThe parser is a requirement, not a nicety. The preset matches `.tsx` because\nthat is where a TypeScript project's JSX lives, and with no parser supplied it\nhands that file to the default one, which stops at the first type annotation:\n`Parsing error: The keyword 'interface' is reserved`.\n\n### JavaScript and JSX\n\nIf the project contains no `.tsx` at all, the preset alone is enough:\n\n```js\n// eslint.config.js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\n\nexport default [bestax.configs.recommended];\n```\n\nAdd one `.tsx` file later and you need the parser block above. The failure is\nloud rather than silent, which is the intended trade: leaving `.tsx` out of the\npreset's own `files` would mean a TypeScript project got no rules on any `.tsx`\nfile and no indication why.\n\n### Picking rules yourself\n\n`files` is load-bearing: a flat config object without it inherits ESLint's\ndefault `**/*.{js,mjs,cjs}` set, so leaving it out silently lints none of your\nJSX.\n\n```js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\n\nexport default [\n {\n files: ['**/*.{jsx,tsx}'],\n plugins: { '@allxsmith/bestax': bestax },\n languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },\n rules: {\n '@allxsmith/bestax/valid-helper-value': 'error',\n '@allxsmith/bestax/no-deprecated-props': 'warn',\n },\n },\n];\n```\n\n## Rules\n\nIn `recommended` — each reports code that does not do what it says:\n\n| Rule | Fixable | What it catches |\n| --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |\n| `valid-helper-value` | — | Helper values the library silently drops: `textAlign=\"center\"` (it is `centered`), `textSize=\"8\"`, `mt=\"1rem\"` |\n| `no-deprecated-props` | partly | Props the library deprecated: `isFullWidth`, `gapSize*`, `icon`. Fixes only the renames that cannot change what renders |\n| `no-inert-flex-props` | — | `justifyContent` and friends without a flex `display`, which emit nothing |\n\nOpt-in — these report code that works, and buy explicitness instead:\n\n| Rule | Fixable | What it asks for |\n| -------------------------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |\n| `no-bulma-component-class` | — | The bestax component instead of a plain element styled with its Bulma class (`<button className=\"button\">`) |\n\nThe rules that judge bestax elements resolve them through the import and\nthrough scope, so neither your own `<Box>` nor a local shadowing the imported\none is linted against Bulma's rules, and each skips a value it cannot read as a\nliteral. `no-bulma-component-class` reads plain HTML elements instead, and\nleaves components, custom elements and anything inside `<svg>` alone.\n\nA spread is handled by what it can change: `no-color-as-surface` and\n`no-inert-flex-props` go silent, since a spread may carry the prop that makes\nthe code correct; `no-deprecated-props` reports but offers no fix; and\n`valid-helper-value` judges only the values that actually render, so a spread\nBEFORE the attribute leaves it reporting and a spread after it does not: JSX is\nlast-wins throughout, spreads included. `no-bulma-component-class` reports\neither way, since the class is written right there. No autofix changes what the\ncode renders.\n\n### valid-helper-value\n\n```jsx\n<Box textAlign=\"center\" /> // ✗ not a value textAlign accepts. Did you mean `centered`?\n<Box textAlign=\"centered\" /> // ✓\n```\n\nThe valid values come from the library's own exported tuples at lint time, by\nway of its `/constants` subpath, rather than from a list copied into this\npackage. The version those tuples come from is the copy of\n`@allxsmith/bestax-bulma` this plugin resolves, which in an ordinary deduped\ninstall is the same one your app uses; across a major bump it may not be, so\nkeep the two in step.\n\nOne family is outside its reach, knowingly: component-specific `color` props\nhave their own unions, so `<Button color=\"ghost\">` is correct and reporting it\nwould be worse than reporting nothing.\n\n`radius` and `columnGap` on `Theme` are the helpers, as everywhere else, but a\nstring outside their values still sets `--bulma-radius` or `--bulma-column-gap`\nthere through a deprecated route. The rule reports it with a message that says\nso and points at `bulmaVars`, unless it is a near miss of one of the values,\nwhich gets the usual suggestion:\n\n```jsx\n<Theme radius=\"6px\" /> // ✗ deprecated → bulmaVars\n<Theme radius=\"radiusles\" /> // ✗ Did you mean `radiusless`?\n<Theme bulmaVars={{ '--bulma-radius': '6px' }} /> // ✓\n<Theme columnGap=\"1rem\" /> // ✗ deprecated → bulmaVars\n<Theme bulmaVars={{ '--bulma-column-gap': '1rem' }} /> // ✓\n```\n\nThe gap props take their steps as numbers as well, so `<Box gap={2} />` is\naccepted where `<Box m={2} />` is reported.\n\n### no-deprecated-props\n\n```jsx\n<Button isFullWidth /> // ✗ deprecated → fixes to isFullwidth\n<Tabs color=\"info\" /> // ✗ no .tabs.is-<color> CSS exists; no fix offered\n```\n\nThe table is generated from the library's own TSDoc, so a rename lands here\nwith the library rather than after someone notices.\n\n### no-color-as-surface\n\nOff by default. `color` on the content elements is a documented alias for\n`textColor`, so this rule is about saying which you meant, not about broken\ncode.\n\n```jsx\n<Box color=\"primary\" /> // ✗ ambiguous → fixes to textColor\n<Box bgColor=\"primary\" /> // ✓ a coloured surface\n<Button color=\"primary\" /> // ✓ Button really has an is-primary variant\n\n// ✓ silent: the background is explicit, so `color` is plainly the text half\n<Box bgColor=\"info\" color=\"primary\" />\n```\n\n### no-bulma-component-class\n\nOff by default. It reports a plain element styled with a Bulma class that\nbestax has a component for, and names the component. Turn it on in an app that\nhas moved onto bestax, with `bestax-migrate bulma-classes` or by hand, to keep\nraw Bulma markup from coming back.\n\n```jsx\n<button className=\"button is-primary\" /> // ✗ bestax renders .button as Button\n<div className=\"dropdown\" /> // ✗ bestax has Dropdown, converted by hand\n<div className=\"has-text-centered mt-4\" /> // ✓ helper classes are left alone\n<p className=\"help\" /> // ✓ bestax renders .help inside its form controls\n```\n\nIt reads the classes a `className` spells out, including the strings in a\nternary, a template, or a call to `clsx`, `classnames` or `tailwind-merge`\n(however the file imports or requires it), and reports one class per element:\nthe one the codemod would decide by. A function your app defines, a `cn` in `lib/utils`\nincluded, is one it cannot see into, so it reads nothing there. It only reports. Whether an element converts\ndepends on its tag, attributes and children, and `bestax-migrate bulma-classes`\nis the one place that judges that.\n\n### no-inert-flex-props\n\n```jsx\n<Box justifyContent=\"center\" /> // ✗ emits nothing\n<Box display=\"flex\" justifyContent=\"center\" /> // ✓\n<Box flexGrow=\"1\" /> // ✓ child props always apply\n```\n\n## Links\n\n- [Documentation](https://bestax.io/docs/guides/getting-started/eslint-plugin)\n- [Component library](https://www.npmjs.com/package/@allxsmith/bestax-bulma)\n- [Repository](https://github.com/allxsmith/bestax)\n\n## License\n\nMIT\n"
|
|
75
|
+
"readme": "# @allxsmith/eslint-plugin-bestax\n\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)\n[](https://opensource.org/licenses/MIT)\n[](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)\n[](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)\n[](https://www.bestpractices.dev/projects/14361)\n[](https://github.com/allxsmith/bestax/blob/main/SECURITY.md)\n\nESLint rules for [`@allxsmith/bestax-bulma`](https://www.npmjs.com/package/@allxsmith/bestax-bulma).\n\nEvery rule here reports code that does not do what it looks like it does. The\nlibrary's helper props validate by membership and emit nothing for a value they\ndo not recognise, with no throw and no warning, so `textColor=\"blue\"` renders\nnothing and says nothing.\n\n**Scope, up front:** the helper props are typed as literal unions, so if you\nwrite bestax in `.tsx` and run `tsc`, it already catches a wrong literal. This\nplugin is for the places that check does not reach: JavaScript and JSX\nprojects, and lint stages that run before or instead of typechecking. The deprecation and flex rules are additive everywhere, since\nno type error marks a deprecated prop or a flex prop that emits nothing.\n\n## Requirements\n\nESLint 10, using [flat config](https://eslint.org/docs/latest/use/configure/configuration-files).\nThe plugin is ESM-only, which does not rule out a CommonJS config. An\n`eslint.config.cjs` can `require()` it on a Node that supports `require(esm)`,\nand `configs.recommended` reads straight off the result with no interop hop,\nbecause `rules` and `configs` are named exports alongside the default. On a\nNode without that support it throws `ERR_REQUIRE_ESM`, and an `import` from\n`eslint.config.mjs` works either way.\n\n## Setup\n\n```bash\nnpm install --save-dev @allxsmith/eslint-plugin-bestax\n```\n\n### TypeScript\n\nThe preset sets no `parser`, so a TypeScript parser has to come from a config\nobject of your own. Put it first; the preset after:\n\n```js\n// eslint.config.js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\nimport parser from '@typescript-eslint/parser';\n\nexport default [\n { files: ['**/*.{ts,tsx}'], languageOptions: { parser } },\n bestax.configs.recommended,\n];\n```\n\nAny TypeScript setup that sets a parser works the same way, `typescript-eslint`\nincluded, precisely because the preset does not set one of its own.\n\nThe parser is a requirement, not a nicety. The preset matches `.tsx` because\nthat is where a TypeScript project's JSX lives, and with no parser supplied it\nhands that file to the default one, which stops at the first type annotation:\n`Parsing error: The keyword 'interface' is reserved`.\n\n### JavaScript and JSX\n\nIf the project contains no `.tsx` at all, the preset alone is enough:\n\n```js\n// eslint.config.js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\n\nexport default [bestax.configs.recommended];\n```\n\nAdd one `.tsx` file later and you need the parser block above. The failure is\nloud rather than silent, which is the intended trade: leaving `.tsx` out of the\npreset's own `files` would mean a TypeScript project got no rules on any `.tsx`\nfile and no indication why.\n\n### Picking rules yourself\n\n`files` is load-bearing: a flat config object without it inherits ESLint's\ndefault `**/*.{js,mjs,cjs}` set, so leaving it out silently lints none of your\nJSX.\n\n```js\nimport bestax from '@allxsmith/eslint-plugin-bestax';\n\nexport default [\n {\n files: ['**/*.{jsx,tsx}'],\n plugins: { '@allxsmith/bestax': bestax },\n languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },\n rules: {\n '@allxsmith/bestax/valid-helper-value': 'error',\n '@allxsmith/bestax/no-deprecated-props': 'warn',\n },\n },\n];\n```\n\n## Rules\n\nIn `recommended` — each reports code that does not do what it says:\n\n| Rule | Fixable | What it catches |\n| --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |\n| `valid-helper-value` | — | Helper values the library silently drops: `textAlign=\"center\"` (it is `centered`), `textSize=\"8\"`, `mt=\"1rem\"` |\n| `no-deprecated-props` | partly | Props the library deprecated: `isFullWidth`, `gapSize*`, `icon`. Fixes only the renames that cannot change what renders |\n| `no-inert-flex-props` | — | `justifyContent` and friends without a flex `display`, which emit nothing |\n\nOpt-in — these report code that works, and buy explicitness instead:\n\n| Rule | Fixable | What it asks for |\n| -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |\n| `no-bulma-component-class` | — | The bestax component instead of its Bulma class, on a plain element (`<button className=\"button\">`) or on another component (`<Columns className=\"box\">`) |\n\nThe rules that judge bestax elements resolve them through the import and\nthrough scope, so neither your own `<Box>` nor a local shadowing the imported\none is linted against Bulma's rules, and each skips a value it cannot read as a\nliteral. `no-bulma-component-class` reads plain HTML elements as well, and\nleaves custom elements and anything inside `<svg>` alone.\n\nA spread is handled by what it can change: `no-color-as-surface` and\n`no-inert-flex-props` go silent, since a spread may carry the prop that makes\nthe code correct; `no-deprecated-props` reports but offers no fix; and\n`valid-helper-value` judges only the values that actually render, so a spread\nBEFORE the attribute leaves it reporting and a spread after it does not: JSX is\nlast-wins throughout, spreads included. `no-bulma-component-class` reports\neither way, since the class is written right there. No autofix changes what the\ncode renders.\n\n### valid-helper-value\n\n```jsx\n<Box textAlign=\"center\" /> // ✗ not a value textAlign accepts. Did you mean `centered`?\n<Box textAlign=\"centered\" /> // ✓\n```\n\nThe valid values come from the library's own exported tuples at lint time, by\nway of its `/constants` subpath, rather than from a list copied into this\npackage. The version those tuples come from is the copy of\n`@allxsmith/bestax-bulma` this plugin resolves, which in an ordinary deduped\ninstall is the same one your app uses; across a major bump it may not be, so\nkeep the two in step.\n\nOne family is outside its reach, knowingly: component-specific `color` props\nhave their own unions, so `<Button color=\"ghost\">` is correct and reporting it\nwould be worse than reporting nothing.\n\n`radius` and `columnGap` on `Theme` are the helpers, as everywhere else, but a\nstring outside their values still sets `--bulma-radius` or `--bulma-column-gap`\nthere through a deprecated route. The rule reports it with a message that says\nso and points at `bulmaVars`, unless it is a near miss of one of the values,\nwhich gets the usual suggestion:\n\n```jsx\n<Theme radius=\"6px\" /> // ✗ deprecated → bulmaVars\n<Theme radius=\"radiusles\" /> // ✗ Did you mean `radiusless`?\n<Theme bulmaVars={{ '--bulma-radius': '6px' }} /> // ✓\n<Theme columnGap=\"1rem\" /> // ✗ deprecated → bulmaVars\n<Theme bulmaVars={{ '--bulma-column-gap': '1rem' }} /> // ✓\n```\n\nThe gap props take their steps as numbers as well, so `<Box gap={2} />` is\naccepted where `<Box m={2} />` is reported.\n\n### no-deprecated-props\n\n```jsx\n<Button isFullWidth /> // ✗ deprecated → fixes to isFullwidth\n<Tabs color=\"info\" /> // ✗ no .tabs.is-<color> CSS exists; no fix offered\n```\n\nThe table is generated from the library's own TSDoc, so a rename lands here\nwith the library rather than after someone notices.\n\n### no-color-as-surface\n\nOff by default. `color` on the content elements is a documented alias for\n`textColor`, so this rule is about saying which you meant, not about broken\ncode.\n\n```jsx\n<Box color=\"primary\" /> // ✗ ambiguous → fixes to textColor\n<Box bgColor=\"primary\" /> // ✓ a coloured surface\n<Button color=\"primary\" /> // ✓ Button really has an is-primary variant\n\n// ✓ silent: the background is explicit, so `color` is plainly the text half\n<Box bgColor=\"info\" color=\"primary\" />\n```\n\n### no-bulma-component-class\n\nOff by default. It reports a plain element styled with a Bulma class that\nbestax has a component for, and names the component. It also reports that\nclass in the `className` of a bestax component that renders another one, which\nis where `bestax-migrate bulma-classes` leaves the second of two such classes\n(`columns box`). Turn it on in an app that has moved onto bestax, with the\ncodemod or by hand, to keep raw Bulma markup from coming back.\n\n```jsx\n<button className=\"button is-primary\" /> // ✗ bestax renders .button as Button\n<div className=\"dropdown\" /> // ✗ bestax has Dropdown, converted by hand\n<Columns className=\"box\" /> // ✗ bestax renders .box as Box\n<div className=\"has-text-centered mt-4\" /> // ✓ helper classes are left alone\n<p className=\"help\" /> // ✓ bestax renders .help inside its form controls\n<Columns className=\"columns is-mobile\" /> // ✓ its own classes\n```\n\nIt reads the classes a `className` spells out, including the strings in a\nternary, a template, or a call to `clsx`, `classnames` or `tailwind-merge`\n(however the file imports or requires it), and reports one class per element:\nthe one the codemod would decide by, a family's first and then, on a plain\nelement, the one whose component fits its tag best, a tag it renders with no\n`as` before one it reaches through `as`. That tag is the one the element's\nclasses give it, so an `.image` ratio, which puts `Image` on a `<figure>`, fits\na `<div>` only through `as`. On a component, whose tag can come from `as`, the\ntable's order decides. It reads `className` only on the components\nthe codemod writes, whose own classes it knows, so `<Input className=\"box\">` is\nleft alone. A function your app defines, a `cn` in `lib/utils`\nincluded, is one it cannot see into, so it reads nothing there. It only reports. Whether an element converts\ndepends on its tag, attributes and children, and `bestax-migrate bulma-classes`\nis the one place that judges that.\n\n### no-inert-flex-props\n\n```jsx\n<Box justifyContent=\"center\" /> // ✗ emits nothing\n<Box display=\"flex\" justifyContent=\"center\" /> // ✓\n<Box flexGrow=\"1\" /> // ✓ child props always apply\n```\n\n## Links\n\n- [Documentation](https://bestax.io/docs/guides/getting-started/eslint-plugin)\n- [Component library](https://www.npmjs.com/package/@allxsmith/bestax-bulma)\n- [Repository](https://github.com/allxsmith/bestax)\n\n## License\n\nMIT\n"
|
|
76
76
|
}
|