@allxsmith/eslint-plugin-bestax 1.1.7 → 1.1.9
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 +12 -4
- package/dist/generated/metadata.js +9 -9
- package/dist/lib/values.d.ts +27 -26
- package/dist/lib/values.d.ts.map +1 -1
- package/dist/lib/values.js +27 -26
- package/dist/rules/valid-helper-value.d.ts +7 -4
- package/dist/rules/valid-helper-value.d.ts.map +1 -1
- package/dist/rules/valid-helper-value.js +22 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -148,10 +148,18 @@ keep the two in step.
|
|
|
148
148
|
|
|
149
149
|
One family is outside its reach, knowingly: component-specific `color` props
|
|
150
150
|
have their own unions, so `<Button color="ghost">` is correct and reporting it
|
|
151
|
-
would be worse than reporting nothing.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
would be worse than reporting nothing.
|
|
152
|
+
|
|
153
|
+
`radius` on `Theme` is the helper, as everywhere else, but a string outside
|
|
154
|
+
its values still sets `--bulma-radius` there through a deprecated route. The
|
|
155
|
+
rule reports it with a message that says so and points at `bulmaVars`, unless
|
|
156
|
+
it is a near miss of `radiusless`, which gets the usual suggestion:
|
|
157
|
+
|
|
158
|
+
```jsx
|
|
159
|
+
<Theme radius="6px" /> // ✗ deprecated → bulmaVars
|
|
160
|
+
<Theme radius="radiusles" /> // ✗ Did you mean `radiusless`?
|
|
161
|
+
<Theme bulmaVars={{ '--bulma-radius': '6px' }} /> // ✓
|
|
162
|
+
```
|
|
155
163
|
|
|
156
164
|
### no-deprecated-props
|
|
157
165
|
|
|
@@ -167,22 +167,13 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
167
167
|
['checkboxes', { component: 'Checkboxes', converts: false }],
|
|
168
168
|
['radio', { component: 'Radio', converts: false }],
|
|
169
169
|
['radios', { component: 'Radios', converts: false }],
|
|
170
|
-
['file', { component: 'File', converts: false }],
|
|
171
170
|
['dropdown', { component: 'Dropdown', converts: false }],
|
|
172
|
-
['icon', { component: 'Icon', converts: false }],
|
|
173
|
-
['icon-text', { component: 'IconText', converts: false }],
|
|
174
171
|
['menu-item', { component: 'Menu.Item', converts: false }],
|
|
175
172
|
['message', { component: 'Message', converts: false }],
|
|
176
173
|
['modal', { component: 'Modal', converts: false }],
|
|
177
174
|
['navbar-burger', { component: 'Navbar.Burger', converts: false }],
|
|
178
175
|
['navbar-link', { component: 'Navbar.Link', converts: false }],
|
|
179
|
-
['pagination-link', { component: 'Pagination.Link', converts: false }],
|
|
180
|
-
[
|
|
181
|
-
'pagination-ellipsis',
|
|
182
|
-
{ component: 'Pagination.Ellipsis', converts: false },
|
|
183
|
-
],
|
|
184
176
|
['panel-icon', { component: 'Panel.Icon', converts: false }],
|
|
185
|
-
['tabs', { component: 'Tabs', converts: false }],
|
|
186
177
|
['columns', { component: 'Columns', converts: true }],
|
|
187
178
|
['column', { component: 'Column', converts: true }],
|
|
188
179
|
['grid', { component: 'Grid', converts: true }],
|
|
@@ -241,6 +232,9 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
241
232
|
['breadcrumb', { component: 'Breadcrumb', converts: true }],
|
|
242
233
|
['skeleton-block', { component: 'Skeleton', converts: true }],
|
|
243
234
|
['skeleton-lines', { component: 'Skeleton', converts: true }],
|
|
235
|
+
['file', { component: 'File', converts: true }],
|
|
236
|
+
['icon', { component: 'Icon', converts: true }],
|
|
237
|
+
['icon-text', { component: 'IconText', converts: true }],
|
|
244
238
|
['image', { component: 'Image', converts: true }],
|
|
245
239
|
['menu', { component: 'Menu', converts: true }],
|
|
246
240
|
['menu-label', { component: 'Menu.Label', converts: true }],
|
|
@@ -259,10 +253,16 @@ export const BULMA_COMPONENT_CLASSES = new Map([
|
|
|
259
253
|
{ component: 'Pagination.Previous', converts: true },
|
|
260
254
|
],
|
|
261
255
|
['pagination-next', { component: 'Pagination.Next', converts: true }],
|
|
256
|
+
['pagination-link', { component: 'Pagination.Link', converts: true }],
|
|
257
|
+
[
|
|
258
|
+
'pagination-ellipsis',
|
|
259
|
+
{ component: 'Pagination.Ellipsis', converts: true },
|
|
260
|
+
],
|
|
262
261
|
['panel', { component: 'Panel', converts: true }],
|
|
263
262
|
['panel-heading', { component: 'Panel.Heading', converts: true }],
|
|
264
263
|
['panel-tabs', { component: 'Panel.Tabs', converts: true }],
|
|
265
264
|
['panel-block', { component: 'Panel.Block', converts: true }],
|
|
265
|
+
['tabs', { component: 'Tabs', converts: true }],
|
|
266
266
|
['table-container', { component: 'Table', converts: true }],
|
|
267
267
|
['fixed-grid', { component: 'Grid', converts: true }],
|
|
268
268
|
]);
|
package/dist/lib/values.d.ts
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* not a tweak here. The hand-written `color` exclusion above is the same
|
|
18
18
|
* limitation showing through.
|
|
19
19
|
*
|
|
20
|
-
* Where a prop
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
20
|
+
* Where a value outside a prop's tuple still does something on some element,
|
|
21
|
+
* the ordinary message would say something false about it and the rule has
|
|
22
|
+
* to be told: see `DEPRECATED_VARIABLE_ROUTE` below.
|
|
23
23
|
*
|
|
24
24
|
* KEYED BY PROP also means each prop is judged ALONE, and the shade props are
|
|
25
25
|
* where that shows. `<Box textColor="white-bis" colorShade="15" />` passes
|
|
@@ -63,34 +63,35 @@ export declare const HELPER_VALUES: ReadonlyMap<string, readonly string[]>;
|
|
|
63
63
|
*/
|
|
64
64
|
export declare const REMOVES_ONLY: ReadonlyMap<string, string>;
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
66
|
+
* Helper props that, on one element, still set a CSS variable when given a
|
|
67
|
+
* string outside their tuple: a deprecated route the library keeps so code
|
|
68
|
+
* written against its old behaviour keeps rendering. Keyed by element, then by
|
|
69
|
+
* prop, to the variable the value lands in.
|
|
68
70
|
*
|
|
69
71
|
* `Theme` mints a prop for every Bulma CSS variable, and `--bulma-radius`
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* `<Theme radius="6px" />`
|
|
74
|
-
* reporting
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* until #694 picks a meaning.
|
|
72
|
+
* collided with the `radius` helper: until #694 that prop set the variable
|
|
73
|
+
* whatever its type said. It is the helper now, as everywhere else, but a
|
|
74
|
+
* string that is not a helper value still reaches `--bulma-radius`, with a
|
|
75
|
+
* development warning pointing at `bulmaVars`. So `<Theme radius="6px" />` is
|
|
76
|
+
* worth reporting, and the ordinary message, which says nothing renders, would
|
|
77
|
+
* be false about it. The rule reports these with a message that says what
|
|
78
|
+
* really happens and names the supported spelling, except for a near miss of
|
|
79
|
+
* a valid value, which gets the usual suggestion with the same correction.
|
|
79
80
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* and needs no entry here. That filter is the precedent #694 would follow.
|
|
81
|
+
* Only a string takes that route. A number or `true` goes to the helper on
|
|
82
|
+
* `Theme` as well, so the ordinary messages about those stay true.
|
|
83
83
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
84
|
+
* `--bulma-shadow` would have collided the same way and was kept out of
|
|
85
|
+
* Theme's variable map from the start, so `shadow` needs no entry.
|
|
86
|
+
*
|
|
87
|
+
* Declared rather than derived, and held to the library by
|
|
88
|
+
* `scripts/helper-prop-collisions.test.mjs`, which reads Theme's source and
|
|
89
|
+
* fails if a helper name is still taken as a variable prop or if this map and
|
|
90
|
+
* the routes Theme really has disagree. Same shape as `SIBLING_RUNTIME_DEPS`
|
|
91
|
+
* in check-conformance.mjs, and for the same reason: a declaration no test can
|
|
92
|
+
* falsify becomes a fiction.
|
|
92
93
|
*/
|
|
93
|
-
export declare const
|
|
94
|
+
export declare const DEPRECATED_VARIABLE_ROUTE: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
94
95
|
/** Props that emit a class only when a flex `display` is also set. */
|
|
95
96
|
export declare const FLEX_CONTAINER_PROPS: readonly string[];
|
|
96
97
|
/** Every `display*` prop name, in declaration order. */
|
package/dist/lib/values.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/lib/values.ts"],"names":[],"mappings":"AA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAoC/D,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAGnD,CAAC;AAEH
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/lib/values.ts"],"names":[],"mappings":"AA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAoC/D,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAGnD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CACjD,MAAM,EACN,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CACoC,CAAC;AAElE,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAMjD,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAG1C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAA4B,CAAC"}
|
package/dist/lib/values.js
CHANGED
|
@@ -73,9 +73,9 @@ const family = (base, bands, values) => [
|
|
|
73
73
|
* not a tweak here. The hand-written `color` exclusion above is the same
|
|
74
74
|
* limitation showing through.
|
|
75
75
|
*
|
|
76
|
-
* Where a prop
|
|
77
|
-
*
|
|
78
|
-
* `
|
|
76
|
+
* Where a value outside a prop's tuple still does something on some element,
|
|
77
|
+
* the ordinary message would say something false about it and the rule has
|
|
78
|
+
* to be told: see `DEPRECATED_VARIABLE_ROUTE` below.
|
|
79
79
|
*
|
|
80
80
|
* KEYED BY PROP also means each prop is judged ALONE, and the shade props are
|
|
81
81
|
* where that shows. `<Box textColor="white-bis" colorShade="15" />` passes
|
|
@@ -158,34 +158,35 @@ export const REMOVES_ONLY = new Map([
|
|
|
158
158
|
['shadow', 'shadow'],
|
|
159
159
|
]);
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
161
|
+
* Helper props that, on one element, still set a CSS variable when given a
|
|
162
|
+
* string outside their tuple: a deprecated route the library keeps so code
|
|
163
|
+
* written against its old behaviour keeps rendering. Keyed by element, then by
|
|
164
|
+
* prop, to the variable the value lands in.
|
|
163
165
|
*
|
|
164
166
|
* `Theme` mints a prop for every Bulma CSS variable, and `--bulma-radius`
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* `<Theme radius="6px" />`
|
|
169
|
-
* reporting
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* until #694 picks a meaning.
|
|
167
|
+
* collided with the `radius` helper: until #694 that prop set the variable
|
|
168
|
+
* whatever its type said. It is the helper now, as everywhere else, but a
|
|
169
|
+
* string that is not a helper value still reaches `--bulma-radius`, with a
|
|
170
|
+
* development warning pointing at `bulmaVars`. So `<Theme radius="6px" />` is
|
|
171
|
+
* worth reporting, and the ordinary message, which says nothing renders, would
|
|
172
|
+
* be false about it. The rule reports these with a message that says what
|
|
173
|
+
* really happens and names the supported spelling, except for a near miss of
|
|
174
|
+
* a valid value, which gets the usual suggestion with the same correction.
|
|
174
175
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* and needs no entry here. That filter is the precedent #694 would follow.
|
|
176
|
+
* Only a string takes that route. A number or `true` goes to the helper on
|
|
177
|
+
* `Theme` as well, so the ordinary messages about those stay true.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
179
|
+
* `--bulma-shadow` would have collided the same way and was kept out of
|
|
180
|
+
* Theme's variable map from the start, so `shadow` needs no entry.
|
|
181
|
+
*
|
|
182
|
+
* Declared rather than derived, and held to the library by
|
|
183
|
+
* `scripts/helper-prop-collisions.test.mjs`, which reads Theme's source and
|
|
184
|
+
* fails if a helper name is still taken as a variable prop or if this map and
|
|
185
|
+
* the routes Theme really has disagree. Same shape as `SIBLING_RUNTIME_DEPS`
|
|
186
|
+
* in check-conformance.mjs, and for the same reason: a declaration no test can
|
|
187
|
+
* falsify becomes a fiction.
|
|
187
188
|
*/
|
|
188
|
-
export const
|
|
189
|
+
export const DEPRECATED_VARIABLE_ROUTE = new Map([['Theme', new Map([['radius', '--bulma-radius']])]]);
|
|
189
190
|
/** Props that emit a class only when a flex `display` is also set. */
|
|
190
191
|
export const FLEX_CONTAINER_PROPS = [
|
|
191
192
|
'flexDirection',
|
|
@@ -25,10 +25,13 @@
|
|
|
25
25
|
* It is deliberately not a substitute for typechecking, and the overlap on
|
|
26
26
|
* `.tsx` is expected rather than a defect.
|
|
27
27
|
*
|
|
28
|
-
* The table is keyed by prop rather than by element
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* The table is keyed by prop rather than by element. The one fact about a
|
|
29
|
+
* particular element the rule needs is `DEPRECATED_VARIABLE_ROUTE`: on
|
|
30
|
+
* `Theme`, a `radius` string outside the tuple still sets `--bulma-radius`
|
|
31
|
+
* through a deprecated route, so that report says so rather than claiming
|
|
32
|
+
* nothing renders. A near miss of a valid value still gets the suggestion
|
|
33
|
+
* there, because it is most likely that value mistyped, and pointing it at
|
|
34
|
+
* `bulmaVars` would only move the typo.
|
|
32
35
|
*/
|
|
33
36
|
import type { Rule } from 'eslint';
|
|
34
37
|
declare const rule: Rule.RuleModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valid-helper-value.d.ts","sourceRoot":"","sources":["../../src/rules/valid-helper-value.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"valid-helper-value.d.ts","sourceRoot":"","sources":["../../src/rules/valid-helper-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAiDnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAsHhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEPRECATED_VARIABLE_ROUTE, HELPER_VALUES, REMOVES_ONLY, } from '../lib/values.js';
|
|
2
2
|
import { isTrueValue, literalValue, numericValue, elementOf, valuesThatRender, withImports, } from '../lib/elements.js';
|
|
3
3
|
/**
|
|
4
4
|
* Closest valid values by a cheap edit-distance, for the message.
|
|
@@ -45,6 +45,8 @@ const rule = {
|
|
|
45
45
|
numericInvalid: '`{{prop}}={{{value}}}` is a number, and {{prop}} is matched against strings. `"{{value}}"` is not a value it accepts either. Valid values: {{valid}}.',
|
|
46
46
|
shorthand: '`{{prop}}` is `true` here, and {{prop}} is matched against strings, so the class is never emitted and nothing renders. Give it a value: {{valid}}.',
|
|
47
47
|
shorthandRemoves: '`{{prop}}` is `true` here, and {{prop}} is matched against strings, so nothing renders. It is also not a switch: its only value {{valid}} REMOVES the {{thing}}. Omit `{{prop}}` to keep the {{thing}}, or write `{{prop}}="{{only}}"` to remove it.',
|
|
48
|
+
deprecatedVariable: "`{{prop}}=\"{{value}}\"` is not a value {{prop}} accepts, so on {{element}} it sets `{{cssVar}}` instead, through a deprecated route. If a {{prop}} of `{{value}}` is what you meant, write `bulmaVars={{ '{{cssVar}}': '{{value}}' }}`. Valid values: {{valid}}.",
|
|
49
|
+
deprecatedVariableWithSuggestion: '`{{prop}}="{{value}}"` is not a value {{prop}} accepts, so on {{element}} it sets `{{cssVar}}` instead, through a deprecated route. Did you mean {{suggestions}}?',
|
|
48
50
|
},
|
|
49
51
|
},
|
|
50
52
|
create(context) {
|
|
@@ -56,14 +58,12 @@ const rule = {
|
|
|
56
58
|
const element = elementOf(context, opening, imports);
|
|
57
59
|
if (element === null)
|
|
58
60
|
return;
|
|
59
|
-
//
|
|
60
|
-
// element
|
|
61
|
-
//
|
|
62
|
-
const
|
|
61
|
+
// Props whose out-of-tuple strings still set a variable on this
|
|
62
|
+
// element. `Theme`'s `radius` is the case; see
|
|
63
|
+
// DEPRECATED_VARIABLE_ROUTE.
|
|
64
|
+
const routes = DEPRECATED_VARIABLE_ROUTE.get(element);
|
|
63
65
|
for (const attr of valuesThatRender(opening)) {
|
|
64
66
|
const prop = attr.name.name;
|
|
65
|
-
if (shadowed?.has(prop))
|
|
66
|
-
continue;
|
|
67
67
|
const valid = HELPER_VALUES.get(prop);
|
|
68
68
|
if (!valid)
|
|
69
69
|
continue;
|
|
@@ -110,12 +110,26 @@ const rule = {
|
|
|
110
110
|
if (value === null || valid.includes(value))
|
|
111
111
|
continue;
|
|
112
112
|
const suggestions = suggest(value, valid);
|
|
113
|
+
// Where the element has a deprecated route, the value renders as a
|
|
114
|
+
// variable, so "nothing renders" would be false. Only a non-empty
|
|
115
|
+
// string takes that route, as in the library: an empty one sets
|
|
116
|
+
// nothing, and the `true` and numeric cases above go to the helper.
|
|
117
|
+
// A near miss still gets the suggestion rather than `bulmaVars`.
|
|
118
|
+
const cssVar = value === '' ? undefined : routes?.get(prop);
|
|
119
|
+
const [withSuggestion, withoutSuggestion] = cssVar === undefined
|
|
120
|
+
? ['invalidWithSuggestion', 'invalid']
|
|
121
|
+
: [
|
|
122
|
+
'deprecatedVariableWithSuggestion',
|
|
123
|
+
'deprecatedVariable',
|
|
124
|
+
];
|
|
113
125
|
context.report({
|
|
114
126
|
node: attr,
|
|
115
|
-
messageId: suggestions.length ?
|
|
127
|
+
messageId: suggestions.length ? withSuggestion : withoutSuggestion,
|
|
116
128
|
data: {
|
|
117
129
|
prop,
|
|
118
130
|
value,
|
|
131
|
+
element,
|
|
132
|
+
cssVar: cssVar ?? '',
|
|
119
133
|
valid: valid.map(v => `\`${v}\``).join(', '),
|
|
120
134
|
suggestions: suggestions.map(v => `\`${v}\``).join(' or '),
|
|
121
135
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allxsmith/eslint-plugin-bestax",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
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.18.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"eslint": "^10.0.0"
|
|
@@ -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. And one element shadows a helper name:\n`Theme` takes a prop per Bulma CSS variable, so its `radius` sets\n`--bulma-radius` rather than emitting a class, while its type still says\notherwise. The rule skips that one pair until the library picks a meaning.\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 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` on `Theme` is the helper, as everywhere else, but a string outside\nits values still sets `--bulma-radius` there through a deprecated route. The\nrule reports it with a message that says so and points at `bulmaVars`, unless\nit is a near miss of `radiusless`, which 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```\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"
|
|
76
76
|
}
|