Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add .pre-commit-hooks.yaml file #13628

Merged
merged 4 commits into from Dec 14, 2020
Merged

Chore: Add .pre-commit-hooks.yaml file #13628

merged 4 commits into from Dec 14, 2020

Conversation

@mondeja
Copy link
Contributor

@mondeja mondeja commented Aug 28, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:

Add .pre-commit-hooks.yaml file to make work Eslint hooks whit pre-commit framework.

This allows users to configure a file in their project named .pre-commit-config.yaml with a content like, for example, this:

repos:
  - repo: https://github.com/eslint/eslint
    rev: master
    hooks:
      - id: eslint
        name: eslint-webpack-config
        files: webpack
        args: ['-c', 'webpack/.eslintrc.json']
      - id: eslint
        name: eslint-frontend
        files: static/src/js
        args: ['-c', 'static/src/js/.eslintrc.json']

...and every commit that users would attempt in their project will run two hooks to check Javascript files against Eslint. If any of the hooks fails, the commit will be aborted. The interesting part is that only files with changes will be linted.

See markdownlint-cli, flake8 or yamllint as other examples of linters that have been added the file without efforts.

Is there anything you'd like reviewers to focus on?

It's something that doesn't need maintainment, so you wouldn't need focus on.

@mondeja mondeja changed the title Add .pre-commit-hooks.yaml file New: Add .pre-commit-hooks.yaml file Aug 28, 2020
@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Sep 12, 2020

I'm not against adding this if it doesn't require any additional maintenance, though it feels like an inverse of responsibilities to me to put the onus on the other projects to include this definition rather than the project that will be consuming it.

Loading

@mondeja
Copy link
Contributor Author

@mondeja mondeja commented Sep 12, 2020

I understand you, close the pull if you don't feel comfortable with the file. It's only useful for the programmers that want to use the master of eslint in their hooks, but we can always settle for the mirror that uses pre-commit.

Loading

@nzakas nzakas changed the title New: Add .pre-commit-hooks.yaml file Chore: Add .pre-commit-hooks.yaml file Oct 7, 2020
nzakas
nzakas approved these changes Oct 7, 2020
Copy link
Member

@nzakas nzakas left a comment

Seems like a small enough change without any overhead, so okay by me.

Loading

@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Oct 10, 2020

Do we need to include this file in the published package on npm, or does this check the repo somehow?

Loading

@mondeja
Copy link
Contributor Author

@mondeja mondeja commented Oct 10, 2020

Only checks the repo, pre-commit clones repos to prepare environments for hooks.

Loading

nzakas
nzakas approved these changes Dec 14, 2020
@nzakas nzakas merged commit dc76911 into eslint:master Dec 14, 2020
12 checks passed
Loading
sthagen added a commit to sthagen/eslint-eslint that referenced this issue Dec 17, 2020
Chore: Add .pre-commit-hooks.yaml file (eslint#13628)
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants