2016-04-15 58 views
1

我正在尝试使用eslint工作流程。我已经安装了通过NVM节点和全球的nessary插件:ESLint配置困境

├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 

和地方在我的项目:

"devDependencies": { 
"eslint": "2.7.0", 
"eslint-config-angular": "0.5.0", 
"eslint-config-standard": "5.1.0", 
"eslint-config-semistandard": "6.0.1", 
"eslint-plugin-angular": "1.0.0", 
"eslint-plugin-promise": "1.1.0", 
"eslint-plugin-standard": "1.3.2" 
}, 

而且我已经建立了一个.eslintrc.json文件在我的项目的根:

{ 
"env": { 
    "browser": 1 
}, 
"extends": "semistandard", 
"plugins": [ 
    "standard","angular" 
], 
"globals": { 
    "angular": 1, 
    "$": 1, 
    "angularDragula": 1 
} 
} 

Atom ESlint和standard-formatter插件发现并尊重我的配置文件,但它不是命令行或Sublime Linter。它不读取配置,所以我得到标记错误:

enter image description here

,这使得它很明显它不是读书的设置。我在这里做错了什么?正如我所说的,它在Atom中工作,但不是命令行或Sublime(它使用命令行选项)。

+0

你需要告诉它在哪里可以找到配置吗?它是否假定本地/项目目录或假定用户全局配置? –

+0

我试过了两个,就像'eslint -c〜/ .eslintrc.json feedback-alerts.controller.js' – Steve

+0

我对eslint并不熟悉,但那些错误怎么表明它不读你的配置?如果你删除你的配置文件并运行cli或者用'-c'使用空配置文件,你会得到什么? –

回答

1

我建议不要使用ESLint的全局安装。如果你想运行它皮棉在你的项目中的文件,你可以使用:

node_modules/.bin/eslint feedback-alerts.controller.js 

或者,更好的是,创建任务的npm script。在你package.json,您可以添加:

"scripts": { 
    "lint": "eslint feedback-alerts.controller.js" 
} 

此外,它看起来像您使用的配置文件,是不是在你的项目根(~/.eslintrc.json是在你的root用户,而不是项目的根目录)。 ESLint将执行自己的配置分辨率,因此除了高级情况外,您不必指定配置文件的路径。