创建React App-控制台棉绒警告与eslintrc不匹配 [英] Create React App - console lint warnings don't match eslintrc

查看:129
本文介绍了创建React App-控制台棉绒警告与eslintrc不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,我在其他地方看不到任何提及。

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

默认情况下,在运行 yarn start 时以及在Chrome中,默认情况下创建React App似乎会在终端中记录棉绒警告安慰。都好。很有道理,并且我已经讨论了该功能是否应该存在以及如何工作。

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.

我的问题是那些警告似乎根本与我的 .eslintrc 设置不匹配!

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

例如,如果我运行 yarn lint ,则使用我的计算机运行 eslint 设置,启动我的应用程序时,控制台和终端中都看不到任何警告。

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.

例如,我在 .eslintrc 文件:

"radix": 0,

因此,当我运行<$时,没有 radix 警告c $ c>纱线皮毛。

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

(仅是为了回答以下问题。针对该特定规则,我已经尝试了多种选择,包括按需。但是我想将完全排除掉了,这显然是我已经完成的,因为运行纱线皮毛根本没有显示与 radix 相关的错误) 。

(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:

任何人都知道为什么我的 .eslintrc 文件在这里被忽略,以及如何获得这些警告来表示我设置的规则?

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

推荐答案

根据文档,则应传递始终 按需 。后者应禁用这些警告。

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

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

编辑:根据此,则您必须弹出 create-react-应用编辑ESLint设置。

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

这篇关于创建React App-控制台棉绒警告与eslintrc不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