stylelint / vscode-stylelint

The official Visual Studio Code extension for Stylelint
https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
MIT License
315 stars 30 forks source link

[Bug]: Extention is not able to locate stylelint package #281

Closed Levdbas closed 2 years ago

Levdbas commented 3 years ago

How did you encounter this bug?

When running this extension I run into an error where stylelint cannot load. Running via CLI does lint the code. I am running on Windows/WSL1 where Code runs on the Windows side and I run Yarn on the WSL side. Files live on the windows filesystem which WSL mounts. Installing Stylelint globally with yarn global add stylelint gives the same result which I do understand since the extention is probably unaware of the global node_modules location in the WSL file structure. Version v0.87.6 still works flawlessly though, probably since the bundled version of styellint, but since there is not a output panel for stylelint in that older version I cannot further debug this.

Current situation:

Locations:

Windows: D:\laragon\www\website.local\node_modules\stylelint
WSL: /mnt/d/laragon/www/website.local/node_modules/stylelint

Code Snippet

No response

Extension Configuration

{
  "config": null,
  "configBasedir": "",
  "configFile": "",
  "customSyntax": "",
  "ignoreDisables": false,
  "packageManager": "yarn",
  "reportInvalidScopeDisables": false,
  "reportNeedlessDisables": false,
  "snippet": [
    "css",
    "postcss",
    "scss"
  ],
  "stylelintPath": "",
  "validate": [
    "css",
    "postcss",
    "scss"
  ]
}

Actual Behaviour

[Warn - 09:50:00] [language-server] Failed to load stylelint either globally or from the current workspace. [Info - 09:50:00] [language-server] No Stylelint found with which to lint document

Expected Behaviour

It would just lint as prior to 1.x

Stylelint Version

14.0

vscode-stylelint Version

v1.0.1

Node.js Version

v16.11

Code of Conduct

adalinesimonian commented 3 years ago

Thanks for the bug report! Can you post more of the logs that you get when Code's run with NODE_ENV=development? I'm afraid I'll need a bit more information to be able to see what's going on. If it's working correctly, you should see a bunch of logs prefixed with [Debug - 00:00 t.t.]

Levdbas commented 3 years ago

I tried debugging on my windows machine via #219 but the output tab does not show logs prefixed with Debug. Let's put this on hold until I get the verbose logging working.

adalinesimonian commented 3 years ago

@Levdbas Just copying what I added to the other issue, looks like spaces were causing a problem on Windows, so cmd /C "set NODE_ENV=development&&code" should work.

Levdbas commented 3 years ago

Hi @adalinesimonian , that worked! I attached a file containing all the log output since startup. debug.log

I went through the logs but wasn't able to point out a specific line pointing us in the right direction. But maybe I missed something. for some reason the output from the resolveFromPath() and resolveFromModules() is missing from the logs probably because #logError() is used instead of this.#logger?.warn()

Right now it just says:

[Debug - 10:54:06 a.m.] [language-server] Resolving Stylelint | uri: "file:///d%3A/laragon/www/redacted.local/web/app/themes/redacted/resources/assets/styles/4_blocks/_acf-content-container.scss"
[Warn  - 10:54:06] [language-server] Failed to load Stylelint either globally or from the current workspace.

If you could add the output of these two methods/functions to the output tab as well it would enhance the debugging experience.

adalinesimonian commented 3 years ago

#logError calls the very same logger used elsewhere in the resolver, so it's strange that you're not seeing any logs. It does have a condition that the connection be defined β€” and I can't think of a case where you wouldn't have one, both places in the code that instantiate a StylelintResolver instance pass to it a connection. But maybe that's exactly what's going wrong here.

Here's a version of the extension with the patch from #294, which should coax out any logs that we may not be getting. If it doesn't, then there's some kind of error or issue happening wherein the inner resolvers don't get a chance to execute, or throw, or perhaps some kind of unhandled promise rejection… all sorts of fun stuff.

vscode-stylelint-1.0.3-logger-patch.zip

Levdbas commented 3 years ago

Thank you for your effort to get this resolved @adalinesimonian , much appreciated! I never encountered a maintainer so involved as you. :)

I uninstalled the regular version and installed the vsix patched version but no luck. It doesn't give any more information then before. See: log2 with patch.log

If there is any way in which I can help you debug this issue, let me know!

adalinesimonian commented 3 years ago

Thank you for your effort to get this resolved @adalinesimonian , much appreciated! I never encountered a maintainer so involved as you. :)

Haha, well, I had to take some time away from work for health reasons, so I'm currently unemployed, hence why I've got all this time to work on this extension. Otherwise, who knows if I'd have the time, most open-source work is volunteered as you know. Luckily, I'm much better now, so I've been trying to nab a part-time job so that I still have time to volunteer with Stylelint. But, boy is it hard to find part-time tech work, almost everything's full-time. Anyway, enough about that!

I uninstalled the regular version and installed the vsix patched version but no luck. It doesn't give any more information then before. See: log2 with patch.log

I just noticed that your package manager configuration is set to Yarn. Are you using PnP in your project? If so, are you using the vscode-stylelint SDK?

chalkygames123 commented 3 years ago

Hi there, I'm facing the same problem. I just wanted to provide some information that might help you solve it.

I'm using Volta to install Node.js (and npm) on macOS, and the problem occurs when I launch VS Code in a normal way, like Launchpad, while it doesn't when I launch it from the terminal (with code or open commands).

The extension version is v1.0.3, and the configuration is left at default except for stylelint.validate.

The Stylelint version is v13.13.1, which is probably irrelevant.

