vam*_*olu 9 javascript watch node.js eslint package.json
我正在尝试使用以下方法在文件更改时使用 eslint 对我的文件进行 lint 处理npm scripts:
"scripts": {
"lint": "eslint ./* lib",
"lint:watch":"watch 'npm run lint' .",
"test": "echo \"Error: no test specified\" && exit 1"
}
Run Code Online (Sandbox Code Playgroud)
我使用watch包来完成此任务。
我发现监视任务无限循环运行。eslint 是否写入应用程序根目录中的文件。如果是这样,我怎样才能教 watch 忽略eslint.
我的.eslintrc,如果有必要的话:
{
"parser":"babel-eslint",
"extends":"eslint:recommended",
"rules":{
"strict":2,
"no-var":2,
"prefer-template":2,
"prefer-arrow-callback":1,
"prefer-rest-params":2,
"prefer-spread":2,
"object-shorthand":1,
"no-duplicate-imports":2,
"no-confusing-arrow":2,
"comma-dangle":0
}
}
Run Code Online (Sandbox Code Playgroud)
.eslintignore您可以通过在项目\xe2\x80\x99s 根目录中创建一个文件来告诉 ESLint 忽略特定文件和目录。看起来像这样:
它是纯文本,只需将.eslintignore文件添加到您的项目中并写入您不希望“观看”的文件
以下将忽略所有 JS 文件:
\n\n**/*.js\nRun Code Online (Sandbox Code Playgroud)\n\n您可以指定或使用如上所述的全局模式来忽略某种类型的所有文件。
\n\n\n| 归档时间: |
|
| 查看次数: |
12379 次 |
| 最近记录: |