如何让我的项目默认使用全局.eslintrc文件?

时间:2016-09-01 15:08:59

标签: javascript reactjs atom-editor eslint

我使用原子文本编辑器。 以下是让我的linter使用React和ES6的步骤:

  • 安装atom-react软件包
  • 当我开始一个新项目时,我运行npm install --save eslint
  • 在我的项目文件夹中创建一个.eslintrc文件(这可以手动完成或运行命令eslint --init,这有助于使用我在命令行回答的一系列问题创建文件)

每次开始编写新项目时,我都不想创建.eslintrc。我想使用全局.eslintrc文件,我在以下时找到了该文件:

  • 转到Atom>首
  • 单击“打开配置文件夹”
  • 点击.atom>包裹> linter> .eslintrc

我怎样才能这样做,当我启动一个新文件并开始编码时,我已经获得了这个全局文件中定义的选项?

特别是,这是我在个别项目中使用的设置:

{
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "sourceType": "module"
  },
  "env": {
    "es6": true
  },
  "plugins": [
    "eslint-plugin-react"
  ]
}

我希望这是默认设置。

2 个答案:

答案 0 :(得分:2)

转到设置 - >包裹 - > linter-eslint设置。在该菜单上,查找.eslintrc Path选项。根据您的特殊偏好,您可以将~/.atom/packages/linter/.eslintrc放在该字段中。您的.eslintrc现在正在全球所有项目中使用。

答案 1 :(得分:1)

您可以使用配置级联来获得优势: http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy

impl<T, U> PartialEq<U> for List<T>
    where Vec<T>: PartialEq<U>
{
    fn eq(&self, other: &U) -> bool {
        self.memory.eq(other)
    }
}


来自eslint文档:

enter image description here