@allxsmith/eslint-plugin-bestax 1.1.9 → 1.3.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
@@ -112,16 +112,16 @@ In `recommended` — each reports code that does not do what it says:
112
112
 
113
113
  Opt-in — these report code that works, and buy explicitness instead:
114
114
 
115
- | Rule | Fixable | What it asks for |
116
- | -------------------------- | ------- | ----------------------------------------------------------------------------------------------------------- |
117
- | `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |
118
- | `no-bulma-component-class` | — | The bestax component instead of a plain element styled with its Bulma class (`<button className="button">`) |
115
+ | Rule | Fixable | What it asks for |
116
+ | -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
117
+ | `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |
118
+ | `no-bulma-component-class` | — | The bestax component instead of its Bulma class, on a plain element (`<button className="button">`) or on another component (`<Columns className="box">`) |
119
119
 
120
120
  The rules that judge bestax elements resolve them through the import and
121
121
  through scope, so neither your own `<Box>` nor a local shadowing the imported
122
122
  one is linted against Bulma's rules, and each skips a value it cannot read as a
123
- literal. `no-bulma-component-class` reads plain HTML elements instead, and
124
- leaves components, custom elements and anything inside `<svg>` alone.
123
+ literal. `no-bulma-component-class` reads plain HTML elements as well, and
124
+ leaves custom elements and anything inside `<svg>` alone.
125
125
 
126
126
  A spread is handled by what it can change: `no-color-as-surface` and
127
127
  `no-inert-flex-props` go silent, since a spread may carry the prop that makes
@@ -150,17 +150,23 @@ 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
151
  would be worse than reporting nothing.
152
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:
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:
157
158
 
158
159
  ```jsx
159
- <Theme radius="6px" /> // ✗ deprecated → bulmaVars
160
- <Theme radius="radiusles" /> // ✗ Did you mean `radiusless`?
161
- <Theme bulmaVars={{ '--bulma-radius': '6px' }} /> // ✓
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' }} /> // ✓
162
165
  ```
163
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.
169
+
164
170
  ### no-deprecated-props
165
171
 
166
172
  ```jsx
@@ -189,21 +195,30 @@ code.
189
195
  ### no-bulma-component-class
190
196
 
191
197
  Off by default. It reports a plain element styled with a Bulma class that
192
- bestax has a component for, and names the component. Turn it on in an app that
193
- has moved onto bestax, with `bestax-migrate bulma-classes` or by hand, to keep
194
- raw Bulma markup from coming back.
198
+ bestax has a component for, and names the component. It also reports that
199
+ class in the `className` of a bestax component that renders another one, which
200
+ is where `bestax-migrate bulma-classes` leaves the second of two such classes
201
+ (`columns box`). Turn it on in an app that has moved onto bestax, with the
202
+ codemod or by hand, to keep raw Bulma markup from coming back.
195
203
 
196
204
  ```jsx
197
205
  <button className="button is-primary" /> // ✗ bestax renders .button as Button
198
206
  <div className="dropdown" /> // ✗ bestax has Dropdown, converted by hand
207
+ <Columns className="box" /> // ✗ bestax renders .box as Box
199
208
  <div className="has-text-centered mt-4" /> // ✓ helper classes are left alone
200
209
  <p className="help" /> // ✓ bestax renders .help inside its form controls
210
+ <Columns className="columns is-mobile" /> // ✓ its own classes
201
211
  ```
202
212
 
203
213
  It reads the classes a `className` spells out, including the strings in a
204
214
  ternary, a template, or a call to `clsx`, `classnames` or `tailwind-merge`
205
215
  (however the file imports or requires it), and reports one class per element:
206
- the one the codemod would decide by. A function your app defines, a `cn` in `lib/utils`
216
+ the one the codemod would decide by, a family's first and then, on a plain
217
+ element, the one whose component fits its tag best, its own tag before one it
218
+ reaches through `as`. On a component, whose tag can come from `as`, the table's
219
+ order decides. It reads `className` only on the components
220
+ the codemod writes, whose own classes it knows, so `<Input className="box">` is
221
+ left alone. A function your app defines, a `cn` in `lib/utils`
207
222
  included, is one it cannot see into, so it reads nothing there. It only reports. Whether an element converts
208
223
  depends on its tag, attributes and children, and `bestax-migrate bulma-classes`
209
224
  is the one place that judges that.
@@ -32,11 +32,26 @@ export interface BulmaComponentClass {
32
32
  * family whose component renders its own parts, converted by hand.
33
33
  */
34
34
  readonly converts: boolean;
35
+ /** For a class that converts: the tag its component renders by itself. */
36
+ readonly tag?: string;
37
+ /**
38
+ * For a class that converts: the tags its component renders, its own and
39
+ * the ones `as` reaches, or `'any'`. Of the classes an element carries,
40
+ * the codemod decides by the one whose component fits its tag best: its
41
+ * own tag, then one of these, then none.
42
+ */
43
+ readonly tags?: readonly string[] | 'any';
44
+ /**
45
+ * How to keep the class on an element another component renders, where an
46
+ * element of its own is not the answer.
47
+ */
48
+ readonly onAnother?: string;
35
49
  }
36
50
  /**
37
51
  * Bulma classes that name a bestax component, from bestax-migrate's
38
52
  * bulma-classes table. In the order the codemod decides an element's
39
- * component when it carries several: a family first, then by precedence.
53
+ * component when it carries several: a family first, then by precedence,
54
+ * among the ones whose component fits the element's tag best.
40
55
  */
41
56
  export declare const BULMA_COMPONENT_CLASSES: ReadonlyMap<string, BulmaComponentClass>;
42
57
  //# sourceMappingURL=metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/generated/metadata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