The logs when the problem occurred
[Info  - 3:48:12 PM] [language-server] Registering module | module: "auto-fix"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "auto-fix"
[Info  - 3:48:12 PM] [language-server] Registering module | module: "code-action"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "code-action"
[Info  - 3:48:12 PM] [language-server] Registering module | module: "completion"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "completion"
[Info  - 3:48:12 PM] [language-server] Registering module | module: "formatter"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "formatter"
[Info  - 3:48:12 PM] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 3:48:12 PM] [language-server] Registering module | module: "validator"
[Info  - 3:48:12 PM] [language-server] Module registered | module: "validator"
[Info  - 3:48:12 PM] [language-server] Starting language server
[Info  - 3:48:12 PM] [language-server] Registering handlers
[Info  - 3:48:12 PM] [language-server] Handlers registered
[Info  - 3:48:12 PM] [language-server] Language server started
[Warn  - 3:48:12 PM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Warn  - 3:48:12 PM] [language-server] Failed to resolve Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Warn  - 3:48:12 PM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Info  - 3:48:12 PM] [language-server] No Stylelint found with which to lint document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
The logs (with NODE_ENV=development) when the problem didn't occur
[Info  - 15:50:03] [language-server] Registering module | module: "auto-fix"
[Info  - 15:50:03] [language-server] Module registered | module: "auto-fix"
[Info  - 15:50:03] [language-server] Registering module | module: "code-action"
[Info  - 15:50:03] [language-server] Module registered | module: "code-action"
[Info  - 15:50:03] [language-server] Registering module | module: "completion"
[Info  - 15:50:03] [language-server] Module registered | module: "completion"
[Info  - 15:50:03] [language-server] Registering module | module: "formatter"
[Info  - 15:50:03] [language-server] Module registered | module: "formatter"
[Info  - 15:50:03] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 15:50:03] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 15:50:03] [language-server] Registering module | module: "validator"
[Info  - 15:50:03] [language-server] Module registered | module: "validator"
[Info  - 15:50:03] [language-server] Starting language server
[Info  - 15:50:03] [language-server] Registering handlers
[Debug - 3:50:03 p.m.] [language-server] onInitialize handler registered
[Debug - 3:50:03 p.m.] [language-server] onDidChangeConfiguration handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoking onDidRegisterHandlers
[Debug - 3:50:03 p.m.] [language-server:auto-fix] Registering onExecuteCommand handler
[Debug - 3:50:03 p.m.] [language-server:auto-fix] onExecuteCommand handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "auto-fix" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server:code-action] Registering onCodeAction handler
[Debug - 3:50:03 p.m.] [language-server:code-action] onCodeAction handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "code-action" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server:completion] Registering onCompletion handler
[Debug - 3:50:03 p.m.] [language-server:completion] onCompletion handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "completion" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server:formatter] Registering onDocumentFormatting handler
[Debug - 3:50:03 p.m.] [language-server:formatter] onDocumentFormatting handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "formatter" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server:old-stylelint-warning] Registering onDidOpen handler
[Debug - 3:50:03 p.m.] [language-server:old-stylelint-warning] onDidOpen handler registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "old-stylelint-warning" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server:validator] Registering handlers
[Debug - 3:50:03 p.m.] [language-server:validator] onDidChangeWatchedFiles handler registered
[Debug - 3:50:03 p.m.] [language-server:validator] onDidChangeContent handler registered
[Debug - 3:50:03 p.m.] [language-server:validator] onDidClose handler registered
[Debug - 3:50:03 p.m.] [language-server:validator] Handlers registered
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "validator" returnValue: undefined
[Info  - 15:50:03] [language-server] Handlers registered
[Info  - 15:50:03] [language-server] Language server started
[Debug - 3:50:03 p.m.] [language-server] received onInitialize | params: {"processId":31842,"clientInfo":{"name":"Visual Studio Code","version":"1.61.2"},"locale":"ja","rootPath":"/Users/takuya/ghq/github.com/chalkygames123/front-end-template","rootUri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]},"tagSupport":{"valueSet":[1]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]}},"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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","name":"front-end-template"}]}
[Debug - 3:50:03 p.m.] [language-server] Invoking onInitialize
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "auto-fix" returnValue: {"capabilities":{"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]}}}
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "code-action" returnValue: {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]}}}
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "completion" returnValue: {"capabilities":{"completionProvider":{}}}
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "formatter" returnValue: {"capabilities":{"documentFormattingProvider":false}}
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "old-stylelint-warning" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server] Invoked onInitialize | module: "validator" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server] Returning initialization results | result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":1},"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]},"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]},"completionProvider":{},"documentFormattingProvider":false}}
[Debug - 3:50:03 p.m.] [language-server] received onDidChangeConfiguration | params: {"settings":{"stylelint":{"enable":true,"config":null,"configFile":"","configBasedir":"","customSyntax":"","ignoreDisables":false,"reportNeedlessDisables":false,"reportInvalidScopeDisables":false,"stylelintPath":"","packageManager":"npm","validate":["scss"],"snippet":["css","less","postcss"]}}}
[Debug - 3:50:03 p.m.] [language-server] Options updated | options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
[Debug - 3:50:03 p.m.] [language-server] Languages that should be validated changed | languages: ["scss"] removedLanguages: ["css","postcss"]
[Debug - 3:50:03 p.m.] [language-server] Invoking onDidChangeValidateLanguages
[Debug - 3:50:03 p.m.] [language-server:formatter] Received onDidChangeValidateLanguages | languages: ["scss"]
[Debug - 3:50:03 p.m.] [language-server:formatter] Registering formatter for languages | languages: ["scss"]
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "formatter" returnValue: {}
[Debug - 3:50:03 p.m.] [language-server:validator] Received onDidChangeValidateLanguages | removedLanguages: ["css","postcss"]
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "validator" returnValue: undefined
[Debug - 3:50:03 p.m.] [language-server] Invoking onDidChangeConfiguration
[Debug - 3:50:03 p.m.] [language-server:validator] Received onDidChangeConfiguration
[Debug - 3:50:03 p.m.] [language-server] Invoked onDidChangeConfiguration | module: "validator" returnValue: {}
[Debug - 3:50:03 p.m.] [language-server] Linting document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" linterOptions: {}
[Debug - 3:50:03 p.m.] [language-server:formatter] Formatter registered
[Debug - 3:50:03 p.m.] [language-server] Resolving Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 3:50:03 p.m.] [language-server:code-action] Received onCodeAction | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" context: {"diagnostics":[]}
[Debug - 3:50:03 p.m.] [language-server:code-action] Unsupported code action kind, ignoring | kind: undefined
[Debug - 3:50:04 p.m.] [language-server] npm returned global path: "/Users/takuya/.zinit/plugins/volta-cli---volta/tools/image/node/16.11.0/lib/node_modules" | verbose: undefined
[Debug - 3:50:04 p.m.] [language-server] npm returned global path: "/Users/takuya/.zinit/plugins/volta-cli---volta/tools/image/node/16.11.0/lib/node_modules" | verbose: undefined
[Debug - 3:50:04 p.m.] [language-server] NODE_PATH value is: /Users/takuya/.zinit/plugins/volta-cli---volta/tools/image/node/16.11.0/lib/node_modules | verbose: undefined
[Debug - 3:50:04 p.m.] [language-server] NODE_PATH value is: /Users/takuya/.zinit/plugins/volta-cli---volta/tools/image/node/16.11.0/lib/node_modules | verbose: undefined
[Debug - 3:50:04 p.m.] [language-server] Running Stylelint | options: {"ignoreDisables":false,"reportNeedlessDisables":false,"reportInvalidScopeDisables":false,"ignorePath":"/Users/takuya/ghq/github.com/chalkygames123/front-end-template/.stylelintignore","code":"...","codeFilename":"/Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"}
[Debug - 3:50:04 p.m.] [language-server] Stylelint resolved | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" resolvedPath: "/Users/takuya/ghq/github.com/chalkygames123/front-end-template/node_modules/stylelint/lib/index.js"
[Warn  - 15:50:04] [language-server:old-stylelint-warning] Found unsupported version of Stylelint: 13.13.1
[Debug - 3:50:04 p.m.] [language-server] Lint run complete | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" results: {"diagnostics":[{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":1}},"message":"Expected \"padding\" to come before \"margin\" (order/properties-order)","severity":1,"code":"order/properties-order","source":"Stylelint"}]}
[Debug - 3:50:04 p.m.] [language-server:validator] Sending diagnostics | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" result: {"diagnostics":[{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":1}},"message":"Expected \"padding\" to come before \"margin\" (order/properties-order)","severity":1,"code":"order/properties-order","source":"Stylelint"}]}
[Debug - 3:50:04 p.m.] [language-server:validator] Diagnostics sent | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 3:50:05 p.m.] [language-server:code-action] Received onCodeAction | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" context: {"diagnostics":[]}
[Debug - 3:50:05 p.m.] [language-server:code-action] Unsupported code action kind, ignoring | kind: undefined
adalinesimonian commented 2 years ago

I'm using Volta to install Node.js (and npm) on macOS, and the problem occurs when I launch VS Code in a normal way, like Launchpad, while it doesn't when I launch it from the terminal (with code or open commands).

In order to get debug logs while not launching Code from the terminal, you'll need to run

launchctl setenv NODE_ENV development

and close the terminal session. I'm not sure if you'll have to restart. Because this sets an environment variable globally, once you're done, you may need to clear the variable afterwards so that it doesn't affect other applications that may also check NODE_ENV.

chalkygames123 commented 2 years ago

I didn't know there was such a way! Okay, here you are.

The logs (with NODE_ENV=development) when the problem occurred
[Info  - 10:49:40 AM] [language-server] Registering module | module: "auto-fix"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "auto-fix"
[Info  - 10:49:40 AM] [language-server] Registering module | module: "code-action"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "code-action"
[Info  - 10:49:40 AM] [language-server] Registering module | module: "completion"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "completion"
[Info  - 10:49:40 AM] [language-server] Registering module | module: "formatter"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "formatter"
[Info  - 10:49:40 AM] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 10:49:40 AM] [language-server] Registering module | module: "validator"
[Info  - 10:49:40 AM] [language-server] Module registered | module: "validator"
[Info  - 10:49:40 AM] [language-server] Starting language server
[Info  - 10:49:40 AM] [language-server] Registering handlers
[Debug - 10:49:40 a.m.] [language-server] onInitialize handler registered
[Debug - 10:49:40 a.m.] [language-server] onDidChangeConfiguration handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoking onDidRegisterHandlers
[Debug - 10:49:40 a.m.] [language-server:auto-fix] Registering onExecuteCommand handler
[Debug - 10:49:40 a.m.] [language-server:auto-fix] onExecuteCommand handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "auto-fix" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server:code-action] Registering onCodeAction handler
[Debug - 10:49:40 a.m.] [language-server:code-action] onCodeAction handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "code-action" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server:completion] Registering onCompletion handler
[Debug - 10:49:40 a.m.] [language-server:completion] onCompletion handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "completion" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server:formatter] Registering onDocumentFormatting handler
[Debug - 10:49:40 a.m.] [language-server:formatter] onDocumentFormatting handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "formatter" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server:old-stylelint-warning] Registering onDidOpen handler
[Debug - 10:49:40 a.m.] [language-server:old-stylelint-warning] onDidOpen handler registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "old-stylelint-warning" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server:validator] Registering handlers
[Debug - 10:49:40 a.m.] [language-server:validator] onDidChangeWatchedFiles handler registered
[Debug - 10:49:40 a.m.] [language-server:validator] onDidChangeContent handler registered
[Debug - 10:49:40 a.m.] [language-server:validator] onDidClose handler registered
[Debug - 10:49:40 a.m.] [language-server:validator] Handlers registered
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidRegisterHandlers | module: "validator" returnValue: undefined
[Info  - 10:49:40 AM] [language-server] Handlers registered
[Info  - 10:49:40 AM] [language-server] Language server started
[Debug - 10:49:40 a.m.] [language-server] received onInitialize | params: {"processId":51085,"clientInfo":{"name":"Visual Studio Code","version":"1.61.2"},"locale":"ja","rootPath":"/Users/takuya/ghq/github.com/chalkygames123/front-end-template","rootUri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]},"tagSupport":{"valueSet":[1]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]}},"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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","name":"front-end-template"}]}
[Debug - 10:49:40 a.m.] [language-server] Invoking onInitialize
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "auto-fix" returnValue: {"capabilities":{"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]}}}
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "code-action" returnValue: {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]}}}
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "completion" returnValue: {"capabilities":{"completionProvider":{}}}
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "formatter" returnValue: {"capabilities":{"documentFormattingProvider":false}}
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "old-stylelint-warning" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server] Invoked onInitialize | module: "validator" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server] Returning initialization results | result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":1},"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]},"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]},"completionProvider":{},"documentFormattingProvider":false}}
[Debug - 10:49:40 a.m.] [language-server] received onDidChangeConfiguration | params: {"settings":{"stylelint":{"enable":true,"config":null,"configFile":"","configBasedir":"","customSyntax":"","ignoreDisables":false,"reportNeedlessDisables":false,"reportInvalidScopeDisables":false,"stylelintPath":"","packageManager":"npm","validate":["scss"],"snippet":["css","less","postcss"]}}}
[Debug - 10:49:40 a.m.] [language-server] Options updated | options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
[Debug - 10:49:40 a.m.] [language-server] Languages that should be validated changed | languages: ["scss"] removedLanguages: ["css","postcss"]
[Debug - 10:49:40 a.m.] [language-server] Invoking onDidChangeValidateLanguages
[Debug - 10:49:40 a.m.] [language-server:formatter] Received onDidChangeValidateLanguages | languages: ["scss"]
[Debug - 10:49:40 a.m.] [language-server:formatter] Registering formatter for languages | languages: ["scss"]
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "formatter" returnValue: {}
[Debug - 10:49:40 a.m.] [language-server:validator] Received onDidChangeValidateLanguages | removedLanguages: ["css","postcss"]
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "validator" returnValue: undefined
[Debug - 10:49:40 a.m.] [language-server] Invoking onDidChangeConfiguration
[Debug - 10:49:40 a.m.] [language-server:validator] Received onDidChangeConfiguration
[Debug - 10:49:40 a.m.] [language-server] Invoked onDidChangeConfiguration | module: "validator" returnValue: {}
[Debug - 10:49:40 a.m.] [language-server] Linting document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" linterOptions: {}
[Debug - 10:49:40 a.m.] [language-server:formatter] Formatter registered
[Debug - 10:49:40 a.m.] [language-server] Resolving Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Warn  - 10:49:40 AM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Warn  - 10:49:40 AM] [language-server] Failed to resolve Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 10:49:40 a.m.] [language-server:old-stylelint-warning] Stylelint not found | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Warn  - 10:49:40 AM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Info  - 10:49:40 AM] [language-server] No Stylelint found with which to lint document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
[Debug - 10:49:40 a.m.] [language-server] Lint run complete | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" results: {"diagnostics":[]}
[Debug - 10:49:40 a.m.] [language-server:validator] Sending diagnostics | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" result: {"diagnostics":[]}
[Debug - 10:49:40 a.m.] [language-server:validator] Diagnostics sent | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
adalinesimonian commented 2 years ago

