Skip to content

Commit 06387c8

Browse files
authored
feat: add 'naming-convention/use-state' and 'naming-convention/context-name' to recommended presets (#956)
1 parent 435889f commit 06387c8

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

examples/vite-react-dom-with-ts-blank-eslint-parser-app/eslint.config.js

+3-18
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,10 @@ import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
66
import tsBlankEslintParser from "ts-blank-eslint-parser";
77
import tseslint from "typescript-eslint";
88
import globals from "globals";
9-
import { isInEditorEnv } from "@eslint-react/shared";
109

1110
import TSCONFIG from "./tsconfig.json" with { type: "json" };
1211
import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" };
1312

14-
function getOptimalParserConfig(project = "tsconfig.json") {
15-
switch (true) {
16-
case isInEditorEnv():
17-
case process.argv.includes("--fix"):
18-
return {
19-
parser: tseslint.parser,
20-
parserOptions: {
21-
project,
22-
tsconfigRootDir: import.meta.dirname,
23-
},
24-
};
25-
}
26-
return { parser: tsBlankEslintParser };
27-
}
28-
2913
export default [
3014
// base configuration for browser environment source files
3115
{
@@ -34,10 +18,11 @@ export default [
3418
globals: {
3519
...globals.browser,
3620
},
37-
...getOptimalParserConfig(),
21+
parser: tsBlankEslintParser,
3822
},
3923
rules: {
4024
...eslintJs.configs.recommended.rules,
25+
"no-unused-vars": "off",
4126
},
4227
},
4328
// base configuration for node environment source files (*.config.js, etc.)
@@ -48,7 +33,7 @@ export default [
4833
globals: {
4934
...globals.node,
5035
},
51-
...getOptimalParserConfig("tsconfig.node.json"),
36+
parser: tsBlankEslintParser,
5237
},
5338
rules: {
5439
...eslintJs.configs.recommended.rules,

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ import type { RulePreset } from "@eslint-react/shared";
22

33
export const name = "react-naming-convention/recommended";
44

5-
export const rules = {} as const satisfies RulePreset;
5+
export const rules = {
6+
"react-naming-convention/context-name": "warn",
7+
"react-naming-convention/use-state": "warn",
8+
} as const satisfies RulePreset;

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

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const rules = {
1616
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
1717
"@eslint-react/hooks-extra/no-useless-custom-hooks": "warn",
1818
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
19+
"@eslint-react/naming-convention/context-name": "warn",
20+
"@eslint-react/naming-convention/use-state": "warn",
1921
} as const satisfies RulePreset;
2022

2123
export const plugins = {

0 commit comments

Comments
 (0)