@allxsmith/eslint-plugin-bestax 1.1.8 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,10 +148,24 @@ 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. And one element shadows a helper name:
152
- `Theme` takes a prop per Bulma CSS variable, so its `radius` sets
153
- `--bulma-radius` rather than emitting a class, while its type still says
154
- otherwise. The rule skips that one pair until the library picks a meaning.
151
+ would be worse than reporting nothing.
152
+
153
+ `radius` and `columnGap` on `Theme` are the helpers, as everywhere else, but a
154
+ string outside their values still sets `--bulma-radius` or `--bulma-column-gap`
155
+ there through a deprecated route. The rule reports it with a message that says
156
+ so and points at `bulmaVars`, unless it is a near miss of one of the values,
157
+ which gets the usual suggestion:
158
+
159
+ ```jsx
160
+ <Theme radius="6px" /> // ✗ deprecated → bulmaVars
161
+ <Theme radius="radiusles" /> // ✗ Did you mean `radiusless`?
162
+ <Theme bulmaVars={{ '--bulma-radius': '6px' }} /> // ✓
163
+ <Theme columnGap="1rem" /> // ✗ deprecated → bulmaVars
164
+ <Theme bulmaVars={{ '--bulma-column-gap': '1rem' }} /> // ✓
165
+ ```
166
+
167
+ The gap props take their steps as numbers as well, so `<Box gap={2} />` is
168
+ accepted where `<Box m={2} />` is reported.
155
169
 
156
170
  ### no-deprecated-props
157
171
 
@@ -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,CAiItD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAUtD,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;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAwGzE,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,CAuItD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAUtD,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;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAwGzE,CAAC"}
@@ -89,6 +89,12 @@ export const DEPRECATED_PROPS = {
89
89
  note: 'Use `variant` and `features` instead.',
90
90
  },
91
91
  },
