@allxsmith/eslint-plugin-bestax 0.0.0-development → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -23
- package/dist/generated/metadata.d.ts +5 -5
- package/dist/generated/metadata.js +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -8
- package/dist/lib/elements.d.ts +119 -0
- package/dist/lib/elements.d.ts.map +1 -1
- package/dist/lib/elements.js +270 -2
- package/dist/lib/values.d.ts +80 -8
- package/dist/lib/values.d.ts.map +1 -1
- package/dist/lib/values.js +100 -13
- package/dist/rules/no-color-as-surface.d.ts +11 -4
- package/dist/rules/no-color-as-surface.d.ts.map +1 -1
- package/dist/rules/no-color-as-surface.js +59 -7
- package/dist/rules/no-deprecated-props.d.ts.map +1 -1
- package/dist/rules/no-deprecated-props.js +42 -10
- package/dist/rules/no-inert-flex-props.d.ts.map +1 -1
- package/dist/rules/no-inert-flex-props.js +7 -5
- package/dist/rules/valid-helper-value.d.ts +13 -2
- package/dist/rules/valid-helper-value.d.ts.map +1 -1
- package/dist/rules/valid-helper-value.js +54 -4
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# @allxsmith/eslint-plugin-bestax
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)
|
|
4
|
+
[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
[](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)
|
|
7
7
|
[](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)
|
|
8
8
|
[](https://www.bestpractices.dev/projects/14361)
|
|
9
|
-
[](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)
|
|
10
9
|
[](https://github.com/allxsmith/bestax/blob/main/SECURITY.md)
|
|
11
10
|
|
|
12
11
|
ESLint rules for [`@allxsmith/bestax-bulma`](https://www.npmjs.com/package/@allxsmith/bestax-bulma).
|
|
@@ -19,15 +18,18 @@ nothing and says nothing.
|
|
|
19
18
|
**Scope, up front:** the helper props are typed as literal unions, so if you
|
|
20
19
|
write bestax in `.tsx` and run `tsc`, it already catches a wrong literal. This
|
|
21
20
|
plugin is for the places that check does not reach: JavaScript and JSX
|
|
22
|
-
projects,
|
|
23
|
-
of typechecking. The deprecation and flex rules are additive everywhere, since
|
|
21
|
+
projects, and lint stages that run before or instead of typechecking. The deprecation and flex rules are additive everywhere, since
|
|
24
22
|
no type error marks a deprecated prop or a flex prop that emits nothing.
|
|
25
23
|
|
|
26
24
|
## Requirements
|
|
27
25
|
|
|
28
26
|
ESLint 10, using [flat config](https://eslint.org/docs/latest/use/configure/configuration-files).
|
|
29
|
-
The plugin is ESM-only,
|
|
30
|
-
|
|
27
|
+
The plugin is ESM-only, which does not rule out a CommonJS config. An
|
|
28
|
+
`eslint.config.cjs` can `require()` it on a Node that supports `require(esm)`,
|
|
29
|
+
and `configs.recommended` reads straight off the result with no interop hop,
|
|
30
|
+
because `rules` and `configs` are named exports alongside the default. On a
|
|
31
|
+
Node without that support it throws `ERR_REQUIRE_ESM`, and an `import` from
|
|
32
|
+
`eslint.config.mjs` works either way.
|
|
31
33
|
|
|
32
34
|
## Setup
|
|
33
35
|
|
|
@@ -35,27 +37,51 @@ The plugin is ESM-only, so it cannot be `require()`d from a legacy
|
|
|
35
37
|
npm install --save-dev @allxsmith/eslint-plugin-bestax
|
|
36
38
|
```
|
|
37
39
|
|
|
40
|
+
### TypeScript
|
|
41
|
+
|
|
42
|
+
The preset sets no `parser`, so a TypeScript parser has to come from a config
|
|
43
|
+
object of your own. Put it first; the preset after:
|
|
44
|
+
|
|
38
45
|
```js
|
|
39
46
|
// eslint.config.js
|
|
40
47
|
import bestax from '@allxsmith/eslint-plugin-bestax';
|
|
48
|
+
import parser from '@typescript-eslint/parser';
|
|
41
49
|
|
|
42
|
-
export default [
|
|
50
|
+
export default [
|
|
51
|
+
{ files: ['**/*.{ts,tsx}'], languageOptions: { parser } },
|
|
52
|
+
bestax.configs.recommended,
|
|
53
|
+
];
|
|
43
54
|
```
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
Any TypeScript setup that sets a parser works the same way, `typescript-eslint`
|
|
57
|
+
included, precisely because the preset does not set one of its own.
|
|
58
|
+
|
|
59
|
+
The parser is a requirement, not a nicety. The preset matches `.tsx` because
|
|
60
|
+
that is where a TypeScript project's JSX lives, and with no parser supplied it
|
|
61
|
+
hands that file to the default one, which stops at the first type annotation:
|
|
62
|
+
`Parsing error: The keyword 'interface' is reserved`.
|
|
63
|
+
|
|
64
|
+
### JavaScript and JSX
|
|
65
|
+
|
|
66
|
+
If the project contains no `.tsx` at all, the preset alone is enough:
|
|
48
67
|
|
|
49
68
|
```js
|
|
69
|
+
// eslint.config.js
|
|
50
70
|
import bestax from '@allxsmith/eslint-plugin-bestax';
|
|
51
|
-
import tseslint from 'typescript-eslint';
|
|
52
71
|
|
|
53
|
-
export default [
|
|
72
|
+
export default [bestax.configs.recommended];
|
|
54
73
|
```
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
Add one `.tsx` file later and you need the parser block above. The failure is
|
|
76
|
+
loud rather than silent, which is the intended trade: leaving `.tsx` out of the
|
|
77
|
+
preset's own `files` would mean a TypeScript project got no rules on any `.tsx`
|
|
78
|
+
file and no indication why.
|
|
79
|
+
|
|
80
|
+
### Picking rules yourself
|
|
81
|
+
|
|
82
|
+
`files` is load-bearing: a flat config object without it inherits ESLint's
|
|
83
|
+
default `**/*.{js,mjs,cjs}` set, so leaving it out silently lints none of your
|
|
84
|
+
JSX.
|
|
59
85
|
|
|
60
86
|
```js
|
|
61
87
|
import bestax from '@allxsmith/eslint-plugin-bestax';
|
|
@@ -80,7 +106,7 @@ In `recommended` — each reports code that does not do what it says:
|
|
|
80
106
|
| Rule | Fixable | What it catches |
|
|
81
107
|
| --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
82
108
|
| `valid-helper-value` | — | Helper values the library silently drops: `textAlign="center"` (it is `centered`), `textSize="8"`, `mt="1rem"` |
|
|
83
|
-
| `no-deprecated-props` |
|
|
109
|
+
| `no-deprecated-props` | partly | Props the library deprecated: `isFullWidth`, `gapSize*`, `icon`. Fixes only the renames that cannot change what renders |
|
|
84
110
|
| `no-inert-flex-props` | — | `justifyContent` and friends without a flex `display`, which emit nothing |
|
|
85
111
|
|
|
86
112
|
Opt-in — this one reports code that works, and buys explicitness instead:
|
|
@@ -96,8 +122,9 @@ Bulma's rules, and each skips a value it cannot read as a literal.
|
|
|
96
122
|
A spread is handled by what it can change: `no-color-as-surface` and
|
|
97
123
|
`no-inert-flex-props` go silent, since a spread may carry the prop that makes
|
|
98
124
|
the code correct; `no-deprecated-props` reports but offers no fix; and
|
|
99
|
-
`valid-helper-value`
|
|
100
|
-
|
|
125
|
+
`valid-helper-value` judges only the values that actually render, so a spread
|
|
126
|
+
BEFORE the attribute leaves it reporting and a spread after it does not: JSX is
|
|
127
|
+
last-wins throughout, spreads included. No autofix changes what the code
|
|
101
128
|
renders.
|
|
102
129
|
|
|
103
130
|
### valid-helper-value
|
|
@@ -112,9 +139,14 @@ way of its `/constants` subpath, rather than from a list copied into this
|
|
|
112
139
|
package. The version those tuples come from is the copy of
|
|
113
140
|
`@allxsmith/bestax-bulma` this plugin resolves, which in an ordinary deduped
|
|
114
141
|
install is the same one your app uses; across a major bump it may not be, so
|
|
115
|
-
keep the two in step.
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
keep the two in step.
|
|
143
|
+
|
|
144
|
+
One family is outside its reach, knowingly: component-specific `color` props
|
|
145
|
+
have their own unions, so `<Button color="ghost">` is correct and reporting it
|
|
146
|
+
would be worse than reporting nothing. And one element shadows a helper name:
|
|
147
|
+
`Theme` takes a prop per Bulma CSS variable, so its `radius` sets
|
|
148
|
+
`--bulma-radius` rather than emitting a class, while its type still says
|
|
149
|
+
otherwise. The rule skips that one pair until the library picks a meaning.
|
|
118
150
|
|
|
119
151
|
### no-deprecated-props
|
|
120
152
|
|
|
@@ -138,7 +170,7 @@ code.
|
|
|
138
170
|
<Button color="primary" /> // ✓ Button really has an is-primary variant
|
|
139
171
|
|
|
140
172
|
// ✓ silent: the background is explicit, so `color` is plainly the text half
|
|
141
|
-
<Box
|
|
173
|
+
<Box bgColor="info" color="primary" />
|
|
142
174
|
```
|
|
143
175
|
|
|
144
176
|
### no-inert-flex-props
|
|
@@ -16,11 +16,11 @@ export declare const DEPRECATED_PROPS: Readonly<Record<string, Readonly<Record<s
|
|
|
16
16
|
* `textColor`, and a coloured background needs `bgColor`.
|
|
17
17
|
*
|
|
18
18
|
* NOT exhaustive. Membership is read from the TSDoc sentence the library uses
|
|
19
|
-
* to say so, and components that behave identically
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* to say so, and components that behave identically while wording it
|
|
20
|
+
* differently are missed, compound parts included. So absence here does NOT
|
|
21
|
+
* mean the element has a real `is-<color>` modifier: it means no sentence
|
|
22
|
+
* claimed otherwise. Elements that genuinely do have one are also absent, so
|
|
23
|
+
* this set is evidence of a text alias and never of a real variant.
|
|
24
24
|
*/
|
|
25
25
|
export declare const TEXT_ALIAS_COLOR_ELEMENTS: readonly string[];
|
|
26
26
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/gen-eslint-meta.mjs from the library's TSDoc.
|
|
2
|
-
// Do not edit by hand — run `pnpm gen:eslint-meta`. CI fails on a stale
|
|
2
|
+
// Do not edit by hand — run `pnpm gen:eslint-meta`. CI fails on a stale one.
|
|
3
3
|
/**
|
|
4
4
|
* Deprecated props, keyed by the JSX element name as written — so a compound
|
|
5
5
|
* part is `"Navbar.Brand"`.
|
|
@@ -139,11 +139,11 @@ export const DEPRECATED_PROPS = {
|
|
|
139
139
|
* `textColor`, and a coloured background needs `bgColor`.
|
|
140
140
|
*
|
|
141
141
|
* NOT exhaustive. Membership is read from the TSDoc sentence the library uses
|
|
142
|
-
* to say so, and components that behave identically
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
142
|
+
* to say so, and components that behave identically while wording it
|
|
143
|
+
* differently are missed, compound parts included. So absence here does NOT
|
|
144
|
+
* mean the element has a real `is-<color>` modifier: it means no sentence
|
|
145
|
+
* claimed otherwise. Elements that genuinely do have one are also absent, so
|
|
146
|
+
* this set is evidence of a text alias and never of a real variant.
|
|
147
147
|
*/
|
|
148
148
|
export const TEXT_ALIAS_COLOR_ELEMENTS = [
|
|
149
149
|
'Block',
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAO7C,eAAO,MAAM,KAAK;;;;;CAKgB,CAAC;AAkBnC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAKxC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAO7C,eAAO,MAAM,KAAK;;;;;CAKgB,CAAC;AAkBnC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAKxC,CAAC;AAyCF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAkB,CAAC;AACrE,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ESLint rules for `@allxsmith/bestax-bulma`.
|
|
3
3
|
*
|
|
4
|
-
* Flat config only (ESLint
|
|
4
|
+
* Flat config only (ESLint 10): import the plugin and spread its recommended
|
|
5
5
|
* config, or register it under a name of your choosing and turn on the rules
|
|
6
6
|
* you want.
|
|
7
7
|
*
|
|
@@ -48,14 +48,26 @@ const plugin = {
|
|
|
48
48
|
* `JSXOpeningElement`, spreading this preset on its own lint nothing at all
|
|
49
49
|
* while reporting no error to say so.
|
|
50
50
|
*
|
|
51
|
-
* `.ts`/`.mts`/`.cts` are
|
|
52
|
-
*
|
|
53
|
-
* would hand espree TypeScript syntax it cannot parse in a preset-only setup.
|
|
51
|
+
* `.tsx` is in the glob and `.ts`/`.mts`/`.cts` are not, which is a real
|
|
52
|
+
* distinction rather than an oversight:
|
|
54
53
|
*
|
|
55
|
-
* `
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
54
|
+
* - `.tsx` is where a TypeScript project's JSX lives, so the rules have to
|
|
55
|
+
* reach it. Leaving it out was considered and is worse: with the extension
|
|
56
|
+
* absent from this glob, a consumer who configures a TypeScript parser
|
|
57
|
+
* still gets no rules on any `.tsx` file, silently, because a flat config
|
|
58
|
+
* object only applies to what its own `files` matches. Silence for the
|
|
59
|
+
* library's main audience beats nothing else here.
|
|
60
|
+
* - `.ts`/`.mts`/`.cts` cannot hold JSX at all (TypeScript requires `.tsx`
|
|
61
|
+
* for that), so matching them would add parse risk for zero reports.
|
|
62
|
+
*
|
|
63
|
+
* The cost of including `.tsx` is that a TypeScript parser is a REQUIREMENT,
|
|
64
|
+
* not a nicety: spread on its own against a `.tsx` file carrying type syntax,
|
|
65
|
+
* this preset produces `Parsing error: The keyword 'interface' is reserved`
|
|
66
|
+
* rather than a lint report. That is why the docs lead with the parser form.
|
|
67
|
+
*
|
|
68
|
+
* `ecmaFeatures.jsx` makes `.jsx` parse under the default parser. No `parser`
|
|
69
|
+
* is set here on purpose: flat config merges `languageOptions`, so whatever an
|
|
70
|
+
* adjacent config object sets survives this block.
|
|
59
71
|
*/
|
|
60
72
|
plugin.configs.recommended = {
|
|
61
73
|
files: ['**/*.{js,mjs,cjs,jsx,tsx}'],
|
package/dist/lib/elements.d.ts
CHANGED
|
@@ -27,6 +27,29 @@ export interface ImportedNames {
|
|
|
27
27
|
export declare const emptyImports: () => ImportedNames;
|
|
28
28
|
/** Record the library's bindings from one import declaration. */
|
|
29
29
|
export declare function collectImport(node: any, into: ImportedNames): void;
|
|
30
|
+
/**
|
|
31
|
+
* Record the library's bindings from a CommonJS `require`.
|
|
32
|
+
*
|
|
33
|
+
* The preset matches `.cjs`, and flat config parses those as `sourceType:
|
|
34
|
+
* 'commonjs'` where `import` is a syntax error — so without this every rule
|
|
35
|
+
* was permanently silent on exactly the JavaScript projects the README sells
|
|
36
|
+
* the plugin to. A CJS `.js` file in a `"type": "commonjs"` package is the
|
|
37
|
+
* same shape.
|
|
38
|
+
*
|
|
39
|
+
* const { Box } = require('@allxsmith/bestax-bulma'); → named
|
|
40
|
+
* const { Box: MyBox } = require(…); → aliased
|
|
41
|
+
* const B = require(…); → namespace
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Does this binding pattern bind `name` anywhere inside it?
|
|
45
|
+
*
|
|
46
|
+
* A shadow does not have to be a plain identifier: `const { require } = shim`
|
|
47
|
+
* and `const [require] = shims` bind the name just as well, and the first
|
|
48
|
+
* version of the shadow guard read only `id.name` and missed both.
|
|
49
|
+
*/
|
|
50
|
+
export declare function patternBinds(pattern: any, name: string): boolean;
|
|
51
|
+
export declare function isLibraryRequire(declarator: any): boolean;
|
|
52
|
+
export declare function collectRequire(node: any, into: ImportedNames): void;
|
|
30
53
|
/**
|
|
31
54
|
* The canonical library name for a JSX element, or null when the element did
|
|
32
55
|
* not come from the library. Returns null rather than guessing.
|
|
@@ -39,14 +62,110 @@ export declare function collectImport(node: any, into: ImportedNames): void;
|
|
|
39
62
|
* without a scope, which the unit tests rely on.
|
|
40
63
|
*/
|
|
41
64
|
export declare function resolveElement(nameNode: any, imports: ImportedNames, bindsToImport?: (name: string) => boolean): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* A numeric JSX attribute value, or null.
|
|
67
|
+
*
|
|
68
|
+
* Every tuple the library validates against holds strings, and its membership
|
|
69
|
+
* check is a plain `includes`, so `m={2}` never matches `'2'` and emits
|
|
70
|
+
* nothing. That is a knowably wrong value rather than an unreadable one, and
|
|
71
|
+
* `m={2}` is the natural spelling in exactly the JavaScript and JSX projects
|
|
72
|
+
* this package exists for, so it must not be lumped in with the values a rule
|
|
73
|
+
* declines to judge.
|
|
74
|
+
*/
|
|
75
|
+
export declare function numericValue(attr: any): number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Attributes with only the LAST occurrence of each name kept, in source order.
|
|
78
|
+
*
|
|
79
|
+
* Duplicate JSX attributes are legal JavaScript and React resolves them
|
|
80
|
+
* last-wins, so judging every occurrence reports a value the element does not
|
|
81
|
+
* render: `<Box m="bogus" m="4" />` renders `m="4"` and was reported anyway.
|
|
82
|
+
*/
|
|
83
|
+
export declare function winningAttributes(opening: any): any[];
|
|
84
|
+
/**
|
|
85
|
+
* Attributes whose VALUE is the one that renders.
|
|
86
|
+
*
|
|
87
|
+
* `winningAttributes` settles duplicate names; this also drops anything a
|
|
88
|
+
* LATER spread could overwrite. JSX is last-wins throughout, spreads included,
|
|
89
|
+
* so "an explicit attribute wins over a spread" — which this package asserted
|
|
90
|
+
* in three places — holds only for a spread that comes FIRST.
|
|
91
|
+
* `<Box textAlign="center" {...rest} />` renders whatever `rest.textAlign`
|
|
92
|
+
* says, so the written value is not necessarily a value that renders at all.
|
|
93
|
+
*
|
|
94
|
+
* Only rules that judge a value need this. A rule reporting that a PROP is
|
|
95
|
+
* deprecated is right either way, because the author wrote the deprecated
|
|
96
|
+
* prop whether or not its value survives.
|
|
97
|
+
*/
|
|
98
|
+
export declare function valuesThatRender(opening: any): any[];
|
|
99
|
+
/**
|
|
100
|
+
* True only when the attribute's value cannot be read at all.
|
|
101
|
+
*
|
|
102
|
+
* This is the predicate every "say nothing" guard should use, and having three
|
|
103
|
+
* rounds of review find the same defect one rule at a time is what earned it a
|
|
104
|
+
* name. The rules kept conflating two different reasons to stay quiet:
|
|
105
|
+
*
|
|
106
|
+
* - the value is genuinely unknown (`{mode}`, an interpolated template) —
|
|
107
|
+
* it could be anything, including the right thing, so silence is correct
|
|
108
|
+
* - the value is readable but of a type no tuple entry can ever be (`true`,
|
|
109
|
+
* `{false}`, a number) — the library drops it, so it is knowably wrong
|
|
110
|
+
*
|
|
111
|
+
* Only the first is unreadable. Any guard that returns early on "not a string
|
|
112
|
+
* literal" swallows the second, which is how a bare `display` bought an
|
|
113
|
+
* element silence on its inert flex props.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isUnreadableValue(attr: any): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* True when the value is readable AND knowably not nullish.
|
|
118
|
+
*
|
|
119
|
+
* `isUnreadableValue` is the wrong predicate in front of a `??`, and this is
|
|
120
|
+
* the one call site in the package that has one: the library resolves
|
|
121
|
+
* `color: textColor ?? color`, so `color` is ignored only when `textColor` is
|
|
122
|
+
* non-nullish. A readable `null` is readable and still nullish, which made the
|
|
123
|
+
* `redundant` report claim `color` was ignored on an element that renders it.
|
|
124
|
+
*
|
|
125
|
+
* `{undefined}` needs no case of its own: it parses as an identifier, so it is
|
|
126
|
+
* unreadable and falls out above.
|
|
127
|
+
*/
|
|
128
|
+
export declare function isKnownNonNullish(attr: any): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* True when the attribute's value is `true`, either spelling.
|
|
131
|
+
*
|
|
132
|
+
* `<Box mt />` and `<Box mt={true} />` are the same value, both reach the
|
|
133
|
+
* library as `true`, and neither matches a tuple of strings — the bare one
|
|
134
|
+
* was reported and the explicit one was not. `{false}` is deliberately not
|
|
135
|
+
* included: it reads as switching the prop off, and the library skips a falsy
|
|
136
|
+
* value either way, so reporting it would be noise.
|
|
137
|
+
*/
|
|
138
|
+
export declare function isTrueValue(attr: any): boolean;
|
|
42
139
|
/**
|
|
43
140
|
* The string value of a JSX attribute, or null when it is not a plain string
|
|
44
141
|
* literal. Anything computed is skipped by every rule here: a value the rule
|
|
45
142
|
* cannot see is not a value it can judge.
|
|
46
143
|
*/
|
|
47
144
|
export declare function literalValue(attr: any): string | null;
|
|
145
|
+
/**
|
|
146
|
+
* The attribute that WINS for `name`, or undefined.
|
|
147
|
+
*
|
|
148
|
+
* Duplicate JSX attributes are legal JavaScript (only TypeScript rejects
|
|
149
|
+
* them) and React resolves them last-wins, so a first-match lookup read the
|
|
150
|
+
* losing one: `<Box color="primary" color="danger" />` renders
|
|
151
|
+
* `has-text-danger`, and hoisting the first to `textColor` changed that to
|
|
152
|
+
* `has-text-primary`.
|
|
153
|
+
*/
|
|
154
|
+
export declare function namedAttr(attrs: any[], name: string): any;
|
|
48
155
|
/** Plain-named attributes of an opening element, skipping spreads. */
|
|
49
156
|
export declare function attributesOf(opening: any): any[];
|
|
157
|
+
/**
|
|
158
|
+
* Attribute names written more than once on this element.
|
|
159
|
+
*
|
|
160
|
+
* Duplicates are legal JavaScript and React resolves them last-wins, so a
|
|
161
|
+
* rule can read the winner with `winningAttributes`. An AUTOFIX cannot: it
|
|
162
|
+
* edits one occurrence and leaves the other, which turned
|
|
163
|
+
* `<Tabs isFullWidth isFullWidth />` into `<Tabs isFullWidth isFullwidth />`,
|
|
164
|
+
* still carrying the deprecated prop. Every fix that rewrites an attribute
|
|
165
|
+
* name has to withhold itself here, so the check is a reader rather than a
|
|
166
|
+
* block copied into each rule.
|
|
167
|
+
*/
|
|
168
|
+
export declare function doubledNames(opening: any): Set<string>;
|
|
50
169
|
/** Does this element carry a spread, making its full prop set unknowable? */
|
|
51
170
|
export declare function hasSpread(opening: any): boolean;
|
|
52
171
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/lib/elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC,eAAO,MAAM,OAAO,4BAA4B,CAAC;AAKjD,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,gCAAgC;IAChC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,YAAY,QAAO,aAG9B,CAAC;AAQH,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAUlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,aAAa,EACtB,aAAa,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAoB,GACpD,MAAM,GAAG,IAAI,CAsBf;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAIhD;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAI/C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,IAAI,EAAE,OAAO,GACZ,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":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