stylelint / vscode-stylelint

The official Visual Studio Code extension for Stylelint

Home Page:https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Setting the path to Stylelint fails

mlbiche opened this issue · comments

How did you encounter this bug?

I am setting up Stylelint in a project using pnpm workspaces. Stylelint is installed within a workspace (sub-directory). Setting the path to the package in the stylelintPath config prevent the extension to start.

Link to Minimal Reproducible Example

https://github.com/mlbiche/stylelint-repro

Code Snippet

No response

Stylelint Configuration

No response

Extension Configuration

{
  "stylelint.stylelintPath": "packages/lint/node_modules/.bin/stylelint"
}

The config is available in the reproduction repository.

Actual Behaviour

When opening VSCode, the following error pops up

[Error - 6:24:50 PM] [language-server] Failed to load Stylelint from "stylelintPath": packages/lint/node_modules/.bin/stylelint. | error: {"name":"SyntaxError","message":"missing ) after argument list","stack":"[...path to my workspace]/packages/lint/node_modules/.bin/stylelint:2
basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1039:15)
    at Module._compile (node:internal/modules/cjs/loader:1074:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at lR.oR (/Users/thibaud/.vscode-oss/extensions/stylelint.vscode-stylelint-1.2.4-universal/dist/start-server.js:70:36260)"}

As the extension does not load correctly, when I open src/style.css file no Stylelint error is raised.

Expected Behaviour

The rule no-empty-source should fail in src/style.css file as it is by running pnpm -F src lint:style

Logs

No response

Stylelint Version

v15.2.0

vscode-stylelint Version

v1.2.4

Node.js Version

v19.7.0

Operating System

macOS 12.6.3

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct

Specify the stylelint module path instead of the executable file in the stylelintPath option. In other words, specify the root directory of stylelint or the main javascript path.

https://github.com/stylelint/vscode-stylelint#stylelintstylelintpath

Han, sorry for the trouble 😬 Cheers !