It looks like errors aren't logged when module resolution throws, which I've patched in #302. Here's a copy of the extension with that patch included in it. Go ahead and install it and share what logs you get when resolution fails; I think we might finally get some answers.

vscode-stylelint-1.0.3-log-all-errors-patch.zip

chalkygames123 commented 2 years ago

Got it, this is it πŸ™‚

The logs (with NODE_ENV=development) when the problem occurred (patched)
[Info  - 2:36:35 PM] [language-server] Registering module | module: "auto-fix"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "auto-fix"
[Info  - 2:36:35 PM] [language-server] Registering module | module: "code-action"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "code-action"
[Info  - 2:36:35 PM] [language-server] Registering module | module: "completion"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "completion"
[Info  - 2:36:35 PM] [language-server] Registering module | module: "formatter"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "formatter"
[Info  - 2:36:35 PM] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 2:36:35 PM] [language-server] Registering module | module: "validator"
[Info  - 2:36:35 PM] [language-server] Module registered | module: "validator"
[Info  - 2:36:35 PM] [language-server] Starting language server
[Info  - 2:36:35 PM] [language-server] Registering handlers
[Debug - 2:36:35 p.m.] [language-server] onInitialize handler registered
[Debug - 2:36:35 p.m.] [language-server] onDidChangeConfiguration handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoking onDidRegisterHandlers
[Debug - 2:36:35 p.m.] [language-server:auto-fix] Registering onExecuteCommand handler
[Debug - 2:36:35 p.m.] [language-server:auto-fix] onExecuteCommand handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "auto-fix" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server:code-action] Registering onCodeAction handler
[Debug - 2:36:35 p.m.] [language-server:code-action] onCodeAction handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "code-action" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server:completion] Registering onCompletion handler
[Debug - 2:36:35 p.m.] [language-server:completion] onCompletion handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "completion" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server:formatter] Registering onDocumentFormatting handler
[Debug - 2:36:35 p.m.] [language-server:formatter] onDocumentFormatting handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "formatter" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server:old-stylelint-warning] Registering onDidOpen handler
[Debug - 2:36:35 p.m.] [language-server:old-stylelint-warning] onDidOpen handler registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "old-stylelint-warning" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server:validator] Registering handlers
[Debug - 2:36:35 p.m.] [language-server:validator] onDidChangeWatchedFiles handler registered
[Debug - 2:36:35 p.m.] [language-server:validator] onDidChangeContent handler registered
[Debug - 2:36:35 p.m.] [language-server:validator] onDidClose handler registered
[Debug - 2:36:35 p.m.] [language-server:validator] Handlers registered
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidRegisterHandlers | module: "validator" returnValue: undefined
[Info  - 2:36:35 PM] [language-server] Handlers registered
[Info  - 2:36:35 PM] [language-server] Language server started
[Debug - 2:36:35 p.m.] [language-server] received onInitialize | params: {"processId":29449,"clientInfo":{"name":"Visual Studio Code","version":"1.61.2"},"locale":"ja","rootPath":"/Users/takuya/ghq/github.com/chalkygames123/front-end-template","rootUri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"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]},"tagSupport":{"valueSet":[1]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]}},"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]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"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]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template","name":"front-end-template"}]}
[Debug - 2:36:35 p.m.] [language-server] Invoking onInitialize
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "auto-fix" returnValue: {"capabilities":{"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]}}}
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "code-action" returnValue: {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]}}}
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "completion" returnValue: {"capabilities":{"completionProvider":{}}}
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "formatter" returnValue: {"capabilities":{"documentFormattingProvider":false}}
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "old-stylelint-warning" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server] Invoked onInitialize | module: "validator" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server] Returning initialization results | result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":1},"executeCommandProvider":{"commands":["stylelint.applyAutoFix"]},"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll.stylelint"]},"completionProvider":{},"documentFormattingProvider":false}}
[Debug - 2:36:35 p.m.] [language-server] received onDidChangeConfiguration | params: {"settings":{"stylelint":{"enable":true,"config":null,"configFile":"","configBasedir":"","customSyntax":"","ignoreDisables":false,"reportNeedlessDisables":false,"reportInvalidScopeDisables":false,"stylelintPath":"","packageManager":"npm","validate":["scss"],"snippet":["css","less","postcss"]}}}
[Debug - 2:36:35 p.m.] [language-server] Options updated | options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
[Debug - 2:36:35 p.m.] [language-server] Languages that should be validated changed | languages: ["scss"] removedLanguages: ["css","postcss"]
[Debug - 2:36:35 p.m.] [language-server] Invoking onDidChangeValidateLanguages
[Debug - 2:36:35 p.m.] [language-server:formatter] Received onDidChangeValidateLanguages | languages: ["scss"]
[Debug - 2:36:35 p.m.] [language-server:formatter] Registering formatter for languages | languages: ["scss"]
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "formatter" returnValue: {}
[Debug - 2:36:35 p.m.] [language-server:validator] Received onDidChangeValidateLanguages | removedLanguages: ["css","postcss"]
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidChangeValidateLanguages | module: "validator" returnValue: undefined
[Debug - 2:36:35 p.m.] [language-server] Invoking onDidChangeConfiguration
[Debug - 2:36:35 p.m.] [language-server:validator] Received onDidChangeConfiguration
[Debug - 2:36:35 p.m.] [language-server] Invoked onDidChangeConfiguration | module: "validator" returnValue: {}
[Debug - 2:36:35 p.m.] [language-server] Linting document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" linterOptions: {}
[Debug - 2:36:35 p.m.] [language-server:formatter] Formatter registered
[Debug - 2:36:35 p.m.] [language-server] Resolving Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 2:36:35 p.m.] [language-server] Failed to resolve Stylelint from global or workspace node_modules. | error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"]}
[Warn  - 2:36:35 PM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Warn  - 2:36:35 PM] [language-server] Failed to resolve Stylelint | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 2:36:35 p.m.] [language-server:old-stylelint-warning] Stylelint not found | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
[Debug - 2:36:35 p.m.] [language-server] Failed to resolve Stylelint from global or workspace node_modules. | error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"]}
[Warn  - 2:36:36 PM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Info  - 2:36:36 PM] [language-server] No Stylelint found with which to lint document | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["scss"]}
[Debug - 2:36:35 p.m.] [language-server] Lint run complete | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" results: {"diagnostics":[]}
[Debug - 2:36:35 p.m.] [language-server:validator] Sending diagnostics | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss" result: {"diagnostics":[]}
[Debug - 2:36:36 p.m.] [language-server:validator] Diagnostics sent | uri: "file:///Users/takuya/ghq/github.com/chalkygames123/front-end-template/assets/styles/base/_base.scss"
Levdbas commented 2 years ago

