Create React App - console lint warnings don't match eslintrc

随声附和 提交于 2019-12-25 03:55:33

问题


I've got a sort of weird problem, that I don't see any mention of elsewhere.

Create React App by default seems to log lint warning in the terminal when running yarn start and also in the Chrome console. All good. Makes sense, and I've seen discussions of whether this functionality should exist, and how it should work.

My issue is that those warnings seem not to match my .eslintrc settings at all!

As in, if I run yarn lint, which runs eslint using my settings, I see none of the warnings that show up in the console and terminal when I start my app.

For example, I have this rule turned off in my .eslintrc file:

"radix": 0,

And, consequently, there's no radix warning when I run yarn lint.

(Just in response to the answer below. I've tried a variety of options for this particular rule, including "as-needed". But I wanted to turn the rule off entirely, which I've evidently accomplished, because running yarn lint shows no errors related to radix at all).

But when I start the app, I see this in yellow warning boxes in the console:

Anybody know why my .eslintrc file is being ignored here, and how to get these warnings to represent the rules I've set?


回答1:


According to the docs, you should pass either "always" or "as-needed". The latter should disable those warnings.

...
"radix": "as-needed",
...

EDIT: According to this source, you will have to eject your create-react-app to edit the ESLint settings.



来源:https://stackoverflow.com/questions/52633551/create-react-app-console-lint-warnings-dont-match-eslintrc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!