git-style-lint
raw JSON → 1.1.14 verified Fri May 01 auth: no javascript
A tool that runs stylelint (currently for *.scss files) only on changed lines in a git repository, designed for pre-commit hooks. Version 1.1.14 requires Node.js v8.x or higher, with version for 6.x in progress. It differs from full-file linters by focusing only on modified lines, providing faster feedback in pre-commit workflows, and is specifically tailored for SCSS files.
Common errors
error Error: Cannot find module 'stylelint' ↓
cause stylelint not installed as a peer dependency
fix
npm install stylelint --save-dev
error SyntaxError: Unexpected token import ↓
cause Node.js version <8 doesn't support ES modules
fix
Use CommonJS: const gitStyleLint = require('git-style-lint') or upgrade Node.
Warnings
breaking Requires Node.js v8+; earlier versions unsupported. ↓
fix Upgrade Node.js to v8 or higher.
gotcha Only supports *.scss files currently, not CSS or other preprocessors. ↓
fix Ensure files are .scss or extend package to support other formats.
deprecated Version for Node.js v6.x was planned but never released; use v8+. ↓
fix Use Node.js >=8.
Install
npm install git-style-lint yarn add git-style-lint pnpm add git-style-lint Imports
- default wrong
const gitStyleLint = require('git-style-lint')correctimport gitStyleLint from 'git-style-lint' - lintStaged
import { lintStaged } from 'git-style-lint' - getChangedLines
import { getChangedLines } from 'git-style-lint' - type Options wrong
import { Options } from 'git-style-lint'correctimport type { Options } from 'git-style-lint'
Quickstart
import gitStyleLint from 'git-style-lint';
import stylelint from 'stylelint';
const result = await gitStyleLint({
files: ['src/**/*.scss'],
linter: stylelint.lint,
config: {
extends: 'stylelint-config-standard-scss'
}
});
console.log('Lint results:', result);