Uh oh!
There was an error while loading. Please reload this page.
Add ESLint extend support to eslint-loader - #7036
Conversation
gaearon
commented
May 12, 2019
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. |
gaearon
commented
May 12, 2019
Maybe we could force the linter to always have |
ianschmitz
commented
May 12, 2019
How do users override TypeScript rules? That was the main driver of this change. |
Uh oh!
There was an error while loading. Please reload this page.
bradzacher
commented
May 12, 2019
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 |
gaearon
commented
May 12, 2019
This sounds reasonable to me. |
ianschmitz
commented
May 12, 2019
Great suggestions, @bradzacher. Thanks! If users don't extend |
mrmckeb
commented
May 13, 2019
@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? |
mrmckeb
commented
May 13, 2019
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? |
Asday
commented
May 21, 2019
@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 |
Asday
commented
May 21, 2019
As @caub says, except also |
dannycochran
commented
May 22, 2019
@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 |
bradzacher
commented
May 22, 2019
@dannycochran - The VSCode extension isn't technically broken, Note that Also note that if you install the eslint extension, turn off |
mrmckeb
commented
May 23, 2019
@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
170af1aCompareUh oh!
There was an error while loading. Please reload this page.
silverwind
commented
Jun 24, 2019
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
d6b1a7eComparemrmckeb
commented
Jun 25, 2019
This PR was updated yesterday to do just that @silverwind (cool name btw), but I neglected to leave a comment. |
silverwind
commented
Jun 25, 2019
Ah I see. I think you need to update docs to remove the mentions of Also would like to see
|
d6b1a7e to
39b7060Compare@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? |
mrmckeb
commented
Jul 8, 2019
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. |
silverwind
commented
Jul 8, 2019
Creating a custom |
39b7060 to
7caf9d6Compare
This allows users to extend the base ESLint config, so long as it is extending the
react-appconfig.Config in
package.jsonInitially, this is limited to users that use
package.jsonto configure ESLint. We can extend this later, but it will have performance implications as we would need to:react-appconfig.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:{ "eslintConfig": { "extends": ["react-app", "./my-eslint-config.js"] } }Documentation
Once this approach is approved, I'll update our ESLint documentation to outline usage.