ESLint 代码检查 node_modules
ESLint linting node_modules
我一直在尝试 google 搜索的所有结果作为可能的解决方案,但到目前为止没有任何运气。
每当我 运行 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]: K extends Path[Pos<I>] ? MergeList<O[K], Path, O1, depth, Next<I>> : O[K];
4113 | } & {} : O;
4114 | /**
所有错误看起来都只是来自一个文件夹:ts-toolbelt
。最终结果可以在这里看到:pastebin
这是我的 .eslintrc
:
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'@vue/airbnb',
'@vue/typescript',
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
'import/no-cycle': 'off',
},
parserOptions: {
parser: '@typescript-eslint/parser',
exclude: [
"node_modules"
]
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
}
],
};
.eslintignore
node_modules/
public/
bin/
build/
vue.config.js
module.exports = {
transpileDependencies: [
'vuetify',
],
pwa: {
workboxOptions: {
skipWaiting: true,
},
},
};
感谢大家花时间提供帮助
我认为.eslintignore
应该是:
node_modules
public
bin
build
在.eslintrc.js
中使用ignorePatterns
:
module.exports = {
// ...
ignorePatterns: ["**/node_modules/**"] // THIS WORKS!
};
我一直在尝试 google 搜索的所有结果作为可能的解决方案,但到目前为止没有任何运气。
每当我 运行 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]: K extends Path[Pos<I>] ? MergeList<O[K], Path, O1, depth, Next<I>> : O[K];
4113 | } & {} : O;
4114 | /**
所有错误看起来都只是来自一个文件夹:ts-toolbelt
。最终结果可以在这里看到:pastebin
这是我的 .eslintrc
:
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'@vue/airbnb',
'@vue/typescript',
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
'import/no-cycle': 'off',
},
parserOptions: {
parser: '@typescript-eslint/parser',
exclude: [
"node_modules"
]
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
}
],
};
.eslintignore
node_modules/
public/
bin/
build/
vue.config.js
module.exports = {
transpileDependencies: [
'vuetify',
],
pwa: {
workboxOptions: {
skipWaiting: true,
},
},
};
感谢大家花时间提供帮助
我认为.eslintignore
应该是:
node_modules
public
bin
build
在.eslintrc.js
中使用ignorePatterns
:
module.exports = {
// ...
ignorePatterns: ["**/node_modules/**"] // THIS WORKS!
};