Registry / testing / stylelint-sass-render-errors

stylelint-sass-render-errors

JSON →
library4.1.3jsnpmunverified

A Stylelint plugin (v4.1.3) that displays Sass render errors and deprecations as lint errors. It integrates the Sass compiler (Dart Sass) into Stylelint, treating deprecations as errors to encourage code modernization. Unlike other Sass linting tools, it operates per file and supports modern Sass APIs (`compile`, `compileString`) with options for sync/async rendering, custom Sass options, and undefined function checking. Requires Node >=18.12, Stylelint >=14, and Dart Sass (peer dependency). Released actively with monthly or quarterly updates.

npm install stylelint-sass-render-errors
INSTALL
IMPORT
SIG · STYLELINT-SASS-REN
S
stylelint-sass-render-errors
testingjavascriptv4.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

stylelint-sass-render-errors (plugin)
plugins: ['stylelint-sass-render-errors']
plugins: ['stylelint-sass-render-errors/index.js']
In Stylelint config, reference the package name directly; no explicit import required in JS files.
rule 'plugin/sass-render-errors'
rules: { 'plugin/sass-render-errors': true }
rules: { 'sass-render-errors': true }
Rule names must be prefixed with 'plugin/' as per Stylelint plugin convention.
ESM import (if used programmatically)
import stylelintSassRenderErrors from 'stylelint-sass-render-errors'; stylelint.createPlugin(stylelintSassRenderErrors);
const stylelintSassRenderErrors = require('stylelint-sass-render-errors');
Since v4.0.0, the package is ESM-only; CommonJS require() will fail.

Configures the plugin to catch Sass deprecations and undefined functions, then lint an SCSS file.

// .stylelintrc.json { "plugins": ["stylelint-sass-render-errors"], "rules": { "plugin/sass-render-errors": [true, { "sync": false, "sassOptions": { "style": "expanded" }, "checkUndefinedFunctions": true, "disallowedKnownCssFunctions": ["lighten", "darken"], "additionalKnownCssFunctions": [] }] } } // Example SCSS that triggers an error: // _test.scss @use 'sass:color'; .foo { color: color.invert(1); // passing number to invert() is deprecated } // Run stylelint on the file: // npx stylelint _test.scss
Debug
Known issues
breakingv4.0.0 dropped CommonJS support; only ESM is supported.
fix
Use import syntax or update Node.js to >=18.12 and ensure your project uses ESM.
affects: >=4.0.0 <5.0.0
breakingv4.0.0 dropped support for Node <18.12 and Dart Sass <1.75.
fix
Upgrade Node to >=18.12 and Dart Sass to >=1.75.
affects: >=4.0.0
breakingv4.0.0 uses the new Sass JS API (compile/compileString) instead of the deprecated render.
fix
Ensure your Sass options are compatible with the new API; see Sass docs.
affects: >=4.0.0
deprecatedThe 'render' method is deprecated in Dart Sass 1.75+ and removed in later versions; plugin v4+ uses 'compile'.
fix
Use the new API; no action needed if using the plugin as-is.
affects: >=4.0.0
gotchaGlobal @import statements are not supported; the plugin operates per file.
fix
Switch to Sass modules (@use/@forward) for better isolation.
affects: >=1.0.0
gotchaUndefined function checking is off by default; you must explicitly enable checkUndefinedFunctions.
fix
Set checkUndefinedFunctions: true in plugin options.
affects: >=1.0.0
Errors
Common errors & fixes
Error: You gave us a `require` call, but this is an ES module. Please use `import` instead.
Using CommonJS require() with ESM-only package (v4+).
fix
Use ES module import syntax or convert your project to ESM.
SyntaxError: Named export 'default' not found. The requested module 'stylelint-sass-render-errors' is a CommonJS module; it may need a default import.
Incorrect import syntax when using the plugin programmatically.
fix
Use `import stylelintSassRenderErrors from 'stylelint-sass-render-errors'` (default import) or use plugin config as string.
Unknown rule: plugin/sass-render-errors
Plugin not loaded in Stylelint config.
fix
Add the plugin to the `plugins` array in .stylelintrc: `"plugins": ["stylelint-sass-render-errors"]`.
Upgrade
Version history
4.1.3latest on npm
Audit
Dependencies
stylelintrequiredPeer dependency: the plugin requires Stylelint 14, 15, or 16 to register rules and report errors.
sassrequiredImplied peer dependency: Dart Sass is used for rendering; the plugin does not bundle it.
Agent activity
5 hits · last 30 days
node
4
Resources
stylelint-sass-render-errors — npm install stylelint-sass-render-errors · libregistry