Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work when the server library prints to standard output #2013

Closed
alecmev opened this issue Aug 7, 2022 · 5 comments
Closed

Doesn't work when the server library prints to standard output #2013

alecmev opened this issue Aug 7, 2022 · 5 comments

Comments

@alecmev
Copy link
Contributor

alecmev commented Aug 7, 2022

LSP-eslint doesn't highlight anything when used in a project with eslint-config-auto. I created a super minimal repro here.

npx eslint . produces correct output:

image

So does VSC:

image

But nothing in ST:

image

LSP logs:

:: --> LSP-eslint initialize(1): {'rootPath': '/path/to/lsp-eslint-config-auto-repro', 'clientInfo': {'version': '1.17.0', 'name': 'Sublime Text LSP'}, 'capabilities': {'workspace': {'semanticTokens': {'refreshSupport': True}, 'workspaceFolders': True, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'codeLens': {'refreshSupport': True}, 'symbol': {'tagSupport': {'valueSet': [1]}, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [12, 2, 14, 1, 3, 22, 17, 5, 6, 13, 4, 20, 19, 7, 11, 25, 15, 21, 26, 8, 24, 9, 16, 23, 10, 18]}}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'configuration': True, 'applyEdit': True, 'executeCommand': {}}, 'window': {'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'showDocument': {'support': True}, 'workDoneProgress': True}, 'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'version': '3.2.2', 'parser': 'Python-Markdown'}}, 'textDocument': {'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'formatting': {'dynamicRegistration': True}, 'synchronization': {'didSave': True, 'willSave': True, 'dynamicRegistration': True, 'willSaveWaitUntil': True}, 'codeAction': {'dataSupport': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.organizeImports']}}, 'dynamicRegistration': True, 'disabledSupport': True, 'resolveSupport': {'properties': ['edit']}}, 'documentHighlight': {'dynamicRegistration': True}, 'hover': {'contentFormat': ['markdown', 'plaintext'], 'dynamicRegistration': True}, 'signatureHelp': {'signatureInformation': {'activeParameterSupport': True, 'parameterInformation': {'labelOffsetSupport': True}, 'documentationFormat': ['markdown', 'plaintext']}, 'dynamicRegistration': True, 'contextSupport': True}, 'documentLink': {'tooltipSupport': True, 'dynamicRegistration': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'colorProvider': {'dynamicRegistration': True}, 'completion': {'completionItem': {'labelDetailsSupport': True, 'tagSupport': {'valueSet': [1]}, 'snippetSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'deprecatedSupport': True, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertTextModeSupport': {'valueSet': [2]}}, 'dynamicRegistration': True, 'insertTextMode': 2, 'completionItemKind': {'valueSet': [3, 11, 21, 17, 9, 20, 15, 12, 5, 19, 2, 6, 10, 8, 24, 25, 16, 7, 18, 14, 23, 4, 22, 1, 13]}}, 'rangeFormatting': {'dynamicRegistration': True}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'semanticTokens': {'tokenTypes': ['function', 'namespace', 'parameter', 'enumMember', 'class', 'struct', 'variable', 'decorator', 'modifier', 'string', 'comment', 'property', 'interface', 'operator', 'macro', 'typeParameter', 'type', 'keyword', 'event', 'number', 'method', 'regexp', 'enum'], 'requests': {'range': True, 'full': {'delta': True}}, 'formats': ['relative'], 'overlappingTokenSupport': False, 'augmentsSyntaxTokens': True, 'tokenModifiers': ['async', 'documentation', 'definition', 'modification', 'defaultLibrary', 'readonly', 'abstract', 'deprecated', 'static', 'declaration'], 'dynamicRegistration': True, 'multilineTokenSupport': True}, 'references': {'dynamicRegistration': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'documentSymbol': {'tagSupport': {'valueSet': [1]}, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [12, 2, 14, 1, 3, 22, 17, 5, 6, 13, 4, 20, 19, 7, 11, 25, 15, 21, 26, 8, 24, 9, 16, 23, 10, 18]}, 'hierarchicalDocumentSymbolSupport': True}, 'publishDiagnostics': {'dataSupport': True, 'relatedInformation': True, 'codeDescriptionSupport': True, 'versionSupport': True, 'tagSupport': {'valueSet': [2, 1]}}, 'codeLens': {'dynamicRegistration': True}}}, 'processId': 1386033, 'workspaceFolders': [{'name': 'lsp-eslint-config-auto-repro', 'uri': 'file:///path/to/lsp-eslint-config-auto-repro'}], 'initializationOptions': {}, 'rootUri': 'file:///path/to/lsp-eslint-config-auto-repro'}
:: <-  LSP-eslint window/logMessage: {'type': 3, 'message': 'ESLint server running in node v18.7.0'}
:: <<< LSP-eslint 1: {'capabilities': {'workspace': {'workspaceFolders': {'supported': True}}, 'executeCommandProvider': {'commands': ['eslint.applySingleFix', 'eslint.applySuggestion', 'eslint.applySameFixes', 'eslint.applyAllFixes', 'eslint.applyDisableLine', 'eslint.applyDisableFile', 'eslint.openRuleDoc']}, 'textDocumentSync': {'change': {'syncKind': 2}, 'didClose': {}, 'save': {'includeText': False}, 'didOpen': {}}, 'codeActionProvider': {'codeActionKinds': ['quickfix', 'source.fixAll.eslint']}}}
::  -> LSP-eslint initialized: {}
::  -> LSP-eslint workspace/didChangeConfiguration: {'settings': {'codeAction': {'showDocumentation': {'enable': True}, 'disableRuleComment': {'location': 'separateLine', 'enable': True}}, 'validate': ['javascript', 'javascriptreact'], 'run': 'onType', 'codeActionOnSave': {'mode': 'all', 'enable': True}, 'onIgnoredFiles': 'off', 'packageManager': 'npm', 'nodePath': None, 'rulesCustomizations': [], 'useESLintClass': False, 'options': {}, 'probe': ['javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'html', 'vue', 'markdown'], 'quiet': False, 'format': False}}
::  -> LSP-eslint textDocument/didOpen: {'textDocument': {'version': 0, 'languageId': 'typescript', 'text': 'var foo = 123\n', 'uri': 'file:///path/to/lsp-eslint-config-auto-repro/index.ts'}}
:: <-- LSP-eslint client/registerCapability(0): {'registrations': [{'id': '8626e8d7-ee70-492e-9b20-896295e97ed6', 'method': 'workspace/didChangeConfiguration', 'registerOptions': {}}]}
:: >>> LSP-eslint 0: None
:: <-- LSP-eslint client/registerCapability(1): {'registrations': [{'id': 'e7560c09-2812-47de-af69-eed606ed5492', 'method': 'workspace/didChangeWorkspaceFolders', 'registerOptions': {}}]}
:: >>> LSP-eslint 1: None
:: <-- LSP-eslint workspace/configuration(2): {'items': [{'section': '', 'scopeUri': 'file:///path/to/lsp-eslint-config-auto-repro/index.ts'}]}
:: >>> LSP-eslint 2: [{'codeAction': {'showDocumentation': {'enable': True}, 'disableRuleComment': {'location': 'separateLine', 'enable': True}}, 'validate': 'probe', 'run': 'onType', 'onIgnoredFiles': 'off', 'packageManager': 'npm', 'workspaceFolder': {'name': 'lsp-eslint-config-auto-repro', 'uri': 'file:///path/to/lsp-eslint-config-auto-repro'}, 'nodePath': None, 'rulesCustomizations': [], 'useESLintClass': False, 'options': {}, 'codeActionOnSave': {'mode': 'all', 'enable': True}, 'quiet': False, 'format': False}]

This is with the published version of the package. Updating the server to 2.2.6 didn't help. LSP-eslint does work for me on a project with a bunch of configs and plugins, e.g.:

"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.4.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.7.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-tsdoc": "^0.2.16",
"eslint-plugin-unicorn": "^43.0.2",

So this isn't a configuration issue.

How do I debug this? Thanks!

@alecmev
Copy link
Contributor Author

alecmev commented Aug 7, 2022

Troubleshooting copy-paste

Version

  • LSP: 1.17.0
  • Sublime Text: 4126

Server Test Run

  • exit code: 0
  • output

Server Configuration

  • command
[
  "${node_bin}", 
  "${server_path}", 
  "--stdio"
]
  • shell command
/usr/bin/node "/path/to/LSP-eslint/18.7.0/language-server/out/eslintServer.js" --stdio
  • selector
source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react | text.html.vue | text.html.basic
  • priority_selector
source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react | text.html.vue | text.html.basic
  • init_options
{}
  • settings
{
  "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"
  ]
}
  • env
{
  "PATH": "/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:"
}

Active view

  • File name
/path/to/lsp-eslint-config-auto-repro/index.ts
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", 
  "lsp_active": true, 
  "syntax": "Packages/JavaScript/TypeScript.sublime-syntax"
}
  • base scope
source.ts

Project / Workspace

  • folders
[
  "/path/to/lsp-eslint-config-auto-repro"
]
  • is project: False

LSP configuration

{
  "clients": {}, 
  "diagnostics_gutter_marker": "circle", 
  "inhibit_snippet_completions": true, 
  "log_debug": true, 
  "log_server": [
    "panel"
  ], 
  "show_diagnostics_panel_on_save": 0, 
  "show_view_status": false
}

@rchl rchl transferred this issue from sublimelsp/LSP-eslint Aug 7, 2022
@alecmev
Copy link
Contributor Author

alecmev commented Aug 7, 2022

I narrowed this down to the fact that eslint-config-auto uses console.log. I went through node_modules and commented out all logs, and it started to work. Trying to figure out what exactly goes wrong, compared to ESLint and VSC.

@rchl
Copy link
Member

rchl commented Aug 7, 2022

Transferred to LSP repo as that is something that would need to be fixed there.

Looks like the eslint-config-auto plugin prints some plain output to stdout that is not valid per LSP spec. Stuff like that normally goes into stderr so that it doesn't affect LSP communication.

Initial thoughts:

  • such content should not be included in stdout so in theory that is something that should be fixed in https://github.com/microsoft/vscode-eslint or maybe even eslint itself
  • vscode handles it fine. Looks like it ignores anything that can't be parsed as LSP messages.
  • Regardless if ST follows vscode, it could provide some more useful feedback in that case. Currently it just silently closes the server.

@alecmev alecmev changed the title Doesn't work with eslint-config-auto Doesn't work when the server library prints to standard output Aug 7, 2022
@alecmev
Copy link
Contributor Author

alecmev commented Aug 7, 2022

Looks like this is a duplicate of #1612, I'll move the discussion there!

@rchl
Copy link
Member

rchl commented Aug 7, 2022

Thanks for digging the original issue out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants