[英]eslint: ignore-pattern rule is not working
I have the following structure我有以下结构
myproject
src
indxe.js
In my package.json I have also:在我的 package.json 中,我还有:
"scripts": {
"build": "babel src -d dist --source-maps",
"serve": "node dist/index.js",
"start": "babel-node src/index.js",
"start:dev": "nodemon src/index.js --exec babel-node",
"test": "jest --runInBand --verbose",
"coverage": "jest --coverage --runInBand --verbose",
"eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""
},
but running但正在运行
yarn eslint
I get an error我得到一个错误
"eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""
$ eslint src/**/.js --ignore-pattern "node_modules/"
Oops! Something went wrong! :(
ESLint: 5.10.0.
No files matching the pattern "src/**/.js" were found.
Please check for typing mistakes in the pattern.
error Command failed with exit code 2.
I don't understand why as it should be OK...我不明白为什么应该没问题...
feedback welcome欢迎反馈
You specified the glob pattern incorrectly:您错误地指定了 glob 模式:
eslint src/**/.js
With this, you are specifying: “In any directory below src , find me any files with the exact name .js ”有了这个,你指定:“在src下的任何目录中,找到任何具有确切名称.js的文件”
What you actually want is: “In any directory below src , find me any files with the name ending in .js ”你真正想要的是:“在src下的任何目录中,找到任何名称以.js结尾的文件”
You can achieve this by adding another asterisk, which serves as placeholder for the beginning of each JS file name, like this:您可以通过添加另一个星号来实现此目的,该星号用作每个 JS 文件名开头的占位符,如下所示:
eslint src/**/*.js
You can find more information on how to use glob patterns here: https://github.com/isaacs/node-glob#readme您可以在此处找到有关如何使用 glob 模式的更多信息: https ://github.com/isaacs/node-glob#readme
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.