-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Pre-commit] Expand Pre-commit Hooks #213
Comments
I don't know exactly what was wrong with the `Object.entries(...).forEach(([key, value]), () => {});` syntax, but `fixmyjs` kept complaining about an `Unexpected token =>` for this loop in particular, so we changed the loop to make it happy.
`jshint`: - Make `.jshint` configuration stricter. Notice that we disabled some of the rules that we can't force the TypeScript compiler to respect. `mypy`: - We disable `mypy` (temporarily) because it requires extensive fixes. Filed #215 to reenable it. - Ignore `.mypy_cache` in `.gitignore`, `stats.sh`, and `.helpers`. YAML Hooks - Add `yamllint` hook. - Add a `.yamlfmt` and `.yamllint` configuration files. Account for them in `stats.sh`. The files were required in order to make the two linters compatible. `.pre-commit-config.yaml` - Reformatted the file to accommodate the new linter requirements: - Add a document start, denoted by `---`. - Set the maximum line length to 80. Rewrite many strings, e.g. by removing the unnecessary quotes, or using the block scalar (denoted by `>` or `|`), or single quotes in order to enable splitting strings to multiple lines. NOTE: https://yaml-multiline.info/ explains YAML strings well. - Rewrote many of the `bash` scripts contained within the file, thanks to the newly-discovered YAML string powers: - Include `set -o nounset` in many of the `bash` scripts. - NOTE: check-do-not-submit` has been fixed. Fix #199. - Delete some redundant `types` specifications. - Delete the `.git` suffix from The paths of a couple of repos. - Changed the TODO about fail-fast to a NOTE because there is currently no action required. - Changed the TODO about installing more hooks from https://pre-commit.com/hooks.html to make it Python-specific, because we already acquired most of the other commits. `json-tool`: - Run on `.csslintrc` and `.jshintrc` as well. `typos`: - Add a new spell-checking hook. (It was problematic, but we're trying to retain it.) Security Hooks: - We add a few hooks that check for leaked secrets. Misc: - Where possible, add links to the configuration pages inside the hook config files. The links don't need to be added to `.pre-commit-config.yaml`, because it already has links to the rpos (albeit not directly to the config pages). But it's helpful to have links in such files as `.yamlfmt`, `.yamllint`, and `eslint.config.mjs`.
- Run most bash hooks with stricter options whenever possible. - Fix bug in commit-file-sizes. Use `"${@}"` in order to be able to handle files with spaces in their names. - Delete redundant `pass_filenames: true`. This is the default value. - Delete redundant `always_run: true`. This is the default behaviour when there are no filters. - Refactor `check-one-readme` to look only at new / modified files, rather than all files in the repo. - Some commands fail when `"${@}"` is empty, so we check for `"$#" == 0` before proceeding. This may be unnecessary in many cases, but we do it anyway. - `check-do-not-submit` mangles the regex instead of excluding `.pre-commit-config.yaml`.
TODO: Likely, the only thing left for this is adding some Python hooks (see). We want to add them (as we did for many others) just because they're recommended on pre-commit.com! I don't think we will have anything else to do for this issue afterwards. NOTE: There is also #215, which concerns |
This is to make it compatible with other Python tools that we are about to adopt.
Side change: - Remove an override of the name of `isort`.
The biggest change is the addition of trailing commas which, in combination with Black's interpretation of trailing commas, results in many parameter lists being spread over several lines instead of being compactly pressed on one line.[1] [1] https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#the-magic-trailing-comma
It conflicts with a standard library package[1], so our linters and formatters get really confused by it! [1] https://docs.python.org/3.9/library/parser.html
It's very unlikely to be used, given that we always mirror our GHSEET files to a local TSV before using them.
We were about to adopt this config for Tidy:
NOTE: It caused some issues with the |
- Unset `noreturnawait` for `jshint`. I don't fully understand the utility of this flag at this point, but it's causing some trouble. I don't know whether it's worth appeasing this flag, so I will simply unset it. - Add `Response` as a known global. P.S. `jshint` is so far useless, and hard to appease.
We open raw HTML files often. Prettifying them even further will be helpful to us. It's a huge commit, but we don't have concerns about commit sizes at the moment.
See the comment in `pre-commit-config.yaml` about fail fast.
The bug was introduced in 754d887. We moved the hook without moving its `exclude` parameter along with it.
- Introduce a new script, `dictionary/marcion.sourceforge.net/appendices.py`, that is responsible for all the appendices-related actions. Currently, the actions are downloading the sheets into the local mirrors, and validating the content. - The script replaces the following: - The Makefile recipe that downloads the sheets and performs some basic validation. The recipe has been replaced with a new recipe that simply calls the script mentioned above. - The logic in the Flashcards pipeline doesn't need to perform any validation, it can take the integrity of the data for granted thanks to the pre-commit hooks. Python is more versatile and suitable for this use case. This definitely didn't belong in a Makefile recipe! This is also consistent with the pattern that we have followed for Crum images.
This is the (main) reason they are not compatible: CSSLint/csslint#792.
The `clean-css` Hook was added in 94b69ae. It was implemented in JavaScript, not TypeScript, because the TypeScript package[^1] is outdated. We required a `clean-css` version >= 5.0 for our use case; in particularly, we want to assign numerical values for line breaks, not just a boolean (see `pre-commit/clean-css.js`). [^1] https://www.npmjs.com/package/@types/clean-css
The name is different on this machine, for some reason!
Notice that this requires modifying the `eslint` config in order to avoid conflict with the new hook.
Notice that this requires modifying the `eslint` config in order to avoid conflict with the new hook.
Time for some developer experience improvements!
The text was updated successfully, but these errors were encountered: