eslint-plugin-react-features 1.1.3 → 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.
Files changed (77) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +99 -19
  3. package/package.json +20 -4
  4. package/src/index.d.ts +1004 -21
  5. package/src/index.js +78 -16
  6. package/src/oxlint.d.ts +20 -0
  7. package/src/oxlint.js +21 -0
  8. package/src/rules/component-api/no-arbitrary-token-class.d.ts +17 -0
  9. package/src/rules/component-api/no-arbitrary-token-class.js +85 -0
  10. package/src/rules/component-api/no-default-test-id.d.ts +15 -0
  11. package/src/rules/component-api/no-default-test-id.js +53 -0
  12. package/src/rules/component-api/no-inline-style.d.ts +15 -0
  13. package/src/rules/component-api/no-inline-style.js +63 -0
  14. package/src/rules/component-api/no-is-prefix-prop.d.ts +17 -0
  15. package/src/rules/component-api/no-is-prefix-prop.js +66 -0
  16. package/src/rules/component-api/no-kind-prop-discriminator.d.ts +25 -0
  17. package/src/rules/component-api/no-kind-prop-discriminator.js +62 -0
  18. package/src/rules/component-api/no-raw-color-literal.d.ts +16 -0
  19. package/src/rules/component-api/no-raw-color-literal.js +63 -0
  20. package/src/rules/component-api/no-wrapper-sub-component.d.ts +23 -0
  21. package/src/rules/component-api/no-wrapper-sub-component.js +103 -0
  22. package/src/rules/component-api/require-data-slot.d.ts +15 -0
  23. package/src/rules/component-api/require-data-slot.js +45 -0
  24. package/src/rules/migration/react-class-to-hooks.js +6 -1
  25. package/src/rules/performance/no-unnecessary-rerenders.js +7 -3
  26. package/src/rules/performance/react-no-inline-functions.js +3 -1
  27. package/src/rules/performance/react-render-optimization.js +2 -1
  28. package/src/rules/react/checked-requires-onchange-or-readonly.js +1 -0
  29. package/src/rules/react/default-props-match-prop-types.js +1 -0
  30. package/src/rules/react/display-name.js +1 -0
  31. package/src/rules/react/hooks-exhaustive-deps.d.ts +1 -1
  32. package/src/rules/react/hooks-exhaustive-deps.js +136 -47
  33. package/src/rules/react/jsx-handler-names.js +1 -0
  34. package/src/rules/react/jsx-key.js +3 -2
  35. package/src/rules/react/jsx-max-depth.js +1 -0
  36. package/src/rules/react/jsx-no-bind.js +1 -0
  37. package/src/rules/react/jsx-no-duplicate-props.js +1 -0
  38. package/src/rules/react/jsx-no-literals.js +1 -0
  39. package/src/rules/react/jsx-no-script-url.js +6 -2
  40. package/src/rules/react/jsx-no-target-blank.js +7 -1
  41. package/src/rules/react/no-access-state-in-setstate.js +1 -0
  42. package/src/rules/react/no-adjacent-inline-elements.js +1 -0
  43. package/src/rules/react/no-arrow-function-lifecycle.js +1 -0
  44. package/src/rules/react/no-children-prop.js +1 -0
  45. package/src/rules/react/no-danger-with-children.js +2 -0
  46. package/src/rules/react/no-danger.js +3 -0
  47. package/src/rules/react/no-deprecated.js +1 -0
  48. package/src/rules/react/no-did-mount-set-state.js +1 -0
  49. package/src/rules/react/no-did-update-set-state.js +1 -0
  50. package/src/rules/react/no-direct-mutation-state.js +24 -66
  51. package/src/rules/react/no-find-dom-node.js +1 -0
  52. package/src/rules/react/no-invalid-html-attribute.js +1 -0
  53. package/src/rules/react/no-is-mounted.js +1 -0
  54. package/src/rules/react/no-multi-comp.js +4 -0
  55. package/src/rules/react/no-namespace.js +1 -0
  56. package/src/rules/react/no-object-type-as-default-prop.js +1 -0
  57. package/src/rules/react/no-redundant-should-component-update.js +1 -0
  58. package/src/rules/react/no-render-return-value.js +1 -0
  59. package/src/rules/react/no-set-state.js +1 -0
  60. package/src/rules/react/no-string-refs.js +1 -0
  61. package/src/rules/react/no-this-in-sfc.js +1 -0
  62. package/src/rules/react/no-typos.js +1 -0
  63. package/src/rules/react/no-unescaped-entities.js +1 -0
  64. package/src/rules/react/no-unknown-property.js +1 -0
  65. package/src/rules/react/no-unsafe.js +1 -0
  66. package/src/rules/react/prefer-es6-class.js +1 -0
  67. package/src/rules/react/prefer-stateless-function.js +8 -3
  68. package/src/rules/react/prop-types.js +2 -0
  69. package/src/rules/react/react-in-jsx-scope.js +1 -0
  70. package/src/rules/react/require-default-props.js +4 -0
  71. package/src/rules/react/require-optimization.js +1 -0
  72. package/src/rules/react/require-render-return.js +1 -0
  73. package/src/rules/react/required-attributes.js +6 -0
  74. package/src/rules/react/sort-comp.js +17 -13
  75. package/src/rules/react/state-in-constructor.js +3 -0
  76. package/src/rules/react/static-property-placement.js +7 -0
  77. package/src/rules/react/void-dom-elements-no-children.js +2 -0
