Javascript “未找到 ESLint 配置”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38173326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"No ESLint configuration found" error
提问by alecxe
Recently, we've upgraded to ESLint 3.0.0and started to receive the following message running the grunt eslint
task:
最近,我们已经升级到ESLint 3.0.0并开始收到以下运行grunt eslint
任务的消息:
> $ grunt eslint
Running "eslint:files" (eslint) task
Warning: No ESLint configuration found. Use --force to continue.
Here is the grunt-eslint
configuration:
这是grunt-eslint
配置:
var lintTargets = [
"<%= app.src %>/**/*/!(*test|swfobject)+(.js)",
"test/e2e/**/*/*.js",
"!test/e2e/db/models/*.js"
];
module.exports.tasks = {
eslint: {
files: {
options: {
config: 'eslint.json',
fix: true,
rulesdir: ['eslint_rules']
},
src: lintTargets
}
}
};
What should we do to fix the error?
我们应该怎么做才能修复错误?
采纳答案by Arkadiusz Lendzian
Try to swap config
with configFile
. Then :
尝试config
与configFile
. 然后 :
- Create
eslint.json
file and - Point the right location of it (relative to
Gruntfile.js
file) - Place some configuration in that file (
eslint.json
), i.e.:
- 创建
eslint.json
文件和 - 指向它的正确位置(相对于
Gruntfile.js
文件) - 在该文件 (
eslint.json
) 中放置一些配置,即:
.
.
{
"rules": {
"eqeqeq": "off",
"curly": "warn",
"quotes": ["warn", "double"]
}
}
for more examples, go here.
有关更多示例,请转到此处。
回答by ankit biswas
The error you are facing is because your configuration is not present. To configure the eslint type
您面临的错误是因为您的配置不存在。配置eslint类型
eslint --init
eslint --init
then configure as your requirement.
然后根据您的要求进行配置。
then execute the project again.
然后再次执行该项目。
回答by ap_snitch
I hade the same problem with Gulp and running "gulp-eslint": "^3.0.1" version. I had to rename config: to configFile in Gulp task
我在 Gulp 和运行“gulp-eslint”:“^3.0.1”版本时遇到了同样的问题。我不得不将 config: 重命名为 Gulp 任务中的 configFile
.pipe(lint({configFile: 'eslint.json'}))
回答by alecxe
For those having the same problem, this is how we've fixed it.
对于那些有同样问题的人,我们就是这样解决的。
Following the Requiring Configuration to Runmigration procedure, we had to rename eslint.json
to .eslintrc.json
which is one of the default ESLint config file names now.
按照需要运行配置的迁移过程,我们现在必须重命名eslint.json
为.eslintrc.json
默认的 ESLint 配置文件名之一。
We've also removed the config
grunt-eslint option.
我们还删除了config
grunt-eslint 选项。
回答by lord5et
Webpack
网络包
I had eslint.rc file in my root project directory but event though
I was getting error.
Solution was to add exclude property to "eslint-loader" rule config:
我的根项目目录中有 eslint.rc 文件,但尽管出现错误,但还是发生了事件。
解决方案是将 exclude 属性添加到“eslint-loader”规则配置中:
module.exports = {
// ...
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
// eslint options (if necessary)
}
},
],
},
// ...
}
回答by Shiva
I've had the same error. It seems to need configuration.
我有同样的错误。好像需要配置。
Go to your project root & run in terminal
转到您的项目根目录并在终端中运行
./node_modules/.bin/eslint --init
回答by Mantu Nigam
Just follow the steps
1.create eslint config file name eslintrc.json
2.place the code as given below
只需按照步骤
1.create eslint config file name eslintrc.json
2.place 代码如下
gulp.src(jsFiles)
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint({configFile: 'eslintrc.json'}))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
回答by Jonas_Hess
We faced this problem today and realized, that the issue was not caused inside the project that we were working on, but inside a package that we had a link on using the command:
我们今天遇到了这个问题,并意识到问题不是在我们正在处理的项目内部引起的,而是在我们有使用命令的链接的包内部引起的:
yarn link
Which is a feature often useful to test out new features or when trying to debug an issue in a package that manifests itself in another project. We solved it by either removing the link, or in case of ember.js disabling the developer mode of our addon package.
这是一项通常用于测试新功能或尝试调试在另一个项目中表现出来的包中的问题时有用的功能。我们通过删除链接或在 ember.js 禁用我们插件包的开发人员模式的情况下解决了这个问题。
index.js
索引.js
module.exports = {
isDevelopingAddon: function() {
return false;
},
...
}
回答by Serhat Türkman
Create a new file on the root directory called .eslintrc.json file:
在根目录创建一个名为 .eslintrc.json 文件的新文件:
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": "error"
}
}
回答by premji012
Run the command ember init. When it asks for overwriting the existing file(s). Type n to skipping overwriting the file. Now it will automatically create required files like .eslintrc, etc.
运行命令ember init。当它要求覆盖现有文件时。键入 n 跳过覆盖文件。现在它将自动创建所需的文件,如 .eslintrc 等。
For me the same issue occurred when i copied my folder except dist, dist_production and node_modules folder to another system and tried running ember build.
对我来说,当我将除 dist、dist_production 和 node_modules 文件夹之外的文件夹复制到另一个系统并尝试运行ember build时,发生了同样的问题。