Unable to get eslint working in Atom Editor

3.3k views Asked by At

I'm totally lost at this point on how to get ESLint to install and function using Atom. So I'm going to post a step by step and would be really awesome if someone could help be get this working.

  • Atom: 1.19.5
  • Atom, linter 2.2.0
  • Atom, linter-eslint 8.2.1

I've uninstalled and reinstalled the Atom plugins and have disabled all other plugins besides those in Core and the 2 linters.

  • npm list -g --depth=0

All Global Installs:

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

These are the attempted steps I've done to get eslint to work in my Atom project:

  • npm install -g eslint
  • cd /into/project
  • eslint --init
  • ? How would you like to configure ESLint? > User a popular style guide
  • ? Which style guide do you want to follow? >Airbnb
  • ? Do you use React? > y
  • ? What format do you want your config file to be in? > JSON
  • Delete /node_modules
  • npm install

    /project /node_modules .eslintrc.json index.js package.json

.eslintrc.json

{
  "extends": "airbnb"
}

package.json

{
  "name": "lint-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "eslint": "^4.6.1",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-config-rallycoding": "^3.2.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.3.0"
  }
}

index.js

This is just a file trying to get some type of results from eslint

Errors

[Linter] Error running ESLint (Open developer console)

Configuration for rule "jsx-a11y/anchor-has-content" is invalid: Value "[object Object]" no (or more than one) schemas match.

No errors are appearing in the Atom developer console. But also nothing is happening with the Linter in the Atom editor. I can type gibberish and nothing happens.

Running Debug

  • DEBUG=eslint:* eslint .

Debug results:

Cannot find module 'eslint-config-airbnb'
Referenced from: /Users/user/development/lint-test/.eslintrc.json
Error: Cannot find module 'eslint-config-airbnb'
Referenced from: /Users/user/development/lint-test/.eslintrc.json
at ModuleResolver.resolve (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/util/module-resolver.js:74:19)
at resolve (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:515:25)
at load (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:584:26)
at configExtends.reduceRight.e (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:421:36)
at Array.reduceRight (native)
at applyExtends (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:403:28)
at loadFromDisk (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:556:22)
at Object.load (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:592:20)
at Config.getLocalConfigHierarchy (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config.js:226:44)
at Config.getConfigHierarchy (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config.js:180:43)

At this point I'm assuming it's trying to read from the global not local

Now again nothing is happening, run debug again

  • DEBUG=eslint:* eslint .

Still can't find the module

At this point I'm still running into Cannot find module 'eslint-config-airbnb'

New local package.json

"devDependencies": {
  "eslint": "^4.6.1",
  "eslint-config-airbnb": "^15.1.0",
  "eslint-plugin-import": "^2.7.0",
  "eslint-plugin-jsx-a11y": "^5.1.1",
  "eslint-plugin-react": "^7.3.0"
}
  • npm install -g eslint-config-airbnb

New Global Modules

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── UNMET PEER DEPENDENCY [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

So now I can run DEBUG=eslint:* eslint . and can get some results. However nothing ever runs in Atom.

Results:

/Users/user/development/lint-test/index.js
  1:1   error  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash
  1:7   error  'config' is assigned a value but never used                no-unused-vars
  1:24  error  Unable to resolve path to module '../something'            import/no-unresolved
  1:39  error  Missing semicolon                                          semi

✖ 4 problems (4 errors, 0 warnings)
  1 error, 0 warnings potentially fixable with the `--fix` option.

At this point I'm out of ideas on how to get Atom to actually work with eslint...

2

There are 2 answers

0
wsfuller On BEST ANSWER

Without digging into the issue and finding specific point of failure I decided on a fresh start.

  • Delete global node modules.
  • Delete all NON core Atom plugins AND themes.
  • uninstall Atom.
  • reinstall Atom.
  • install ESLint and supporting dependencies only.

Doing that I was able to run ESLint with no issues. My assumption in all of this is there was a conflict in a plugin or theme. From there installing my core tool plugins was successful.

0
朱阳星 On

uncheck the setting "Use global ESLint installation" in linter-eslint of ATOM will make it correct