sublimelsp / LSP-eslint

ESLint support for Sublime LSP plugin
MIT License
36 stars 5 forks source link

LSP-eslint silently not runing at a react project #52

Closed zisiszikos closed 2 years ago

zisiszikos commented 2 years ago

LSP-eslint seems to be correctly installed and works fine for a node.js project, but it doesn't work for a react project. Nothing is written at the sublime console and the language server status at sublime status bar is not showing at this project.

I use the 16.4.0 node.js version and the following eslint configuration:

  "parser": "@babel/eslint-parser",
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:jest/recommended",
    "plugin:react-hooks/recommended",
    "plugin:prettier/recommended"
  ],
  "plugins": ["react", "jest"],
  "rules": {
    "no-console": 0,
    "jest/no-done-callback": 0
  },
  "parserOptions": {
    "sourceType": "module"
  },
  "globals": {
    "jsdom": true,
    "Promise": true,
    "shallow": true,
    "mount": true,
    "render": true
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jest/globals": true
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

I also use eslint version 7.22.0 at package.json.

Is there something else that might prevent the service from running?

rchl commented 2 years ago

Open a file where you'd expect LSP-eslint to run and run LSP: Troubleshoot Server from the Command Palette.

You can paste the output here (optionally censor any private information before).

rwols commented 2 years ago

What syntax are you using and what is the base scope of that syntax?

zisiszikos commented 2 years ago

The problem doesn't seem to has something to do with the selected syntax, because whetever syntax I use -Javascript (Babel), JSX or Javascript- it works fine at the node.js project but it doesn't work at the react project.

And this is the Troubleshoot output:

Troubleshooting: LSP-eslint

Version

## Server Configuration
 - command
```json
[
  "${node_bin}", 
  "${server_path}", 
  "--stdio"
]

Active view

Project / Workspace

LSP configuration

{
  "lsp_code_actions_on_save": {}, 
  "show_diagnostics_count_in_view_status": true, 
  "show_diagnostics_panel_on_save": 0
}

System PATH

rchl commented 2 years ago

According to this output, the LSP-eslint should show in the status bar. You said it doesn't.

There is an issue with using *.js extension though if that's an react file because js file will report a javascript langauge ID to the server while you want javascriptreact if it's a react file. So you should name the file jsx.

But if you really don't see LSP-eslint in the status bar then run LSP: Toggle Log Panel from the command palette and provide its output. It's possible that eslint server is crashing in your project for whatever reason.

zisiszikos commented 2 years ago

Thank you all for your feedback.

The react project contains react files with both js and jsx extensions and native javascript files. LSP-eslint is not working at neither of them. I checked all possible extensions with all possible syntaxes with no luck. The weird thing is that LSP-eslint string is showing as the status bar at the beggining for 5 to 10 seconds and then disappears.

LSP: Toggle Log Panel has this output (LSP-typescript is also used at both react and nodejs projects and works fine at both of them):

LSP-typescript: [lspserver] Using Typescript version (bundled) 4.5.4 from path "/Users/zisiszikos/Library/Caches/Sublime Text/Package Storage/LSP-typescript/16.4.0/typescript-language-server/node_modules/typescript/lib/tsserver.js"
LSP-eslint: ESLint server running in node v16.4.0
LSP-eslint: ESLint library loaded from: /Users/zisiszikos/Projects/trigonon/ui-core/node_modules/eslint/lib/api.js

I wonder if there is some how a conflict between the nodejs version used by the lib (16.4.0 here), and the version that node_modules are installed at the react project (10.15.3).

rchl commented 2 years ago

If you can reproduce in vscode then you could report it at https://github.com/microsoft/vscode-eslint.

Different node versions should not be an issue as long as eslint server runs in a recent enough version.

You could try enabling more verbose logging (https://lsp.sublimetext.io/troubleshooting/#self-help-instructions) and check whether the LSP-eslint server says something relevant before it shuts itself down.

rchl commented 2 years ago

Closing due to no response. We'll look into it more if you provide the requested information.