Create an official ESLint plugin #12522
aaronadamsCA
started this conversation in
Proposals
Replies: 1 comment
-
Another idea: a rule to forbid the usage of components, functions or attributes that can't be used in the declarative or data mode. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it would be a great idea to ship an official
@react-router/eslint-plugin
.Similar to other projects' official plugins like
@vitest/eslint-plugin
andeslint-plugin-storybook
, this plugin would contain rules that help developers of all skill levels avoid mistakes.A few rule ideas to start:
no-action-only-routes
: Require a route that exports an action to also export a loader or a route component.If an action-only route returns an error and the user refreshes the page, React Router returns an error because the route cannot respond to
GET
requests. The simplest fix is to add a loader that redirects the user to a valid path.require-root-error-boundary
: Make sure the root route exports an error boundary.valid-resource-route
: Make sure a resource root returns aResponse
.valid-route-module-path
: Validate that the route module paths inroutes.ts
can be resolved (or better yet, that they resolve to valid route modules).Like any good ESLint plugin, the simplest rules would help to reduce the learning curve (and the corresponding support load), while the most advanced rules could help large apps find and fix all kinds of edge-case problems.
Presumably there could also be shared configs, e.g. a "recommended" config that checks for common errors, and a "strict" config that extends the recommended config with a more opinionated set of best practices.
Beta Was this translation helpful? Give feedback.
All reactions