stylelint: Fix `max-nesting-depth` error for at-rules in Sass syntax

What steps are needed to reproduce the bug?

run npx stylelint “**/*.sass” with config

while “customSyntax”: require(“postcss-sass”) doesnt work

“customSyntax”: require(“postcss-scss”) works and display styles that dont stand in the rules

What Stylelint configuration is needed to reproduce the bug?

stylelint.config.js

module.exports = { "extends": "stylelint-config-sass-guidelines", "customSyntax": require("postcss-sass"), "rules": { "declaration-block-trailing-semicolon": "never", "block-opening-brace-space-before": null, "max-nesting-depth": 3, "selector-class-pattern": "", "color-named": null, "selector-no-qualifying-type": [true, { ignore: ["class"] }], } }

package.json "postcss-sass": "^0.5.0", "stylelint": "^14.9.1", "stylelint-config-sass-guidelines": "^9.0.1",

How did you run Stylelint?

npx stylelint “**/*.sass”

Which version of Stylelint are you using?

14.9.1

What did you expect to happen?

display styles that dont stand in the rules

What actually happened?

Error: The parent node must exist at nestingDepth (/node_modules/stylelint/lib/rules/max-nesting-depth/index.js:93:10) at checkStatement (node_modules/stylelint/lib/rules/max-nesting-depth/index.js:71:18) at node_modules/postcss/lib/container.js:96:18 at /node_modules/postcss/lib/container.js:55:18 at Root.each (node_modules/postcss/lib/container.js:41:16) at Root.walk (node_modules/postcss/lib/container.js:52:17) at Root.walkRules (node_modules/postcss/lib/container.js:94:19) at parent (node_modules/stylelint/lib/rules/max-nesting-depth/index.js:52:8) at node_modules/stylelint/lib/lintPostcssResult.js:113:8 at Array.map (<anonymous>)

Does the bug relate to non-standard syntax?

No response

Proposal to fix the bug

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@skepsys Thank you for digging into it some more.

We assume that syntaxes will provide a source, but it seems postcss-sass does not.

I’ll label as discussion as we can either:

  • fix this in our rules by returning early when source is missing, rather than throwing
  • marking this as an upstream issue in the postcss-sass syntax

Found interesting error, while disabling those rules, see this repo.

Seems, it’s easier to just migrate to SCSS by using stylelint-config-standard-scss which works just fine for me.

@skepsys Thank you for digging into it some more.

We assume that syntaxes will provide a source, but it seems postcss-sass does not.

I’ll label as discussion as we can either:

  • fix this in our rules by returning early when source is missing, rather than throwing
  • marking this as an upstream issue in the postcss-sass syntax