I haven't forgotten this thread but I am kinda busy at the moment. I am trying to make some room to debug this tomorrow!

fabd commented 2 years ago

module resolution throws

The migration guide mentions "If the extension doesn't seem to be linting any documents, make sure you have Stylelint installed." however it doesn't give me any error or warnings messages at all in VSCode, so I am unable to find out why I have no linting within VSCode since updating all related packages (stylelint & configs) & applying migration guide.

Validation works for me in the CLI but not in VSCode, so I wonder...

Does the extension account for node_modules not at the root of the project? (since as I understand, it no longer bundles stylelint, and looks for it in the "open workspace".)

In my project for example (old php app with a vite/ subfolder for all the frontend & npm stuff):

data/
lib/
vite/      
.. node_modules/     <-- is not at the root of the project
.. src/            <-- all the scss / css files are here
.. stylelint.config.js
www/
adalinesimonian commented 2 years ago

Got it, this is it πŸ™‚ The logs (with NODE_ENV=development) when the problem occurred (patched)

[Debug - 2:36:35 p.m.] [language-server] Failed to resolve Stylelint from global or workspace node_modules. | error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"]}

@chalkygames123 Aha! This is the key line: it looks like when you start VS Code outside of the terminal, the extension's attempt to run npm to find out where npm's global node_modules is fails as the OS reports that there's no command available named npm. I'll do some investigating on my Mac to see what might need changing to let this work.

