From cfc017b7078b3b71f6962cea213ef3c00b8daf4c Mon Sep 17 00:00:00 2001 From: Simon Hartcher Date: Sun, 25 Oct 2026 21:24:41 +1100 Subject: [PATCH] Add gdzig-zlint with the 0.6.1 ruleset --- .github/workflows/lint.yml | 33 ++++++++++++++++ hk.pkl | 6 +-- mise.lock | 79 ++++++++++++++++---------------------- mise.toml | 6 ++- src/Document.zig | 7 ++-- src/Node.zig | 6 ++- src/main.zig | 5 +-- src/parser.zig | 11 ++++-- src/tokenizer.zig | 6 +-- tools/check_snapshots.zig | 4 +- zlint.json | 48 +++++++++++++++++++++++ 11 files changed, 144 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 zlint.json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..9780bff --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: gdzig-zlint + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup mise + uses: jdx/mise-action@v2 + with: + install: false + cache: true + cache_save_post: true + + - name: Lint + run: mise exec -- gdzig-zlint . diff --git a/hk.pkl b/hk.pkl index 106d211..fe30daa 100644 --- a/hk.pkl +++ b/hk.pkl @@ -17,10 +17,10 @@ local linters: Mapping = new { check = "zig fmt --check {{files}}" fix = "zig fmt {{files}}" } - ["zlint"] = new Step { + ["gdzig-zlint"] = new Step { glob = List("*.zig") - check = "zlint --deny-warnings {{files}}" - fix = "zlint --deny-warnings --fix {{files}}" + check = "gdzig-zlint {{files}}" + fix = "gdzig-zlint --fix {{files}}" } } diff --git a/mise.lock b/mise.lock index 5902c81..05caeef 100644 --- a/mise.lock +++ b/mise.lock @@ -1,51 +1,38 @@ # @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html -[[tools."github:DonIsaac/zlint"]] -version = "0.7.9" -backend = "github:DonIsaac/zlint" - -[tools."github:DonIsaac/zlint"."platforms.linux-arm64"] -checksum = "sha256:fb73191c680ac9303605ba8a05974f06827c980ea593316abc00934c6bd17faf" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-linux-aarch64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295160" -provenance = "github-attestations" - -[tools."github:DonIsaac/zlint"."platforms.linux-arm64-musl"] -checksum = "sha256:fb73191c680ac9303605ba8a05974f06827c980ea593316abc00934c6bd17faf" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-linux-aarch64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295160" -provenance = "github-attestations" - -[tools."github:DonIsaac/zlint"."platforms.linux-x64"] -checksum = "sha256:388c501bfb8ffe0e4ffb5ac633b71c1b74e4465a0d1cf8cb2f23f99b08299a29" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-linux-x86_64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295161" -provenance = "github-attestations" - -[tools."github:DonIsaac/zlint"."platforms.linux-x64-musl"] -checksum = "sha256:388c501bfb8ffe0e4ffb5ac633b71c1b74e4465a0d1cf8cb2f23f99b08299a29" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-linux-x86_64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295161" -provenance = "github-attestations" - -[tools."github:DonIsaac/zlint"."platforms.macos-arm64"] -checksum = "sha256:39e49f1fba0ffa636082a317c2970d1c5fa4d5db3dd059569fbc95c808788f1f" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-macos-aarch64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295157" -provenance = "github-attestations" -provenance_verified = true - -[tools."github:DonIsaac/zlint"."platforms.macos-x64"] -checksum = "sha256:72b9abead168bd5d70a26de1da193a495f2ef243be80b02e41dfebdafb5345cf" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-macos-x86_64" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295159" -provenance = "github-attestations" - -[tools."github:DonIsaac/zlint"."platforms.windows-x64"] -checksum = "sha256:565a1b5847205920a63f300587a4c8bac6191e7ebd268260d60d521c42df3a76" -url = "https://github.com/DonIsaac/zlint/releases/download/v0.7.9/zlint-windows-x86_64.exe" -url_api = "https://api.github.com/repos/DonIsaac/zlint/releases/assets/273295158" -provenance = "github-attestations" +[[tools."github:gdzig/gdzig-zlint"]] +version = "0.6.1" +backend = "github:gdzig/gdzig-zlint" + +[tools."github:gdzig/gdzig-zlint"."platforms.linux-arm64"] +checksum = "sha256:8418802024eefa85669b728e3485f0b7a5fbc7bd812e20eb8474dfe1a44ece21" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-linux-aarch64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649152" + +[tools."github:gdzig/gdzig-zlint"."platforms.linux-arm64-musl"] +checksum = "sha256:8418802024eefa85669b728e3485f0b7a5fbc7bd812e20eb8474dfe1a44ece21" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-linux-aarch64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649152" + +[tools."github:gdzig/gdzig-zlint"."platforms.linux-x64"] +checksum = "sha256:1928e09077dc956eccf8426203d7d75d80596304936ca57d539b5d951626a401" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-linux-x86_64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649150" + +[tools."github:gdzig/gdzig-zlint"."platforms.linux-x64-musl"] +checksum = "sha256:1928e09077dc956eccf8426203d7d75d80596304936ca57d539b5d951626a401" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-linux-x86_64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649150" + +[tools."github:gdzig/gdzig-zlint"."platforms.macos-arm64"] +checksum = "sha256:c4e4f23e62b7bfb4284a12f567d53d132c11d092eea46e4efe029b7b199d91c8" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-macos-aarch64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649154" + +[tools."github:gdzig/gdzig-zlint"."platforms.macos-x64"] +checksum = "sha256:0bb149d34b0f719541ed4ce196770d1933306b22c281203e72261cbbd533a50b" +url = "https://github.com/gdzig/gdzig-zlint/releases/download/v0.6.1/gdzig-zlint-macos-x86_64" +url_api = "https://api.github.com/repos/gdzig/gdzig-zlint/releases/assets/674649156" [[tools.hk]] version = "1.42.0" diff --git a/mise.toml b/mise.toml index d391ef5..00a4d48 100644 --- a/mise.toml +++ b/mise.toml @@ -4,4 +4,8 @@ zls = "0.16.0" hk = "1.42.0" pkl = "0.30.0" yamllint = "1.38.0" -"github:DonIsaac/zlint" = "latest" +"github:gdzig/gdzig-zlint" = "0.6.1" + +[tasks.lint] +description = "Run gdzig-zlint with the repository rules" +run = "gdzig-zlint ." diff --git a/src/Document.zig b/src/Document.zig index a049712..819102f 100644 --- a/src/Document.zig +++ b/src/Document.zig @@ -160,7 +160,7 @@ pub fn print(self: Document, writer: anytype) !void { /// Returns: A new Walker for iterating through nodes /// Errors: OutOfMemory if walker initialization fails pub fn walk(self: Document, allocator: Allocator, order: Walker.TraversalOrder) !Walker { - return Walker.init(self, allocator, order); + return .init(self, allocator, order); } /// Tree walker for traversing all nodes in a document. @@ -280,10 +280,11 @@ pub const Walker = struct { } }; -const std = @import("std"); const Document = @This(); -const Node = @import("Node.zig"); +const std = @import("std"); const Allocator = std.mem.Allocator; + +const Node = @import("Node.zig"); const parser = @import("parser.zig"); const shared = @import("shared.zig"); const tokenizer = @import("tokenizer.zig"); diff --git a/src/Node.zig b/src/Node.zig index 493c548..fd961d9 100644 --- a/src/Node.zig +++ b/src/Node.zig @@ -340,8 +340,10 @@ pub const Iterator = struct { /// Args: /// opts: Configuration options including optional type filter /// Returns: A new Iterator for the children -pub fn iterator(self: Node, opts: struct { type: ?Type = null }) Iterator { - return Iterator{ +pub fn iterator(self: Node, opts: struct { + type: ?Type = null, +}) Iterator { + return .{ .type = opts.type, .node = self, .index = 0, diff --git a/src/main.zig b/src/main.zig index c0c3ff5..3da8cda 100644 --- a/src/main.zig +++ b/src/main.zig @@ -81,12 +81,11 @@ const usage = \\ ; -const renderDocument = lib.fmt.md.renderDocument; - +const std = @import("std"); const File = std.Io.File; const ArenaAllocator = std.heap.ArenaAllocator; const Level = std.log.Level; const Options = std.Options; -const std = @import("std"); const lib = @import("bbcodez"); +const renderDocument = lib.fmt.md.renderDocument; diff --git a/src/parser.zig b/src/parser.zig index c66419b..634d013 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -236,13 +236,16 @@ test "complex parsing" { // std.debug.print("Document: {s}\n", .{document}); } +const std = @import("std"); const testing = std.testing; -const Token = tokenizer.TokenResult.Token; const ArrayList = std.ArrayListUnmanaged; -const TokenResult = tokenizer.TokenResult; -const std = @import("std"); +const Document = @import("Document.zig"); + const Node = @import("Node.zig"); + const shared = @import("shared.zig"); -const Document = @import("Document.zig"); + const tokenizer = @import("tokenizer.zig"); +const Token = tokenizer.TokenResult.Token; +const TokenResult = tokenizer.TokenResult; diff --git a/src/tokenizer.zig b/src/tokenizer.zig index 365c242..992a228 100644 --- a/src/tokenizer.zig +++ b/src/tokenizer.zig @@ -201,7 +201,7 @@ pub const TokenResult = struct { }; pub fn iterator(self: TokenResult) Iterator { - return Iterator{ + return .{ .tokens = self, .index = 0, }; @@ -1189,8 +1189,8 @@ test "hypenated parameter" { try testing.expectEqual(null, it.next()); } -const StringHashMap = std.StringHashMapUnmanaged; - const std = @import("std"); +const StringHashMap = std.StringHashMapUnmanaged; const testing = std.testing; + const shared = @import("shared.zig"); diff --git a/tools/check_snapshots.zig b/tools/check_snapshots.zig index 069941d..4abb1d6 100644 --- a/tools/check_snapshots.zig +++ b/tools/check_snapshots.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const RepositoryKind = enum { jj, git, unknown }; pub fn main(init: std.process.Init) !void { @@ -164,3 +162,5 @@ fn fatal(io: std.Io, comptime fmt: []const u8, args: anytype) !void { try writer.interface.print(fmt, args); try writer.interface.flush(); } + +const std = @import("std"); diff --git a/zlint.json b/zlint.json new file mode 100644 index 0000000..9189285 --- /dev/null +++ b/zlint.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://raw.githubusercontent.com/DonIsaac/zlint/refs/tags/v0.10.0/zlint.schema.json", + "ignore": [ + "vendor/**", + "zig-out/**", + "zig-pkg/**", + ".zig-cache/**", + "**/src/linter/rules/snapshots/**" + ], + "rules": { + "gdzig-imports-sorted": [ + "warn", + { + "std_modules": [ + "std", + "builtin" + ] + } + ], + "gdzig-imports-placement": [ + "warn", + { + "position": "bottom" + } + ], + "gdzig-file-name-case": "warn", + "gdzig-import-alias-case": "warn", + "gdzig-tests-last": "warn", + "gdzig-trailing-comma": "warn", + "gdzig-public-docs": "warn", + "gdzig-inferred-initializers": "warn", + "gdzig-testing-usage": "warn", + "homeless-try": "error", + "no-unresolved": "off", + "unused-decls": "off", + "unsafe-undefined": "off", + "avoid-as": "off", + "no-print": "off", + "suppressed-errors": "off", + "line-length": [ + "warn", + { + "max_length": 120 + } + ], + "empty-file": "off" + } +}