Mirrors all* Stylelint releases for the pre-commit hooks framework.
Add the following to your .pre-commit-config.yaml
:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
Change rev to the stylelint version you want to use from the available versions as tags.
To use plugins or shared configurations with stylelint
, declare them (and stylelint) with additional_dependencies
:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
additional_dependencies:
# stylelint itself needs to be here when using additional_dependencies.
- stylelint@14.4.0
- stylelint-config-standard-scss@3.0.0
# Package names starting with `@` need to be quoted.
- "@scope/my-awesome-plugin@0.12.0"
Use pre-commit’s args
:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
args: [--report-needless-disables, --report-invalid-scope-disables]
Stylelint supports a --fix
option that will automatically fix the code. This requires the args
option:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
args: [--fix]
By default, this hook will run stylelint for the following file extensions: .css
, .sass
, .scss
. If you want to change this, use files
:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
files: \.(scss|vue)$
Compared to awebdeveloper/pre-commit-stylelint, this repository makes it possible to control the stylelint version with the rev
property. This tiny difference removes the guesswork of trying to understand how to set up the hook.
Switching is just a matter of updating the repo
, and setting a rev
for the desired version:
-- repo: https://github.com/awebdeveloper/pre-commit-stylelint
- rev: c4c991cd38b0218735858716b09924f8b20e3812
+- repo: https://github.com/thibaudcolas/pre-commit-stylelint
+ rev: v14.4.0
hooks:
- id: stylelint
* some versions of stylelint may be missing, though this isn’t the case as of June 2024 (v16.6.1 and below). This repository doesn’t automatically mirror patch releases to older versions of Stylelint, when they get released after another version with a "bigger" version number. If this happens, please open an issue so we manually add the release to the mirror.
As a temporary workaround, you can configure pre-commit to install from any arbitrary version of stylelint with additional_dependencies
:
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v14.4.0
hooks:
- id: stylelint
additional_dependencies:
# v14.16.43 isn’t available as a tag, so we instead load it directly from npm:
- stylelint@14.16.43
pre-commit itself has poor support for the Node ecosystem, preferring to install projects with git rather than using packages as published. Setting up a mirror completely sidesteps those issues, and results in much faster installation times.
See:
- Document pre-commit framework integration stylelint/stylelint#5373
- Add mirror for stylelint pre-commit/pre-commit#1768
- Suggestion: move pre-commit support to another repo prettier/prettier#8925
- Chore: Add .pre-commit-hooks.yaml file eslint/eslint#13628
This repository is based on mirrors-prettier, with the hook configuration options of awebdeveloper/pre-commit-stylelint.