Steve
Steve

Reputation: 14922

ESLint configuration woes

I am trying to use an eslint workflow. I have installed Node via nvm and the nessary plugins globally:

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

And locally in my project:

"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"
},

And I have set up an .eslintrc.json file in my project root:

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

The Atom ESlint and standard-formatter plugins find and respect my config file, but it not the command line or the Sublime Linter. It does not read the config, so I get errors flagged:

enter image description here

Which make it obvious it's not reading the settings. What am I doing wrong here? As I said, it works in Atom but not command line or Sublime (which uses the command-line options).

Upvotes: 1

Views: 556

Answers (1)

IanVS
IanVS

Reputation: 3775

I'd recommend against using a global installation of ESLint. If you want to run it to lint the files in your project, you can use:

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

Or, better yet, create an npm script for the task. In your package.json, you can add:

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

Furthermore, it looks like you are using a config file that is not in your project root (~/.eslintrc.json is in your user root, not project root). ESLint will do its own config resolution, so you should not have to specify the path to the config file except in advanced cases.

Upvotes: 1

Related Questions