diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5cbfec49d8d..2d506f6dcf2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,16 +17,60 @@ repos: # Prevents commits to certain branches - id: no-commit-to-branch args: ["--branch", "master", "--branch", "beta", "--branch", "rc"] + # Checks that large files have not been added. Default cut-off for "large" files is 500kb. + - id: check-added-large-files + # POFiles and TTF fonts can't be made smaller + exclude_types: ["pofile", "ttf"] + # Same applies for NVDA dictionary (.dic) files and Spline Font Database (.SFD) files, but these aren't recognised by the Identify library. + exclude: "\\.(dic|sfd)$" # Checks python syntax - id: check-ast # File uses encoding not supported in Linux exclude: source/comInterfaces/_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py + # Checks for filenames that will conflict on case insensitive filesystems (the majority of Windows filesystems, most of the time) - id: check-case-conflict + # Checks for artifacts from resolving merge conflicts. - id: check-merge-conflict + # Checks Python files for debug statements, such as python's breakpoint function, or those inserted by some IDEs. + - id: debug-statements + # File uses encoding not supported in Linux + exclude: source/comInterfaces/_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py + # Removes trailing whitespace. - id: trailing-whitespace types_or: [python, c, c++, batch, markdown] + # Ensures all files end in 1 (and only 1) newline. - id: end-of-file-fixer types_or: [python, c, c++, batch, markdown] + # Removes the UTF-8 BOM from files that have it. + # See https://github.com/nvaccess/nvda/blob/master/projectDocs/dev/codingStandards.md#encoding + - id: fix-byte-order-marker + types_or: [python, c, c++, batch, markdown] + # Validates TOML files. + - id: check-toml + # Validates YAML files. + - id: check-yaml + # Validates XML files. + - id: check-xml + # Ensures that links to lines in files under version control point to a particular commit. + - id: check-vcs-permalinks + # Checks that tests are named test_*.py. + - id: name-tests-test + args: ["--unittest"] + # Exclude Python files under `tests/` that aren't unittest files. + # This is a Python verbose regular expression. + # See https://docs.python.org/3/library/re.html#re.VERBOSE + exclude: | + (?x)^tests/( + checkPot.py | # Doesn't use unittest + system | # Uses robot + unit/ ( + # Test helpers + textProvider.py | + extensionPointTestHelpers.py | + objectProvider.py | + test_speechManager/speechManagerTestHarness.py + ) + ) - repo: https://github.com/asottile/add-trailing-comma rev: v3.1.0