question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix custom syntax module path not properly resolving

See original GitHub issue

Clearly describe the bug

As per https://github.com/stylelint-scss/stylelint-config-standard-scss/issues/2, custom syntax module path is not properly resolved.

Stylelint tries to resolve custom syntax location (stylelint/stylelint@main/lib/getPostcssResult.js#L95) but uses Node require algorithm, so it search from that file upwards.

If you have dependancy tree where postcss-scss is not in one of the root directories, but is nested inside this config’s node_modules (it happens if you have different versions of same package), path resolution fails.

Which rule, if any, is the bug related to?

None, it’s related to core functionality

What code is needed to reproduce the bug?

Even empty SCSS file would do.

What Stylelint configuration is needed to reproduce the bug?

{
  "extends": "stylelint-config-standard-scss"
}

But postcss-scss shouldn’t be installed inside root node_modules.

Which version of Stylelint are you using?

14.0.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

stylelint "**/*.scss"

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

Yes, it’s related to SCSS custom syntax.

What did you expect to happen?

Should return at least error/warning related to style code or exit code 0 if everything is OK.

What actually happened (e.g. what warnings or errors did you get)?

Cannot resolve custom syntax module "postcss-scss". Check that module "postcss-scss" is available and spelled correctly.

at getCustomSyntax (node_modules/stylelint/lib/getPostcssResult.js:97:10)
at getPostcssResult (node_modules/stylelint/lib/getPostcssResult.js:41:5)
at lintSource (node_modules/stylelint/lib/lintSource.js:76:20)
at Function.standalone [as lint] (node_modules/stylelint/lib/standalone.js:132:26)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:16
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
tom-riccicommented, Nov 19, 2021

Welp seems like I’m not just a user anymore lol

3reactions
jeddy3commented, Oct 26, 2021

It’s incompatible versions of postcss, not postcss-scss. You’ll need to use yarn why postcss to find them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using eslint with typescript - Unable to resolve path to module
In my eslintrc.js config file, the "import/resolver" object needed to sit within the "rules" node, not the " ...
Read more >
Documentation - Module Resolution - TypeScript
A non-relative import can be resolved relative to baseUrl , or through path mapping, which we'll cover below. They can also resolve to...
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
Configuration | Stylelint
No rules are turned on by default and there are no default values. You must explicitly configure each rule to turn it on....
Read more >
API - esbuild
Outfile. In addition, you can also specify a fully custom output path for each individual entry point using an alternative entry point syntax:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found