92
+ 'Popover.Close': {
93
+ isFullWidth: {
94
+ replacement: 'isFullwidth',
95
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
96
+ },
97
+ },
92
98
  Select: {
93
99
  isFullWidth: {
94
100
  replacement: 'isFullwidth',
@@ -167,9 +173,7 @@ export const BULMA_COMPONENT_CLASSES = new Map([
167
173
  ['checkboxes', { component: 'Checkboxes', converts: false }],
168
174
  ['radio', { component: 'Radio', converts: false }],
169
175
  ['radios', { component: 'Radios', converts: false }],
170
- ['file', { component: 'File', converts: false }],
171
176
  ['dropdown', { component: 'Dropdown', converts: false }],
172
- ['icon-text', { component: 'IconText', converts: false }],
173
177
  ['menu-item', { component: 'Menu.Item', converts: false }],
174
178
  ['message', { component: 'Message', converts: false }],
175
179
  ['modal', { component: 'Modal', converts: false }],
@@ -234,7 +238,9 @@ export const BULMA_COMPONENT_CLASSES = new Map([
234
238
  ['breadcrumb', { component: 'Breadcrumb', converts: true }],
235
239
  ['skeleton-block', { component: 'Skeleton', converts: true }],
236
240
  ['skeleton-lines', { component: 'Skeleton', converts: true }],
241
+ ['file', { component: 'File', converts: true }],
237
242
  ['icon', { component: 'Icon', converts: true }],
243
+ ['icon-text', { component: 'IconText', converts: true }],
238
244
  ['image', { component: 'Image', converts: true }],
239
245
  ['menu', { component: 'Menu', converts: true }],
240
246
  ['menu-label', { component: 'Menu.Label', converts: true }],
@@ -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 name means something else ENTIRELY on some element, the safe
21
- * direction is not available and the table has to be told: see
22
- * `NOT_A_HELPER_PROP` below.
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
@@ -46,51 +46,82 @@
46
46
  * riding along.
47
47
  */
48
48
  export declare const HELPER_VALUES: ReadonlyMap<string, readonly string[]>;
49
+ /**
50
+ * Props that take their steps as numbers as well as strings, so `gap={2}`
51
+ * renders `is-gap-2` where `m={2}` renders nothing.
52
+ *
53
+ * The gap props are the case: `Grid` took its gaps as numbers before they
54
+ * were shared helper props, and every gap prop still does. A number is
55
+ * judged against the tuple read as strings, so `gap={1.5}` is accepted and
56
+ * `gap={9}` is not. On `Columns` the tuple is its own whole steps, from
57
+ * ELEMENT_VALUES, so `<Columns gap={1.5} />` is reported.
58
+ */
59
+ export declare const NUMERIC_STEPS: ReadonlySet<string>;
49
60
  /**
50
61
  * Props whose only value REMOVES the thing the prop names, and what to call
51
62
  * that thing in a message.
52
63
  *
53
- * `radius` and `shadow` read like switches for "give this a radius" and "give
54
- * this a shadow", and their one value does the reverse: `radiusless`,
55
- * `shadowless`. The generic shorthand remedy, "give it a value:
56
- * `shadowless`", therefore tells an author who wrote `<Box shadow />` to do
57
- * the opposite of what they meant, on an element whose shadow is on by
64
+ * `shadow` reads like a switch for "give this a shadow", and its one value
65
+ * does the reverse: `shadowless`. The generic shorthand remedy, "give it a
66
+ * value: `shadowless`", therefore tells an author who wrote `<Box shadow />`
67
+ * to do the opposite of what they meant, on an element whose shadow is on by
58
68
  * default. The report is right either way; only the remedy needed separating.
59
69
  *
70
+ * `radius` left this map when it took Bulma's radius sizes, so `<Box radius />`
71
+ * now gets the ordinary remedy, whose list includes values that add one.
72
+ *
60
73
  * The rule pairs this with a `valid.length === 1` check rather than trusting
61
74
  * it alone, so "its only value" cannot become false by a value being added to
62
- * one of those tuples.
75
+ * a prop's tuple.
63
76
  */
64
77
  export declare const REMOVES_ONLY: ReadonlyMap<string, string>;
65
78
  /**
66
- * Elements on which one of the names above is NOT a helper prop, so the table
67
- * must not be applied to it.
79
+ * Helper props that, on one element, still set a CSS variable when given a
80
+ * string outside their tuple: a deprecated route the library keeps so code
81
+ * written against its old behaviour keeps rendering. Keyed by element, then by
82
+ * prop, to the variable the value lands in.
68
83
  *
69
84
  * `Theme` mints a prop for every Bulma CSS variable, and `--bulma-radius`
70
- * collides with the `radius` helper. On `Theme` the variable wins at runtime
71
- * while the declared type stays the helper union, so the two disagree and the
72
- * rule cannot say anything true about the pair (#694). Both readings:
73
- * `<Theme radius="6px" />` does not typecheck and does set the variable, so
74
- * reporting it is a false positive in the JS and JSX projects this rule is
75
- * for; `<Theme radius="radiusless" />` typechecks and renders
76
- * `style="--bulma-radius: radiusless"`, so the value the rule would call
77
- * correct is the one that does nothing. Silence is the only honest answer
78
- * until #694 picks a meaning.
79
- *
80
- * `--bulma-shadow` would collide the same way and is filtered out of that map
81
- * for exactly this reason, which is why `shadow` is a helper prop on `Theme`
82
- * and needs no entry here. That filter is the precedent #694 would follow.
83
- *
84
- * This is the one-way invariant above being held rather than abandoned:
85
- * silence on a wrong value is the direction to be wrong in, and a report on a
86
- * right one is not. Declared rather than derived, and held to the library by
87
- * `scripts/helper-prop-collisions.test.mjs`, which recomputes the collision
88
- * from the library's own variable list and fails if this map and the real one
89
- * disagree. Same shape as `SIBLING_RUNTIME_DEPS` in check-conformance.mjs,
90
- * and for the same reason: a declaration no test can falsify becomes a
91
- * fiction.
85
+ * collided with the `radius` helper: until #694 that prop set the variable
86
+ * whatever its type said. It is the helper now, as everywhere else, but a
87
+ * string that is not a helper value still reaches `--bulma-radius`, with a
88
+ * development warning pointing at `bulmaVars`. So `<Theme radius="6px" />` is
89
+ * worth reporting, and the ordinary message, which says nothing renders, would
90
+ * be false about it. The rule reports these with a message that says what
91
+ * really happens and names the supported spelling, except for a near miss of
92
+ * a valid value, which gets the usual suggestion with the same correction.
93
+ *
94
+ * Only a string takes that route. A number or `true` goes to the helper on
95
+ * `Theme` as well, so the ordinary messages about those stay true.
96
+ *
97
+ * `columnGap` is the same story one release later: `--bulma-column-gap` minted
98
+ * it as a variable prop, untyped but working, until the gap helpers became
99
+ * shared helper props. A string that is not a gap step still sets the
100
+ * variable on `Theme`, so `<Theme columnGap="1rem" />` gets the same report.
101
+ *
102
+ * `--bulma-shadow` would have collided the same way and was kept out of
103
+ * Theme's variable map from the start, so `shadow` needs no entry.
104
+ *
105
+ * Declared rather than derived, and held to the library by
106
+ * `scripts/helper-prop-collisions.test.mjs`, which reads Theme's source and
107
+ * fails if a helper name is still taken as a variable prop or if this map and
108
+ * the routes Theme really has disagree. Same shape as `SIBLING_RUNTIME_DEPS`
109
+ * in check-conformance.mjs, and for the same reason: a declaration no test can
110
+ * falsify becomes a fiction.
111
+ */
112
+ export declare const DEPRECATED_VARIABLE_ROUTE: ReadonlyMap<string, ReadonlyMap<string, string>>;
113
+ /**
114
+ * Props an element declares itself with narrower values than the helper prop
115
+ * of the same name. Keyed by element, then by prop, to the values the element
116
+ * renders, and read before `HELPER_VALUES`.
117
+ *
118
+ * `Columns` declares its own `gap`, the columns gutter, which renders
119
+ * `is-<n>` and comes in whole steps only. Judged against `validGaps`, a half
120
+ * step there passed although it renders nothing, and a report listed the
121
+ * half steps as valid. The whole steps are read off the library's tuple
122
+ * rather than copied.
92
123
  */
93
- export declare const NOT_A_HELPER_PROP: ReadonlyMap<string, ReadonlySet<string>>;
124
+ export declare const ELEMENT_VALUES: ReadonlyMap<string, ReadonlyMap<string, readonly string[]>>;
94
125
  /** Props that emit a class only when a flex `display` is also set. */
95
126
  export declare const FLEX_CONTAINER_PROPS: readonly string[];
96
127
  /** Every `display*` prop name, in declaration order. */
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CACzC,MAAM,EACN,WAAW,CAAC,MAAM,CAAC,CACwB,CAAC;AAE9C,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"}
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/lib/values.ts"],"names":[],"mappings":"AAgGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CA6C/D,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAI5C,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAEnD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CACjD,MAAM,EACN,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAS3B,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CACtC,MAAM,EACN,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAMtC,CAAC;AAEH,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"}
@@ -13,7 +13,7 @@
13
13
  * does not. See eslint-plugin/CLAUDE.md, which also records why the dependency
14
14
  * is a runtime one and must stay that way.
15
15
  */
16
- import { validAlignContents, validAlignItems, validAlignSelfs, validAlignments, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validInteractions, validJustifyContents, validOverflows, validRadii, validResponsives, validSchemeColors, validShadows, validSizes, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities, } from '@allxsmith/bestax-bulma/constants';
16
+ import { validAlignContents, validAlignItems, validAlignSelfs, validAlignments, validAspectRatios, validAxisOverflows, validColorShades, validColors, validCursors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFloats, validFontFamilies, validGaps, validInteractions, validJustifyContents, validOverflows, validPositions, validRadii, validResponsives, validSchemeColors, validShadows, validSizes, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities, } from '@allxsmith/bestax-bulma/constants';
17
17
  const SPACING_PROPS = [
18
18
  'm',
19
19
  'mt',
@@ -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 name means something else ENTIRELY on some element, the safe
77
- * direction is not available and the table has to be told: see
78
- * `NOT_A_HELPER_PROP` below.
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
@@ -122,11 +122,20 @@ export const HELPER_VALUES = new Map([
122
122
  ['viewport', validViewports],
123
123
  ['float', validFloats],
124
124
  ['overflow', validOverflows],
125
+ ['overflowX', validAxisOverflows],
126
+ ['overflowY', validAxisOverflows],
125
127
  ['interaction', validInteractions],
126
128
  ['cursor', validCursors],
127
129
  ['radius', validRadii],
128
130
  ['shadow', validShadows],
129
131
  ['responsive', validResponsives],
132
+ ['pos', validPositions],
133
+ ['aspectRatio', validAspectRatios],
134
+ // `gapless` is a boolean and stays out, like the other switches. The steps
135
+ // are also accepted as numbers; see NUMERIC_STEPS.
136
+ ['gap', validGaps],
137
+ ['columnGap', validGaps],
138
+ ['rowGap', validGaps],
130
139
  ['colorShade', validColorShades],
131
140
  ['backgroundColorShade', validColorShades],
132
141
  // The colour props take the tuple plus the two CSS-wide keywords that
@@ -138,54 +147,101 @@ export const HELPER_VALUES = new Map([
138
147
  [...validColors, ...validSchemeColors, 'inherit', 'current'],
139
148
  ],
140
149
  ]);
150
+ /**
151
+ * Props that take their steps as numbers as well as strings, so `gap={2}`
152
+ * renders `is-gap-2` where `m={2}` renders nothing.
153
+ *
154
+ * The gap props are the case: `Grid` took its gaps as numbers before they
155
+ * were shared helper props, and every gap prop still does. A number is
156
+ * judged against the tuple read as strings, so `gap={1.5}` is accepted and
157
+ * `gap={9}` is not. On `Columns` the tuple is its own whole steps, from
158
+ * ELEMENT_VALUES, so `<Columns gap={1.5} />` is reported.
159
+ */
160
+ export const NUMERIC_STEPS = new Set([
161
+ 'gap',
162
+ 'columnGap',
163
+ 'rowGap',
164
+ ]);
141
165
  /**
142
166
  * Props whose only value REMOVES the thing the prop names, and what to call
143
167
  * that thing in a message.
144
168
  *
145
- * `radius` and `shadow` read like switches for "give this a radius" and "give
146
- * this a shadow", and their one value does the reverse: `radiusless`,
147
- * `shadowless`. The generic shorthand remedy, "give it a value:
148
- * `shadowless`", therefore tells an author who wrote `<Box shadow />` to do
149
- * the opposite of what they meant, on an element whose shadow is on by
169
+ * `shadow` reads like a switch for "give this a shadow", and its one value
170
+ * does the reverse: `shadowless`. The generic shorthand remedy, "give it a
171
+ * value: `shadowless`", therefore tells an author who wrote `<Box shadow />`
172
+ * to do the opposite of what they meant, on an element whose shadow is on by
150
173
  * default. The report is right either way; only the remedy needed separating.
151
174
  *
175
+ * `radius` left this map when it took Bulma's radius sizes, so `<Box radius />`
176
+ * now gets the ordinary remedy, whose list includes values that add one.
177
+ *
152
178
  * The rule pairs this with a `valid.length === 1` check rather than trusting
153
179
  * it alone, so "its only value" cannot become false by a value being added to
154
- * one of those tuples.
180
+ * a prop's tuple.
155
181
  */
156
182
  export const REMOVES_ONLY = new Map([
157
- ['radius', 'border radius'],
158
183
  ['shadow', 'shadow'],
159
184
  ]);
160
185
  /**
161
- * Elements on which one of the names above is NOT a helper prop, so the table
162
- * must not be applied to it.
186
+ * Helper props that, on one element, still set a CSS variable when given a
187
+ * string outside their tuple: a deprecated route the library keeps so code
188
+ * written against its old behaviour keeps rendering. Keyed by element, then by
189
+ * prop, to the variable the value lands in.
163
190
  *
164
191
  * `Theme` mints a prop for every Bulma CSS variable, and `--bulma-radius`
165
- * collides with the `radius` helper. On `Theme` the variable wins at runtime
166
- * while the declared type stays the helper union, so the two disagree and the
167
- * rule cannot say anything true about the pair (#694). Both readings:
168
- * `<Theme radius="6px" />` does not typecheck and does set the variable, so
169
- * reporting it is a false positive in the JS and JSX projects this rule is
170
- * for; `<Theme radius="radiusless" />` typechecks and renders
171
- * `style="--bulma-radius: radiusless"`, so the value the rule would call
172
- * correct is the one that does nothing. Silence is the only honest answer
173
- * until #694 picks a meaning.
174
- *
175
- * `--bulma-shadow` would collide the same way and is filtered out of that map
176
- * for exactly this reason, which is why `shadow` is a helper prop on `Theme`
177
- * and needs no entry here. That filter is the precedent #694 would follow.
178
- *
179
- * This is the one-way invariant above being held rather than abandoned:
180
- * silence on a wrong value is the direction to be wrong in, and a report on a
181
- * right one is not. Declared rather than derived, and held to the library by
182
- * `scripts/helper-prop-collisions.test.mjs`, which recomputes the collision
183
- * from the library's own variable list and fails if this map and the real one
184
- * disagree. Same shape as `SIBLING_RUNTIME_DEPS` in check-conformance.mjs,
185
- * and for the same reason: a declaration no test can falsify becomes a
186
- * fiction.
192
+ * collided with the `radius` helper: until #694 that prop set the variable
193
+ * whatever its type said. It is the helper now, as everywhere else, but a
194
+ * string that is not a helper value still reaches `--bulma-radius`, with a
195
+ * development warning pointing at `bulmaVars`. So `<Theme radius="6px" />` is
196
+ * worth reporting, and the ordinary message, which says nothing renders, would
197
+ * be false about it. The rule reports these with a message that says what
198
+ * really happens and names the supported spelling, except for a near miss of
199
+ * a valid value, which gets the usual suggestion with the same correction.
200
+ *
201
+ * Only a string takes that route. A number or `true` goes to the helper on
202
+ * `Theme` as well, so the ordinary messages about those stay true.
203
+ *
204
+ * `columnGap` is the same story one release later: `--bulma-column-gap` minted
205
+ * it as a variable prop, untyped but working, until the gap helpers became
206
+ * shared helper props. A string that is not a gap step still sets the
207
+ * variable on `Theme`, so `<Theme columnGap="1rem" />` gets the same report.
208
+ *
209
+ * `--bulma-shadow` would have collided the same way and was kept out of
210
+ * Theme's variable map from the start, so `shadow` needs no entry.
211
+ *
212
+ * Declared rather than derived, and held to the library by
213
+ * `scripts/helper-prop-collisions.test.mjs`, which reads Theme's source and
214
+ * fails if a helper name is still taken as a variable prop or if this map and
215
+ * the routes Theme really has disagree. Same shape as `SIBLING_RUNTIME_DEPS`
216
+ * in check-conformance.mjs, and for the same reason: a declaration no test can
217
+ * falsify becomes a fiction.
187
218
  */
188
- export const NOT_A_HELPER_PROP = new Map([['Theme', new Set(['radius'])]]);
219
+ export const DEPRECATED_VARIABLE_ROUTE = new Map([
220
+ [
221
+ 'Theme',
222
+ new Map([
223
+ ['radius', '--bulma-radius'],
224
+ ['columnGap', '--bulma-column-gap'],
225
+ ]),
226
+ ],
227
+ ]);
228
+ /**
229
+ * Props an element declares itself with narrower values than the helper prop
230
+ * of the same name. Keyed by element, then by prop, to the values the element
231
+ * renders, and read before `HELPER_VALUES`.
232
+ *
233
+ * `Columns` declares its own `gap`, the columns gutter, which renders
234
+ * `is-<n>` and comes in whole steps only. Judged against `validGaps`, a half
235
+ * step there passed although it renders nothing, and a report listed the
236
+ * half steps as valid. The whole steps are read off the library's tuple
237
+ * rather than copied.
238
+ */
239
+ export const ELEMENT_VALUES = new Map([
240
+ [
241
+ 'Columns',
242
+ new Map([['gap', validGaps.filter(step => !step.includes('.'))]]),
243
+ ],
244
+ ]);
189
245
  /** Props that emit a class only when a flex `display` is also set. */
190
246
  export const FLEX_CONTAINER_PROPS = [
191
247
  'flexDirection',
@@ -25,10 +25,14 @@
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, with one exception the
29
- * rule has to know about: a name in it can mean something else entirely on a
30
- * particular element, and then judging it reports working code.
31
- * `NOT_A_HELPER_PROP` is that list, and `Theme`'s `radius` is why it exists.
28
+ * The table is keyed by prop rather than by element. The facts about a
29
+ * particular element the rule needs are `ELEMENT_VALUES`, for a prop an
30
+ * element declares with narrower values (`Columns`' whole-step `gap`), and
31
+ * `DEPRECATED_VARIABLE_ROUTE`: on `Theme`, a `radius` or `columnGap` string
32
+ * outside the tuple still sets a variable through a deprecated route, so that
33
+ * report says so rather than claiming nothing renders. A near miss of a valid value still gets the suggestion
34
+ * there, because it is most likely that value mistyped, and pointing it at
35
+ * `bulmaVars` would only move the typo.
32
36
  */
33
37
  import type { Rule } from 'eslint';
34
38
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAiDnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAoGhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"valid-helper-value.d.ts","sourceRoot":"","sources":["../../src/rules/valid-helper-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAyDnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA4IhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,4 +1,4 @@
1
- import { HELPER_VALUES, NOT_A_HELPER_PROP, REMOVES_ONLY, } from '../lib/values.js';
1
+ import { DEPRECATED_VARIABLE_ROUTE, ELEMENT_VALUES, HELPER_VALUES, NUMERIC_STEPS, 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.
@@ -6,10 +6,17 @@ import { isTrueValue, literalValue, numericValue, elementOf, valuesThatRender, w
6
6
  * Short values are not suggested for: every entry of a numeric scale is one
7
7
  * edit from `"8"`, so `textSize="8"` would be answered with "did you mean 1
8
8
  * or 2 or 3", where the full list of valid values is what actually helps.
9
+ *
10
+ * Nor is a number with a unit. `"8px"` is a CSS length, not a mistyped step,
11
+ * and it is two edits from the bare digit `8`, so the gap props answered it
12
+ * with "did you mean `8`?", a 4rem gap, where on Theme the `bulmaVars` remedy
13
+ * was the true one.
9
14
  */
10
15
  function suggest(value, valid) {
11
16
  if (value.length < 3)
12
17
  return [];
18
+ if (/^[\d.]+[a-z%]+$/i.test(value))
19
+ return [];
13
20
  const distance = (a, b) => {
14
21
  const d = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
15
22
  for (let i = 0; i <= a.length; i++)
@@ -39,12 +46,15 @@ const rule = {
39
46
  },
40
47
  schema: [],
41
48
  messages: {
42
- invalid: '`{{prop}}="{{value}}"` is not a value {{prop}} accepts, so the class is never emitted and nothing renders. Valid values: {{valid}}.',
43
- invalidWithSuggestion: '`{{prop}}="{{value}}"` is not a value {{prop}} accepts, so the class is never emitted and nothing renders. Did you mean {{suggestions}}?',
44
- numeric: '`{{prop}}={{{value}}}` is a number, and {{prop}} is matched against strings, so the class is never emitted and nothing renders. Write `{{prop}}="{{value}}"`.',
49
+ invalid: '`{{prop}}="{{value}}"` is not a value {{prop}} accepts, so nothing renders. Valid values: {{valid}}.',
50
+ invalidWithSuggestion: '`{{prop}}="{{value}}"` is not a value {{prop}} accepts, so nothing renders. Did you mean {{suggestions}}?',
51
+ numeric: '`{{prop}}={{{value}}}` is a number, and {{prop}} is matched against strings, so nothing renders. Write `{{prop}}="{{value}}"`.',
45
52
  numericInvalid: '`{{prop}}={{{value}}}` is a number, and {{prop}} is matched against strings. `"{{value}}"` is not a value it accepts either. Valid values: {{valid}}.',
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}}.',
53
+ numericStepInvalid: '`{{prop}}={{{value}}}` is not a step {{prop}} accepts, so nothing renders. Valid values: {{valid}}.',
54
+ shorthand: '`{{prop}}` is `true` here, and {{prop}} is matched against strings, so nothing renders. Give it a value: {{valid}}.',
47
55
  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.',
56
+ 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}}.",
57
+ 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
58
  },
49
59
  },
50
60
  create(context) {
@@ -56,24 +66,25 @@ const rule = {
56
66
  const element = elementOf(context, opening, imports);
57
67
  if (element === null)
58
68
  return;
59
- // A name in the table can mean something else on a particular
60
- // element, in which case the table says nothing about it. `Theme`'s
61
- // `radius` is the case; see NOT_A_HELPER_PROP.
62
- const shadowed = NOT_A_HELPER_PROP.get(element);
69
+ // Props whose out-of-tuple strings still set a variable on this
70
+ // element. `Theme`'s `radius` and `columnGap` are the cases; see
71
+ // DEPRECATED_VARIABLE_ROUTE.
72
+ const routes = DEPRECATED_VARIABLE_ROUTE.get(element);
73
+ // Props this element declares with its own, narrower values; see
74
+ // ELEMENT_VALUES.
75
+ const own = ELEMENT_VALUES.get(element);
63
76
  for (const attr of valuesThatRender(opening)) {
64
77
  const prop = attr.name.name;
65
- if (shadowed?.has(prop))
66
- continue;
67
- const valid = HELPER_VALUES.get(prop);
78
+ const valid = own?.get(prop) ?? HELPER_VALUES.get(prop);
68
79
  if (!valid)
69
80
  continue;
70
81
  // `true`, bare or explicit, matches no tuple of strings. Same
71
82
  // argument as the numeric case, one type further out.
72
83
  if (isTrueValue(attr)) {
73
- // `radius` and `shadow` are the props a shorthand is most natural
74
- // on and most wrong on, because their one value removes rather
75
- // than adds. The length check is what keeps "its only value" true
76
- // rather than trusting the table to stay a single value.
84
+ // A prop in REMOVES_ONLY is where a shorthand is most natural and
85
+ // most wrong, because its one value removes rather than adds. The
86
+ // length check is what keeps "its only value" true rather than
87
+ // trusting the table to stay a single value.
77
88
  const thing = REMOVES_ONLY.get(prop);
78
89
  const removes = thing !== undefined && valid.length === 1;
79
90
  context.report({
@@ -93,6 +104,23 @@ const rule = {
93
104
  // quotes, not the value.
94
105
  const numeric = numericValue(attr);
95
106
  if (numeric !== null) {
107
+ // A prop that takes its steps as numbers renders a valid one, so
108
+ // only a number that is not a step is worth a report, and the
109
+ // quotes are not the fix.
110
+ if (NUMERIC_STEPS.has(prop)) {
111
+ if (!valid.includes(String(numeric))) {
112
+ context.report({
113
+ node: attr,
114
+ messageId: 'numericStepInvalid',
115
+ data: {
116
+ prop,
117
+ value: String(numeric),
118
+ valid: valid.map(v => `\`${v}\``).join(', '),
119
+ },
120
+ });
121
+ }
122
+ continue;
123
+ }
96
124
  context.report({
97
125
  node: attr,
98
126
  messageId: valid.includes(String(numeric))
@@ -110,12 +138,26 @@ const rule = {
110
138
  if (value === null || valid.includes(value))
111
139
  continue;
112
140
  const suggestions = suggest(value, valid);
141
+ // Where the element has a deprecated route, the value renders as a
142
+ // variable, so "nothing renders" would be false. Only a non-empty
143
+ // string takes that route, as in the library: an empty one sets
144
+ // nothing, and the `true` and numeric cases above go to the helper.
145
+ // A near miss still gets the suggestion rather than `bulmaVars`.
146
+ const cssVar = value === '' ? undefined : routes?.get(prop);
147
+ const [withSuggestion, withoutSuggestion] = cssVar === undefined
148
+ ? ['invalidWithSuggestion', 'invalid']
149
+ : [
150
+ 'deprecatedVariableWithSuggestion',
151
+ 'deprecatedVariable',
152
+ ];
113
153
  context.report({
114
154
  node: attr,
115
- messageId: suggestions.length ? 'invalidWithSuggestion' : 'invalid',
155
+ messageId: suggestions.length ? withSuggestion : withoutSuggestion,
116
156
  data: {
117
157
  prop,
118
158
  value,
159
+ element,
160
+ cssVar: cssVar ?? '',
119
161
  valid: valid.map(v => `\`${v}\``).join(', '),
120
162
  suggestions: suggestions.map(v => `\`${v}\``).join(' or '),
121
163
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allxsmith/eslint-plugin-bestax",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
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.18.0"
44
+ "@allxsmith/bestax-bulma": "^5.26.0"
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[![npm version](https://img.shields.io/npm/v/@allxsmith/eslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[![npm downloads](https://img.shields.io/npm/dm/@allxsmith/eslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[![npm provenance](https://img.shields.io/badge/npm-provenance-3fb950.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Socket Badge](https://badge.socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/latest)](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)\n[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/allxsmith/bestax/badge)](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/14361/badge)](https://www.bestpractices.dev/projects/14361)\n[![Security policy](https://img.shields.io/badge/security-policy-blue.svg)](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[![npm version](https://img.shields.io/npm/v/@allxsmith/eslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[![npm downloads](https://img.shields.io/npm/dm/@allxsmith/eslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)\n[![npm provenance](https://img.shields.io/badge/npm-provenance-3fb950.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Socket Badge](https://badge.socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/latest)](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)\n[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/allxsmith/bestax/badge)](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/14361/badge)](https://www.bestpractices.dev/projects/14361)\n[![Security policy](https://img.shields.io/badge/security-policy-blue.svg)](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"
76
76
  }