Skip to content

Commit 1d1053a

Browse files
committed
refactor(plugins/x): rename rules 'jsx-uses-vars' to 'use-jsx-vars' and 'jsx-no-duplicate-props' to 'no-duplicate-jsx-props'
1 parent f6e2bc1 commit 1d1053a

File tree

15 files changed

+61
-36
lines changed

15 files changed

+61
-36
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
### 🪄 Improvements
44

5-
- refactor(plugins/dom): rename `no-children-in-void-dom-elements` to `no-void-elements-with-children` (the previous rule will still be available until the next major update to avoid breaking changes).
5+
- refactor(plugins/x): rename `jsx-use-vars` to `use-jsx-vars`.
6+
- refactor(plugins/x): rename `jsx-no-duplicate-props` to `no-duplicate-jsx-props`.
7+
- refactor(plugins/dom): rename `no-children-in-void-dom-elements` to `no-void-elements-with-children`.
8+
9+
### 📝 Changes you should be aware of
10+
11+
The following rules have been renamed:
12+
13+
- `jsx-uses-vars` to `use-jsx-vars`.
14+
- `jsx-no-duplicate-props` to `no-duplicate-jsx-props`.
15+
- `dom/no-children-in-void-dom-elements` to `dom/no-void-elements-with-children`.
16+
17+
The new rule names are aligned with the same rules in the biome (if any) to enhance consistency. The old rule names will still be available until the next major update to avoid breaking changes.
618

719
## v1.21.0 (Fri 20 Dec 2024)
820

