ESLint linting node_modules [英] ESLint linting node_modules

查看:113
本文介绍了ESLint linting node_modules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试谷歌搜索上的所有结果作为可能的解决方案,但到目前为止没有任何运气.

I have been trying all results on google search as a possible solution but without any luck so far.

每当我在我的 vue 项目(使用 vue cli 创建)上运行 npm run vue-cli-service serve --port 1024 时,我都会收到来自 node_modules

Whenever I run npm run vue-cli-service serve --port 1024 on my vue project (created using vue cli) I get errors from 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

All errors looks like it is coming simplely from one folder: ts-toolbelt. The final result can be seen here: 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,
    },
  },
};

感谢您抽出时间提供帮助

Thank you for anyone taking the time to help

推荐答案

.eslintrc.js中使用ignorePatterns:

module.exports = {
  // ...
  ignorePatterns: ["**/node_modules/**"] // THIS WORKS!
};

这篇关于ESLint linting node_modules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