broccoli-sass-lint
raw JSON → 1.1.2 verified Fri May 01 auth: no javascript maintenance
A Broccoli plugin that provides pure Node.js scss/sass linting using sass-lint. Version 1.1.2 is the latest stable release with infrequent updates. It integrates seamlessly into Broccoli build pipelines, offering options for configuration, error handling, logging, custom test generation, and support for persistent filtering. Unlike CLI-based linters, this package is designed specifically for Broccoli-based projects.
Common errors
error Error: Cannot find module 'sass-lint' ↓
cause Missing sass-lint as a dependency
fix
Run npm install --save-dev sass-lint
error TypeError: SassLinter is not a constructor ↓
cause Using import instead of require, or incorrectly destructuring
fix
Use const SassLinter = require('broccoli-sass-lint');
Warnings
deprecated sass-lint package is deprecated; consider using stylelint with scss plugin instead ↓
fix Migrate to stylelint-config-standard-scss and broccoli-stylelint
gotcha If shouldThrowExceptions is false, errors will not stop the build, which may lead to uncaught lint errors ↓
fix Set shouldThrowExceptions: true to ensure errors break the build
breaking In version 1.1.0, the constructor API changed from accepting options as first argument to accepting input tree and options ↓
fix Use new SassLinter(inputTree, options) instead of new SassLinter(options)
Install
npm install broccoli-sass-lint yarn add broccoli-sass-lint pnpm add broccoli-sass-lint Imports
- SassLinter wrong
import SassLinter from 'broccoli-sass-lint';correctconst SassLinter = require('broccoli-sass-lint'); - SassLinter wrong
import { SassLinter } from 'broccoli-sass-lint';correctvar SassLinter = require('broccoli-sass-lint'); - SassLinter wrong
const { default: SassLinter } = require('broccoli-sass-lint');correctconst SassLinter = require('broccoli-sass-lint');
Quickstart
const SassLinter = require('broccoli-sass-lint');
const linter = new SassLinter('app/styles', {
configPath: '.sass-lint.yml',
shouldThrowExceptions: true,
shouldLog: true,
});
// In a Brocfile.js, export linter or use with broccoli mergeTrees
const broccoli = require('broccoli');
const tree = linter; // or merge with other trees
module.exports = tree;