node.js - 为 .ejs 文件禁用 eslint

标签 node.js ejs eslint eslintrc eslintignore

我的项目中有一个模板文件,在运行 eslint 时我遇到了各种问题。其中一些是 -

error Parsing error: Unexpected token !

error Parsing error: Unexpected token <

为了克服这个问题,我尝试使用 eslint-plugin-ejs没有帮助。我也访问过下面的链接 -

Turning off eslint rule for a specific file

ESLint Parsing error: Unexpected token

Mysterious ESLint Parsing Error

还有很多,但还是没有运气。现在我只想将此文件从 eslint 中排除,但找不到方法。任何帮助将不胜感激。

最佳答案

作为documentation说。

您可以使用inline configuration /*eslint-disable*//*eslint-enable*/

<小时/>

enter image description here

<小时/>

@EDIT对于您在评论中所说的内容,有两种解决方案

1 您可以使用属性excludedFiles,我在文档中找到了一个示例:

enter image description here

<小时/>

2 您可以按照 here 中所述的特定方式处理 HTMLEJS 文件。

3 您还可以使用 .eslintignore 文件,如 Ignoring Files and Directories 中所述。

关于node.js - 为 .ejs 文件禁用 eslint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47575167/

相关文章:

angularjs - Socket.io - 向不同权限级别的用户广播的策略

javascript - Mongoose 和 Node 错误 : cannot read property 'forEach' of undefined

javascript - .js 文件出现 ESLint 错误

node.js - 顺序运行 npm 脚本时忽略错误

javascript - 传递刚刚创建的参数

javascript - 有没有办法在 find 方法中使用 OR ?

node.js - 全局变量导致 nodejs 索引文件崩溃

javascript - d3 使用 eslint 进行常规缩进

javascript - 从子文件夹运行 eslint 时无法解析相对模块路径

node.js - 如何在每次页面刷新时验证 session cookie 的完整性,应该如何处理?