-
Notifications
You must be signed in to change notification settings - Fork 42
build(lint): consolidate linters under pre-commit #903
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
base: main
Are you sure you want to change the base?
build(lint): consolidate linters under pre-commit #903
Conversation
Migrate all linting tools to pre-commit for unified local and CI execution. - Add .pre-commit-config.yaml with hooks for file checks, Python version consistency, EditorConfig, markdownlint-cli2, Ruff, mypy, and Mergify - Add conditional_hook.py wrapper for a graceful skip (with a warning) when requirements for linters (like Node.js for markdownlint-cli2) are not installed locally - Update Hatch lint environment with pre-commit integration - Rename .markdownlint-config.yaml to .markdownlint.yaml for markdownlint-cli2 compatibility - Update AGENTS.md and docs/develop.md with pre-commit documentation
0223c49 to
332cd1e
Compare
|
FWIW, I'm not a fan of pre-commit. I prefer to have linters and tests in the same automation tool, so I can run all checks in parallel from the same tool with a single command. I'm still maintaining my own |
@tiran This is what pre-commit does... You don't have to install the hooks, you can run |
| repos: | ||
| # --------------------------------------------------------------------------- | ||
| # 1. Standard file checks (fastest, run first) | ||
| # --------------------------------------------------------------------------- |
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.
Looks like some extra texts from AI agents?
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.
It's intentional, it's just comments that help visually notice different sections (there are more on top of each pre-commit
It explains why this is the first one, in case someone wants to move it.
I can remove it if it seems redundant, it's not that important.
Maybe looking at it here instead of the diff view will help.
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.
@MichaelYochpaz It is a nit pick, can you ask your AI agent to add only must have comments. We need comments only when the section is hard to understand, so that a comment will help with understanding if someone-going through it. Just not this instance of comments, but I saw some other comments which we do not actually need. Specially it is easier to understand why the code block is there with the help of a AI agent.
|
Pre-commit is a significant change in developer workflow, we can skip the pre-commit failures in the local workflow incase we want to focus on the code chnages initially i.e. |
|
Just to make sure it's clear - you are not required to install pre-commit as a git hook. It's opt-in and you have to install the hook manually locally by running Another way to use it (which is what I use, and is written in the README) is just by running it manually with |
|
We need a compelling reason why we should introduce yet another automation tool to run linters. Also I'm worried about
|
|
@tiran We already have pre-commit used here on Fromager. @dhellmann added it to the repo (Link #1, Link #2). I'm just consolidating the linters under the same tool, and making it easier to run the linters we only have on the CI, locally. I don't think line counts should be a metric. I've used a lot of comments and updated the What training would developers need? It's literally just a single command to run. |
This PR migrates all linting tools to pre-commit for unified local and CI execution.
This allows developers to run
hatch run lint:precommit(orpre-commit run) to check for lint issues locally and auto-fix them locally, or even install git pre-commit hooks that will auto-fix them before making a commit.Notes:
Super-Linterwhich had Markdown linting (already covered bymarkdownlint) and editorconfig validation (now covered byeditorconfig-checker) was removed..markdownlint-config.yamlconfig file was renamed to.markdownlint.yamlto follow the official naming convention, which is auto-used by the CLI tool used (reference). Beforehand the name was a "made up" name that was referenced by using--config .markdownlint-config.yaml.markdownlintrequired Node.js to work (we install it in the CI beforehand). The pre-commit implementation here makes so that it's required on the CI, but for local runs themarkdownlintcheck is skipped (with a warning) if Node.js isn't installed.