Does the extension account for node_modules not at the root of the project? (since as I understand, it no longer bundles stylelint, and looks for it in the "open workspace".)

@fabd The resolution logic is as follows; any reference to a setting is a reference to the extension's settings in VS Code, not Stylelint's configuration file.

  1. If stylelintPath is configured, try to require the module it points to.

    If the path is relative, the workspace folder, if one is available, is used as the directory that the path is relative to. Otherwise, the path is used as-is.

    If stylelintPath is not provided, this is skipped.

  2. Get the global node_modules path for the package manager indicated by the packageManager option, which defaults to npm if not specified.

    This is done by calling the package manager with the correct command for it to spit out its global package installation path. For npm, this is npm config get prefix, for yarn, yarn global dir --json, and for pnpm, pnpm root -g.

  3. Determine the current working directory from which to resolve modules.

    If the document being linted has a corresponding filesystem path, the document's path is used. Otherwise, the workspace folder is used.

  4. Try to require the module using vscode-languageserver's Files.resolve.

    Files.resolve tries to get the package path using Node's module resolution logic. The global package path is used to fill out NODE_PATH, which is used for global package resolution. The working directory, as provided, is used for the directory in which the require would be taking place.

In any of these cases, Stylelint is only considered resolved if the resolved module has an exported lint function.

So specifically in regard to your question, it should, in theory, be resolving the Stylelint package using the path of the document that the extension is attempting to lint as a starting point. So, at least if everything is working as it should, the extension should be able to resolve the Stylelint package even if it is not directly in the workspace root, whether it is deeper into the workspace or outside of it.

If you are experiencing issues with resolution, I suggest running Code with NODE_ENV set to development, which will tell the extension to emit debug logs. Then you can inspect the logs to see what's going wrong. If you don't see any details other than Failed to load Stylelint either globally or from the current workspace. without any errors or other details, try the patch mentioned earlier.

Levdbas commented 2 years ago

I finally found some time to try your latest patch and got the same error as @chalkygames123. [Debug - 9:24:33 a.m.] [language-server] Failed to resolve Stylelint from global or workspace node_modules. | error: {}

So a little background on where my files live. Installing is done via yarn in WSL.

Project root / workspace
β”œβ”€β”€ bunch of random files for initializing my PHP project
└── web
    β”œβ”€β”€ app
    β”‚   └──themes
    β”‚          └── WordPress theme folder
    β”‚                  β”œβ”€β”€ node_modules  (containing stylelint)
    β”‚                  β”œβ”€β”€ package.json
    β”‚                  └── .stylelintrc
    β”œβ”€β”€ wp-config.php
    β”œβ”€β”€ index.php
    └── wp

I know its probably a very specific setup but hopefully you can help. Meanwhile I'm going to try out to remote into WSL via the WSL extention and see how that works in my day to day work.

adalinesimonian commented 2 years ago

I finally found some time to try your latest patch and got the same error as @chalkygames123. [Debug - 9:24:33 a.m.] [language-server] Failed to resolve Stylelint from global or workspace node_modules. | error: {}

Agh! The error object as logged is empty, so there's no way to know exactly what went wrong, even though there's definitely something happening there. It looks like the logger wasn't properly serializing error objects, so certain information was missing when logged. I fixed this in #310, and a patched VSIX is below that contains this fix.

vscode-stylelint-1.0.3-error-serialization-patch.zip

So a little background on where my files live. Installing is done via yarn in WSL.

Project root / workspace
β”œβ”€β”€ bunch of random files for initializing my PHP project
└── web
    β”œβ”€β”€ app
    β”‚   └──themes
    β”‚          └── WordPress theme folder
    β”‚                  β”œβ”€β”€ node_modules  (containing stylelint)
    β”‚                  β”œβ”€β”€ package.json
    β”‚                  └── .stylelintrc
    β”œβ”€β”€ wp-config.php
    β”œβ”€β”€ index.php
    └── wp

I know its probably a very specific setup but hopefully you can help. Meanwhile I'm going to try out to remote into WSL via the WSL extention and see how that works in my day to day work.

I'm guessing the CSS you're trying to lint is in your theme folder or deeper? In theory, so long as the extension is properly installed in WSL, it should work. Even if the package is installed in a subdirectory (or further out of the project), it should be able to be resolved.

