1
0
forked from mirrors/0ad

22 Commits

Author SHA1 Message Date
Dunedan 93ce94655d Use @stylistic/brace-style for eslint
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace
style for JavaScript code. This plugin was however updated the last time
over 9 years ago and will be incompatible with ESLint v10, as that
[removes `context.getSourceCode()`][1], the plugin relies on.

To keep the eslint config working with ESLint v10, this replaces
`eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule
from `@stylistic/eslint-plugin`, a package we already use.

While `@stylistic/brace-style` doesn't offer an option to format braces
in exactly the same way as before, the "allman" style seems to be the
one closest to the existing code.

[1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members
[2]: https://eslint.style/rules/brace-style
2026-01-12 21:33:52 +01:00
Dunedan f43f4ae1b1 Update the pre-commit hooks
With v3.12.0 shfmt changed the behavior of the `--simplify` option to
ignore any EditorConfig when it's provided. Therefore, this option is
now moved to the EditorConfig as suggested by the shfmt author. See
https://github.com/mvdan/sh/issues/1173 for details.
2025-08-22 13:04:38 +02:00
Ralph Sennhauser 58219b974c Fix trailing whitespace and add pre-commit hook
Some have their editor configured to remove trailing whitespace and
editing such a file would "fix" it, adding an unrelated change.

Fix whitespace violations excluding third party libs and generated files
like glad or patches.

Enable pre-commit hook trailing-whitespace to enforce it in the future.

Fixes: #8016
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-15 20:08:48 +02:00
Dunedan 638d4d28d2 Use the official eslint pre-commit hook
Recently eslint added official support for pre-commit, so let's use
their official pre-commit hook instead of a third-party one.
2025-06-11 13:22:44 +02:00
Itms 994645930c Move maps XML files out of LFS
Fixes #7519.

Reviewed-By: Dunedan
Reviewed-On: https://gitea.wildfiregames.com/0ad/0ad/pulls/8014
2025-06-11 10:33:57 +02:00
Ralph Sennhauser 0ce889ca6d Use stylistic for deprecated eslint rules
During the eslint 8 cycle the formatting rules were split out [1],
deprecating the corresponding rules in core.

This replaces all rules that where moved to @stylistic/eslint-plugin [2]
and accounts for the difference in the indenting rule behaviour.

To allow the pre-commit import hack to continue to work with the
stylisitc plugin for a recent nodejs version to be used.

[1] https://eslint.org/blog/2023/10/deprecating-formatting-rules/
[2] https://eslint.style/packages/default

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-10 21:23:23 +02:00
Ralph Sennhauser 02e15da51b Add eslint pre-commit hook
This replaces the old arclint eslint setup 1:1 rule wise, only porting
the configuration to a format recent eslint can read.

Further remove the arclint setup as it is no longer of use.

Thanks to Stan for reviewing all needed fixes to Javascript code to
allow for adding this without compromises.

Fixes: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-30 17:30:25 +02:00
Dunedan b42ea94c3c Update the pre-commit hooks 2025-05-26 17:19:03 +02:00
Dunedan d111d4cc84 Specify the NodeJS version for markdownlint
Running the markdownlint pre-commit hook as Gitea Action fails for
markdownlint >=0.38.0, as the NodeJS version available in the Act Runner
Docker image so too old for that. To solve this, this commit specifies a
newer NodeJS version to use.
2025-05-26 17:18:58 +02:00
Dunedan efdc1fab0a Add a pre-commit hook to check for large files
This checks there are no large files being committed, which aren't
stored in git-lfs.
2025-05-22 20:43:52 +02:00
Dunedan a92a4ff45c Update the pre-commit hooks 2025-01-11 21:44:52 +01:00
Ralph Sennhauser 28b0801e82 Print diff for ruff-format if check fails
It's a bit hard for contributors to figure out what ruff-format is
unhappy about if all they get is a return status of non zero. Enable
printing a diff with suggested changes with the pre-commit hook.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-12-30 06:23:22 +01:00
Ralph Sennhauser 36e1109624 Remove obsolete pre-commit excludes
With the removal of the premake sources all exclude directives in
.pre-commit-config.yaml are obsolete, so remove them.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-12-13 21:15:13 +01:00
Dunedan c0232c6b5f Specify the Python target version in ruff.toml
This ensures the same Python target version used for `ruff format`
is used for `ruff check` as well. It also allows ruff, even if it's not
run through pre-commit, to use the correct target Python version.
2024-09-21 20:54:24 +02:00
Ralph Sennhauser 966d859050 Add yamllint to pre-commit
Adding a hook to pre-commit to enforce a consistent style and remove the
hook check-yaml which only checks if a document is parsable and so
become redundant.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-09-08 13:08:11 +02:00
Ralph Sennhauser 87f667732c Format yaml files
The schema at https://json.schemastore.org/gitea-issue-forms.json
doesn't like empty titles, so just remove the key to the same effect as
a zero length string.

Add document start markers where they are missing.

Use a max line length of 100 as discussed with Dunedan.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-09-08 13:08:11 +02:00
Ralph Sennhauser 631f7b292e Add pre-commit hook for shellcheck
Using shellcheck-py[1] instead of the official shellcheck-precommit[2]
to avoid a dependency on docker.

[1] https://github.com/shellcheck-py/shellcheck-py
[2] https://github.com/koalaman/shellcheck-precommit

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-28 18:23:18 +02:00
Dunedan ae3fad73ce Add a markdownlint pre-commit hook
This adds a pre-commit hook to link Markdown files and fixes all
reported findings.
2024-08-27 10:06:31 +02:00
Ralph Sennhauser af6cda9073 Add shfmt to .pre-commit-config
Run shfmt as part of the ci workflow.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2024-08-26 09:03:00 +02:00
Dunedan c763c010b8 Add a bunch of additional pre-commit hooks 2024-08-26 07:46:41 +02:00
Dunedan 1f51fcb87f Add hook for non-breaking space in 0 A.D.
This replaces the existing arclint linter to ensure the project name
does only include a non-breaking space with a pre-commit hook. The regex
to check is slightly different to account for escaped non-breaking
spaces in JavaScript files and to avoid some false-positives.
2024-08-24 13:08:42 +02:00
Dunedan d055090dd2 Add ruff pre-commit hook
Add configuration for pre-commit, ruff as a hook and configuration to
run ruff whenever a pull request is opened or code is pushed.
2024-08-24 10:54:26 +02:00