对于 node.js 项目,我添加了 eslint-plugin-security 并且它在我的测试/规范文件(使用 mochajs)中为代码提供了很多警告。由于测试代码不会在生产环境中运行,这些看起来不像在项目的实际代码中那样有用。(很多通用对象注入接收器警告)
除了放在/* eslint-disable */每个规范文件的顶部之外,有没有办法让安全插件忽略某些文件?
我正在尝试在 Next.js 项目中实现 eslint,但我不想next.config.js被 lint。我尝试添加ignorePatterns到.eslintrc.json,添加.eslintignore文件并添加eslintIgnore属性到我的package.json,它们似乎都有相同的错误行为。
当只留下目录路径时,它会按预期工作:
// .eslintrc.json
{
"env": {
"browser": true
},
"extends": ["airbnb", "plugin:@typescript-eslint/recommended"],
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["graphql/generated/", "third-party/"],
"rules": { /* ... */ },
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {}
},
"polyfills": ["fetch"]
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
/Users/mac-user/development/my-project/next.config.js
1:18 error Require statement not part of import statement @typescript-eslint/no-var-requires
2:17 error Require statement not part …Run Code Online (Sandbox Code Playgroud) 我的项目中有一个模板文件,在运行 eslint 时我面临着各种问题。其中一些是 -
error Parsing error: Unexpected token !
error Parsing error: Unexpected token <
为了克服这个问题,我尝试在没有帮助的情况下使用eslint-plugin-ejs。我也访问过下面的链接 -
还有更多,但再次没有运气。现在我只想将此文件从 eslint 中排除,但找不到方法。任何帮助将不胜感激。
假设我要使用以下规则:
https://eslint.org/docs/rules/no-debugger
但是,我有大约15个文件要保留调试器。陈述。
我可以在.ts / .js文件的顶部添加一些内容,以使ESLint忽略no-debugger此特定文件的规则吗?
我一直在尝试谷歌搜索上的所有结果作为可能的解决方案,但到目前为止没有任何运气。
每当我运行npm run vue-cli-service serve --port 1024我的 vue 项目(使用 vue cli 创建)时,我都会收到错误node_modules
4111:10 Type alias 'MergeList' circularly references itself.
4109 | @hidden
4110 | */
> 4111 | type MergeList<O, Path extends List<Key>, O1 extends object, depth extends Depth, I extends Iteration = IterationOf<'0'>> = O extends object ? O extends (infer A)[] ? MergeList<A, Path, O1, depth, I>[] : Pos<I> extends Length<Path> ? OMerge<O, O1, depth> : {
| ^
4112 | [K in keyof O]: …Run Code Online (Sandbox Code Playgroud)