I'm running Windows 11 with Fedora 35 running in WSL 2, with Node installed using Volta. I decided to see if I could repro the resolution error. I created the following file structure:

Workspace root
└── subfolder
    β”œβ”€β”€ node_modules
    β”œβ”€β”€ package.json
    β”œβ”€β”€ stylelint.config.js
    └── test.css

And it seems to work:

Screenshot of lint results and logs


@chalkygames123 It looks like the error you and @Levdbas are experiencing are different, otherwise, the error that you both see would be the same. Could you copy your comment into a new issue so that we can track it as a separate bug?


Thanks to both of you for your patience with this. I want to get this working for you and whoever else may also be encountering the same issues. Your help debugging this is incredibly valuable. Without it, it would be so much harder to try and figure out what's gone wrong and how to fix it.

kryshac commented 2 years ago
[Info  - 12:33:37 AM] [language-server] Registering module | module: "auto-fix"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "auto-fix"
[Info  - 12:33:37 AM] [language-server] Registering module | module: "code-action"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "code-action"
[Info  - 12:33:37 AM] [language-server] Registering module | module: "completion"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "completion"
[Info  - 12:33:37 AM] [language-server] Registering module | module: "formatter"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "formatter"
[Info  - 12:33:37 AM] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 12:33:37 AM] [language-server] Registering module | module: "validator"
[Info  - 12:33:37 AM] [language-server] Module registered | module: "validator"
[Info  - 12:33:37 AM] [language-server] Starting language server
[Info  - 12:33:37 AM] [language-server] Registering handlers
[Info  - 12:33:37 AM] [language-server] Handlers registered
[Info  - 12:33:37 AM] [language-server] Language server started
[Warn  - 12:33:37 AM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Warn  - 12:33:37 AM] [language-server] Failed to resolve Stylelint | uri: "file:///home/ccazacu/work/angular/zeelix-front-end/test.scss"
[Warn  - 12:33:37 AM] [language-server] Failed to load Stylelint either globally or from the current workspace.
[Info  - 12:33:37 AM] [language-server] No Stylelint found with which to lint document | uri: "file:///home/ccazacu/work/angular/zeelix-front-end/test.scss" options: {"config":null,"configBasedir":"","configFile":"","customSyntax":"","ignoreDisables":false,"packageManager":"npm","reportInvalidScopeDisables":false,"reportNeedlessDisables":false,"snippet":["css","less","postcss"],"stylelintPath":"","validate":["css","scss"]}
chalkygames123 commented 2 years ago

@adalinesimonian Sure! I'm happy to help. Created: https://github.com/stylelint/vscode-stylelint/issues/312

fabd commented 2 years ago

Since you mentioned Windows, I thought I'd add mention I am also running macOS. Could be related.

For me VSCode is running on the host. I was trying to run stylelint 14 with a node_modules that is maintained by npm inside a Ubuntu 20.04 container. The project's root folder is just mapped to /var/www/html, served by Apache.

From VSCode standpoint I think it doesn't matter since it sees all the files on the host OS, so may be irrelevant.

To summarize for me the issue is that running stylelint 14 via CLI was working, but in VSCode it wouldn't lint anything, and it wouldn't give me any errors or startup so I can't really tell why it wasn't active.

adalinesimonian commented 2 years ago

@kryshac @fabd Without debug logs, there's not a whole lot I can do to figure out what's going wrong. If you wouldn't mind, could you install the patched version of the extension from https://github.com/stylelint/vscode-stylelint/issues/281#issuecomment-960075064 and run VS Code with NODE_ENV set to development? You should see logs beginning with [Debug …] if you've started VS Code correctly. With the patch, you should see the underlying error reported in the logs when resolution fails, and running with debug logs enabled, you'll see more information about the resolution process.

ronilaukkarinen commented 2 years ago

I have this same problem on Windows 10. VSCode-stylelint just stopped working after the update.

On my macOS it picks up the stylelint bin automatically. cmd /C "set NODE_ENV=development&&code-insiders" really doesn't tell me why in DevTools or then I just don't know where to look.

cmd stylelint path:

C:\>C:\Users\Rolle\AppData\Roaming\npm\stylelint --version
14.0.1

Please advice.

kryshac commented 2 years ago

@adalinesimonian the problem for me was that I was opening vscode from a bash script that was executed from i3 and was open as a normal user and had no access to npm

adalinesimonian commented 2 years ago

Can you try updating to v1.1.0 and see if it does the trick? It has a bug fix for #312 which causes resolution to error out when the package manager cannot be accessed.

kryshac commented 2 years ago

I deleted the link from npm from /usr/bin and I get this warning but it works

[Info  - 12:44:47 AM] [language-server] Registering module | module: "auto-fix"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "auto-fix"
[Info  - 12:44:47 AM] [language-server] Registering module | module: "code-action"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "code-action"
[Info  - 12:44:47 AM] [language-server] Registering module | module: "completion"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "completion"
[Info  - 12:44:47 AM] [language-server] Registering module | module: "formatter"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "formatter"
[Info  - 12:44:47 AM] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 12:44:47 AM] [language-server] Registering module | module: "validator"
[Info  - 12:44:47 AM] [language-server] Module registered | module: "validator"
[Info  - 12:44:47 AM] [language-server] Starting language server
[Info  - 12:44:47 AM] [language-server] Registering handlers
[Info  - 12:44:47 AM] [language-server] Handlers registered
[Info  - 12:44:47 AM] [language-server] Language server started
[Warn  - 12:44:48 AM] [language-server] Failed to resolve global node_modules path. | packageManager: "npm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"],"name":"Error","message":"spawn npm ENOENT","stack":"Error: spawn npm ENOENT\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n    at onErrorNT (internal/child_process.js:465:16)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)"}
[Warn  - 12:44:48 AM] [language-server] Failed to resolve global node_modules path. | packageManager: "npm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"],"name":"Error","message":"spawn npm ENOENT","stack":"Error: spawn npm ENOENT\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n    at onErrorNT (internal/child_process.js:465:16)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)"}
Levdbas commented 2 years ago

1.1.0 Works for me! πŸŽ‰

The first 5 lines from the log fail, which is exactly what I expected since I do not have stylelint installed inside Windows.

[Debug - 10:08:23 a.m.] [language-server:code-action] Received onCodeAction | uri: "file:///d%3A/laragon/www/redacted/web/app/themes/redacted/resources/assets/styles/01-settings/_variables.scss" context: {"diagnostics":[{"range":{"start":{"line":21,"character":1},"end":{"line":21,"character":1}},"message":"Expected indentation of 0 tabs (indentation)","code":"indentation","codeDescription":{"href":"https://stylelint.io/user-guide/rules/indentation"},"severity":1,"source":"Stylelint"}],"only":["source.fixAll.stylelint"]}
[Warn  - 10:08:23] [language-server] Failed to resolve global node_modules path. | packageManager: "yarn" error: {"name":"Error","message":"Command \"yarn\" exited with code 1.","stack":"Error: Command \"yarn\" exited with code 1.\n    at h (c:\\Users\\erikv\\.vscode\\extensions\\stylelint.vscode-stylelint-1.1.0\\dist\\start-server.js:71:1416)\n    at ChildProcess.<anonymous> (c:\\Users\\erikv\\.vscode\\extensions\\stylelint.vscode-stylelint-1.1.0\\dist\\start-server.js:71:1707)\n    at ChildProcess.emit (events.js:315:20)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)"}
[Debug - 10:08:24 a.m.] [language-server] Did not find PnP loader at tested path | path: "d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.cjs" error: {"errno":-4058,"code":"ENOENT","syscall":"stat","path":"d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.cjs","name":"Error","message":"ENOENT: no such file or directory, stat 'd:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.cjs'","stack":"Error: ENOENT: no such file or directory, stat 'd:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.cjs'"}
[Debug - 10:08:24 a.m.] [language-server] Did not find PnP loader at tested path | path: "d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.js" error: {"errno":-4058,"code":"ENOENT","syscall":"stat","path":"d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.js","name":"Error","message":"ENOENT: no such file or directory, stat 'd:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.js'","stack":"Error: ENOENT: no such file or directory, stat 'd:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\.pnp.js'"}
[Debug - 10:08:24 a.m.] [language-server] Could not find a PnP loader | path: "d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted"

Then the next 5 lines try to resolve Stylelint from the filesystem and does succeed.

[Debug - 10:08:24 a.m.] [language-server] Resolved Stylelint from node_modules | path: "d:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\node_modules\\stylelint\\lib\\index.js"
[Debug - 10:08:24 a.m.] [language-server] Running Stylelint | options: {"fix":true,"ignoreDisables":false,"reportNeedlessDisables":false,"reportInvalidScopeDisables":false,"ignorePath":"d:\\laragon\\www\\redacted\\.stylelintignore","code":"...","codeFilename":"D:\\laragon\\www\\redacted\\web\\app\\themes\\redacted\\resources\\assets\\styles\\01-settings\\_variables.scss"}
[Debug - 10:08:24 a.m.] [language-server] Fixes retrieved | uri: "file:///d%3A/laragon/www/redacted/web/app/themes/redacted/resources/assets/styles/01-settings/_variables.scss" edits: [{"range":{"start":{"line":21,"character":0},"end":{"line":21,"character":1}},"newText":""}]
[Debug - 10:08:24 a.m.] [language-server:code-action] Returning code actions | actions: [{"title":"Fix all Stylelint auto-fixable problems","edit":{"documentChanges":[{"textDocument":{"uri":"file:///d%3A/laragon/www/redacted/web/app/themes/redacted/resources/assets/styles/01-settings/_variables.scss","version":1},"edits":[{"range":{"start":{"line":21,"character":0},"end":{"line":21,"character":1}},"newText":""}]}]},"kind":"source.fixAll.stylelint"}]
[Debug - 10:08:24 a.m.] [language-server] Linting document | uri: "file:///d%3A/laragon/www/redacted/web/app/themes/redacted/resources/assets/styles/01-settings/_variables.scss" linterOptions: {}

Thanks a lot @adalinesimonian for your perseverance in this issue!

adalinesimonian commented 2 years ago

Glad to hear it's working. Closing this issue now. Thanks for all the help with this!

ronilaukkarinen commented 2 years ago

For me 1.1.0 doesn't change the situation. Not seeing any linter errors in the editor. On command line stylelint works fine in both cmd and Ubuntu WSL. Using Windows 10 and Node.js for Windows v15.14.0. What to do?

ronilaukkarinen commented 2 years ago

...missed some settings, sorry. It works now with these:

  "[scss]": {
    "editor.defaultFormatter": "ronilaukkarinen.vscode-stylefmt",
    "editor.formatOnSave": true,
    "editor.lineNumbers": "on",
    "editor.wordWrap": "bounded",
    "files.trimTrailingWhitespace": true
  },
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": false,
    "source.fixAll.tslint": false,
    "source.fixAll.stylelint": true
  },
  "stylelint.validate": [
    "scss"
  ],
  "stylelint.snippet": [
    "css",
    "scss"
  ],
  "stylelint.syntax": "scss",
  "stylelint.customSyntax": "postcss-scss",