javascript - ESLint - 别名设置

标签 javascript eslint

所以我在我的 webpack 配置中使用了别名,并且我有关于 no-extraneous-dependencies 等的 eslint 警告

所以我安装了 eslint-plugin-importeslint-import-resolver-alias 并像这样配置了我的 .eslintrc 文件:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "env": {
    "browser": true,
    "es6": true,
    "node": true,
    "jest": true
  },
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "defaultParams": true
    }
  },
  "rules": {
    "react/jsx-filename-extension": 0,
    "react/sort-comp": 0,
    "linebreak-style": 0,
    "prefer-arrow-callback": 0,
    "consistent-return": 0,
    "func-names": 0,
  },
  "settings": {
    "import/resolver": {
      "alias": [
        // I have my actions folder in ./shared/actions
        ["Actions", "./shared/actions"]
      ]
    }
  }
}

我的 linter 无法使用此 settings 选项。我错过了什么?

最佳答案

问题必须出在你的相对路径上

"./shared/actions"

尝试将其更改为

"../shared/actions"

如果这不起作用,请尝试绝对路径并从那里开始。

基本上,根目录/当前工作目录,并不是你想的那个...

关于javascript - ESLint - 别名设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45857679/

相关文章:

javascript - Jquery类型错误无法读取未定义的属性 'length'

javascript - 我如何从下拉菜单中的数据库中获取数据

javascript - 如何在 Rails 应用程序上有效地限定 javascript set css 的范围?

javascript - .eslint 文件的说明

javascript - ESLint 与 Babel : plugin-proposal-class-properties not found declared in . eslintrc

javascript - 从多个 RGBA 值创建 WebGL 纹理

Javascript 验证表单问题

javascript - 为什么 typescript 中不推荐使用 "type"?

javascript - 从 JSCS 到 ESLint : missing rules

javascript - 在 ReactJS 箭头函数类属性上防止 ESLint "no-undef"