Create-react-app: Eslint Auto fix

Created on 20 Feb 2017  路  13Comments  路  Source: facebook/create-react-app

can we make Eslint Auto fix configurable?

I like that when in watch mode, it fixes my eslint on the fly.

Most helpful comment

I think that using a custom .eslintrc is very important, is there an open discusstion on it?, so I will write done my opinion about it.

All 13 comments

Which rules would it be valuable for? Our lint rules don't include any style rules, so I'm not sure anything we report is autofixable. I also heard reports of autofix not working well with eslint-loader, causing infinite cycles.

For enforcing style, I would instead suggest Prettier. Does this help?

I am not sure what rules are used in this project.

but if there are not there I will add them in eslint.js

Rules that the auto fix was useful for me is (you can see that all rules are fixable)

jsx-indent
arrow-body-style
object-shorthand
and there is a lot more.

it's very convenient that it auto fix my stuff.

can we add it?

I don't quite understand what you're asking.

Before ejecting, you can't change the ESLint config. Our ESLint config does not contain any style rules, as I said earlier. This is intentional, and briefly discussed at the end of https://github.com/facebookincubator/create-react-app/issues/808.

I recommend using Prettier to enforce style, if you want to.

I don't want to use Prettier, I just want to turn on Auto fix in eslint.

I added some rules in my own custom eslint config.

and I Can't turn on eslint auto fix.

Sorry, it is not clear from your comments what you problem is. You didn't specify whether you ejected or not, what have you tried, what exactly didn't work, etc. It is very hard to help if you give so little information.

I didn't eject.

everything is working, I am not reporting a bug.

I didn't try to turn on Eslint fix option because there is no way to do that without eject.

I am asking for an ability to turn on Eslint fix without ejecting

I Understand that your ESLint config does not include style rules.

I added style rules manually (no eject, only by adding .eslintrc to my project as discussed at #808)
and I want to turn on fix flag but there is no way to do it without eject.

I understand that there is reports of autofix not working well with eslint-loader, causing infinite cycles, but for me its working fine (we have 50 engineers working with it)

so Thats why I want the fix flag to be configurable (default off) so we can decide if to use it.

I added style rules manually (no eject, only by adding .eslintrc to my project as discussed at #808)

Okay, I understand better now. This is not really supported. If you add your own style rules, then please also manually run eslint --fix to get them fixed. As I mentioned before, eslint-loader has issues with autofix, and we won't be enabling it by default.

I understand that there is reports of autofix not working well with eslint-loader, causing infinite cycles, but for me its working fine for me (we have 50 engineers working with it)

so Thats why I want the fix flag to be configurable (default off) so we can decide if to use it.

adding run eslint --fix will not help, because I Will need to run it every time I change my code.
when we run the project, it is in watch mode and every change is hot reloading the browser.
Adding fix flag in eslint-loader option is a more convenient, because it will fix the code on the fly (in watch mode). fixing my code instantly.

please consider adding it, its a very minor change. 馃憤

It is not a minor change if it breaks in some cases, and people can't turn it off.

I understand your concerns but using a custom .eslintrc is not supported in the first place. It may happen to work, but it's not how this tool is intended to be used.

I'm sorry if this is frustrating to you.

If you need modifications like this, consider making a fork for your company: https://github.com/facebookincubator/create-react-app/issues/682

I think that using a custom .eslintrc is very important, is there an open discusstion on it?, so I will write done my opinion about it.

Thanks, it's been discussed in #808 at length. Feel free to write here.

so, there's no way to get autofix?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Evan-GK picture Evan-GK  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

adrice727 picture adrice727  路  3Comments

alleroux picture alleroux  路  3Comments

barcher picture barcher  路  3Comments