-
-
Notifications
You must be signed in to change notification settings - Fork 56
Add React Server Components (RSC) plugin #1457
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
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4281bcd
Add React Server Components (RSC) plugin
Rel1cx d234fe1
Update heading to eslint-plugin-react-rsc
Rel1cx d52a8a7
[WIP] WIP Address changes based on feedback for React Server Componen…
Copilot 1db2b2c
Update packages/plugins/eslint-plugin-react-rsc/src/index.ts
Rel1cx dea47ce
[WIP] Address feedback on the React Server Components plugin (#1455)
Copilot 6ab63a8
[WIP] Update React Server Components plugin based on feedback (#1454)
Copilot ed6d1c6
[WIP] Update RSC plugin based on feedback from PR #1451 (#1453)
Copilot 6e29d60
[WIP] Update React Server Components plugin based on feedback (#1456)
Copilot c7206d2
[WIP] Address feedback on React Server Components plugin PR (#1459)
Copilot 1d812ce
[WIP] Update PR for React Server Components plugin feedback (#1458)
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 2.9.0-beta.0 | ||
| 2.9.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/plugins/eslint-plugin-react-naming-convention/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # eslint-plugin-react-rsc | ||
|
|
||
| ## Install | ||
|
|
||
| ```sh | ||
| # npm | ||
| npm install --save-dev eslint-plugin-react-rsc | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| ```js | ||
| // eslint.config.js | ||
|
|
||
| // @ts-check | ||
| import js from "@eslint/js"; | ||
| import react from "eslint-plugin-react-x"; | ||
| import { defineConfig } from "eslint/config"; | ||
| import tseslint from "typescript-eslint"; | ||
|
|
||
| export default defineConfig( | ||
| { | ||
| files: ["**/*.{ts,tsx}"], | ||
| extends: [ | ||
| js.configs.recommended, | ||
| tseslint.configs.recommended, | ||
| react.configs.recommended, | ||
| ], | ||
| rules: { | ||
| // Put rules you want to override here | ||
| "react-rsc/function-definition": "error", | ||
| }, | ||
| }, | ||
| ); | ||
| ``` | ||
|
|
||
| ## Rules | ||
|
|
||
| <Callout type="info"> | ||
| RSC rules target [React Server Components](https://react.dev/reference/rsc/server-components), [React Server Functions](https://react.dev/reference/rsc/server-functions) and RSC [Directives](https://react.dev/reference/rsc/directives). | ||
| </Callout> | ||
|
|
||
| - [`function-definition`](https://eslint-react.xyz/docs/rules/rsc-function-definition) - Validate and transform React Server/Client Function definitions. (🔧 Fixable, 🧪 Experimental) | ||
|
|
||
| <https://eslint-react.xyz/docs/rules/overview#rsc-rules> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| { | ||
| "name": "eslint-plugin-react-rsc", | ||
| "version": "2.9.0", | ||
| "description": "ESLint React's ESLint plugin for RSC related rules.", | ||
| "keywords": [ | ||
| "react", | ||
| "eslint", | ||
| "eslint-react", | ||
| "eslint-plugin", | ||
| "eslint-plugin-react-rsc" | ||
| ], | ||
| "homepage": "https://github.com/Rel1cx/eslint-react", | ||
| "bugs": { | ||
| "url": "https://github.com/Rel1cx/eslint-react/issues" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/Rel1cx/eslint-react.git", | ||
| "directory": "packages/plugins/eslint-plugin-react-rsc" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Rel1cx", | ||
| "sideEffects": false, | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "files": [ | ||
| "dist", | ||
| "./package.json" | ||
| ], | ||
| "scripts": { | ||
| "build": "tsdown", | ||
| "lint:publish": "publint", | ||
| "lint:ts": "tsc --noEmit", | ||
| "publish": "pnpm run build && pnpm run lint:publish" | ||
| }, | ||
| "dependencies": { | ||
| "@eslint-react/ast": "workspace:*", | ||
| "@eslint-react/shared": "workspace:*", | ||
| "@eslint-react/var": "workspace:*", | ||
| "@typescript-eslint/types": "^8.54.0", | ||
| "@typescript-eslint/utils": "^8.54.0", | ||
| "ts-pattern": "^5.9.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@local/configs": "workspace:*", | ||
| "@types/react": "^19.2.10", | ||
| "@types/react-dom": "^19.2.3", | ||
| "tsdown": "^0.20.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "eslint": "^8.57.0 || ^9.0.0", | ||
| "typescript": ">=4.8.4 <6.0.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20.19.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
packages/plugins/eslint-plugin-react-rsc/src/configs/disable-experimental.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type { RuleConfig } from "@eslint-react/shared"; | ||
|
|
||
| export const name = "react-rsc/disable-experimental"; | ||
|
|
||
| export const rules: Record<string, RuleConfig> = { | ||
| "react-rsc/function-definition": "off", | ||
| }; |
17 changes: 17 additions & 0 deletions
17
packages/plugins/eslint-plugin-react-rsc/src/configs/recommended-typescript.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { RuleConfig } from "@eslint-react/shared"; | ||
|
|
||
| import * as recommended from "./recommended"; | ||
|
|
||
| export const name = "react-rsc/recommended-typescript"; | ||
|
|
||
| export const rules = { | ||
| ...recommended.rules, | ||
| } as const satisfies Record<string, RuleConfig>; | ||
|
|
||
| export const plugins = { | ||
| ...recommended.plugins, | ||
| }; | ||
|
|
||
| export const settings = { | ||
| ...recommended.settings, | ||
| }; |
18 changes: 18 additions & 0 deletions
18
packages/plugins/eslint-plugin-react-rsc/src/configs/recommended.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import type { RuleConfig } from "@eslint-react/shared"; | ||
| import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; | ||
|
|
||
| import { plugin } from "../plugin"; | ||
|
|
||
| export const name = "react-rsc/recommended"; | ||
|
|
||
| export const rules = { | ||
| "react-rsc/function-definition": "error", | ||
| } as const satisfies Record<string, RuleConfig>; | ||
|
|
||
| export const plugins = { | ||
| "react-rsc": plugin, | ||
| }; | ||
|
|
||
| export const settings = { | ||
| "react-rsc": DEFAULT_ESLINT_REACT_SETTINGS, | ||
| }; |
17 changes: 17 additions & 0 deletions
17
packages/plugins/eslint-plugin-react-rsc/src/configs/strict-typescript.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { RuleConfig } from "@eslint-react/shared"; | ||
|
|
||
| import * as strict from "./strict"; | ||
|
|
||
| export const name = "react-rsc/strict-typescript"; | ||
|
|
||
| export const rules = { | ||
| ...strict.rules, | ||
| } as const satisfies Record<string, RuleConfig>; | ||
|
|
||
| export const plugins = { | ||
| ...strict.plugins, | ||
| }; | ||
|
|
||
| export const settings = { | ||
| ...strict.settings, | ||
| }; |
16 changes: 16 additions & 0 deletions
16
packages/plugins/eslint-plugin-react-rsc/src/configs/strict.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import type { RuleConfig } from "@eslint-react/shared"; | ||
| import * as recommended from "./recommended"; | ||
|
|
||
| export const name = "react-rsc/strict"; | ||
|
|
||
| export const rules = { | ||
| ...recommended.rules, | ||
| } as const satisfies Record<string, RuleConfig>; | ||
|
|
||
| export const plugins = { | ||
| ...recommended.plugins, | ||
| }; | ||
|
|
||
| export const settings = { | ||
| ...recommended.settings, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.