diff --git a/README.md b/README.md index 1382ff1..bc0480a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,15 @@ Rules: alt="Sponsored by Evil Martians" width="236" height="54"> +## Pre-Commit Hook + +This project is also available as a pre-commit hook. Please add the following to your pre-commit configuration. + +```yaml +repos: + - repo: https://github.com/browserslist/lint + id: browserslist-lint +``` ## JS API diff --git a/pre-commit-hooks.yaml b/pre-commit-hooks.yaml new file mode 100644 index 0000000..d268cc6 --- /dev/null +++ b/pre-commit-hooks.yaml @@ -0,0 +1,16 @@ +# Define the hooks available in this repository +- id: browserslist-lint + name: Validate Browserslist Configuration + # Command to execute the linter using npx for local installation + entry: npx browserslist-lint + # Specify the language for the hook; 'node' is used for npm-based tools + language: node + # Regular expression to match files that should trigger the hook + # The hook will run if `.browserslistrc` or `package.json` is modified + files: (\.browserslistrc|package\.json)$ + # Disable passing filenames as arguments since the linter inspects its own targets + pass_filenames: false + # Run the hook only when relevant files are modified, not always + always_run: false + # Description of the hook to inform users about its purpose + description: Validate Browserslist configuration using browserslist-lint.