Skip to content

feat: enable context-name rule in recommended presets #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2025
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
2 changes: 1 addition & 1 deletion apps/website/content/docs/rules/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Linter rules can have false positives, false negatives, and some rules are depen
| Rule | ✅ | 🌟 | Description |
| :------------------------------------------------------------- | :- | :-: | :------------------------------------------------------------------------------- |
| [`component-name`](./naming-convention-component-name) | 0️⃣ | `⚙️` | Enforces naming conventions for components |
| [`context-name`](./naming-convention-context-name) | 0️⃣ | | Enforces context name to be a valid component name with the suffix `Context` |
| [`context-name`](./naming-convention-context-name) | 1️⃣ | | Enforces context name to be a valid component name with the suffix `Context` |
| [`filename`](./naming-convention-filename) | 0️⃣ | `⚙️` | Enforces consistent file naming conventions |
| [`filename-extension`](./naming-convention-filename-extension) | 0️⃣ | `⚙️` | Enforces consistent use of the JSX file extension |
| [`use-state`](./naming-convention-use-state) | 0️⃣ | | Enforces destructuring and symmetric naming of `useState` hook value and setter |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ import type { RulePreset } from "@eslint-react/kit";

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

export const rules = {} as const satisfies RulePreset;
export const rules = {
"react-naming-convention/context-name": "warn",
// "react-naming-convention/use-state": "warn",
} as const satisfies RulePreset;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ react-naming-convention/context-name
@eslint-react/naming-convention/context-name
```

**Presets**

- `recommended`
- `recommended-typescript`
- `recommended-type-checked`

## Description

Enforces context name to be a valid component name with the suffix `Context`.
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/eslint-plugin/src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ export const rules = {
...core.rules,
...dom.rules,
...webApi.rules,

"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": "warn",
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",

"@eslint-react/naming-convention/context-name": "warn",
// "@eslint-react/naming-convention/use-state": "warn",
} as const satisfies RulePreset;

export const plugins = {
Expand Down