Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/website/content/docs/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ full: true
| [`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 |
| [`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 |
| [`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 |
| [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | [`no-duplicate-jsx-props`](/docs/rules/no-duplicate-jsx-props) | 1.22.0 |
| [`jsx-uses-vars`](/docs/rules/jsx-uses-vars) | [`use-jsx-vars`](/docs/rules/use-jsx-vars) | 1.22.0 |
| [`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 |
| [`no-complicated-conditional-rendering`](/docs/rules/no-complicated-conditional-rendering) | [`no-complex-conditional-rendering`](/docs/rules/no-complex-conditional-rendering) | 1.6.0 |
| [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | [`jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | 1.22.0 |
| [`no-nested-components`](/docs/rules/no-nested-components) | [`no-nested-component-definitions`](/docs/rules/no-nested-component-definitions) | 1.34.0 |
| [`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 |
| [`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 |
| [`use-jsx-vars`](/docs/rules/use-jsx-vars) | [`jsx-uses-vars`](/docs/rules/jsx-uses-vars) | 1.22.0 |

## Presets

Expand Down
4 changes: 2 additions & 2 deletions apps/website/content/docs/rules/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"no-create-ref",
"no-default-props",
"no-direct-mutation-state",
"no-duplicate-jsx-props",
"no-duplicate-key",
"no-forward-ref",
"no-implicit-key",
Expand Down Expand Up @@ -53,7 +52,8 @@
"prefer-read-only-props",
"prefer-shorthand-boolean",
"prefer-shorthand-fragment",
"use-jsx-vars",
"jsx-no-duplicate-props",
"jsx-uses-vars",
"---DOM Rules---",
"dom-no-dangerously-set-innerhtml",
"dom-no-dangerously-set-innerhtml-with-children",
Expand Down
4 changes: 2 additions & 2 deletions apps/website/content/docs/rules/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Linter rules can have false positives, false negatives, and some rules are depen
| [`no-create-ref`](./no-create-ref) | 2️⃣ | | Disallow `createRef` in function components | |
| [`no-default-props`](./no-default-props) | 2️⃣ | | Disallow `defaultProps` property in favor of ES6 default parameters | |
| [`no-direct-mutation-state`](./no-direct-mutation-state) | 2️⃣ | | Disallow direct mutation of `this.state` | |
| [`no-duplicate-jsx-props`](./no-duplicate-jsx-props) | 1️⃣ | | Disallow duplicate props in JSX elements | |
| [`no-duplicate-key`](./no-duplicate-key) | 2️⃣ | | Disallow duplicate `key` on elements in the same array or a list of `children` | |
| [`no-forward-ref`](./no-forward-ref) | 1️⃣ | `🔄` | Replaces usages of `forwardRef` with passing `ref` as a prop | >=19.0.0 |
| [`no-implicit-key`](./no-implicit-key) | 1️⃣ | `🧪` | Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects) | |
Expand Down Expand Up @@ -76,7 +75,8 @@ Linter rules can have false positives, false negatives, and some rules are depen
| [`prefer-read-only-props`](./prefer-read-only-props) | 0️⃣ | `💭` `🧪` | Enforces read-only props in components | |
| [`prefer-shorthand-boolean`](./prefer-shorthand-boolean) | 0️⃣ | `🔧` | Enforces shorthand syntax for boolean attributes | |
| [`prefer-shorthand-fragment`](./prefer-shorthand-fragment) | 0️⃣ | `🔧` | Enforces shorthand syntax for fragments | |
| [`use-jsx-vars`](./use-jsx-vars) | 1️⃣ | | Marks variables used in JSX as used | |
| [`jsx-no-duplicate-props`](./jsx-no-duplicate-props) | 1️⃣ | | Disallow duplicate props in JSX elements | |
| [`jsx-uses-vars`](./jsx-uses-vars) | 1️⃣ | | Marks variables used in JSX as used | |

## DOM Rules

Expand Down
6 changes: 3 additions & 3 deletions apps/website/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ const config = {
},
// Redirects for deprecated rules
{
source: "/docs/rules/jsx-uses-vars",
destination: "/docs/rules/use-jsx-vars",
source: "/docs/rules/use-jsx-vars",
destination: "/docs/rules/jsx-uses-vars",
permanent: true,
},
{
source: "/docs/rules/jsx-no-duplicate-props",
destination: "/docs/rules/no-duplicate-jsx-props",
destination: "/docs/rules/jsx-no-duplicate-props",
permanent: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const name = "react-x/recommended-typescript";

export const rules = {
...recommended.rules,
"react-x/no-duplicate-jsx-props": "off",
"react-x/use-jsx-vars": "off",
"react-x/jsx-no-duplicate-props": "off",
"react-x/jsx-uses-vars": "off",
} as const satisfies RulePreset;

export const settings = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-x/no-create-ref": "error",
"react-x/no-default-props": "error",
"react-x/no-direct-mutation-state": "error",
"react-x/no-duplicate-jsx-props": "warn",
"react-x/jsx-no-duplicate-props": "warn",

Check warning on line 23 in packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "react-x/jsx-no-duplicate-props" to come before "react-x/no-direct-mutation-state"

Check warning on line 23 in packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

View workflow job for this annotation

GitHub Actions / check

Expected "react-x/jsx-no-duplicate-props" to come before "react-x/no-direct-mutation-state"
"react-x/no-duplicate-key": "warn",
"react-x/no-forward-ref": "warn",
"react-x/no-implicit-key": "warn",
Expand All @@ -41,7 +41,7 @@
"react-x/no-unused-state": "warn",
"react-x/no-use-context": "warn",
"react-x/no-useless-forward-ref": "warn",
"react-x/use-jsx-vars": "warn",
"react-x/jsx-uses-vars": "warn",

Check warning on line 44 in packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "react-x/jsx-uses-vars" to come before "react-x/no-useless-forward-ref"

Check warning on line 44 in packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts

View workflow job for this annotation

GitHub Actions / check

Expected "react-x/jsx-uses-vars" to come before "react-x/no-useless-forward-ref"
} as const satisfies RulePreset;

export const settings = {
Expand Down
18 changes: 10 additions & 8 deletions packages/plugins/eslint-plugin-react-x/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { name, version } from "../package.json";
import avoidShorthandBoolean from "./rules/avoid-shorthand-boolean";
import avoidShorthandFragment from "./rules/avoid-shorthand-fragment";
import jsxNoDuplicateProps from "./rules/jsx-no-duplicate-props";
import jsxUsesVars from "./rules/jsx-uses-vars";
import noAccessStateInSetstate from "./rules/no-access-state-in-setstate";
import noArrayIndexKey from "./rules/no-array-index-key";
import noChildrenCount from "./rules/no-children-count";
Expand All @@ -20,7 +22,6 @@ import noContextProvider from "./rules/no-context-provider";
import noCreateRef from "./rules/no-create-ref";
import noDefaultProps from "./rules/no-default-props";
import noDirectMutationState from "./rules/no-direct-mutation-state";
import noDuplicateJsxProps from "./rules/no-duplicate-jsx-props";
import noDuplicateKey from "./rules/no-duplicate-key";
import noForwardRef from "./rules/no-forward-ref";
import noImplicitKey from "./rules/no-implicit-key";
Expand Down Expand Up @@ -50,7 +51,6 @@ import preferReactNamespaceImport from "./rules/prefer-react-namespace-import";
import preferReadOnlyProps from "./rules/prefer-read-only-props";
import preferShorthandBoolean from "./rules/prefer-shorthand-boolean";
import preferShorthandFragment from "./rules/prefer-shorthand-fragment";
import useJsxVars from "./rules/use-jsx-vars";

export const plugin = {
meta: {
Expand Down Expand Up @@ -79,7 +79,6 @@ export const plugin = {
"no-create-ref": noCreateRef,
"no-default-props": noDefaultProps,
"no-direct-mutation-state": noDirectMutationState,
"no-duplicate-jsx-props": noDuplicateJsxProps,
"no-duplicate-key": noDuplicateKey,
"no-forward-ref": noForwardRef,
"no-implicit-key": noImplicitKey,
Expand Down Expand Up @@ -109,18 +108,21 @@ export const plugin = {
"prefer-read-only-props": preferReadOnlyProps,
"prefer-shorthand-boolean": preferShorthandBoolean,
"prefer-shorthand-fragment": preferShorthandFragment,
"use-jsx-vars": useJsxVars,

// Part: JSX only rules
"jsx-no-duplicate-props": jsxNoDuplicateProps,
"jsx-uses-vars": jsxUsesVars,

// Part: deprecated rules
/** @deprecated Use `no-useless-forward-ref` instead */
"ensure-forward-ref-using-ref": noUselessForwardRef,
/** @deprecated Use `no-duplicate-jsx-props` instead */
"jsx-no-duplicate-props": noDuplicateJsxProps,
/** @deprecated Use `use-jsx-vars` instead */
"jsx-uses-vars": useJsxVars,
/** @deprecated Use `no-complex-conditional-rendering` instead */
"no-complicated-conditional-rendering": noComplexConditionalRendering,
/** @deprecated Use `jsx-no-duplicate-props` instead */
"no-duplicate-jsx-props": jsxNoDuplicateProps,
/** @deprecated Use `no-nested-component-definitions` instead */
"no-nested-components": noNestedComponentDefinitions,
/** @deprecated Use `jsx-uses-vars` instead */
"use-jsx-vars": jsxUsesVars,
},
} as const;
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: no-duplicate-jsx-props
title: jsx-no-duplicate-props
---

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

```plain copy
react-x/no-duplicate-jsx-props
react-x/jsx-no-duplicate-props
```

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

```plain copy
@eslint-react/no-duplicate-jsx-props
@eslint-react/jsx-no-duplicate-props
```

**Presets**
Expand Down Expand Up @@ -39,5 +39,5 @@ Disallow duplicate props in JSX elements.

## Implementation

- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/no-duplicate-jsx-props.spec.ts)
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-no-duplicate-props.spec.ts)
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import tsx from "dedent";

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

ruleTester.run(RULE_NAME, rule, {
invalid: [
{
code: tsx`<div a="1" a="2" />;`,
errors: [{ messageId: "noDuplicateJsxProps" }],
errors: [{ messageId: "jsxNoDuplicateProps" }],
},
{
code: tsx`<div a="1" b="2" a="3" />;`,
errors: [{ messageId: "noDuplicateJsxProps" }],
errors: [{ messageId: "jsxNoDuplicateProps" }],
},
{
code: tsx`<div a="1" {...b} a="2" />;`,
errors: [{ messageId: "noDuplicateJsxProps" }],
errors: [{ messageId: "jsxNoDuplicateProps" }],
},
{
code: tsx`<div a="1" {...a} {...b} a="2" />;`,
errors: [{ messageId: "noDuplicateJsxProps" }],
errors: [{ messageId: "jsxNoDuplicateProps" }],
},
],
valid: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/types";

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

export const RULE_NAME = "no-duplicate-jsx-props";
export const RULE_NAME = "jsx-no-duplicate-props";

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

Expand All @@ -19,7 +19,7 @@ export default createRule<[], MessageID>({
[Symbol.for("rule_features")]: RULE_FEATURES,
},
messages: {
noDuplicateJsxProps: "This JSX property is assigned multiple times.",
jsxNoDuplicateProps: "This JSX property is assigned multiple times.",
},
schema: [],
},
Expand All @@ -45,7 +45,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
continue;
}
context.report({
messageId: "noDuplicateJsxProps",
messageId: "jsxNoDuplicateProps",
node: attr,
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: use-jsx-vars
title: jsx-uses-vars
---

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

```plain copy
react-x/use-jsx-vars
react-x/jsx-uses-vars
```

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

```plain copy
@eslint-react/use-jsx-vars
@eslint-react/jsx-uses-vars
```

**Presets**
Expand Down Expand Up @@ -44,5 +44,5 @@ const Hello = require("./Hello");

## Implementation

- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/use-jsx-vars.spec.ts)
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-uses-vars.ts)
- [Test source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/jsx-uses-vars.spec.ts)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tsx from "dedent";

import { allValid, ruleTester } from "../../../../../test";
import rule, { RULE_NAME } from "./use-jsx-vars";
import rule, { RULE_NAME } from "./jsx-uses-vars";

ruleTester.run(RULE_NAME, rule, {
invalid: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/types";

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

export const RULE_NAME = "use-jsx-vars";
export const RULE_NAME = "jsx-uses-vars";

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

Expand All @@ -19,7 +19,7 @@ export default createRule<[], MessageID>({
[Symbol.for("rule_features")]: RULE_FEATURES,
},
messages: {
useJsxVars: "",
jsxUsesVars: "JSX variables should be marked as used.",
},
schema: [],
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/eslint-plugin/src/configs/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@eslint-react/no-create-ref": "error",
"@eslint-react/no-default-props": "error",
"@eslint-react/no-direct-mutation-state": "error",
"@eslint-react/no-duplicate-jsx-props": "warn",
"@eslint-react/jsx-no-duplicate-props": "warn",

Check warning on line 34 in packages/plugins/eslint-plugin/src/configs/all.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "@eslint-react/jsx-no-duplicate-props" to come before "@eslint-react/no-direct-mutation-state"

Check warning on line 34 in packages/plugins/eslint-plugin/src/configs/all.ts

View workflow job for this annotation

GitHub Actions / check

Expected "@eslint-react/jsx-no-duplicate-props" to come before "@eslint-react/no-direct-mutation-state"
"@eslint-react/no-duplicate-key": "warn",
"@eslint-react/no-forward-ref": "warn",
"@eslint-react/no-implicit-key": "warn",
Expand All @@ -58,7 +58,7 @@
"@eslint-react/prefer-destructuring-assignment": "warn",
"@eslint-react/prefer-shorthand-boolean": "warn",
"@eslint-react/prefer-shorthand-fragment": "warn",
"@eslint-react/use-jsx-vars": "warn",
"@eslint-react/jsx-uses-vars": "warn",

Check warning on line 61 in packages/plugins/eslint-plugin/src/configs/all.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "@eslint-react/jsx-uses-vars" to come before "@eslint-react/prefer-shorthand-fragment"

Check warning on line 61 in packages/plugins/eslint-plugin/src/configs/all.ts

View workflow job for this annotation

GitHub Actions / check

Expected "@eslint-react/jsx-uses-vars" to come before "@eslint-react/prefer-shorthand-fragment"

"@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
"@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/eslint-plugin/src/configs/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@eslint-react/no-create-ref": "error",
"@eslint-react/no-default-props": "error",
"@eslint-react/no-direct-mutation-state": "error",
"@eslint-react/no-duplicate-jsx-props": "warn",
"@eslint-react/jsx-no-duplicate-props": "warn",

Check warning on line 24 in packages/plugins/eslint-plugin/src/configs/core.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "@eslint-react/jsx-no-duplicate-props" to come before "@eslint-react/no-direct-mutation-state"

Check warning on line 24 in packages/plugins/eslint-plugin/src/configs/core.ts

View workflow job for this annotation

GitHub Actions / check

Expected "@eslint-react/jsx-no-duplicate-props" to come before "@eslint-react/no-direct-mutation-state"
"@eslint-react/no-duplicate-key": "warn",
"@eslint-react/no-forward-ref": "warn",
"@eslint-react/no-implicit-key": "warn",
Expand All @@ -43,7 +43,7 @@
"@eslint-react/no-use-context": "warn",
"@eslint-react/no-useless-forward-ref": "warn",
"@eslint-react/no-useless-fragment": "warn",
"@eslint-react/use-jsx-vars": "warn",
"@eslint-react/jsx-uses-vars": "warn",

Check warning on line 46 in packages/plugins/eslint-plugin/src/configs/core.ts

View workflow job for this annotation

GitHub Actions / Publish

Expected "@eslint-react/jsx-uses-vars" to come before "@eslint-react/no-useless-fragment"

Check warning on line 46 in packages/plugins/eslint-plugin/src/configs/core.ts

View workflow job for this annotation

GitHub Actions / check

Expected "@eslint-react/jsx-uses-vars" to come before "@eslint-react/no-useless-fragment"
} as const satisfies RulePreset;

export const plugins = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const name = "@eslint-react/recommended-typescript";
export const rules = {
...recommended.rules,
"@eslint-react/dom/no-unknown-property": "off",
"@eslint-react/no-duplicate-jsx-props": "off",
"@eslint-react/use-jsx-vars": "off",
"@eslint-react/jsx-no-duplicate-props": "off",
"@eslint-react/jsx-uses-vars": "off",
} as const satisfies RulePreset;

export const plugins = {
Expand Down