-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add a pre-commit hook #8
Open
AliSajid
wants to merge
2
commits into
browserslist:main
Choose a base branch
from
AliSajid:pre-commit-hook
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,15 @@ Rules: | |
alt="Sponsored by Evil Martians" width="236" height="54"> | ||
</a> | ||
|
||
## 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let’s use 2 space indents to have consistent code style |
||
id: browserslist-lint | ||
``` | ||
|
||
## JS API | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-linter | ||
AliSajid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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)$ | ||
AliSajid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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-linter. | ||
AliSajid marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s add link here.
pre-commit
is a popular name, there are many projects with this name. People will now understand it without a link.