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

[Bug]: TypeError: Cannot read properties of undefined (reading '0') at LessParser.interpolation #378

Closed
1 task done
tjx666 opened this issue Feb 11, 2022 · 12 comments
Closed
1 task done
Labels
help wanted is likely non-trival and help is wanted status: needs clarification triage needs clarification from author status: needs reproducible example triage needs reproducible demo or repo type: bug a problem with a feature or rule

Comments

@tjx666
Copy link

tjx666 commented Feb 11, 2022

How did you encounter this bug?

  1. git clone [email protected]:tjx666/stylelint-issue-repro.git
  2. install dependencies by pnpm install
  3. open index.less
  4. input dot .

Code Snippet

Just input .:

.

Stylelint Configuration

{
    "extends": [
        "stylelint-config-standard",
        "stylelint-config-prettier",
        "stylelint-config-recess-order"
    ],
    "plugins": ["stylelint-declaration-block-no-ignored-properties"],
    "customSyntax": "postcss-less",
    "rules": {
        "alpha-value-notation": null,
        "color-function-notation": null,
        "comment-empty-line-before": null,
        "declaration-empty-line-before": null,
        "function-name-case": "lower",
        "no-descending-specificity": null,
        "no-invalid-double-slash-comments": null,
        "number-max-precision": null,
        "property-no-vendor-prefix": null,
        "selector-class-pattern": null,
        "value-no-vendor-prefix": null
    },
    "ignoreFiles": ["**/node_modules/**", "reset.less"]
}

Extension Configuration

None

Actual Behaviour

image

Expected Behaviour

No error notification.

Logs

[Info - 10:43:31 AM] [language-server] Registering module | module: "auto-fix"
[Info - 10:43:31 AM] [language-server] Module registered | module: "auto-fix"
[Info - 10:43:31 AM] [language-server] Registering module | module: "code-action"
[Info - 10:43:31 AM] [language-server] Module registered | module: "code-action"
[Info - 10:43:31 AM] [language-server] Registering module | module: "completion"
[Info - 10:43:31 AM] [language-server] Module registered | module: "completion"
[Info - 10:43:31 AM] [language-server] Registering module | module: "formatter"
[Info - 10:43:31 AM] [language-server] Module registered | module: "formatter"
[Info - 10:43:31 AM] [language-server] Registering module | module: "old-stylelint-warning"
[Info - 10:43:31 AM] [language-server] Module registered | module: "old-stylelint-warning"
[Info - 10:43:31 AM] [language-server] Registering module | module: "validator"
[Info - 10:43:31 AM] [language-server] Module registered | module: "validator"
[Info - 10:43:31 AM] [language-server] Starting language server
[Info - 10:43:31 AM] [language-server] Registering handlers
[Info - 10:43:31 AM] [language-server] Handlers registered
[Info - 10:43:31 AM] [language-server] Language server started
[Error - 10:43:48 AM] [language-server] Error running lint | uri: "file:///Users/yutengjing/Library/Application%20Support/Adobe/CEP/extensions/ae-power-tools/web/a.less" error: {"name":"TypeError","message":"Cannot read properties of undefined (reading '0')","stack":"TypeError: Cannot read properties of undefined (reading '0')\n at LessParser.interpolation (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/nodes/interpolation.js:9:45)\n at LessParser.atrule (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:22:33)\n at LessParser.mixin (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:145:10)\n at LessParser.unknownWord (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:204:12)\n at LessParser.other (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/parser.js:151:12)\n at LessParser.other (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:157:13)\n at LessParser.parse (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/parser.js:59:16)\n at parse (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/index.js:13:12)\n at new LazyResult (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/lazy-result.js:133:16)\n at getPostcssResult (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/stylelint/lib/getPostcssResult.js:77:30)"}
[Error - 10:43:51 AM] [language-server] Error running lint | uri: "file:///Users/yutengjing/Library/Application%20Support/Adobe/CEP/extensions/ae-power-tools/web/a.less" error: {"name":"TypeError","message":"Cannot read properties of undefined (reading '0')","stack":"TypeError: Cannot read properties of undefined (reading '0')\n at LessParser.interpolation (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/nodes/interpolation.js:9:45)\n at LessParser.atrule (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:22:33)\n at LessParser.mixin (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:145:10)\n at LessParser.unknownWord (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:204:12)\n at LessParser.other (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/parser.js:151:12)\n at LessParser.other (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/LessParser.js:157:13)\n at LessParser.parse (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/parser.js:59:16)\n at parse (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss-less/lib/index.js:13:12)\n at new LazyResult (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/postcss/lib/lazy-result.js:133:16)\n at getPostcssResult (/Users/yutengjing/Library/Application Support/Adobe/CEP/extensions/ae-power-tools/node_modules/stylelint/lib/getPostcssResult.js:77:30)"}

