-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add ESLint extend support to eslint-loader #7036
Conversation
The reason config wasn't configurable in the first place is to prevent hyper-opinionated configs full of styling rules from showing up in the browser overlay integration. If we allow arbitrary configs we should make sure that this is still the case. E.g. at least adding Airbnb config shouldn't make a wrong indentation appear as a build error. |
Maybe we could force the linter to always have |
How do users override TypeScript rules? That was the main driver of this change. |
If you're enforcing that users still include Whilst it's not technically required, pretty much every plugin (and base eslint rules definitely do) follows the exported config structure defined by eslint: This means that every rule should have a I would just setup the hard rule that a plugin must have type set to Similarly there is a |
This sounds reasonable to me. |
Great suggestions, @bradzacher. Thanks! If users don't extend |
@gaearon I think we're all on the same page. I personally don't like breaking builds unless it's a serious issue, but we're trying to allow people to have more control over this. We can use recommend people to set @bradzacher, as @ianschmitz mentioned, it's about consistency with IDE integration. I'd prefer that users know what's going on - because they explicitly set that config - rather than us adding things in the background. I'd be interested to hear more about your idea @bradzacher, as I can't see a simple way to configure that in |
I was weighing in from a linting perspective! I don't have much of an idea of CRA/Webpack. I had a quick look and there's a lot of codepaths - I'm not sure how it would work within this project. With my lack of knowledge of what CRA error output looks like (I've never properly used CRA), it looks like it could be a bit of a larger change across a number of files? |
Sorry @bradzacher, I misunderstood and thought you meant we could configure ESLint that way. I think it would be a fairly large change... And I'm not sure of the performance and maintainability impacts it might have. @gaearon @ianschmitz What do you think? |
@gaearon not wanting opinionated linting to break builds is an opinion, though. On my project, I want to enforce code style, and have good reasons to believe it should be on save rather than on commit which I don't think I need to go into here. CRA is awesome, but if I want to lint aggressively, I need to maintain a fork, or eject, both options of which are way over the top for something so simple. At least give us the option. |
Thanks for this PR, this is useful when you migrate from an older codebase (using CRA v1 for example), and need to convert a few eslint errors to warnings, just to @mrmckeb Could we allow also an |
As @caub says, except also |
@gaearon Isn't this configurable by the developer? Eslint rules differentiate between warning or error (
I also don't think we should mandate prettier usage. The VSCode extension is actually currently broken which makes it very difficult to use while working locally. In general, I don't understand why CRA cares what a user does with their codebase after initialization, and should only provide guard rails for things that would break other parts of the CRA build tools. For instance, we cannot import files outside the IMO trying to mandate linting rules is no different than mandating usage of, say, RXJS instead of Redux. This seems out of scope for CRA. @caub thank you for doing this. I think it would be good to support |
@dannycochran - The VSCode extension isn't technically broken, Note that Also note that if you install the eslint extension, turn off |
@caub We could do that for sure. We could release without and perhaps drop it in as an update - I think at this stage we need to get something out, and we can then "enhance" once we've proven that it's working. |
3565973
to
170af1a
Compare
I agree that forcing the configuration via I suggest letting eslint's own config resolution do all the work:
So basically, the config would just be |
ec9a005
to
d6b1a7e
Compare
This PR was updated yesterday to do just that @silverwind (cool name btw), but I neglected to leave a comment. |
Ah I see. I think you need to update docs to remove the mentions of Also would like to see
|
d6b1a7e
to
39b7060
Compare
@silverwind that was an oversight, corrected now. That env will be required until the next major release, where we may make this the default. The config options are already updated. The |
Hey, this PR sounds like an awesome addition to CRA but I'm wondering how does it compare to the existing way of extending ESLint? In the editor setup docs, it says the following:
The ESLint configuration file can also (already) extend other configurations or plugins right? |
Hi @ReasonableDeveloper, this is nothing special in that sense - we're just requiring that people extend our config for now. We're not doing anything clever here, so you'll be able to work as you always have with ESLint. |
Creating a custom |
39b7060
to
7caf9d6
Compare
This allows users to extend the base ESLint config, so long as it is extending the
react-app
config.Config in
package.json
Initially, this is limited to users that use
package.json
to configure ESLint. We can extend this later, but it will have performance implications as we would need to:react-app
config.eslint-loader
.Eslint provides tooling to support this, but again, this will impact performance.
Users could work around this, by setting the following in
package.json
:Documentation
Once this approach is approved, I'll update our ESLint documentation to outline usage.