@allxsmith/eslint-plugin-bestax 1.3.0 → 1.3.2
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 +7 -3
- package/dist/generated/metadata.d.ts +24 -2
- package/dist/generated/metadata.d.ts.map +1 -1
- package/dist/generated/metadata.js +65 -0
- package/dist/rules/no-bulma-component-class.d.ts +6 -3
- package/dist/rules/no-bulma-component-class.d.ts.map +1 -1
- package/dist/rules/no-bulma-component-class.js +23 -5
- package/dist/rules/no-inert-flex-props.d.ts +15 -0
- package/dist/rules/no-inert-flex-props.d.ts.map +1 -1
- package/dist/rules/no-inert-flex-props.js +36 -1
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -214,9 +214,11 @@ It reads the classes a `className` spells out, including the strings in a
|
|
|
214
214
|
ternary, a template, or a call to `clsx`, `classnames` or `tailwind-merge`
|
|
215
215
|
(however the file imports or requires it), and reports one class per element:
|
|
216
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,
|
|
218
|
-
reaches through `as`.
|
|
219
|
-
|
|
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
|
|
220
222
|
the codemod writes, whose own classes it knows, so `<Input className="box">` is
|
|
221
223
|
left alone. A function your app defines, a `cn` in `lib/utils`
|
|
222
224
|
included, is one it cannot see into, so it reads nothing there. It only reports. Whether an element converts
|
|
@@ -229,6 +231,8 @@ is the one place that judges that.
|
|
|
229
231
|
<Box justifyContent="center" /> // ✗ emits nothing
|
|
230
232
|
<Box display="flex" justifyContent="center" /> // ✓
|
|
231
233
|
<Box flexGrow="1" /> // ✓ child props always apply
|
|
234
|
+
<Stack alignItems="center" /> // ✓ Stack, Group, Center and Flex are flex containers
|
|
235
|
+
<Stack display="block" alignItems="center" /> // ✗ unless display makes them something else
|
|
232
236
|
```
|
|
233
237
|
|
|
234
238
|
## Links
|
|
@@ -23,6 +23,13 @@ export declare const DEPRECATED_PROPS: Readonly<Record<string, Readonly<Record<s
|
|
|
23
23
|
* this set is evidence of a text alias and never of a real variant.
|
|
24
24
|
*/
|
|
25
25
|
export declare const TEXT_ALIAS_COLOR_ELEMENTS: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* Elements that are flex containers by their own CSS, so the flex container
|
|
28
|
+
* props (`alignItems`, `justifyContent` and the rest) render on them with
|
|
29
|
+
* no `display` prop, unless a `display` prop makes them something else.
|
|
30
|
+
* Read from the `@flexContainer` tag on each one's props type or its bases.
|
|
31
|
+
*/
|
|
32
|
+
export declare const FLEX_CONTAINER_ELEMENTS: readonly string[];
|
|
26
33
|
/** A Bulma class that names a bestax component. */
|
|
27
34
|
export interface BulmaComponentClass {
|
|
28
35
|
/** The bestax component, dotted for a part (`Hero.Body`). */
|
|
@@ -37,16 +44,31 @@ export interface BulmaComponentClass {
|
|
|
37
44
|
/**
|
|
38
45
|
* For a class that converts: the tags its component renders, its own and
|
|
39
46
|
* 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:
|
|
41
|
-
*
|
|
47
|
+
* the codemod decides by the one whose component fits its tag best: the
|
|
48
|
+
* tag it renders with no `as`, then one of these, then none.
|
|
42
49
|
*/
|
|
43
50
|
readonly tags?: readonly string[] | 'any';
|
|
51
|
+
/**
|
|
52
|
+
* For a class that converts: the classes beside it that decide the tag its
|
|
53
|
+
* component renders with no `as` (`Image`'s ratios a <figure>, `Title`'s
|
|
54
|
+
* sizes their heading), each with that tag, null for its own, and the tags
|
|
55
|
+
* it converts on when not all. The first the element carries that converts
|
|
56
|
+
* on its tag decides.
|
|
57
|
+
*/
|
|
58
|
+
readonly retags?: Readonly<Record<string, BulmaRetag>>;
|
|
44
59
|
/**
|
|
45
60
|
* How to keep the class on an element another component renders, where an
|
|
46
61
|
* element of its own is not the answer.
|
|
47
62
|
*/
|
|
48
63
|
readonly onAnother?: string;
|
|
49
64
|
}
|
|
65
|
+
/** A class that decides the tag a component renders with no `as`. */
|
|
66
|
+
export interface BulmaRetag {
|
|
67
|
+
/** The tag it renders, or null for the component's own. */
|
|
68
|
+
readonly tag: string | null;
|
|
69
|
+
/** The tags it converts on, when not all. */
|
|
70
|
+
readonly on?: readonly string[];
|
|
71
|
+
}
|
|
50
72
|
/**
|
|
51
73
|
* Bulma classes that name a bestax component, from bestax-migrate's
|
|
52
74
|
* bulma-classes table. In the order the codemod decides an element's
|
|
@@ -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,CAyKtD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EActD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAKpD,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"}
|
|
@@ -28,6 +28,12 @@ export const DEPRECATED_PROPS = {
|
|
|
28
28
|
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
|
+
'Buttons.IconButton': {
|
|
32
|
+
isFullWidth: {
|
|
33
|
+
replacement: 'isFullwidth',
|
|
34
|
+
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
31
37
|
'Buttons.LinkButton': {
|
|
32
38
|
isFullWidth: {
|
|
33
39
|
replacement: 'isFullwidth',
|
|
@@ -79,6 +85,12 @@ export const DEPRECATED_PROPS = {
|
|
|
79
85
|
note: 'Use `variant` and `features` instead.',
|
|
80
86
|
},
|
|
81
87
|
},
|
|
88
|
+
IconButton: {
|
|
89
|
+
isFullWidth: {
|
|
90
|
+
replacement: 'isFullwidth',
|
|
91
|
+
note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
82
94
|
'IconText.Icon': {
|
|
83
95
|
icon: { replacement: 'name', note: 'Use `name` instead.' },
|
|
84
96
|
libraryFeatures: {
|
|
@@ -189,6 +201,18 @@ export const TEXT_ALIAS_COLOR_ELEMENTS = [
|
|
|
189
201
|
'Image',
|
|
190
202
|
'Panel.Icon',
|
|
191
203
|
];
|
|
204
|
+
/**
|
|
205
|
+
* Elements that are flex containers by their own CSS, so the flex container
|
|
206
|
+
* props (`alignItems`, `justifyContent` and the rest) render on them with
|
|
207
|
+
* no `display` prop, unless a `display` prop makes them something else.
|
|
208
|
+
* Read from the `@flexContainer` tag on each one's props type or its bases.
|
|
209
|
+
*/
|
|
210
|
+
export const FLEX_CONTAINER_ELEMENTS = [
|
|
211
|
+
'Center',
|
|
212
|
+
'Flex',
|
|
213
|
+
'Group',
|
|
214
|
+
'Stack',
|
|
215
|
+
];
|
|
192
216
|
/**
|
|
193
217
|
* Bulma classes that name a bestax component, from bestax-migrate's
|
|
194
218
|
* bulma-classes table. In the order the codemod decides an element's
|
|
@@ -494,6 +518,14 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
494
518
|
converts: true,
|
|
495
519
|
tag: 'h1',
|
|
496
520
|
tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'],
|
|
521
|
+
retags: {
|
|
522
|
+
'is-1': { tag: 'h1', on: ['h1', 'p'] },
|
|
523
|
+
'is-2': { tag: 'h2', on: ['h2', 'p'] },
|
|
524
|
+
'is-3': { tag: 'h3', on: ['h3', 'p'] },
|
|
525
|
+
'is-4': { tag: 'h4', on: ['h4', 'p'] },
|
|
526
|
+
'is-5': { tag: 'h5', on: ['h5', 'p'] },
|
|
527
|
+
'is-6': { tag: 'h6', on: ['h6', 'p'] },
|
|
528
|
+
},
|
|
497
529
|
},
|
|
498
530
|
],
|
|
499
531
|
[
|
|
@@ -503,6 +535,14 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
503
535
|
converts: true,
|
|
504
536
|
tag: 'h1',
|
|
505
537
|
tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'],
|
|
538
|
+
retags: {
|
|
539
|
+
'is-1': { tag: 'h1', on: ['h1', 'p'] },
|
|
540
|
+
'is-2': { tag: 'h2', on: ['h2', 'p'] },
|
|
541
|
+
'is-3': { tag: 'h3', on: ['h3', 'p'] },
|
|
542
|
+
'is-4': { tag: 'h4', on: ['h4', 'p'] },
|
|
543
|
+
'is-5': { tag: 'h5', on: ['h5', 'p'] },
|
|
544
|
+
'is-6': { tag: 'h6', on: ['h6', 'p'] },
|
|
545
|
+
},
|
|
506
546
|
},
|
|
507
547
|
],
|
|
508
548
|
[
|
|
@@ -550,6 +590,31 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
550
590
|
converts: true,
|
|
551
591
|
tag: 'div',
|
|
552
592
|
tags: ['div', 'figure', 'p'],
|
|
593
|
+
retags: {
|
|
594
|
+
'is-16x16': { tag: null },
|
|
595
|
+
'is-24x24': { tag: null },
|
|
596
|
+
'is-32x32': { tag: null },
|
|
597
|
+
'is-48x48': { tag: null },
|
|
598
|
+
'is-64x64': { tag: null },
|
|
599
|
+
'is-96x96': { tag: null },
|
|
600
|
+
'is-128x128': { tag: null },
|
|
601
|
+
'is-square': { tag: null },
|
|
602
|
+
'is-1by1': { tag: 'figure' },
|
|
603
|
+
'is-5by4': { tag: 'figure' },
|
|
604
|
+
'is-4by3': { tag: 'figure' },
|
|
605
|
+
'is-3by2': { tag: 'figure' },
|
|
606
|
+
'is-5by3': { tag: 'figure' },
|
|
607
|
+
'is-16by9': { tag: 'figure' },
|
|
608
|
+
'is-2by1': { tag: 'figure' },
|
|
609
|
+
'is-3by1': { tag: 'figure' },
|
|
610
|
+
'is-4by5': { tag: 'figure' },
|
|
611
|
+
'is-3by4': { tag: 'figure' },
|
|
612
|
+
'is-2by3': { tag: 'figure' },
|
|
613
|
+
'is-3by5': { tag: 'figure' },
|
|
614
|
+
'is-9by16': { tag: 'figure' },
|
|
615
|
+
'is-1by2': { tag: 'figure' },
|
|
616
|
+
'is-1by3': { tag: 'figure' },
|
|
617
|
+
},
|
|
553
618
|
},
|
|
554
619
|
],
|
|
555
620
|
[
|
|
@@ -30,9 +30,12 @@
|
|
|
30
30
|
* of a family, since the family's own class is reported where it sits. An
|
|
31
31
|
* element carrying several is reported once, for the class the codemod
|
|
32
32
|
* would decide by: a family first, else, on a plain element, the one whose
|
|
33
|
-
* component fits its tag best (
|
|
34
|
-
* first in the table's order among
|
|
35
|
-
* can
|
|
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.
|
|
36
39
|
*
|
|
37
40
|
* A spread does not silence it: the report is about the class the author
|
|
38
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"}
|
|
@@ -20,13 +20,30 @@ function insideForeign(ancestors) {
|
|
|
20
20
|
}
|
|
21
21
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* it
|
|
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.
|
|
25
26
|
*/
|
|
26
|
-
function
|
|
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) {
|
|
27
44
|
if (tag === null)
|
|
28
45
|
return 0;
|
|
29
|
-
if (entry
|
|
46
|
+
if (rendersWith(entry, tag, tokens) === tag)
|
|
30
47
|
return 2;
|
|
31
48
|
return entry.tags === 'any' || entry.tags?.includes(tag) ? 1 : 0;
|
|
32
49
|
}
|
|
@@ -44,7 +61,8 @@ function decidingClass(tokens, tag, keep = () => true) {
|
|
|
44
61
|
if (family !== undefined)
|
|
45
62
|
return family;
|
|
46
63
|
const carried = [...BULMA_COMPONENT_CLASSES].filter(([key, entry]) => tokens.includes(key) && keep(entry));
|
|
47
|
-
const best = carried.reduce((found, candidate) => found === undefined ||
|
|
64
|
+
const best = carried.reduce((found, candidate) => found === undefined ||
|
|
65
|
+
fit(candidate[1], tag, tokens) > fit(found[1], tag, tokens)
|
|
48
66
|
? candidate
|
|
49
67
|
: found, undefined);
|
|
50
68
|
return best?.[0];
|
|
@@ -11,6 +11,21 @@
|
|
|
11
11
|
* element as a flex CHILD, whose container is elsewhere — so they are not
|
|
12
12
|
* reported.
|
|
13
13
|
*
|
|
14
|
+
* An element that is a flex container by its own CSS (`Stack`, `Group`,
|
|
15
|
+
* `Center`, `Flex`) emits the five with no `display` prop, so it needs none.
|
|
16
|
+
* It is reported in one case only, the one that is certain: a literal
|
|
17
|
+
* `display` that is one of the library's own non-flex displays (`block`,
|
|
18
|
+
* `grid` and the rest of `validDisplays`), with no `viewport` prop and no
|
|
19
|
+
* viewport `display*` prop beside it. `useVisibilityClasses` then renders
|
|
20
|
+
* Bulma's `is-<display>`, which is `!important`, at every width. Everything
|
|
21
|
+
* else stays silent, because the library may render no display class at all:
|
|
22
|
+
* it ignores `display` once any viewport `display*` is set, `viewport` limits
|
|
23
|
+
* `display` to one width, and a value outside the tuple (`{true}`, `""`, and
|
|
24
|
+
* `none`, which hides the element instead) emits no display class. The miss
|
|
25
|
+
* that costs is an element whose every viewport `display*` is a block, which
|
|
26
|
+
* would take modelling that hook to see. The set is generated from the
|
|
27
|
+
* library, `FLEX_CONTAINER_ELEMENTS`, rather than listed here.
|
|
28
|
+
*
|
|
14
29
|
* Silence beats a guess: an element carrying a spread, or a `display*` whose
|
|
15
30
|
* value the rule cannot read, is left alone.
|
|
16
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-inert-flex-props.d.ts","sourceRoot":"","sources":["../../src/rules/no-inert-flex-props.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"no-inert-flex-props.d.ts","sourceRoot":"","sources":["../../src/rules/no-inert-flex-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAsCnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAwEhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
import { validDisplays } from '@allxsmith/bestax-bulma/constants';
|
|
2
|
+
import { FLEX_CONTAINER_ELEMENTS } from '../generated/metadata.js';
|
|
1
3
|
import { DISPLAY_PROPS, FLEX_CONTAINER_PROPS, FLEX_DISPLAYS, } from '../lib/values.js';
|
|
2
4
|
import { isUnreadableValue, winningAttributes, hasSpread, literalValue, elementOf, withImports, } from '../lib/elements.js';
|
|
3
5
|
const CONTAINER = new Set(FLEX_CONTAINER_PROPS);
|
|
4
6
|
const DISPLAY = new Set(DISPLAY_PROPS);
|
|
7
|
+
const FLEX_CONTAINERS = new Set(FLEX_CONTAINER_ELEMENTS);
|
|
8
|
+
/** The displays the library renders a class for that aren't flex ones. */
|
|
9
|
+
const NON_FLEX_DISPLAYS = new Set(validDisplays.filter(d => !FLEX_DISPLAYS.includes(d)));
|
|
10
|
+
/**
|
|
11
|
+
* Whether a flex container by its own CSS is certainly not one: a literal
|
|
12
|
+
* `display` from `NON_FLEX_DISPLAYS`, with no `viewport` and no viewport
|
|
13
|
+
* `display*`, the only shape in which the library renders it at every width.
|
|
14
|
+
*/
|
|
15
|
+
function displayTurnsOff(attrs) {
|
|
16
|
+
if (attrs.some(a => a.name.name === 'viewport'))
|
|
17
|
+
return false;
|
|
18
|
+
const displays = attrs.filter(a => DISPLAY.has(a.name.name));
|
|
19
|
+
if (displays.some(a => a.name.name !== 'display'))
|
|
20
|
+
return false;
|
|
21
|
+
const value = displays.length === 1 ? literalValue(displays[0]) : undefined;
|
|
22
|
+
return typeof value === 'string' && NON_FLEX_DISPLAYS.has(value);
|
|
23
|
+
}
|
|
5
24
|
const rule = {
|
|
6
25
|
meta: {
|
|
7
26
|
type: 'problem',
|
|
@@ -12,6 +31,7 @@ const rule = {
|
|
|
12
31
|
schema: [],
|
|
13
32
|
messages: {
|
|
14
33
|
inert: '`{{prop}}` emits no class here: it applies only when a `display` prop is `flex` or `inline-flex`. Add `display="flex"`, or drop `{{prop}}`.',
|
|
34
|
+
notFlex: '`{{prop}}` does nothing here: `{{element}}` is a flex container by its own styles, but its `display` prop makes it something else. Drop `display`, or drop `{{prop}}`.',
|
|
15
35
|
},
|
|
16
36
|
},
|
|
17
37
|
create(context) {
|
|
@@ -20,7 +40,8 @@ const rule = {
|
|
|
20
40
|
...visitor,
|
|
21
41
|
JSXOpeningElement(node) {
|
|
22
42
|
const opening = node;
|
|
23
|
-
|
|
43
|
+
const element = elementOf(context, opening, imports);
|
|
44
|
+
if (element === null)
|
|
24
45
|
return;
|
|
25
46
|
if (hasSpread(opening))
|
|
26
47
|
return;
|
|
@@ -28,6 +49,20 @@ const rule = {
|
|
|
28
49
|
const containerProps = attrs.filter((a) => CONTAINER.has(a.name.name));
|
|
29
50
|
if (!containerProps.length)
|
|
30
51
|
return;
|
|
52
|
+
// A flex container by its own CSS: reported only where `display`
|
|
53
|
+
// certainly turns it off at every width.
|
|
54
|
+
if (FLEX_CONTAINERS.has(element)) {
|
|
55
|
+
if (!displayTurnsOff(attrs))
|
|
56
|
+
return;
|
|
57
|
+
for (const attr of containerProps) {
|
|
58
|
+
context.report({
|
|
59
|
+
node: attr,
|
|
60
|
+
messageId: 'notFlex',
|
|
61
|
+
data: { prop: attr.name.name, element },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
31
66
|
const displays = attrs.filter((a) => DISPLAY.has(a.name.name));
|
|
32
67
|
// A display the rule cannot read could be a flex one; say nothing.
|
|
33
68
|
// Anything it CAN read and that is not a flex string — `true`, a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allxsmith/eslint-plugin-bestax",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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,20 +41,18 @@
|
|
|
41
41
|
"url": "https://github.com/allxsmith/bestax/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@allxsmith/bestax-bulma": "^5.
|
|
44
|
+
"@allxsmith/bestax-bulma": "^5.59.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"eslint": "^10.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"ts-jest": "^29.4.14",
|
|
57
|
-
"typescript": "^6.0.3"
|
|
50
|
+
"@types/node": "^26.6.6",
|
|
51
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
52
|
+
"@vitest/coverage-istanbul": "^5.0.5",
|
|
53
|
+
"eslint": "^10.13.0",
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vitest": "^5.0.5"
|
|
58
56
|
},
|
|
59
57
|
"publishConfig": {
|
|
60
58
|
"access": "public"
|
|
@@ -62,9 +60,9 @@
|
|
|
62
60
|
"scripts": {
|
|
63
61
|
"build": "tsc",
|
|
64
62
|
"dev": "tsc --watch",
|
|
65
|
-
"test": "
|
|
66
|
-
"test:watch": "
|
|
67
|
-
"test:coverage": "
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
68
66
|
"lint": "eslint src",
|
|
69
67
|
"typecheck": "tsc --noEmit",
|
|
70
68
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
@@ -72,5 +70,5 @@
|
|
|
72
70
|
"clean": "rimraf dist",
|
|
73
71
|
"release": "npx semantic-release"
|
|
74
72
|
},
|
|
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, its own tag before one it\nreaches through `as`. On a component, whose tag can come from `as`, the table's\norder 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"
|
|
73
|
+
"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<Stack alignItems=\"center\" /> // ✓ Stack, Group, Center and Flex are flex containers\n<Stack display=\"block\" alignItems=\"center\" /> // ✗ unless display makes them something else\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
74
|
}
|