@allxsmith/eslint-plugin-bestax 0.0.0-development

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alex Smith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # @allxsmith/eslint-plugin-bestax
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@allxsmith%2Feslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@allxsmith%2Feslint-plugin-bestax.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Socket Badge](https://socket.dev/api/badge/npm/package/@allxsmith/eslint-plugin-bestax)](https://socket.dev/npm/package/@allxsmith/eslint-plugin-bestax/overview)
7
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/allxsmith/bestax/badge)](https://scorecard.dev/viewer/?uri=github.com/allxsmith/bestax)
8
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/14361/badge)](https://www.bestpractices.dev/projects/14361)
9
+ [![npm provenance](https://img.shields.io/badge/npm-provenance-3fb950.svg)](https://www.npmjs.com/package/@allxsmith/eslint-plugin-bestax#provenance)
10
+ [![Security policy](https://img.shields.io/badge/security-policy-blue.svg)](https://github.com/allxsmith/bestax/blob/main/SECURITY.md)
11
+
12
+ ESLint rules for [`@allxsmith/bestax-bulma`](https://www.npmjs.com/package/@allxsmith/bestax-bulma).
13
+
14
+ Every rule here reports code that does not do what it looks like it does. The
15
+ library's helper props validate by membership and emit nothing for a value they
16
+ do not recognise, with no throw and no warning, so `textColor="blue"` renders
17
+ nothing and says nothing.
18
+
19
+ **Scope, up front:** the helper props are typed as literal unions, so if you
20
+ write bestax in `.tsx` and run `tsc`, it already catches a wrong literal. This
21
+ plugin is for the places that check does not reach: JavaScript and JSX
22
+ projects, code in markdown and MDX, and lint stages that run before or instead
23
+ of typechecking. The deprecation and flex rules are additive everywhere, since
24
+ no type error marks a deprecated prop or a flex prop that emits nothing.
25
+
26
+ ## Requirements
27
+
28
+ ESLint 10, using [flat config](https://eslint.org/docs/latest/use/configure/configuration-files).
29
+ The plugin is ESM-only, so it cannot be `require()`d from a legacy
30
+ `.eslintrc.js`.
31
+
32
+ ## Setup
33
+
34
+ ```bash
35
+ npm install --save-dev @allxsmith/eslint-plugin-bestax
36
+ ```
37
+
38
+ ```js
39
+ // eslint.config.js
40
+ import bestax from '@allxsmith/eslint-plugin-bestax';
41
+
42
+ export default [bestax.configs.recommended];
43
+ ```
44
+
45
+ The preset matches `.js`, `.mjs`, `.cjs`, `.jsx` and `.tsx`, and enables JSX
46
+ parsing. It sets no `parser`, so whatever you configure for TypeScript
47
+ survives; put your TypeScript config first and this after:
48
+
49
+ ```js
50
+ import bestax from '@allxsmith/eslint-plugin-bestax';
51
+ import tseslint from 'typescript-eslint';
52
+
53
+ export default [...tseslint.configs.recommended, bestax.configs.recommended];
54
+ ```
55
+
56
+ Or register it yourself and pick rules. `files` is load-bearing: a flat config
57
+ object without it inherits ESLint's default `**/*.{js,mjs,cjs}` set, so leaving
58
+ it out silently lints none of your JSX.
59
+
60
+ ```js
61
+ import bestax from '@allxsmith/eslint-plugin-bestax';
62
+
63
+ export default [
64
+ {
65
+ files: ['**/*.{jsx,tsx}'],
66
+ plugins: { '@allxsmith/bestax': bestax },
67
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
68
+ rules: {
69
+ '@allxsmith/bestax/valid-helper-value': 'error',
70
+ '@allxsmith/bestax/no-deprecated-props': 'warn',
71
+ },
72
+ },
73
+ ];
74
+ ```
75
+
76
+ ## Rules
77
+
78
+ In `recommended` — each reports code that does not do what it says:
79
+
80
+ | Rule | Fixable | What it catches |
81
+ | --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
82
+ | `valid-helper-value` | — | Helper values the library silently drops: `textAlign="center"` (it is `centered`), `textSize="8"`, `mt="1rem"` |
83
+ | `no-deprecated-props` | yes | Props the library deprecated: `isFullWidth`, `gapSize*`, `icon`. Also the retired ones that emit a class no CSS matches |
84
+ | `no-inert-flex-props` | — | `justifyContent` and friends without a flex `display`, which emit nothing |
85
+
86
+ Opt-in — this one reports code that works, and buys explicitness instead:
87
+
88
+ | Rule | Fixable | What it asks for |
89
+ | --------------------- | ------- | ----------------------------------------------------------------------------- |
90
+ | `no-color-as-surface` | yes | `textColor` instead of the `color` alias, where `color` cannot mean a surface |
91
+
92
+ Each rule resolves elements through the import and through scope, so neither
93
+ your own `<Box>` nor a local shadowing the imported one is linted against
94
+ Bulma's rules, and each skips a value it cannot read as a literal.
95
+
96
+ A spread is handled by what it can change: `no-color-as-surface` and
97
+ `no-inert-flex-props` go silent, since a spread may carry the prop that makes
98
+ the code correct; `no-deprecated-props` reports but offers no fix; and
99
+ `valid-helper-value` still reports, because an explicit attribute wins over a
100
+ spread so a wrong literal is wrong regardless. No autofix changes what the code
101
+ renders.
102
+
103
+ ### valid-helper-value
104
+
105
+ ```jsx
106
+ <Box textAlign="center" /> // ✗ not a value textAlign accepts. Did you mean `centered`?
107
+ <Box textAlign="centered" /> // ✓
108
+ ```
109
+
110
+ The valid values come from the library's own exported tuples at lint time, by
111
+ way of its `/constants` subpath, rather than from a list copied into this
112
+ package. The version those tuples come from is the copy of
113
+ `@allxsmith/bestax-bulma` this plugin resolves, which in an ordinary deduped
114
+ install is the same one your app uses; across a major bump it may not be, so
115
+ keep the two in step. Component-specific `color` props are deliberately not
116
+ checked, since `<Button color="ghost">` is correct and reporting it would be
117
+ worse than reporting nothing.
118
+
119
+ ### no-deprecated-props
120
+
121
+ ```jsx
122
+ <Button isFullWidth /> // ✗ deprecated → fixes to isFullwidth
123
+ <Tabs color="info" /> // ✗ no .tabs.is-<color> CSS exists; no fix offered
124
+ ```
125
+
126
+ The table is generated from the library's own TSDoc, so a rename lands here
127
+ with the library rather than after someone notices.
128
+
129
+ ### no-color-as-surface
130
+
131
+ Off by default. `color` on the content elements is a documented alias for
132
+ `textColor`, so this rule is about saying which you meant, not about broken
133
+ code.
134
+
135
+ ```jsx
136
+ <Box color="primary" /> // ✗ ambiguous → fixes to textColor
137
+ <Box bgColor="primary" /> // ✓ a coloured surface
138
+ <Button color="primary" /> // ✓ Button really has an is-primary variant
139
+
140
+ // ✓ silent: the background is explicit, so `color` is plainly the text half
141
+ <Box backgroundColor="light" color="dark" />
142
+ ```
143
+
144
+ ### no-inert-flex-props
145
+
146
+ ```jsx
147
+ <Box justifyContent="center" /> // ✗ emits nothing
148
+ <Box display="flex" justifyContent="center" /> // ✓
149
+ <Box flexGrow="1" /> // ✓ child props always apply
150
+ ```
151
+
152
+ ## Links
153
+
154
+ - [Documentation](https://bestax.io/docs/guides/getting-started/eslint-plugin)
155
+ - [Component library](https://www.npmjs.com/package/@allxsmith/bestax-bulma)
156
+ - [Repository](https://github.com/allxsmith/bestax)
157
+
158
+ ## License
159
+
160
+ MIT
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The recommended set, and the rules deliberately left out of it.
3
+ *
4
+ * Everything in `recommended` reports code that does not do what it says — a
5
+ * value that never renders, a prop the library has retired, a flex prop that
6
+ * emits nothing. None of those is a preference, so none is a warning.
7
+ *
8
+ * `no-color-as-surface` is opt-in instead: `color` is a documented alias that
9
+ * works, so the rule buys explicitness rather than correctness. Linting the
10
+ * library's own documentation with it on reported dozens of correct examples,
11
+ * which is the evidence it does not belong in a default-on set.
12
+ */
13
+ import type { Linter } from 'eslint';
14
+ export declare const RECOMMENDED_RULES: Linter.RulesRecord;
15
+ /**
16
+ * Rules the plugin ships with but leaves off by default. Declared rather than
17
+ * inferred, so a new rule that nobody wires into a config fails the surface
18
+ * test instead of shipping switched off by accident.
19
+ */
20
+ export declare const OPT_IN_RULES: readonly string[];
21
+ //# sourceMappingURL=recommended.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,WAItC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAA4B,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const RECOMMENDED_RULES = {
2
+ '@allxsmith/bestax/valid-helper-value': 'error',
3
+ '@allxsmith/bestax/no-deprecated-props': 'error',
4
+ '@allxsmith/bestax/no-inert-flex-props': 'error',
5
+ };
6
+ /**
7
+ * Rules the plugin ships with but leaves off by default. Declared rather than
8
+ * inferred, so a new rule that nobody wires into a config fails the surface
9
+ * test instead of shipping switched off by accident.
10
+ */
11
+ export const OPT_IN_RULES = ['no-color-as-surface'];
@@ -0,0 +1,26 @@
1
+ /** What a deprecated prop should become, and why it was deprecated. */
2
+ export interface Deprecation {
3
+ /** The prop to use instead, when the note names one. Drives the autofix. */
4
+ readonly replacement: string | null;
5
+ /** The library's own deprecation note, quoted to the user verbatim. */
6
+ readonly note: string | null;
7
+ }
8
+ /**
9
+ * Deprecated props, keyed by the JSX element name as written — so a compound
10
+ * part is `"Navbar.Brand"`.
11
+ */
12
+ export declare const DEPRECATED_PROPS: Readonly<Record<string, Readonly<Record<string, Deprecation>>>>;
13
+ /**
14
+ * Elements whose `color` prop is a text-colour alias, NOT a filled surface
15
+ * variant. On these, `color` renders `has-text-<color>` exactly like
16
+ * `textColor`, and a coloured background needs `bgColor`.
17
+ *
18
+ * NOT exhaustive. Membership is read from the TSDoc sentence the library uses
19
+ * to say so, and components that behave identically but word it differently
20
+ * (`Level`, `Section`, `Footer`, `Media`) are missed. So absence
21
+ * here does NOT mean the element has a real `is-<color>` modifier — only
22
+ * that no sentence claimed otherwise. Elements that genuinely do have one
23
+ * (`Button`, `Hero`, `Notification`, `Progress`) are also absent.
24
+ */
25
+ export declare const TEXT_ALIAS_COLOR_ELEMENTS: readonly string[];
26
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/generated/metadata.ts"],"names":[],"mappings":"AAGA,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"}
@@ -0,0 +1,158 @@
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 copy.
3
+ /**
4
+ * Deprecated props, keyed by the JSX element name as written — so a compound
5
+ * part is `"Navbar.Brand"`.
6
+ */
7
+ export const DEPRECATED_PROPS = {
8
+ Button: {
9
+ isFullWidth: {
10
+ replacement: 'isFullwidth',
11
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
12
+ },
13
+ },
14
+ 'Buttons.Button': {
15
+ isFullWidth: {
16
+ replacement: 'isFullwidth',
17
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
18
+ },
19
+ },
20
+ 'Buttons.LinkButton': {
21
+ isFullWidth: {
22
+ replacement: 'isFullwidth',
23
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
24
+ },
25
+ },
26
+ Columns: {
27
+ gapSize: {
28
+ replacement: 'gap',
29
+ note: 'Use `gap` instead — `gap` wins if both are set.',
30
+ },
31
+ gapSizeDesktop: {
32
+ replacement: 'gapDesktop',
33
+ note: 'Use `gapDesktop` instead — `gapDesktop` wins if both are set.',
34
+ },
35
+ gapSizeFullhd: {
36
+ replacement: 'gapFullhd',
37
+ note: 'Use `gapFullhd` instead — `gapFullhd` wins if both are set.',
38
+ },
39
+ gapSizeMobile: {
40
+ replacement: 'gapMobile',
41
+ note: 'Use `gapMobile` instead — `gapMobile` wins if both are set.',
42
+ },
43
+ gapSizeTablet: {
44
+ replacement: 'gapTablet',
45
+ note: 'Use `gapTablet` instead — `gapTablet` wins if both are set.',
46
+ },
47
+ gapSizeWidescreen: {
48
+ replacement: 'gapWidescreen',
49
+ note: 'Use `gapWidescreen` instead — `gapWidescreen` wins if both are set.',
50
+ },
51
+ },
52
+ File: {
53
+ isFullWidth: {
54
+ replacement: 'isFullwidth',
55
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
56
+ },
57
+ },
58
+ Icon: {
59
+ icon: { replacement: 'name', note: 'Use `name` instead.' },
60
+ libraryFeatures: {
61
+ replacement: null,
62
+ note: 'Use `variant` and `features` instead.',
63
+ },
64
+ },
65
+ 'IconText.Icon': {
66
+ icon: { replacement: 'name', note: 'Use `name` instead.' },
67
+ libraryFeatures: {
68
+ replacement: null,
69
+ note: 'Use `variant` and `features` instead.',
70
+ },
71
+ },
72
+ LinkButton: {
73
+ isFullWidth: {
74
+ replacement: 'isFullwidth',
75
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
76
+ },
77
+ },
78
+ Pagination: {
79
+ color: {
80
+ replacement: null,
81
+ note: 'No `.pagination.is-<color>` CSS exists; the prop renders unstyled and will be removed in the next major version.',
82
+ },
83
+ },
84
+ 'Panel.Icon': {
85
+ icon: { replacement: 'name', note: 'Use `name` instead.' },
86
+ libraryFeatures: {
87
+ replacement: null,
88
+ note: 'Use `variant` and `features` instead.',
89
+ },
90
+ },
91
+ Select: {
92
+ isFullWidth: {
93
+ replacement: 'isFullwidth',
94
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
95
+ },
96
+ },
97
+ SelectBase: {
98
+ isFullWidth: {
99
+ replacement: 'isFullwidth',
100
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
101
+ },
102
+ },
103
+ Sidebar: {
104
+ fullWidth: {
105
+ replacement: 'isFullwidth',
106
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
107
+ },
108
+ },
109
+ Table: {
110
+ isFullWidth: {
111
+ replacement: 'isFullwidth',
112
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
113
+ },
114
+ },
115
+ Tabs: {
116
+ color: {
117
+ replacement: null,
118
+ note: 'No `.tabs.is-<color>` CSS exists; the prop renders unstyled and will be removed in the next major version.',
119
+ },
120
+ fullwidth: {
121
+ replacement: 'isFullwidth',
122
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
123
+ },
124
+ isFullWidth: {
125
+ replacement: 'isFullwidth',
126
+ note: 'Use `isFullwidth` instead — `isFullwidth` wins if both are set.',
127
+ },
128
+ },
129
+ Tags: {
130
+ isMultiline: {
131
+ replacement: null,
132
+ note: "Bulma's `.tags` wraps by default (no shipped `are-multiline` CSS exists for it) — this prop has never had a visual effect and will be removed in the next major version.",
133
+ },
134
+ },
135
+ };
136
+ /**
137
+ * Elements whose `color` prop is a text-colour alias, NOT a filled surface
138
+ * variant. On these, `color` renders `has-text-<color>` exactly like
139
+ * `textColor`, and a coloured background needs `bgColor`.
140
+ *
141
+ * NOT exhaustive. Membership is read from the TSDoc sentence the library uses
142
+ * to say so, and components that behave identically but word it differently
143
+ * (`Level`, `Section`, `Footer`, `Media`) are missed. So absence
144
+ * here does NOT mean the element has a real `is-<color>` modifier — only
145
+ * that no sentence claimed otherwise. Elements that genuinely do have one
146
+ * (`Button`, `Hero`, `Notification`, `Progress`) are also absent.
147
+ */
148
+ export const TEXT_ALIAS_COLOR_ELEMENTS = [
149
+ 'Block',
150
+ 'Box',
151
+ 'Buttons',
152
+ 'Card',
153
+ 'Container',
154
+ 'Content',
155
+ 'Delete',
156
+ 'IconText',
157
+ 'Image',
158
+ ];
@@ -0,0 +1,13 @@
1
+ import type { ESLint, Linter } from 'eslint';
2
+ export declare const rules: {
3
+ 'valid-helper-value': import("eslint").Rule.RuleModule;
4
+ 'no-deprecated-props': import("eslint").Rule.RuleModule;
5
+ 'no-color-as-surface': import("eslint").Rule.RuleModule;
6
+ 'no-inert-flex-props': import("eslint").Rule.RuleModule;
7
+ };
8
+ declare const plugin: ESLint.Plugin & {
9
+ configs: Record<string, Linter.Config>;
10
+ };
11
+ export declare const configs: Record<string, Linter.Config>;
12
+ export default plugin;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AA6BF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAkB,CAAC;AACrE,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ESLint rules for `@allxsmith/bestax-bulma`.
3
+ *
4
+ * Flat config only (ESLint 9+): import the plugin and spread its recommended
5
+ * config, or register it under a name of your choosing and turn on the rules
6
+ * you want.
7
+ *
8
+ * import bestax from '@allxsmith/eslint-plugin-bestax';
9
+ * export default [bestax.configs.recommended];
10
+ */
11
+ import { createRequire } from 'node:module';
12
+ import noColorAsSurface from './rules/no-color-as-surface.js';
13
+ import noDeprecatedProps from './rules/no-deprecated-props.js';
14
+ import noInertFlexProps from './rules/no-inert-flex-props.js';
15
+ import validHelperValue from './rules/valid-helper-value.js';
16
+ import { RECOMMENDED_RULES } from './configs/recommended.js';
17
+ export const rules = {
18
+ 'valid-helper-value': validHelperValue,
19
+ 'no-deprecated-props': noDeprecatedProps,
20
+ 'no-color-as-surface': noColorAsSurface,
21
+ 'no-inert-flex-props': noInertFlexProps,
22
+ };
23
+ /**
24
+ * Read at runtime rather than inlined, so semantic-release's version bump is
25
+ * picked up without a codegen step.
26
+ *
27
+ * `meta.version` is not decoration: ESLint hashes the serialized config into
28
+ * the `--cache` fingerprint, and a plugin's id in that config carries its
29
+ * version only when this field is present. Without it a consumer running
30
+ * `eslint --cache` who upgrades to a release that adds a rule, tightens one,
31
+ * or picks up a regenerated deprecation table gets the same hash, so every
32
+ * unchanged file is served from cache and the new behaviour never runs.
33
+ */
34
+ const { name, version } = createRequire(import.meta.url)('../package.json');
35
+ const plugin = {
36
+ meta: { name, version },
37
+ rules,
38
+ configs: {},
39
+ };
40
+ /**
41
+ * `recommended` registers the plugin under `@allxsmith/bestax` so the rule
42
+ * names in it resolve. That prefix is what the rule ids are written as
43
+ * everywhere, so it is fixed rather than derived.
44
+ *
45
+ * `files` is not optional here. A flat config object without it inherits
46
+ * ESLint's default file set, which is `**\/*.{js,mjs,cjs}` — so `.jsx` and
47
+ * `.tsx` matched nothing, and since every rule in this package visits only
48
+ * `JSXOpeningElement`, spreading this preset on its own lint nothing at all
49
+ * while reporting no error to say so.
50
+ *
51
+ * `.ts`/`.mts`/`.cts` are deliberately absent: TypeScript requires `.tsx` for
52
+ * JSX, so those files can hold nothing these rules look at, and matching them
53
+ * would hand espree TypeScript syntax it cannot parse in a preset-only setup.
54
+ *
55
+ * `ecmaFeatures.jsx` makes `.jsx` parse under the default parser. `.tsx` still
56
+ * needs a TypeScript parser, which the consumer supplies; flat config merges
57
+ * `languageOptions`, so a `parser` set by an adjacent config object survives
58
+ * this block.
59
+ */
60
+ plugin.configs.recommended = {
61
+ files: ['**/*.{js,mjs,cjs,jsx,tsx}'],
62
+ plugins: { '@allxsmith/bestax': plugin },
63
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
64
+ rules: RECOMMENDED_RULES,
65
+ };
66
+ export const configs = plugin.configs;
67
+ export default plugin;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Resolving a JSX element back to the library export it came from.
3
+ *
4
+ * Every rule here must answer "is this one of ours?" before reporting, and
5
+ * must answer it by following the import rather than by trusting the tag name
6
+ * — a project with its own `<Box>` must not be linted against Bulma's.
7
+ *
8
+ * Four import shapes reach the same canonical name:
9
+ *
10
+ * import { Box } → <Box> → "Box"
11
+ * import { Box as MyBox } → <MyBox> → "Box"
12
+ * import * as B → <B.Box> → "Box"
13
+ * import { Navbar } → <Navbar.Brand> → "Navbar.Brand"
14
+ * <B.Navbar.Brand> → "Navbar.Brand"
15
+ *
16
+ * The canonical name is the JSX path as the library documents it, which is
17
+ * what `DEPRECATED_PROPS` and `TEXT_ALIAS_COLOR_ELEMENTS` are keyed by.
18
+ */
19
+ import type { Rule } from 'eslint';
20
+ export declare const PACKAGE = "@allxsmith/bestax-bulma";
21
+ export interface ImportedNames {
22
+ /** local binding → the name it was imported under */
23
+ readonly named: Map<string, string>;
24
+ /** local binding → NAMESPACE */
25
+ readonly namespaces: Set<string>;
26
+ }
27
+ export declare const emptyImports: () => ImportedNames;
28
+ /** Record the library's bindings from one import declaration. */
29
+ export declare function collectImport(node: any, into: ImportedNames): void;
30
+ /**
31
+ * The canonical library name for a JSX element, or null when the element did
32
+ * not come from the library. Returns null rather than guessing.
33
+ *
34
+ * `bindsToImport` decides whether the root identifier really resolves to the
35
+ * import rather than to a local that shadows it. Both tables here key on
36
+ * identifier TEXT, so without it a file that imports `Box` from the library
37
+ * AND declares its own `const Box` inside a function gets the local's JSX
38
+ * linted against Bulma's rules. Default-true keeps `resolveElement` usable
39
+ * without a scope, which the unit tests rely on.
40
+ */
41
+ export declare function resolveElement(nameNode: any, imports: ImportedNames, bindsToImport?: (name: string) => boolean): string | null;
42
+ /**
43
+ * The string value of a JSX attribute, or null when it is not a plain string
44
+ * literal. Anything computed is skipped by every rule here: a value the rule
45
+ * cannot see is not a value it can judge.
46
+ */
47
+ export declare function literalValue(attr: any): string | null;
48
+ /** Plain-named attributes of an opening element, skipping spreads. */
49
+ export declare function attributesOf(opening: any): any[];
50
+ /** Does this element carry a spread, making its full prop set unknowable? */
51
+ export declare function hasSpread(opening: any): boolean;
52
+ /**
53
+ * True when `name`, seen at `node`, resolves to an import binding rather than
54
+ * to a local declaration that shadows it.
55
+ *
56
+ * An unresolvable name answers true, keeping the name-table behaviour: a miss
57
+ * here costs a report on library code, which is less bad than going quiet.
58
+ */
59
+ export declare function bindsToImportAt(context: Rule.RuleContext, node: unknown): (name: string) => boolean;
60
+ /**
61
+ * The library name for a JSX opening element, scope-checked. This is what the
62
+ * rules call; `resolveElement` is the name-table half of it.
63
+ */
64
+ export declare function elementOf(context: Rule.RuleContext, opening: any, imports: ImportedNames): string | null;
65
+ /**
66
+ * Wire an import collector into a rule's visitor, returning the shared binding
67
+ * table. Every rule needs exactly this preamble.
68
+ *
69
+ * The collection happens on `Program`, walking its body, rather than in an
70
+ * `ImportDeclaration` visitor. ESLint traverses in document order, so a
71
+ * visitor-based collector has not seen an import that appears BELOW the JSX
72
+ * using it, and every rule here would go silent on that file. Imports hoist,
73
+ * so that file is legal and compiles.
74
+ */
75
+ export declare function withImports(): {
76
+ imports: ImportedNames;
77
+ visitor: Rule.RuleListener;
78
+ };
79
+ //# sourceMappingURL=elements.d.ts.map
@@ -0,0 +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,CAsB3B;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,aAAa,GACrB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B,CAcA"}