Brackets: ESLint not working

Created on 6 Aug 2019  路  5Comments  路  Source: adobe/brackets

Prerequisites

  • [x] Can you reproduce the problem with Debug -> Reload Without Extensions?
  • [x] Did you perform a cursory search to see if your bug or enhancement is already reported?
  • [x] Did you read the Troubleshooting guide?

For more information on how to write a good bug report read here
For more information on how to contribute read here

Description

I have set up a .eslintrc.json file in my projects root directory. The ESlinter reports an error "ESLint error: You need to install ESLint in your project folder with 'npm install eslint'". The problem is I have run this, I also have it installed as a dev dependancy and installed globally. I have restarted the editor a few times and it is not working. Am I doing something wrong?

Expected behavior: Linter to work

Actual behavior: Linter asks me to install ESLint

Versions

MacOS Mojave 10.14.5
Brackets Release 1.14 build 1.14.0-17740
ESLint v6.1.0

Most helpful comment

I'm having the same issue:
Windows 7
Brackets Release 1.14 build 1.14.1-17752
ESLint v6.8.0

I have tried:
Installing eslint locally (in my current project folder -- npm install eslint)
Installing eslint globally (npm install -g eslint)
Setting "brackets-eslint.useLocalESLint": true
Setting "brackets-eslint.useLocalESLint": false

None of the above work. I can run ESLint outside of Brackets just fine:

$ node_modules/eslint/bin/eslint.js --version
v6.8.0

$ node_modules/.bin/eslint --version
v6.8.0

$ eslint --version
v6.8.0

All 5 comments

To configure ESLint with an external configuration file, you either need to use npm to install ESLint into your current directory or add "brackets-eslint.useLocalESLint": true to your preferences file. For more details (and in the future), you can check out already existing issues with similar problems, like #13720, and see if some of the more recent posts solve your question.

I'm having the same issue:
Windows 7
Brackets Release 1.14 build 1.14.1-17752
ESLint v6.8.0

I have tried:
Installing eslint locally (in my current project folder -- npm install eslint)
Installing eslint globally (npm install -g eslint)
Setting "brackets-eslint.useLocalESLint": true
Setting "brackets-eslint.useLocalESLint": false

None of the above work. I can run ESLint outside of Brackets just fine:

$ node_modules/eslint/bin/eslint.js --version
v6.8.0

$ node_modules/.bin/eslint --version
v6.8.0

$ eslint --version
v6.8.0

You have to make that ESlint is installed locally and that brackets-eslint.useLocalESlint is set to true in your brackets.json. You also have to disable the default brackets-eslint from the extension manager if you're using brackets. That worked for me.

I am also having this problem. I have an .eslintrc.json file present and ESLint has been working just fine until I updated my project's ESLint to v6.8.0, then Brackets began reporting that ESLint needed to be installed. I checked my brackets.json file and changed brackets-eslint.useLocalESLint from false to true and that didn't make any noticeable change in behavior. I then tried disabling the default ESLint plugin, but then all linting stopped.

So I've tried;
ESLint plugin enabled & brackets-eslint.useLocalESLint: false
ESLint plugin disabled & brackets-eslint.useLocalESLint: false
ESLint plugin enabled & brackets-eslint.useLocalESLint: true
ESLint plugin disabled & brackets-eslint.useLocalESLint: true

And the only change in behavior I've noticed is that disabling the plugin stops all linting, enabling it reports eslint needs to be installed. No noticeable difference changing the preference to true or false.

Here are some more details:

  • Brackets v1.14.2
  • ESlint v4.19.1 and Brackets were working together fine
  • brackets-eslint.useLocalESLint: false (same as when previously working)
  • default ESLint plugin enabled (same as when previously working)
  • ESlint v6.8.0 installed in local package as a dev dependency (same as when previously working)
  • using .eslintrc.json at top of package (same as when previously working)
  • extending ESlint conf with eslint-config-airbnb-base (same as when previously working)
  • ESLint works fine from the command line

I've done some more troubleshooting and found that the default brackets-eslint plugin is for some reason failing to load / reference eslint in its getCli method. More specifically when it tries to require eslint it throws this error in the console;
[node-error 3:45:09 PM] [brackets-eslint] Wasn't able to load eslint from /proj/node_modules/eslint/lib/api.js, be sure to run 'npm install' properly: /proj/node_modules/eslint/lib/cli-engine/cli-engine.js:256
But ESLint has been installed using 'npm install'. So I tried getting a better idea of what exactly was happening when it tried requiring eslint.

It tries to require a variable named eslintPath which evaluates to "/proj/node_modules/eslint" so I fired up node and executed var linter = require('/proj/node_modules/eslint'); and it returned an object that looks like this;

{
  Linter: [Function: Linter],
  CLIEngine: [Function: CLIEngine] {
    version: '6.8.0',
    getFormatter: [Function: getFormatter]
  },
  RuleTester: [Function: RuleTester] {
    [Symbol(it)]: null,
    [Symbol(describe)]: null
  },
  SourceCode: [Function: SourceCode]
}

So a couple things I notice here;

  1. node does not throw an error when trying to require eslint same as Brackets does, and
  2. it appears to be loading my project's eslint just fine

I think that's about as far as I know how to take it.

Thanks to @Savacken, I can confirm that ESLint 5.16.0 works with Brackets; however, the above described error happens with both ESLint 6.8.0 and 7.2.0.

For now, it looks like downgrading ESLint to 5.x is a workaround assuming you don't need any recent functionality introduced in the past two major versions (I don't believe I do).

Brackets should, of course, support ESLint 6.x, 7.x, and any future releases of ESLint.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AgamlaRage picture AgamlaRage  路  4Comments

TheHedge picture TheHedge  路  3Comments

declanmarks picture declanmarks  路  3Comments

brendonmm picture brendonmm  路  4Comments

macjabeth picture macjabeth  路  3Comments