Stylelint Version

14.4.0

vscode-stylelint Version

v1.2.2

Node.js Version

v16.13.2

Operating System

MacOS12.2

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct
@tjx666 tjx666 added the type: bug a problem with a feature or rule label Feb 11, 2022
@ccqgithub
Copy link

I have the same issue, any solution ?

@ota-meshi ota-meshi added the status: needs reproducible example triage needs reproducible demo or repo label Aug 17, 2022
tjx666 pushed a commit to tjx666/stylelint-issue-repro that referenced this issue Aug 30, 2022
tjx666 pushed a commit to tjx666/stylelint-issue-repro that referenced this issue Aug 30, 2022
@tjx666
Copy link
Author

tjx666 commented Aug 30, 2022

@ota-meshi I had created a reproduce repository

@ota-meshi
Copy link
Member

ota-meshi commented Aug 31, 2022

I tried with your provided repository and it works fine.

image

@tjx666
Copy link
Author

tjx666 commented Aug 31, 2022

@orta

What's your vscode version?

My Version is:

Version: 1.71.0-insider (Universal)
Commit: 16faaf4eb07424d5d7dba7d12bffd64309c283f7
Date: 2022-08-29T15:28:34.899Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 21.6.0
Sandboxed: Yes

My Stylint config in settings.json:

 "stylelint.validate": [
        "css",
        "less",
        "scss"
    ],
2022-08-31.11.19.54.mov

@ota-meshi
Copy link
Member

I don't have your environment so I can't fix it. Could you please debug the issue and submit a PR that fixes the issue?

@ota-meshi ota-meshi added help wanted is likely non-trival and help is wanted status: needs clarification triage needs clarification from author labels Aug 31, 2022
@tjx666
Copy link
Author

tjx666 commented Aug 31, 2022

I try to fix the issue yesterday, but can't find out how to debug the lsp extension. I'm not familiar with lsp extension. But I will study some lsp knowledge and try to fix again these days.

I don't have your environment so I can't fix it. Could you please debug the issue and submit a PR that fixes the issue?

@tjx666
Copy link
Author

tjx666 commented Sep 4, 2022

@ota-meshi

I fix the server debug config: #421,

and find this message is from here:

image

The error message is:

TypeError: 
Cannot read properties of undefined (reading '0') 
at LessParser.interpolation (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/nodes/interpolation.js:9:45)    
at LessParser.atrule (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:22:33)    
at LessParser.mixin (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:145:10)    
at LessParser.unknownWord (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:204:12)    
at LessParser.other (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/parser.js:164:12)    
at LessParser.other (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:157:13)    
at LessParser.parse (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/parser.js:72:16)    
at parse (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/index.js:13:12)    
at new LazyResult (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/lazy-result.js:133:16)    
at getPostcssResult (/Users/yutengjing/code/stylelint-issue-repro/node_modules/stylelint/lib/getPostcssResult.js:77:30)

Seems like just a parse syntax error. Should we just ignore the error?

@ota-meshi
Copy link
Member

What is the difference from running from the CLI?
If there is a difference there, I think it is necessary to fix the vscode extension to handle it well. If not, I'm still not sure if we need to fix the vscode extension.

@tjx666
Copy link
Author

tjx666 commented Sep 4, 2022

image

TypeError: Cannot read properties of undefined (reading '0')
    at LessParser.interpolation (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/nodes/interpolation.js:9:45)
    at LessParser.atrule (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:22:33)
    at LessParser.mixin (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:145:10)
    at LessParser.unknownWord (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:204:12)
    at LessParser.other (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/parser.js:164:12)
    at LessParser.other (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/LessParser.js:157:13)
    at LessParser.parse (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/parser.js:72:16)
    at parse (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss-less/lib/index.js:13:12)
    at new LazyResult (/Users/yutengjing/code/stylelint-issue-repro/node_modules/postcss/lib/lazy-result.js:133:16)
    at getPostcssResult (/Users/yutengjing/code/stylelint-issue-repro/node_modules/stylelint/lib/getPostcssResult.js:77:30)

@ota-meshi
Copy link
Member

ota-meshi commented Sep 4, 2022

Your problem may not be a vscode-stylelint issue. I think it's stylelint, less(postcss-less) or your environment issue.

@ota-meshi
Copy link
Member

I'm closing this issue as I don't think the issue is with vscode-stylelint.

@cumt-robin
Copy link

i have met the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted is likely non-trival and help is wanted status: needs clarification triage needs clarification from author status: needs reproducible example triage needs reproducible demo or repo type: bug a problem with a feature or rule
Development

No branches or pull requests

4 participants