brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

ESLint not working #14517

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by mhorne89 Tuesday Aug 06, 2019 at 16:31 GMT Originally opened as https://github.com/adobe/brackets/issues/14844


Prerequisites

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

core-ai-bot commented 3 years ago

Comment by thatcomputerguy0101 Sunday Sep 15, 2019 at 11:37 GMT


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.

core-ai-bot commented 3 years ago

Comment by JoshuaCWebDeveloper Sunday Feb 02, 2020 at 22:55 GMT


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
core-ai-bot commented 3 years ago

Comment by naslevente Monday Jun 01, 2020 at 18:36 GMT


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.

core-ai-bot commented 3 years ago

Comment by Savacken Monday Jun 08, 2020 at 20:38 GMT


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:

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.

core-ai-bot commented 3 years ago

Comment by JoshuaCWebDeveloper Friday Jun 12, 2020 at 21:26 GMT


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.