-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby): use separate eslint-loader for rules that are always required #29317
Conversation
if ( | ||
isCustomEslint && | ||
process.env.GATSBY_HOT_LOADER === `fast-refresh` | ||
) { | ||
configRules = configRules.concat([rules.eslintRequired()]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically the main piece. We add another minimal loader only when there is user-defined eslint config. When there is no custom config - we still use a single default Gatsby loader (with fast-refresh rules added to it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried testing as much combinations from reports as possible - with gatsby-plugin-eslint
- both v2 (that use eslint-loader
) and v3 (that use eslint-webpack-plugin
) and without
using optional chaining (for old parser), using eslint-disable
with "not existing rules" and from what I can tell I had expected results, so let's merge this - at very least this will fix known issues.
Huge thanks!
Published in |
Description
Fast-refresh as a hot-reloading mechanism has several constraints. And we need to enforce those constraints using eslint and custom eslint rules. Originally we've implemented this in #28911. And the idea was to merge those rules into a custom user eslint config.
This has caused several issues. This PR suggests a different approach by introducing a separate
eslint-loader
for fast-refresh rules that is completely isolated from the user custom eslint setup.This loader is only added when there is a custom .eslintrc`. For default Gatsby eslint config we still have a single loader (and just add fast-refresh rules to it).
Documentation
https://www.gatsbyjs.com/docs/how-to/custom-configuration/eslint/
(this PR warrants updating those docs a bit)
Related Issues
An alternative approach to #28911
Fixes #29105
Fixes #29133