packages/plugins/eslint-plugin-react-x/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export default [
3030
rules: {
3131
// react-x recommended rules
3232
"react-x/ensure-forward-ref-using-ref": "warn",
33-
"react-x/jsx-no-duplicate-props": "warn",
34-
"react-x/jsx-uses-vars": "warn",
3533
"react-x/no-access-state-in-setstate": "error",
3634
"react-x/no-array-index-key": "warn",
3735
"react-x/no-children-count": "warn",
@@ -48,6 +46,7 @@ export default [
4846
"react-x/no-create-ref": "error",
4947
"react-x/no-default-props": "error",
5048
"react-x/no-direct-mutation-state": "error",
49+
"react-x/no-duplicate-jsx-props": "warn",
5150
"react-x/no-duplicate-key": "error",
5251
"react-x/no-forward-ref": "warn",
5352
"react-x/no-implicit-key": "warn",
@@ -66,6 +65,7 @@ export default [
6665
"react-x/no-unstable-default-props": "warn",
6766
"react-x/no-unused-class-component-members": "warn",
6867
"react-x/no-unused-state": "warn",
68+
"react-x/use-jsx-vars": "warn",
6969
},
7070
},
7171
];

packages/plugins/eslint-plugin-react-x/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { name, version } from "../package.json";
22
import avoidShorthandBoolean from "./rules/avoid-shorthand-boolean";
33
import avoidShorthandFragment from "./rules/avoid-shorthand-fragment";
44
import forwardRefUsingRef from "./rules/ensure-forward-ref-using-ref";
5-
import jsxNoDuplicateProps from "./rules/jsx-no-duplicate-props";
6-
import jsxUsesVars from "./rules/jsx-uses-vars";
75
import noAccessStateInSetstate from "./rules/no-access-state-in-setstate";
86
import noArrayIndexKey from "./rules/no-array-index-key";
97
import noChildrenCount from "./rules/no-children-count";
@@ -23,6 +21,7 @@ import noContextProvider from "./rules/no-context-provider";
2321
import noCreateRef from "./rules/no-create-ref";
2422
import noDefaultProps from "./rules/no-default-props";
2523
import noDirectMutationState from "./rules/no-direct-mutation-state";
24+
import noDuplicateJsxProps from "./rules/no-duplicate-jsx-props";
2625
import noDuplicateKey from "./rules/no-duplicate-key";
2726
import noForwardRef from "./rules/no-forward-ref";
2827
import noImplicitKey from "./rules/no-implicit-key";
@@ -49,6 +48,7 @@ import preferReactNamespaceImport from "./rules/prefer-react-namespace-import";
4948
import preferReadOnlyProps from "./rules/prefer-read-only-props";
5049
import preferShorthandBoolean from "./rules/prefer-shorthand-boolean";
5150
import preferShorthandFragment from "./rules/prefer-shorthand-fragment";
51+
import useJsxVars from "./rules/use-jsx-vars";
5252

5353
export default {
5454
meta: {
@@ -59,8 +59,6 @@ export default {
5959
"avoid-shorthand-boolean": avoidShorthandBoolean,
6060
"avoid-shorthand-fragment": avoidShorthandFragment,
6161
"ensure-forward-ref-using-ref": forwardRefUsingRef,
62-
"jsx-no-duplicate-props": jsxNoDuplicateProps,
63-
"jsx-uses-vars": jsxUsesVars,
6462
"no-access-state-in-setstate": noAccessStateInSetstate,
6563
"no-array-index-key": noArrayIndexKey,
6664
"no-children-count": noChildrenCount,
@@ -80,6 +78,7 @@ export default {
8078
"no-create-ref": noCreateRef,
8179
"no-default-props": noDefaultProps,
8280
"no-direct-mutation-state": noDirectMutationState,
81+
"no-duplicate-jsx-props": noDuplicateJsxProps,
8382
"no-duplicate-key": noDuplicateKey,
8483
"no-forward-ref": noForwardRef,
8584
"no-implicit-key": noImplicitKey,
@@ -106,8 +105,13 @@ export default {
106105
"prefer-read-only-props": preferReadOnlyProps,
107106
"prefer-shorthand-boolean": preferShorthandBoolean,
108107
"prefer-shorthand-fragment": preferShorthandFragment,
108+
"use-jsx-vars": useJsxVars,
109109

110110
// Part: deprecated rules
111+
/** @deprecated Use `no-duplicate-jsx-props` instead. */
112+
"jsx-no-duplicate-props": noDuplicateJsxProps,
113+
/** @deprecated Use `use-jsx-vars` instead. */
114+
"jsx-uses-vars": useJsxVars,
111115
/** @deprecated Use `no-complex-conditional-rendering` instead. */
112116
"no-complicated-conditional-rendering": noComplexConditionalRendering,
113117
},

packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.spec.ts renamed to packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { allValid, ruleTester } from "../../../../../test";
2-
import rule, { RULE_NAME } from "./jsx-no-duplicate-props";
2+
import rule, { RULE_NAME } from "./no-duplicate-jsx-props";
33

44
ruleTester.run(RULE_NAME, rule, {
55
invalid: [
66
{
77
code: /* tsx */ `<div a="1" a="2" />;`,
8-
errors: [{ messageId: "jsxNoDuplicateProps" }],
8+
errors: [{ messageId: "noDuplicateJsxProps" }],
99
},
1010
{
1111
code: /* tsx */ `<div a="1" b="2" a="3" />;`,
12-
errors: [{ messageId: "jsxNoDuplicateProps" }],
12+
errors: [{ messageId: "noDuplicateJsxProps" }],
1313
},
1414
{
1515
code: /* tsx */ `<div a="1" {...b} a="2" />;`,
16-
errors: [{ messageId: "jsxNoDuplicateProps" }],
16+
errors: [{ messageId: "noDuplicateJsxProps" }],
1717
},
1818
{
1919
code: /* tsx */ `<div a="1" {...a} {...b} a="2" />;`,
20-
errors: [{ messageId: "jsxNoDuplicateProps" }],
20+
errors: [{ messageId: "noDuplicateJsxProps" }],
2121
},
2222
],
2323
valid: [

packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.ts renamed to packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { CamelCase } from "string-ts";
55

66
import { createRule } from "../utils";
77

8-
export const RULE_NAME = "jsx-no-duplicate-props";
8+
export const RULE_NAME = "no-duplicate-jsx-props";
99

1010
export const RULE_FEATURES = [
1111
"CHK",
@@ -21,7 +21,7 @@ export default createRule<[], MessageID>({
2121
[Symbol.for("rule_features")]: RULE_FEATURES,
2222
},
2323
messages: {
24-
jsxNoDuplicateProps: "Duplicate prop '{{name}}'",
24+
noDuplicateJsxProps: "This JSX property is assigned multiple times.",
2525
},
2626
schema: [],
2727
},
@@ -39,9 +39,8 @@ export default createRule<[], MessageID>({
3939
continue;
4040
}
4141
context.report({
42-
messageId: "jsxNoDuplicateProps",
42+
messageId: "noDuplicateJsxProps",
4343
node: attr,
44-
data: { name },
4544
});
4645
}
4746
},

packages/plugins/eslint-plugin-react-x/src/rules/jsx-uses-vars.spec.ts renamed to packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { allValid, ruleTester } from "../../../../../test";
2-
import rule, { RULE_NAME } from "./jsx-uses-vars";
2+
import rule, { RULE_NAME } from "./use-jsx-vars";
33

44
ruleTester.run(RULE_NAME, rule, {
55
invalid: [],

packages/plugins/eslint-plugin-react-x/src/rules/jsx-uses-vars.ts renamed to packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { CamelCase } from "string-ts";
66

77
import { createRule } from "../utils";
88

9-
export const RULE_NAME = "jsx-uses-vars";
9+
export const RULE_NAME = "use-jsx-vars";
1010

1111
export const RULE_FEATURES = [] as const satisfies RuleFeature[];
1212

@@ -21,7 +21,7 @@ export default createRule<[], MessageID>({
2121
[Symbol.for("rule_features")]: RULE_FEATURES,
2222
},
2323
messages: {
24-
jsxUsesVars: "",
24+
useJsxVars: "",
2525
},
2626
schema: [],
2727
},

packages/plugins/eslint-plugin/src/configs/all.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export const name = "@eslint-react/all";
1111

1212
export const rules = {
1313
"@eslint-react/ensure-forward-ref-using-ref": "warn",
14-
"@eslint-react/jsx-no-duplicate-props": "warn",
15-
"@eslint-react/jsx-uses-vars": "warn",
1614
"@eslint-react/no-access-state-in-setstate": "error",
1715
"@eslint-react/no-array-index-key": "warn",
1816
"@eslint-react/no-children-count": "warn",
@@ -32,6 +30,7 @@ export const rules = {
3230
"@eslint-react/no-create-ref": "error",
3331
"@eslint-react/no-default-props": "error",
3432
"@eslint-react/no-direct-mutation-state": "error",
33+
"@eslint-react/no-duplicate-jsx-props": "warn",
3534
"@eslint-react/no-duplicate-key": "error",
3635
"@eslint-react/no-forward-ref": "warn",
3736
"@eslint-react/no-implicit-key": "warn",
@@ -55,9 +54,9 @@ export const rules = {
5554
"@eslint-react/prefer-destructuring-assignment": "warn",
5655
"@eslint-react/prefer-shorthand-boolean": "warn",
5756
"@eslint-react/prefer-shorthand-fragment": "warn",
57+
"@eslint-react/use-jsx-vars": "warn",
5858

5959
// Part: DOM
60-
"@eslint-react/dom/no-void-elements-with-children": "warn",
6160
"@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
6261
"@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
6362
"@eslint-react/dom/no-find-dom-node": "error",
@@ -69,6 +68,7 @@ export const rules = {
6968
"@eslint-react/dom/no-unknown-property": "warn",
7069
"@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
7170
"@eslint-react/dom/no-unsafe-target-blank": "warn",
71+
"@eslint-react/dom/no-void-elements-with-children": "warn",
7272

7373
// Part: Web API
7474
"@eslint-react/web-api/no-leaked-event-listener": "warn",

packages/plugins/eslint-plugin/src/configs/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export const name = "@eslint-react/core";
66

77
export const rules = {
88
"@eslint-react/ensure-forward-ref-using-ref": "warn",
9-
"@eslint-react/jsx-no-duplicate-props": "warn",
10-
"@eslint-react/jsx-uses-vars": "warn",
119
"@eslint-react/no-access-state-in-setstate": "error",
1210
"@eslint-react/no-array-index-key": "warn",
1311
"@eslint-react/no-children-count": "warn",
@@ -24,6 +22,7 @@ export const rules = {
2422
"@eslint-react/no-create-ref": "error",
2523
"@eslint-react/no-default-props": "error",
2624
"@eslint-react/no-direct-mutation-state": "error",
25+
"@eslint-react/no-duplicate-jsx-props": "warn",
2726
"@eslint-react/no-duplicate-key": "error",
2827
"@eslint-react/no-forward-ref": "warn",
2928
"@eslint-react/no-implicit-key": "warn",
@@ -42,6 +41,7 @@ export const rules = {
4241
"@eslint-react/no-unstable-default-props": "warn",
4342
"@eslint-react/no-unused-class-component-members": "warn",
4443
"@eslint-react/no-unused-state": "warn",
44+
"@eslint-react/use-jsx-vars": "warn",
4545
} as const satisfies RulePreset;
4646

4747
export const plugins = {

packages/plugins/eslint-plugin/src/configs/recommended-typescript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const name = "@eslint-react/recommended-typescript";
77
export const rules = {
88
...recommended.rules,
99
"@eslint-react/dom/no-unknown-property": "off",
10-
"@eslint-react/jsx-no-duplicate-props": "off",
11-
"@eslint-react/jsx-uses-vars": "off",
10+
"@eslint-react/no-duplicate-jsx-props": "off",
11+
"@eslint-react/use-jsx-vars": "off",
1212
} as const satisfies RulePreset;
1313

1414
export const plugins = {

0 commit comments

Comments
 (0)