package/src/index.js CHANGED
@@ -64,6 +64,15 @@ const react_class_to_hooks_1 = require("./rules/migration/react-class-to-hooks")
64
64
  const no_unnecessary_rerenders_1 = require("./rules/performance/no-unnecessary-rerenders");
65
65
  const react_render_optimization_1 = require("./rules/performance/react-render-optimization");
66
66
  const react_no_inline_functions_1 = require("./rules/performance/react-no-inline-functions");
67
+ // Component-API rules (interlace-component skill R5/R6/R8/R11/R12/R18/R19)
68
+ const no_default_test_id_1 = require("./rules/component-api/no-default-test-id");
69
+ const require_data_slot_1 = require("./rules/component-api/require-data-slot");
70
+ const no_is_prefix_prop_1 = require("./rules/component-api/no-is-prefix-prop");
71
+ const no_inline_style_1 = require("./rules/component-api/no-inline-style");
72
+ const no_raw_color_literal_1 = require("./rules/component-api/no-raw-color-literal");
73
+ const no_arbitrary_token_class_1 = require("./rules/component-api/no-arbitrary-token-class");
74
+ const no_kind_prop_discriminator_1 = require("./rules/component-api/no-kind-prop-discriminator");
75
+ const no_wrapper_sub_component_1 = require("./rules/component-api/no-wrapper-sub-component");
67
76
  exports.rules = {
68
77
  // Flat names
69
78
  'required-attributes': required_attributes_1.requiredAttributes,
@@ -121,6 +130,15 @@ exports.rules = {
121
130
  'no-unnecessary-rerenders': no_unnecessary_rerenders_1.noUnnecessaryRerenders,
122
131
  'react-render-optimization': react_render_optimization_1.reactRenderOptimization,
123
132
  'react-no-inline-functions': react_no_inline_functions_1.reactNoInlineFunctions,
133
+ // Component-API (flat)
134
+ 'no-default-test-id': no_default_test_id_1.noDefaultTestId,
135
+ 'require-data-slot': require_data_slot_1.requireDataSlot,
136
+ 'no-is-prefix-prop': no_is_prefix_prop_1.noIsPrefixProp,
137
+ 'no-inline-style': no_inline_style_1.noInlineStyle,
138
+ 'no-raw-color-literal': no_raw_color_literal_1.noRawColorLiteral,
139
+ 'no-arbitrary-token-class': no_arbitrary_token_class_1.noArbitraryTokenClass,
140
+ 'no-kind-prop-discriminator': no_kind_prop_discriminator_1.noKindPropDiscriminator,
141
+ 'no-wrapper-sub-component': no_wrapper_sub_component_1.noWrapperSubComponent,
124
142
  // Categorized names
125
143
  'react/required-attributes': required_attributes_1.requiredAttributes,
126
144
  'react/jsx-key': jsx_key_1.jsxKey,
@@ -177,35 +195,79 @@ exports.rules = {
177
195
  'performance/no-unnecessary-rerenders': no_unnecessary_rerenders_1.noUnnecessaryRerenders,
178
196
  'performance/react-render-optimization': react_render_optimization_1.reactRenderOptimization,
179
197
  'performance/react-no-inline-functions': react_no_inline_functions_1.reactNoInlineFunctions,
198
+ // Component-API (categorized) — interlace-component skill R5/R6/R8/R11/R12/R18/R19
199
+ 'component-api/no-default-test-id': no_default_test_id_1.noDefaultTestId,
200
+ 'component-api/require-data-slot': require_data_slot_1.requireDataSlot,
201
+ 'component-api/no-is-prefix-prop': no_is_prefix_prop_1.noIsPrefixProp,
202
+ 'component-api/no-inline-style': no_inline_style_1.noInlineStyle,
203
+ 'component-api/no-raw-color-literal': no_raw_color_literal_1.noRawColorLiteral,
204
+ 'component-api/no-arbitrary-token-class': no_arbitrary_token_class_1.noArbitraryTokenClass,
205
+ 'component-api/no-kind-prop-discriminator': no_kind_prop_discriminator_1.noKindPropDiscriminator,
206
+ 'component-api/no-wrapper-sub-component': no_wrapper_sub_component_1.noWrapperSubComponent,
180
207
  };
181
208
  exports.plugin = {
182
209
  meta: {
183
210
  name: 'eslint-plugin-react-features',
184
- version: '1.0.0',
211
+ version: '1.2.0',
185
212
  },
186
213
  rules: exports.rules,
187
214
  };
188
215
  exports.configs = {
216
+ /**
217
+ * Flagship preset — the rule from this plugin in the ecosystem-wide
218
+ * flagship list (`.agent/flagship-rules.md`). Head-to-head with
219
+ * `react-hooks/exhaustive-deps` — same scope, more permissive context
220
+ * detection (catches non-array deps, TS `as const` cast deps).
221
+ */
222
+ flagship: {
223
+ plugins: {
224
+ 'react-features': exports.plugin,
225
+ },
226
+ rules: {
227
+ 'react-features/hooks-exhaustive-deps': 'error',
228
+ },
229
+ },
189
230
  recommended: {
190
231
  plugins: {
191
- '@eslint/react-features': exports.plugin,
232
+ 'react-features': exports.plugin,
192
233
  },
193
234
  rules: {
194
- '@eslint/react-features/react/jsx-key': 'error',
195
- '@eslint/react-features/react/no-children-prop': 'warn',
196
- '@eslint/react-features/react/no-danger': 'warn',
197
- '@eslint/react-features/react/no-string-refs': 'error',
198
- '@eslint/react-features/react/no-unknown-property': 'error',
199
- '@eslint/react-features/react/hooks-exhaustive-deps': 'warn',
235
+ 'react-features/jsx-key': 'error',
236
+ 'react-features/no-children-prop': 'warn',
237
+ 'react-features/no-danger': 'warn',
238
+ 'react-features/no-string-refs': 'error',
239
+ 'react-features/no-unknown-property': 'error',
240
+ 'react-features/hooks-exhaustive-deps': 'warn',
200
241
  // Security rules
201
- '@eslint/react-features/react/jsx-no-target-blank': 'error',
202
- '@eslint/react-features/react/jsx-no-script-url': 'error',
203
- '@eslint/react-features/react/jsx-no-duplicate-props': 'error',
204
- '@eslint/react-features/react/no-danger-with-children': 'error',
205
- '@eslint/react-features/react/no-deprecated': 'warn',
206
- // Performance
207
- '@eslint/react-features/performance/no-unnecessary-rerenders': 'warn',
208
- '@eslint/react-features/performance/react-render-optimization': 'warn',
242
+ 'react-features/jsx-no-target-blank': 'error',
243
+ 'react-features/jsx-no-script-url': 'error',
244
+ 'react-features/jsx-no-duplicate-props': 'error',
245
+ 'react-features/no-danger-with-children': 'error',
246
+ 'react-features/no-deprecated': 'warn',
247
+ // Performance rules are opt-in: they flag inline objects/arrays/functions which
248
+ // are very common patterns in React codebases. They belong in the performance
249
+ // preset, not recommended — the FP rate in general codebases is too high.
250
+ },
251
+ },
252
+ /**
253
+ * Component-API preset — enforces the mechanical rules from the
254
+ * `interlace-component` skill (R5/R6/R8/R11/R12/R18/R19). Apply this to any
255
+ * package that ships shared React components (registry, design-system,
256
+ * @interlace/ui).
257
+ */
258
+ componentApi: {
259
+ plugins: {
260
+ 'react-features': exports.plugin,
261
+ },
262
+ rules: {
263
+ 'react-features/component-api/no-default-test-id': 'error',
264
+ 'react-features/component-api/require-data-slot': 'warn',
265
+ 'react-features/component-api/no-is-prefix-prop': 'warn',
266
+ 'react-features/component-api/no-inline-style': 'warn',
267
+ 'react-features/component-api/no-raw-color-literal': 'warn',
268
+ 'react-features/component-api/no-arbitrary-token-class': 'warn',
269
+ 'react-features/component-api/no-kind-prop-discriminator': 'warn',
270
+ 'react-features/component-api/no-wrapper-sub-component': 'warn',
209
271
  },
210
272
  },
211
273
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * oxlint sub-export.
8
+ *
9
+ * Consumers wire oxlint to this entry via:
10
+ * { "jsPlugins": ["eslint-plugin-react-features/oxlint"] }
11
+ *
12
+ * oxlint's JS plugin loader does `require('eslint-plugin-react-features/oxlint')` and reads
13
+ * `.rules` off the result. The compiled output of `export = plugin` is
14
+ * `module.exports = plugin`, which gives oxlint the plugin object directly
15
+ * (`{ meta, rules }`) — no wrapper, no `.default` indirection.
16
+ *
17
+ * Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
18
+ */
19
+ import { plugin } from './index';
20
+ export = plugin;
package/src/oxlint.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ /**
8
+ * oxlint sub-export.
9
+ *
10
+ * Consumers wire oxlint to this entry via:
11
+ * { "jsPlugins": ["eslint-plugin-react-features/oxlint"] }
12
+ *
13
+ * oxlint's JS plugin loader does `require('eslint-plugin-react-features/oxlint')` and reads
14
+ * `.rules` off the result. The compiled output of `export = plugin` is
15
+ * `module.exports = plugin`, which gives oxlint the plugin object directly
16
+ * (`{ meta, rules }`) — no wrapper, no `.default` indirection.
17
+ *
18
+ * Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
19
+ */
20
+ const index_1 = require("./index");
21
+ module.exports = index_1.plugin;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-arbitrary-token-class
8
+ * Enforces R19: no Tailwind arbitrary-value classes (`rounded-[12px]`,
9
+ * `px-[18px]`) on properties that have a design-token equivalent. Allows
10
+ * arbitrary values that reference CSS variables (`rounded-[var(--token)]`),
11
+ * computed expressions (`w-[calc(...)]`), or non-pixel units that don't map
12
+ * to the spacing scale (`min-h-[60vh]`).
13
+ */
14
+ import type { TSESLint } from '@interlace/eslint-devkit';
15
+ export declare const noArbitraryTokenClass: TSESLint.RuleModule<"arbitraryClass", [], unknown, TSESLint.RuleListener> & {
16
+ name: string;
17
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noArbitraryTokenClass = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const TOKENIZABLE_PROPS = new Set([
11
+ 'rounded',
12
+ 'rounded-t', 'rounded-r', 'rounded-b', 'rounded-l',
13
+ 'rounded-tl', 'rounded-tr', 'rounded-bl', 'rounded-br',
14
+ 'px', 'py', 'pt', 'pb', 'pl', 'pr', 'p',
15
+ 'mx', 'my', 'mt', 'mb', 'ml', 'mr', 'm',
16
+ 'gap', 'gap-x', 'gap-y',
17
+ 'space-x', 'space-y',
18
+ // Sizing handled separately — only flag when the arbitrary value is a token-able pixel size
19
+ ]);
20
+ // Captures e.g. `rounded-[12px]`, `px-[18px]`, `gap-[4rem]`, but NOT
21
+ // `w-[calc(...)]`, `rounded-[var(--x)]`, `min-h-[60vh]`, `data-[state=open]:...`.
22
+ const ARBITRARY_CLASS_PATTERN = /([\w-]+)-\[([^\]]+)\]/g;
23
+ const TOKENIZABLE_VALUE = /^\d+(?:\.\d+)?(?:px|rem|em)$/;
24
+ exports.noArbitraryTokenClass = (0, eslint_devkit_1.createRule)({
25
+ name: 'no-arbitrary-token-class',
26
+ meta: {
27
+ type: 'problem',
28
+ docs: {
29
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-arbitrary-token-class.md',
30
+ description: 'No Tailwind arbitrary values when a token exists for that property (R19)',
31
+ },
32
+ schema: [],
33
+ messages: {
34
+ arbitraryClass: (0, eslint_devkit_1.formatLLMMessage)({
35
+ icon: eslint_devkit_1.MessageIcons.WARNING,
36
+ issueName: 'Arbitrary Tailwind class',
37
+ description: 'Arbitrary value `{{cls}}` — use a token or extend the theme (R19)',
38
+ severity: 'MEDIUM',
39
+ fix: 'Replace with the matching spacing/radius token or wire a `var(--token)` Tailwind class.',
40
+ documentationLink: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-arbitrary-token-class.md',
41
+ }),
42
+ },
43
+ },
44
+ defaultOptions: [],
45
+ create(context) {
46
+ const scanString = (node, raw) => {
47
+ for (const match of raw.matchAll(ARBITRARY_CLASS_PATTERN)) {
48
+ const [whole, prop, value] = match;
49
+ if (!TOKENIZABLE_PROPS.has(prop))
50
+ continue;
51
+ if (!TOKENIZABLE_VALUE.test(value))
52
+ continue;
53
+ context.report({
54
+ node,
55
+ messageId: 'arbitraryClass',
56
+ data: { cls: whole },
57
+ });
58
+ }
59
+ };
60
+ return {
61
+ // className="..." string literal
62
+ 'JSXAttribute[name.name="className"] > Literal'(node) {
63
+ if (typeof node.value === 'string')
64
+ scanString(node, node.value);
65
+ },
66
+ // className={`...`} template literal (static parts only)
67
+ 'JSXAttribute[name.name="className"] TemplateElement'(node) {
68
+ scanString(node, node.value.cooked);
69
+ },
70
+ // cn("...", "...") / clsx(...) string args
71
+ CallExpression(node) {
72
+ if (node.callee.type !== 'Identifier')
73
+ return;
74
+ const name = node.callee.name;
75
+ if (name !== 'cn' && name !== 'clsx' && name !== 'twMerge' && name !== 'classNames')
76
+ return;
77
+ for (const arg of node.arguments) {
78
+ if (arg.type === 'Literal' && typeof arg.value === 'string') {
79
+ scanString(arg, arg.value);
80
+ }
81
+ }
82
+ },
83
+ };
84
+ },
85
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-default-test-id
8
+ * Enforces R5 from the interlace-component skill: data-testid must be
9
+ * type-required and consumer-provided. A runtime default contradicts the
10
+ * type-level requirement and silently masks consumer omissions.
11
+ */
12
+ import type { TSESLint } from '@interlace/eslint-devkit';
13
+ export declare const noDefaultTestId: TSESLint.RuleModule<"defaultTestId", [], unknown, TSESLint.RuleListener> & {
14
+ name: string;
15
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noDefaultTestId = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ exports.noDefaultTestId = (0, eslint_devkit_1.createRule)({
11
+ name: 'no-default-test-id',
12
+ meta: {
13
+ type: 'problem',
14
+ docs: {
15
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-default-test-id.md',
16
+ description: 'data-testid must be consumer-provided — no runtime default value (R5)',
17
+ },
18
+ fixable: 'code',
19
+ schema: [],
20
+ messages: {
21
+ defaultTestId: (0, eslint_devkit_1.formatLLMMessage)({
22
+ icon: eslint_devkit_1.MessageIcons.WARNING,
23
+ issueName: 'data-testid default value',
24
+ description: 'data-testid has a runtime default — consumer must provide it (R5)',
25
+ severity: 'HIGH',
26
+ fix: 'Remove the default. Require data-testid at the type level and let the consumer pass it.',
27
+ documentationLink: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-default-test-id.md',
28
+ }),
29
+ },
30
+ },
31
+ defaultOptions: [],
32
+ create(context) {
33
+ return {
34
+ Property(node) {
35
+ // Match `"data-testid": x = "..."` in destructuring patterns
36
+ if (node.key.type !== 'Literal' || node.key.value !== 'data-testid')
37
+ return;
38
+ if (node.value.type !== 'AssignmentPattern')
39
+ return;
40
+ const assignment = node.value;
41
+ context.report({
42
+ node: assignment,
43
+ messageId: 'defaultTestId',
44
+ fix(fixer) {
45
+ // Replace `x = "..."` with just `x` — drop the default.
46
+ const bindingText = context.sourceCode.getText(assignment.left);
47
+ return fixer.replaceText(assignment, bindingText);
48
+ },
49
+ });
50
+ },
51
+ };
52
+ },
53
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-inline-style
8
+ * Enforces R18: no inline `style={{...}}` for static styling. The only
9
+ * permitted case is CSS-variable assignment (`style={{ "--snp-x": x }}`)
10
+ * for genuinely dynamic values. Everything else belongs in Tailwind classes.
11
+ */
12
+ import type { TSESLint } from '@interlace/eslint-devkit';
13
+ export declare const noInlineStyle: TSESLint.RuleModule<"inlineStyle", [], unknown, TSESLint.RuleListener> & {
14
+ name: string;
15
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noInlineStyle = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const isCssVariableKey = (prop) => {
11
+ if (prop.type !== 'Property')
12
+ return false;
13
+ if (prop.key.type === 'Literal' && typeof prop.key.value === 'string') {
14
+ return prop.key.value.startsWith('--');
15
+ }
16
+ return false;
17
+ };
18
+ const isStaticLiteralValue = (prop) => {
19
+ if (prop.type !== 'Property')
20
+ return false;
21
+ const v = prop.value;
22
+ return v.type === 'Literal' && (typeof v.value === 'string' || typeof v.value === 'number');
23
+ };
24
+ exports.noInlineStyle = (0, eslint_devkit_1.createRule)({
25
+ name: 'no-inline-style',
26
+ meta: {
27
+ type: 'problem',
28
+ docs: {
29
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-inline-style.md',
30
+ description: 'No inline `style={{}}` except for CSS-variable assignment (R18)',
31
+ },
32
+ schema: [],
33
+ messages: {
34
+ inlineStyle: (0, eslint_devkit_1.formatLLMMessage)({
35
+ icon: eslint_devkit_1.MessageIcons.WARNING,
36
+ issueName: 'Inline style prop',
37
+ description: 'Inline `style={{}}` with static value(s) — use Tailwind classes (R18)',
38
+ severity: 'MEDIUM',
39
+ fix: 'Move the static value to a Tailwind class. Reserve inline style for CSS variables and computed dynamic values.',
40
+ documentationLink: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-inline-style.md',
41
+ }),
42
+ },
43
+ },
44
+ defaultOptions: [],
45
+ create(context) {
46
+ return {
47
+ JSXAttribute(node) {
48
+ if (node.name.type !== 'JSXIdentifier' || node.name.name !== 'style')
49
+ return;
50
+ if (!node.value || node.value.type !== 'JSXExpressionContainer')
51
+ return;
52
+ const expr = node.value.expression;
53
+ if (expr.type !== 'ObjectExpression')
54
+ return;
55
+ // Report only when at least one property is a static literal AND not a CSS variable assignment.
56
+ const hasStaticNonVarProp = expr.properties.some((p) => !isCssVariableKey(p) && isStaticLiteralValue(p));
57
+ if (hasStaticNonVarProp) {
58
+ context.report({ node, messageId: 'inlineStyle' });
59
+ }
60
+ },
61
+ };
62
+ },
63
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-is-prefix-prop
8
+ * Enforces R8: boolean props default-false, name describes the true state.
9
+ * Bans `isXxx: boolean` props in TypeScript interfaces / type aliases.
10
+ * `looped` reads naturally; `isLooped` is MUI-flagged noise.
11
+ */
12
+ import type { TSESLint } from '@interlace/eslint-devkit';
13
+ type MessageIds = 'isPrefix' | 'renameSuggestion';
14
+ export declare const noIsPrefixProp: TSESLint.RuleModule<MessageIds, [], unknown, TSESLint.RuleListener> & {
15
+ name: string;
16
+ };
17
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noIsPrefixProp = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const stripIsPrefix = (name) => name.slice(2, 3).toLowerCase() + name.slice(3);
11
+ exports.noIsPrefixProp = (0, eslint_devkit_1.createRule)({
12
+ name: 'no-is-prefix-prop',
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-is-prefix-prop.md',
17
+ description: 'Boolean props must not be prefixed with `is` (R8)',
18
+ },
19
+ hasSuggestions: true,
20
+ schema: [],
21
+ messages: {
22
+ isPrefix: (0, eslint_devkit_1.formatLLMMessage)({
23
+ icon: eslint_devkit_1.MessageIcons.WARNING,
24
+ issueName: '`is` prefix on boolean prop',
25
+ description: 'Boolean prop `{{name}}` should be renamed to `{{suggested}}` (R8)',
26
+ severity: 'MEDIUM',
27
+ fix: 'Rename to `{{suggested}}` — booleans describe the true state directly.',
28
+ documentationLink: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-is-prefix-prop.md',
29
+ }),
30
+ renameSuggestion: 'Rename to `{{suggested}}` (also rename consumer call sites manually)',
31
+ },
32
+ },
33
+ defaultOptions: [],
34
+ create(context) {
35
+ return {
36
+ TSPropertySignature(node) {
37
+ if (node.key.type !== 'Identifier')
38
+ return;
39
+ const { name } = node.key;
40
+ if (!/^is[A-Z]/.test(name))
41
+ return;
42
+ const ann = node.typeAnnotation?.typeAnnotation;
43
+ if (!ann || ann.type !== 'TSBooleanKeyword')
44
+ return;
45
+ const suggested = stripIsPrefix(name);
46
+ const keyNode = node.key;
47
+ context.report({
48
+ node: keyNode,
49
+ messageId: 'isPrefix',
50
+ data: { name, suggested },
51
+ // Suggestion (not auto-fix) — renaming the prop has consumer-side
52
+ // blast radius. The reviewer must update call sites manually.
53
+ suggest: [
54
+ {
55
+ messageId: 'renameSuggestion',
56
+ data: { suggested },
57
+ fix(fixer) {
58
+ return fixer.replaceText(keyNode, suggested);
59
+ },
60
+ },
61
+ ],
62
+ });
63
+ },
64
+ };
65
+ },
66
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-kind-prop-discriminator
8
+ * Enforces R11: ban the `type: "A" | "B"` kind-prop pattern when the value
9
+ * is intended to switch the rendered tree. Heuristic: a property named
10
+ * `type` / `kind` / `variant` with a string-literal-union of 2+ members,
11
+ * AND the component body contains a conditional `if (props.<name> === ...)`
12
+ * or switch-case branching on that prop.
13
+ *
14
+ * Notes on intentional false positives:
15
+ * - `variant` is permitted by some teams as a CVA discriminator that only
16
+ * switches `role` / `className` (not the element tree). This rule flags
17
+ * the shape; review confirms whether the branching is structural or just
18
+ * a contract switch.
19
+ * - We only flag `type` / `kind` here; `variant` is allow-listed by default
20
+ * because CVA usage is the dominant case.
21
+ */
22
+ import type { TSESLint } from '@interlace/eslint-devkit';
23
+ export declare const noKindPropDiscriminator: TSESLint.RuleModule<"kindProp", [], unknown, TSESLint.RuleListener> & {
24
+ name: string;
25
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noKindPropDiscriminator = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const FLAGGED_NAMES = new Set(['type', 'kind']);
11
+ const isStringLiteralUnion = (node) => {
12
+ if (!node)
13
+ return false;
14
+ if (node.type !== 'TSUnionType')
15
+ return false;
16
+ const members = node.types;
17
+ if (members.length < 2)
18
+ return false;
19
+ return members.every((m) => m.type === 'TSLiteralType' &&
20
+ m.literal.type === 'Literal' &&
21
+ typeof m.literal.value === 'string');
22
+ };
23
+ exports.noKindPropDiscriminator = (0, eslint_devkit_1.createRule)({
24
+ name: 'no-kind-prop-discriminator',
25
+ meta: {
26
+ type: 'problem',
27
+ docs: {
28
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-kind-prop-discriminator.md',
29
+ description: 'Ban `type`/`kind` string-union props that select between rendered trees (R11)',
30
+ },
31
+ schema: [],
32
+ messages: {
33
+ kindProp: (0, eslint_devkit_1.formatLLMMessage)({
34
+ icon: eslint_devkit_1.MessageIcons.WARNING,
35
+ issueName: 'Kind-prop discriminator',
36
+ description: 'Prop `{{name}}: "A" | "B"` likely switches the rendered tree — split into sub-components (R11)',
37
+ severity: 'MEDIUM',
38
+ fix: 'Split into sub-components (`Foo.A`, `Foo.B`). If this is only a CVA contract switch (e.g. role only), rename to `variant` and document the test.',
39
+ documentationLink: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/component-api/no-kind-prop-discriminator.md',
40
+ }),
41
+ },
42
+ },
43
+ defaultOptions: [],
44
+ create(context) {
45
+ return {
46
+ TSPropertySignature(node) {
47
+ if (node.key.type !== 'Identifier')
48
+ return;
49
+ if (!FLAGGED_NAMES.has(node.key.name))
50
+ return;
51
+ const ann = node.typeAnnotation?.typeAnnotation;
52
+ if (!isStringLiteralUnion(ann))
53
+ return;
54
+ context.report({
55
+ node: node.key,
56
+ messageId: 'kindProp',
57
+ data: { name: node.key.name },
58
+ });
59
+ },
60
+ };
61
+ },
62
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-raw-color-literal
8
+ * Enforces R19: no raw color literals (hex, rgb/rgba, hsl/hsla, oklch/oklab)
9
+ * in source. Colors must come from design tokens via CSS custom properties
10
+ * or Tailwind classes wired to them. Scoped to JSX `style` / `className`
11
+ * object values and `cn()`/`clsx()` arguments to minimize false positives.
12
+ */
13
+ import type { TSESLint } from '@interlace/eslint-devkit';
14
+ export declare const noRawColorLiteral: TSESLint.RuleModule<"rawColor", [], unknown, TSESLint.RuleListener> & {
15
+ name: string;
16
+ };