Skip to content

Commit

Permalink
feat(rules/consistent-syntax): better rule name
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Sep 18, 2024
1 parent ad406bd commit 1d8692a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ ESLint plugin to ensure consistent react imports
✅ Set in the `recommended` configuration.\
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).

| Name   | Description | 💼 | 🔧 |
| :----------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- |
| [syntax](docs/rules/syntax.md) | Enforces React import style across your code. Can be customized to use default or namespace import. By default converts exports using namespace import || 🔧 |
| Name              | Description | 💼 | 🔧 |
| :--------------------------------------------------- | :-------------------------------------------------------------------------------------------------- | :- | :- |
| [consistent-syntax](docs/rules/consistent-syntax.md) | Enforces React import style across your code. Can be customized to use default or namespace import. || 🔧 |

<!-- end auto-generated rules list -->

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/syntax.md → docs/rules/consistent-syntax.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Enforces React import style across your code. Can be customized to use default or namespace import. (`react-import/syntax`)
# Enforces React import style across your code. Can be customized to use default or namespace import (`react-import/consistent-syntax`)

💼 This rule is enabled in the ✅ `recommended` config.

Expand All @@ -21,7 +21,7 @@ import * as React from "react";
## Options

```text
"react-import/syntax": [<enabled>, <'namespace' | 'default'>]
"react-import/consistent-syntax": [<enabled>, <'namespace' | 'default'>]
```

This rule has one string options that allows to choose the preferred syntax for React imports:
Expand Down
2 changes: 1 addition & 1 deletion src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const createRecommendedConfig = (options: {
"react-import": plugin,
},
rules: {
"react-import/syntax": ["error", "namespace"],
"react-import/consistent-syntax": ["error", "namespace"],
},
languageOptions: {
parserOptions: {
Expand Down
4 changes: 2 additions & 2 deletions src/eslintPluginReactImport.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ESLint, Linter } from "eslint";

import syntaxRule from "./rules/syntax.js";
import consistentSyntaxRule from "./rules/consistent-syntax.js";

import { createRecommendedConfig } from "./configs/recommended.js";
import { PLUGIN_NAME, PLUGIN_VERSION } from "./meta.js";
Expand All @@ -12,7 +12,7 @@ const eslintPluginReactImport = {
},
configs: {} as { recommended: Linter.Config },
rules: {
syntax: syntaxRule,
"consistent-syntax": consistentSyntaxRule,
},
processors: {},
} satisfies ESLint.Plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe } from "vitest";
import { RuleTester } from "eslint";
import typescriptEslintParser from "@typescript-eslint/parser";

import syntaxRule from "./syntax.js";
import syntaxRule from "./consistent-syntax.js";

describe("syntax rule js", () => {
const ruleTester = new RuleTester();
Expand Down
2 changes: 1 addition & 1 deletion src/rules/syntax.ts → src/rules/consistent-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const syntaxRule: Rule.RuleModule = {
"Enforces React import style across your code.",
"Can be customized to use default or namespace import.",
].join(" "),
url: getRuleURL("syntax"),
url: getRuleURL("consistent-syntax"),
},
messages: {
wrongImport: "You should import React using {{syntax}} syntax",
Expand Down
18 changes: 9 additions & 9 deletions tests/__snapshots__/recommended-ts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`config recommended > should have errors for invalid > should have 3 err
"message": "You should import React using namespace syntax",
"messageId": "wrongImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -35,7 +35,7 @@ exports[`config recommended > should have errors for invalid > should have 3 err
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -53,7 +53,7 @@ exports[`config recommended > should have errors for invalid > should have 3 err
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
]
Expand All @@ -76,7 +76,7 @@ exports[`config recommended > should raise error when having two imports (1 valu
"message": "You should import React using namespace syntax",
"messageId": "wrongImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -94,7 +94,7 @@ exports[`config recommended > should raise error when having two imports (1 valu
"message": "React was already imported. This import should be removed when using namespace import",
"messageId": "duplicateImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -112,7 +112,7 @@ exports[`config recommended > should raise error when having two imports (1 valu
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -130,7 +130,7 @@ exports[`config recommended > should raise error when having two imports (1 valu
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
]
Expand All @@ -153,7 +153,7 @@ exports[`config recommended > should raise error when renaming a named import of
"message": "You should import React using namespace syntax",
"messageId": "wrongImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -171,7 +171,7 @@ exports[`config recommended > should raise error when renaming a named import of
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
]
Expand Down
8 changes: 4 additions & 4 deletions tests/__snapshots__/recommended.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`config recommended > should have errors for invalid > should have 2 err
"message": "You should import React using namespace syntax",
"messageId": "wrongImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -35,7 +35,7 @@ exports[`config recommended > should have errors for invalid > should have 2 err
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
]
Expand All @@ -58,7 +58,7 @@ exports[`config recommended > should raise error when renaming a named import of
"message": "You should import React using namespace syntax",
"messageId": "wrongImport",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
{
Expand All @@ -76,7 +76,7 @@ exports[`config recommended > should raise error when renaming a named import of
"message": "This React import should have a 'React.' prefix",
"messageId": "addPrefix",
"nodeType": null,
"ruleId": "react-import/syntax",
"ruleId": "react-import/consistent-syntax",
"severity": 2,
},
]
Expand Down

0 comments on commit 1d8692a

Please sign in to comment.