sublimelsp / lsp-eslint Goto Github PK
View Code? Open in Web Editor NEWESLint support for Sublime LSP plugin
License: MIT License
ESLint support for Sublime LSP plugin
License: MIT License
C:\Users\***\AppData\Local\Sublime Text 3\Package Storage\LSP-eslint\12.14.1\language-server\out\eslintServer.js:242
return ruleId2Meta.get(ruleId)?.docs?.url;
^
SyntaxError: Unexpected token '.'
at Module._compile (internal/modules/cjs/loader.js:891:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
[
"${node_bin}",
"${server_path}",
"--stdio"
]
"C:\Program Files\nodejs\node.EXE" "C:\Users\***\AppData\Local\Sublime Text 3\Package Storage\LSP-eslint\12.14.1\language-server\out\eslintServer.js" --stdio
(source.jsx | source.js.jsx | source.js.react)|(source.js)|(source.tsx | source.ts.react)|(source.ts)|(text.html.vue)|(text.html.basic)
(source.javascriptreact)|(source.javascript)|(source.typescriptreact)|(source.typescript)|(source.vue)|(source.html)
{}
{
"codeAction": {
"disableRuleComment": {
"enable": true,
"location": "separateLine"
},
"showDocumentation": {
"enable": true
}
},
"codeActionOnSave": {
"enable": true,
"mode": "all"
},
"format": false,
"nodePath": null,
"onIgnoredFiles": "off",
"options": {},
"packageManager": "npm",
"probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown"
],
"quiet": false,
"rulesCustomizations": [],
"run": "onType",
"useESLintClass": false,
"validate": [
"javascript",
"javascriptreact"
]
}
{
"PATH": "C:\\Program Files\\nodejs;C:\\Program Files\\nodejs;"
}
C:\Users\***\Experimental\IniToJson\index.js
{
"auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
"lsp_active": null,
"syntax": "Packages/JavaScript/JavaScript.sublime-syntax"
}
source.js
[
"C:\\Users\\***\\Experimental\\IniToJson"
]
Hi,
after installing, I get the following error in the console:
lsp-eslint: ESLint server running in node v12.14.0
lsp-eslint: Registering request handler for workspace/didChangeConfiguration failed.
lsp-eslint: (node:74725) UnhandledPromiseRejectionWarning: Error: client/registerCapability
lsp-eslint: Registering request handler for workspace/didChangeWorkspaceFolders failed.
lsp-eslint: at handleResponse (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:447:48)
lsp-eslint: at processMessageQueue (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:274:17)
lsp-eslint: at Immediate.<anonymous> (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:258:13)
lsp-eslint: at processImmediate (internal/timers.js:439:21)
lsp-eslint: (node:74725) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
lsp-eslint: (node:74725) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lsp-eslint: (node:74725) UnhandledPromiseRejectionWarning: Error: client/registerCapability
lsp-eslint: at handleResponse (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:447:48)
lsp-eslint: at processMessageQueue (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:274:17)
lsp-eslint: at Immediate.<anonymous> (/Users/karolyi/Library/Application Support/Sublime Text 3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:258:13)
lsp-eslint: at processImmediate (internal/timers.js:439:21)
lsp-eslint: (node:74725) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
and then eslint is not working. Please investigate.
Hello, I'm trying to use this plugin in a project that I recently started working on and I follow every possible instruction but I don't seem to be able to run the eslint --fix
option when saving a file; even when having the following setting in the LSP
:
"lsp_code_actions_on_save": {
"source.fixAll.eslint": true,
},
Any ideas? ๐ค ๐
When hovering over a diagnostic, eslint allows me to go to the documentation for that diagnostic (via a code action). It would be nice if that request from the server were handled and my browser jumps to that page.
LSP: <-- eslint/openDoc
LSP: {'url': 'https://eslint.org/docs/rules/no-unused-vars'}
LSP: Unhandled request eslint/openDoc
LSP: {}
I don't know what it is supposed to do:
:: <-- eslint eslint/noLibrary(3): {'source': {'uri': 'file:///home/raoul/.config/sublime-text-3/Packages/LSP-eslint/vscode-eslint/out/eslintServer.js'}}
:: ~~> eslint 3: {'code': -32601, 'message': 'eslint/noLibrary'}
It's a bit weird that the language ID is "eslint". Can we get away with having "javascript" and "vue" as separate language IDs?
ST3:
"languages":
[
{
"languageId": "javascript",
"scopes": ["source.js"],
"syntaxes":
[
"Packages/Babel/JavaScript (Babel).sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/User/JS Custom/Syntaxes/React.sublime-syntax"
]
},
{
"languageId": "vue",
"scopes": ["text.html.vue"],
"syntaxes": ["Packages/Vue Syntax Highlight/Vue Component.sublime-syntax"]
}
],
ST4:
"languages":
[
{
"languageId": "javascript",
"document_selector": "source.js"
},
{
"languageId": "vue",
"document_selector": "text.html.vue"
}
],
Hi, I was wondering which path should I take to have eslint equivalent for StandardJS
https://github.com/standard/vscode-standard.
Would you mind guiding me through it?
Hello,
I'm having hard time to make eslint work on HTML files.
What I have done:
eslint --init
on root project directoryeslint-plugin-html
...
" plugins": [
"html"
]
...
It works on Visual Studio Code, but I couldn't make it work on Sublime Text. Can anybody share how to properly enable linting HTML file?
Hi.
I am trying to set my subfolder's config file (nuxt/.eslintrc.js) and my nuxt subdirectory as the root when my Sublime project is set one level higher.
/
/project.sublime-project
/nuxt
/nuxt/.eslintrc.cjs
My sublime project file contains this :
{
"folders":
[
{
"path": "."
}
],
"settings": {
"LSP": {
"LSP-eslint": {
"settings": {
"workingDirectories": [
{
"!cwd": true,
"directory": "./nuxt"
}
]
}
}
}
}
}
The eslint config seems to be loaded with my rules, but the aliases aren't working because LSP-eslint considers itself working from the root directory. For example, import whatever from "~/something/wow.js"
reports an error, but import whatever from "~/nuxt/something/wow.js"
removes the error. Another trick I'm doing right now is to open a new sublime window in nuxt subdirectory directly and everything works file, so LSP-eslint seems to really need to work at the root directory only and seems to ignore settings that tell it otherwise.
Here's my .eslintrc.cjs config file in case it contains something that could give a clue.
const twConfig = require('./tailwind.config.cjs');
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['airbnb-base', 'plugin:vue/vue3-recommended', 'plugin:tailwindcss/recommended'],
parserOptions: {
ecmaVersion: 2022,
},
plugins: ['vue', 'tailwindcss'],
rules: {
indent: ['error', 4],
'import/extensions': 'off',
'import/no-extraneous-dependencies': [0, { 'packageDir ': './' }],
'max-len': [
'error',
{
code: 160,
ignorePattern: 'class="([\\s\\S]*?)"|d="([\\s\\S]*?)"', // ignore classes or svg draw attributes
ignoreUrls: true,
},
],
'vue/multi-word-component-names': 'off',
'vue/script-indent': [
'error',
4,
{
baseIndent: 0,
switchCase: 0,
},
],
'vue/html-indent': [
'error',
4,
{
attribute: 1,
baseIndent: 1,
closeBracket: 0,
alignAttributesVertically: true,
},
],
'vue/max-attributes-per-line': [
'error',
{
singleline: {
max: 2,
},
multiline: {
max: 1,
},
},
],
'vue/v-on-style': ['error', 'longform'],
'tailwindcss/no-custom-classname': [0],
'tailwindcss/classnames-order': [1, { config: twConfig }],
'no-plusplus': 0,
'vue/no-v-html': 0,
'no-unused-vars': 'warn',
'no-debugger': 'warn',
'no-console': 'warn',
'no-underscore-dangle': 0,
'no-undef': 0,
'import/prefer-default-export': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.svg', '.css'],
moduleDirectory: ['node_modules', './'],
},
alias: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.svg', '.css'],
map: [['~', './']],
},
typescript: {},
},
},
overrides: [
{
files: ['*.vue'],
parser: 'vue-eslint-parser',
rules: {
indent: 'off',
},
},
],
};
Upstream documents a eslint.rules.customizations
setting that looks like it should be able to ignore certain codes (albeit this exact behavior is not explicitly mentioned). This settings is not mentioned in LSP-eslint's settings, but I tried using it as follows regardless:
{
"settings": {
"rules.customizations": [
{ "rule": "no-trailing-spaces", "severity": "off" },
{ "rule": "eol-last", "severity": "off" },
],
},
}
Unfortunately, that didn't seem to have any effect. I also tried with eslint.rules.customizations
and adding this to the global LSP settings file but that didn't make a difference either. (I also tried with a "downgrade" value to see whether it's just the "off" value that isn't supported.)
Is there a way currently for me to achieve what I want or does this need to be explcitly supported by the LSP plugin?
When quick-switching projects, I get this unhandled notification from eslint:
:: <? lsp-eslint eslint/exitCalled: [0, 'Error: stack\n at process.exit (/home/raoul/.config/sublime-text-3/Cache/LSP-eslint/vscode-eslint/out/eslintServer.js:190:17)\n at /home/raoul/.config/sublime-text-3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-languageserver/lib/main.js:1021:25\n at handleNotification (/home/raoul/.config/sublime-text-3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:494:43)\n at processMessageQueue (/home/raoul/.config/sublime-text-3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:271:17)\n at Immediate._onImmediate (/home/raoul/.config/sublime-text-3/Cache/LSP-eslint/vscode-eslint/node_modules/vscode-jsonrpc/lib/main.js:258:13)\n at processImmediate (internal/timers.js:439:21)']
Node.js version requirement failed. Expected minimum: 14.0.0, got 12.20.1.
[
"${node_bin}",
"${server_path}",
"--stdio"
]
source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react | text.html.vue | text.html.basic
source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react | text.html.vue | text.html.basic
{}
{
"codeAction": {
"disableRuleComment": {
"enable": true,
"location": "separateLine"
},
"showDocumentation": {
"enable": true
}
},
"codeActionOnSave": {
"enable": true,
"mode": "all"
},
"format": false,
"nodePath": null,
"onIgnoredFiles": "off",
"options": {},
"packageManager": "npm",
"probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown"
],
"quiet": false,
"rulesCustomizations": [],
"run": "onType",
"useESLintClass": false,
"validate": [
"javascript",
"javascriptreact"
]
}
{}
/path/to/file
{
"auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
"lsp_active": true,
"syntax": "Packages/Babel/JavaScript (Babel).sublime-syntax"
}
source.js
[
"/path/to/folder"
]
I cannot upgrade to v14 yet, because of dependencies in some of my projects. Hence am not able to use this LSP server, although I'd like to. Is there any particular reason that the minimum required version is so high?
Hi โ great work on this plugin!
Try as I might I can't seem to get this to work properly with .jsx files though, is this supported out of the box? I do see LSP-eslint mentioned in the status bar when opening a .jsx file, and if I introduce an error it updates the count so it seems it does load properly, but it doesn't show any underlines or gutter dots and auto fixing doesn't work specifically for files saved with the .jsx extension. If I rename the same file to .js it works just fine however.
I've looked through the default configuration to see if there's anything there to help, but I can't figure this out โ could you point me in the right direction?
I'm trying to run eslint.
I'm auto-installing the server. But after restarting ST it crashes immediately. These are my logs:
:: --> lsp-eslint initialize(1): {'clientInfo': {'name': 'Sublime Text LSP'}, 'initializationOptions': {}, 'processId': 19826, 'rootUri': 'file:///home/raoul/dev/temp/nuxt-i18n', 'capabilities': {'workspace': {'symbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'applyEdit': True, 'configuration': True, 'executeCommand': {}, 'workspaceFolders': True, 'didChangeConfiguration': {}}, 'textDocument': {'hover': {'contentFormat': ['markdown', 'plaintext']}, 'formatting': {}, 'definition': {'linkSupport': True}, 'rename': {}, 'synchronization': {'didSave': True, 'willSaveWaitUntil': True, 'willSave': True}, 'references': {}, 'documentSymbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'completion': {'completionItem': {'snippetSupport': True}, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}, 'publishDiagnostics': {'relatedInformation': True}, 'colorProvider': {}, 'rangeFormatting': {}, 'signatureHelp': {'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}, 'documentationFormat': ['markdown', 'plaintext']}}, 'typeDefinition': {'linkSupport': True}, 'documentHighlight': {}, 'implementation': {'linkSupport': True}, 'codeAction': {'codeActionLiteralSupport': {'codeActionKind': {'valueSet': []}}}, 'declaration': {'linkSupport': True}}}, 'workspaceFolders': [{'uri': 'file:///home/raoul/dev/temp/nuxt-i18n', 'name': 'nuxt-i18n'}], 'rootPath': '/home/raoul/dev/temp/nuxt-i18n'}
lsp-eslint: throw err;
lsp-eslint: internal/modules/cjs/loader.js:800
lsp-eslint: throw err;
I should note that I'm installing eslint while a JS file is open. So LSP is trying to start the server but it is still installing. I'm not sure if this is related, but might be a clue.
For the moment, switching out node path to:
"command": [
"/opt/homebrew/bin/bun"
, "${server_path}", "--stdio"],
Throws an error due to Bun's welcome being message included in the initial payload:
--- Error: ---
Unexpected payload in server's stdout:
Bun: a fast JavaScript runtime, package manager, bundler and test runner. (1.0.3)
Adding --silent here doesn't help either:
"command": ["/opt/homebrew/bin/bun", "${server_path}", "--stdio",
"--silent"
],
Not sure if this is Bun not receiving or honoring --silent
or there actually isn't a way to turn it off and the message needs to be parsed out manually.
Getting this to work would be awesome, will get rid of a lot of mjs / cjs eslint-config incompatibility pains.
Some of the eslint rules use process.cwd()
, so not having configuration to change the working_dir is hard for the case having a sub-folder of the project in another workspace.
VSCode eslint extension has eslint.workingDirectories
configuration which can be use as cwd when starting the lang server.
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?
I did not find this through the package manager.
What to do?
vscode-eslint has a probe
setting:
"eslint.probe": {
"scope": "resource",
"type": "array",
"items": {
"type": "string"
},
"default": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown"
],
"description": "An array of language ids for which the extension should probe if support is installed."
},
validate
option is set to either on
, off
, or probe
validate
is set to probe
then the server will:
validate
to on
so eslint is unconditionally enabled for all files that match the list of our syntaxes/selectors.workspace/configuration
didOpen
hookeslint/probeFailed
message if probing has resulted with setting validate
to off
so that client can cache the resultHello,
LSP-eslint is reporting false positives when the file has CRLF; I have Prettier ESLint plugin and there is an error/suggestion to insert CR at the end of a line, even when it's not necessary (also, autofix on save messes up the file, inserting the unneeded CR). Here is repo where I can reproduce the issue: https://github.com/jakubmazanec/lsp-eslint-crlf-issue (it also contains a screenshot of the issue).
Can somebody help me investigate this? Thanks.
Describe the bug
LSP no longer recognizes some (but not all) ESLint rules and no longer shows the diagnostic panel upon saving despite these settings:
{
"log_debug": true,
"show_view_status": true,
"lsp_format_on_save": false,
"show_diagnostics_panel_on_save": 1,
"show_inlay_hints": true,
"lsp_code_actions_on_save": {
"source.fixAll": true,
"source.fixAll.eslint": true,
},
}
To Reproduce
Unknown
Expected behavior
LSP does not begin to silently fail. I'm not actually sure how many days this issue has occurred before I realized
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Another machine with an identical configuration continues to work and I cannot make it fail there.
Hello,
I use Volta to manage the Node environment. Is there a good way to support the Node installed via Volta?
This is a lang server issue but I'll post the issue here for bookkeeping.
eslint should check the text editor's capabilities to see if it supports dynamicRegistration. If it doesn't, then it should not do the client/registerCapability request.
Alternatively, eslint should handle errors returned from requests.
I'm not entirely sure what it's supposed to mean, but it'd be nice to catch it and print something informative in the status bar or the console.
LSP: <-- eslint/status
LSP: {'state': 1}
LSP: Unhandled notification eslint/status
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.