Skip to content
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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AliSajid
Copy link

@AliSajid AliSajid commented Dec 5, 2024

This pull request introduces a pre-commit hook for validating Browserslist configurations. The most important changes include the addition of a configuration file for the pre-commit hooks. There are also relevant additions to the README.md.

Pre-commit hook addition:

  • pre-commit-hooks.yaml: Defined a new hook, browserslist-lint, to validate Browserslist configurations using npx browserslist-linter. This hook is triggered by changes to .browserslistrc or package.json.

Documentation updates:

  • README.md: Added a section on the pre-commit hook, including instructions on how to add it to the pre-commit configuration.

Signed-off-by: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com>
@ai
Copy link
Member

ai commented Dec 5, 2024

For what tool we need this YAML file? Can you explain me a little more?

@AliSajid
Copy link
Author

AliSajid commented Dec 5, 2024

This yaml implementation is a part of the pre-commit configuration. pre-commit is an open source framework that lets people deploy different packages for checks before they commit something toa. git repository. It is widely adopted and is practically an industry standard.

You can see the following pre-commit enabled repositories:

The pre-commit-hooks.yaml file allows a pre-commit user to include browserslist-linting as a part of their workflow. It does not change anything in the package itself. An end user, such as myself, can then include this as part of their suite of pre-commit checks by the two lines as follows:

repos:
	repo: https://github.com/browserslist
	hooks:
		- id: browserslist-lint

pre-commit-hooks.yaml Outdated Show resolved Hide resolved
pre-commit-hooks.yaml Outdated Show resolved Hide resolved
pre-commit-hooks.yaml Outdated Show resolved Hide resolved
Co-authored-by: Andrey Sitnik <andrey@sitnik.ru>
@@ -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.
Copy link
Member

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.


```yaml
repos:
- repo: https://github.com/browserslist/lint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s use 2 space indents to have consistent code style

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants