Skip to content

Commit 98217b1

Browse files
authored
refactor: rename jsx only rules (#1017)
1 parent 3ffde53 commit 98217b1

File tree

16 files changed

+50
-48
lines changed

16 files changed

+50
-48
lines changed

apps/website/content/docs/deprecated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ full: true
1212
| [`ensure-forward-ref-using-ref`](/docs/rules/ensure-forward-ref-using-ref) | [`no-useless-forward-ref`](/docs/rules/no-useless-forward-ref) | 1.33.0 |
1313
| [`ensure-use-callback-has-non-empty-deps`](/docs/rules/hooks-extra-ensure-use-callback-has-non-empty-deps) | [`no-unnecessary-use-callback`](/docs/rules/hooks-extra-no-unnecessary-use-callback) | 1.13.0 |
1414
| [`ensure-use-memo-has-non-empty-deps`](/docs/rules/hooks-extra-ensure-use-memo-has-non-empty-deps) | [`no-unnecessary-use-memo`](/docs/rules/hooks-extra-no-unnecessary-use-memo) | 1.13.0 |
15-
| [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | [`no-duplicate-jsx-props`](/docs/rules/no-duplicate-jsx-props) | 1.22.0 |
16-
| [`jsx-uses-vars`](/docs/rules/jsx-uses-vars) | [`use-jsx-vars`](/docs/rules/use-jsx-vars) | 1.22.0 |
1715
| [`no-children-in-void-dom-elements`](/docs/rules/dom-no-children-in-void-dom-elements) | [`no-void-elements-with-children`](/docs/rules/dom-no-void-elements-with-children) | 1.22.0 |
1816
| [`no-complicated-conditional-rendering`](/docs/rules/no-complicated-conditional-rendering) | [`no-complex-conditional-rendering`](/docs/rules/no-complex-conditional-rendering) | 1.6.0 |
17+
| [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | 1.22.0 |
1918
| [`no-nested-components`](/docs/rules/no-nested-components) | [`no-nested-component-definitions`](/docs/rules/no-nested-component-definitions) | 1.34.0 |
2019
| [`no-redundant-custom-hook`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | [`no-unnecessary-use-prefix`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | 1.21.0 |
2120
| [`no-useless-custom-hooks`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | [`no-unnecessary-use-prefix`](/docs/rules/hooks-extra-no-unnecessary-use-prefix) | 1.21.0 |
21+
| [`use-jsx-vars`](/docs/rules/use-jsx-vars) | [`jsx-uses-vars`](/docs/rules/jsx-uses-vars) | 1.22.0 |
2222

2323
## Presets
2424

apps/website/content/docs/rules/meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"no-create-ref",
2424
"no-default-props",
2525
"no-direct-mutation-state",
26-
"no-duplicate-jsx-props",
2726
"no-duplicate-key",
2827
"no-forward-ref",
2928
"no-implicit-key",
@@ -53,7 +52,8 @@
5352
"prefer-read-only-props",
5453
"prefer-shorthand-boolean",
5554
"prefer-shorthand-fragment",
56-
"use-jsx-vars",
55+
"jsx-no-duplicate-props",
56+
"jsx-uses-vars",
5757
"---DOM Rules---",
5858
"dom-no-dangerously-set-innerhtml",
5959
"dom-no-dangerously-set-innerhtml-with-children",

apps/website/content/docs/rules/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Linter rules can have false positives, false negatives, and some rules are depen
4646
| [`no-create-ref`](./no-create-ref) | 2️⃣ | | Disallow `createRef` in function components | |
4747
| [`no-default-props`](./no-default-props) | 2️⃣ | | Disallow `defaultProps` property in favor of ES6 default parameters | |
4848
| [`no-direct-mutation-state`](./no-direct-mutation-state) | 2️⃣ | | Disallow direct mutation of `this.state` | |
49-
| [`no-duplicate-jsx-props`](./no-duplicate-jsx-props) | 1️⃣ | | Disallow duplicate props in JSX elements | |
5049
| [`no-duplicate-key`](./no-duplicate-key) | 2️⃣ | | Disallow duplicate `key` on elements in the same array or a list of `children` | |
5150
| [`no-forward-ref`](./no-forward-ref) | 1️⃣ | `🔄` | Replaces usages of `forwardRef` with passing `ref` as a prop | >=19.0.0 |
5251
| [`no-implicit-key`](./no-implicit-key) | 1️⃣ | `🧪` | Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects) | |
@@ -76,7 +75,8 @@ Linter rules can have false positives, false negatives, and some rules are depen
7675
| [`prefer-read-only-props`](./prefer-read-only-props) | 0️⃣ | `💭` `🧪` | Enforces read-only props in components | |
7776
| [`prefer-shorthand-boolean`](./prefer-shorthand-boolean) | 0️⃣ | `🔧` | Enforces shorthand syntax for boolean attributes | |
7877
| [`prefer-shorthand-fragment`](./prefer-shorthand-fragment) | 0️⃣ | `🔧` | Enforces shorthand syntax for fragments | |
79-
| [`use-jsx-vars`](./use-jsx-vars) | 1️⃣ | | Marks variables used in JSX as used | |
78+
| [`jsx-no-duplicate-props`](./jsx-no-duplicate-props) | 1️⃣ | | Disallow duplicate props in JSX elements | |
79+
| [`jsx-uses-vars`](./jsx-uses-vars) | 1️⃣ | | Marks variables used in JSX as used | |
8080

8181
## DOM Rules
8282

apps/website/next.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ const config = {
7575
},
7676
// Redirects for deprecated rules
7777
{
78-
source: "/docs/rules/jsx-uses-vars",
79-
destination: "/docs/rules/use-jsx-vars",
78+
source: "/docs/rules/use-jsx-vars",
79+
destination: "/docs/rules/jsx-uses-vars",
8080
permanent: true,
8181
},
8282
{
8383
source: "/docs/rules/jsx-no-duplicate-props",
84-
destination: "/docs/rules/no-duplicate-jsx-props",
84+
destination: "/docs/rules/jsx-no-duplicate-props",
8585
permanent: true,
8686
},
8787
{

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

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

77
export const rules = {
88
...recommended.rules,
9-
"react-x/no-duplicate-jsx-props": "off",
10-
"react-x/use-jsx-vars": "off",
9+
"react-x/jsx-no-duplicate-props": "off",
10+
"react-x/jsx-uses-vars": "off",
1111
} as const satisfies RulePreset;
1212

1313
export const settings = {

packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const rules = {
2020
"react-x/no-create-ref": "error",
2121
"react-x/no-default-props": "error",
2222
"react-x/no-direct-mutation-state": "error",
23-
"react-x/no-duplicate-jsx-props": "warn",
23+
"react-x/jsx-no-duplicate-props": "warn",
2424
"react-x/no-duplicate-key": "warn",
2525
"react-x/no-forward-ref": "warn",
2626
"react-x/no-implicit-key": "warn",
@@ -41,7 +41,7 @@ export const rules = {
4141
"react-x/no-unused-state": "warn",
4242
"react-x/no-use-context": "warn",
4343
"react-x/no-useless-forward-ref": "warn",
44-
"react-x/use-jsx-vars": "warn",
44+
"react-x/jsx-uses-vars": "warn",
4545
} as const satisfies RulePreset;
4646

4747
export const settings = {

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { name, version } from "../package.json";
22
import avoidShorthandBoolean from "./rules/avoid-shorthand-boolean";
33
import avoidShorthandFragment from "./rules/avoid-shorthand-fragment";
4+
import jsxNoDuplicateProps from "./rules/jsx-no-duplicate-props";
5+
import jsxUsesVars from "./rules/jsx-uses-vars";
46
import noAccessStateInSetstate from "./rules/no-access-state-in-setstate";
57
import noArrayIndexKey from "./rules/no-array-index-key";
68
import noChildrenCount from "./rules/no-children-count";
@@ -20,7 +22,6 @@ import noContextProvider from "./rules/no-context-provider";
2022
import noCreateRef from "./rules/no-create-ref";
2123
import noDefaultProps from "./rules/no-default-props";
2224
import noDirectMutationState from "./rules/no-direct-mutation-state";
23-
import noDuplicateJsxProps from "./rules/no-duplicate-jsx-props";
2425
import noDuplicateKey from "./rules/no-duplicate-key";
2526
import noForwardRef from "./rules/no-forward-ref";
2627
import noImplicitKey from "./rules/no-implicit-key";
@@ -50,7 +51,6 @@ import preferReactNamespaceImport from "./rules/prefer-react-namespace-import";
5051
import preferReadOnlyProps from "./rules/prefer-read-only-props";
5152
import preferShorthandBoolean from "./rules/prefer-shorthand-boolean";
5253
import preferShorthandFragment from "./rules/prefer-shorthand-fragment";
53-
import useJsxVars from "./rules/use-jsx-vars";
5454

5555
export const plugin = {
5656
meta: {
@@ -79,7 +79,6 @@ export const plugin = {
7979
"no-create-ref": noCreateRef,
8080
"no-default-props": noDefaultProps,
8181
"no-direct-mutation-state": noDirectMutationState,
82-
"no-duplicate-jsx-props": noDuplicateJsxProps,
8382
"no-duplicate-key": noDuplicateKey,
8483
"no-forward-ref": noForwardRef,
8584
"no-implicit-key": noImplicitKey,
@@ -109,18 +108,21 @@ export const plugin = {
109108
"prefer-read-only-props": preferReadOnlyProps,
110109
"prefer-shorthand-boolean": preferShorthandBoolean,
111110
"prefer-shorthand-fragment": preferShorthandFragment,
112-
"use-jsx-vars": useJsxVars,
111+
112+
// Part: JSX only rules
113+
"jsx-no-duplicate-props": jsxNoDuplicateProps,
114+
"jsx-uses-vars": jsxUsesVars,
113115

114116
// Part: deprecated rules
115117
/** @deprecated Use `no-useless-forward-ref` instead */
116118
"ensure-forward-ref-using-ref": noUselessForwardRef,
117-
/** @deprecated Use `no-duplicate-jsx-props` instead */
118-
"jsx-no-duplicate-props": noDuplicateJsxProps,
119-
/** @deprecated Use `use-jsx-vars` instead */
120-
"jsx-uses-vars": useJsxVars,
121119
/** @deprecated Use `no-complex-conditional-rendering` instead */
122120
"no-complicated-conditional-rendering": noComplexConditionalRendering,
121+
/** @deprecated Use `jsx-no-duplicate-props` instead */
122+
"no-duplicate-jsx-props": jsxNoDuplicateProps,
123123
/** @deprecated Use `no-nested-component-definitions` instead */
124124
"no-nested-components": noNestedComponentDefinitions,
125+
/** @deprecated Use `jsx-uses-vars` instead */
126+
"use-jsx-vars": jsxUsesVars,
125127
},
126128
} as const;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
title: no-duplicate-jsx-props
2+
title: jsx-no-duplicate-props
33
---
44

55
**Full Name in `eslint-plugin-react-x`**
66

77
```plain copy
8-
react-x/no-duplicate-jsx-props
8+
react-x/jsx-no-duplicate-props
99
```
1010

1111
**Full Name in `@eslint-react/eslint-plugin`**
1212

1313
```plain copy
14-
@eslint-react/no-duplicate-jsx-props
14+
@eslint-react/jsx-no-duplicate-props
1515
```
1616

1717
**Presets**
@@ -39,5 +39,5 @@ Disallow duplicate props in JSX elements.
3939

4040
## Implementation
4141

42-
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts)
43-
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.spec.ts)
42+
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.ts)
43+
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.spec.ts)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import tsx from "dedent";
22

33
import { allValid, ruleTester } from "../../../../../test";
4-
import rule, { RULE_NAME } from "./no-duplicate-jsx-props";
4+
import rule, { RULE_NAME } from "./jsx-no-duplicate-props";
55

66
ruleTester.run(RULE_NAME, rule, {
77
invalid: [
88
{
99
code: tsx`<div a="1" a="2" />;`,
10-
errors: [{ messageId: "noDuplicateJsxProps" }],
10+
errors: [{ messageId: "jsxNoDuplicateProps" }],
1111
},
1212
{
1313
code: tsx`<div a="1" b="2" a="3" />;`,
14-
errors: [{ messageId: "noDuplicateJsxProps" }],
14+
errors: [{ messageId: "jsxNoDuplicateProps" }],
1515
},
1616
{
1717
code: tsx`<div a="1" {...b} a="2" />;`,
18-
errors: [{ messageId: "noDuplicateJsxProps" }],
18+
errors: [{ messageId: "jsxNoDuplicateProps" }],
1919
},
2020
{
2121
code: tsx`<div a="1" {...a} {...b} a="2" />;`,
22-
errors: [{ messageId: "noDuplicateJsxProps" }],
22+
errors: [{ messageId: "jsxNoDuplicateProps" }],
2323
},
2424
],
2525
valid: [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
55

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

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

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

@@ -19,7 +19,7 @@ export default createRule<[], MessageID>({
1919
[Symbol.for("rule_features")]: RULE_FEATURES,
2020
},
2121
messages: {
22-
noDuplicateJsxProps: "This JSX property is assigned multiple times.",
22+
jsxNoDuplicateProps: "This JSX property is assigned multiple times.",
2323
},
2424
schema: [],
2525
},
@@ -45,7 +45,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4545
continue;
4646
}
4747
context.report({
48-
messageId: "noDuplicateJsxProps",
48+
messageId: "jsxNoDuplicateProps",
4949
node: attr,
5050
});
5151
}

0 commit comments

Comments
 (0)