Skip to content

feat: add a pre-commit hook#8

Merged
ai merged 3 commits intobrowserslist:mainfrom
AliSajid:pre-commit-hook
Feb 12, 2025
Merged

feat: add a pre-commit hook#8
ai merged 3 commits intobrowserslist:mainfrom
AliSajid:pre-commit-hook

Conversation

@AliSajid
Copy link
Contributor

@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
Contributor 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

Co-authored-by: Andrey Sitnik <andrey@sitnik.ru>
Signed-off-by: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com>
@ai
Copy link
Member

ai commented Feb 10, 2025

I am back :D

What do you think of moving it to https://github.com/browserslist/lint

If we add some linter it will be more relevant to use linter’s URL?

@AliSajid
Copy link
Contributor Author

I'm confused. Isn't this the browserslist/lint repository? I thought it was. If it's not, I'd be happy to move it.

@ai ai merged commit ecce1f8 into browserslist:main Feb 12, 2025
4 checks passed
@ai
Copy link
Member

ai commented Feb 12, 2025

Oh, too much work. I thought that it was Browserslist repo 😅.

Thanks, merged.

@AliSajid
Copy link
Contributor Author

Thank you! I appreciate the opportunity to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants