And*_*ems 3 javascript webstorm reactjs eslint
我正在使用标准的React设置在WebStorm中编写React应用程序.我之前从未明确设置任何linting,因此出现的任何错误/警告消息都来自某种默认配置.当我跑步时,npm start
我得到以下警告:
Compiled with warnings.
Warning in ./path/to/MyComponent.js
/my/complete/path/to/MyComponent.js
19:49 warning Unexpected whitespace before property bind no-whitespace-before-property
...
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
Run Code Online (Sandbox Code Playgroud)
最后两行明确指出警告来自ESLint(而不是JSHint或某些自定义React linting等).
我想保持ESLint运行,即我不想全局禁用所有linting.但是,我想在任何地方关闭"no-whitespace-before-property"警告,而不仅仅是在一行或一个文件中.我怎么做?
我package.json
显示以下内容npm start
(这是警告出现时我运行的内容):
"scripts": {
"start": "react-scripts start",
...
}
Run Code Online (Sandbox Code Playgroud)
我正在开发WebStorm.该ESLint首选项面板中有"启用"复选框选中,那么所有的在IDE中ESLint配置选项是灰色的,并可能无关紧要,所以想必也是ESLint的配置和调用都发生在其他地方(如内置反应是?).
我尝试将以下.eslintrc.json
文件放入我的项目主目录:
{
"rules": {
"no-whitespace-before-property": "off"
}
}
Run Code Online (Sandbox Code Playgroud)
单独以及与"extends": "eslint:recommended"
.
我尝试将以下内容添加到项目的package.json
文件中:
{
...
"eslintConfig": {
"rules": {
"no-whitespace-before-property": "off"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过将值设置为0
而不是"off"
.
我正在编写一个React应用程序可能有也可能没有关系,它可能与我在WebStorm中开发有关,也可能没有关系,但我包含这些事实以防万一.
我在StackOverflow上查了一下,但找不到答案.
错误下面的注释不是来自ESLint(错误是).所以我假设你正在使用某种包装器,比如github.com/facebookincubator/create-react-app那些包装器不使用.eslintrc文件而且不能直接配置.您必须阅读包装器的文档以了解如何禁用此规则.
一般来说,像create-react-app,standard,xo等ESLint包装器专门设计为"正常工作",因此删除了配置和微调样式/规则的能力.
归档时间: |
|
查看次数: |
5963 次 |
最近记录: |