Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 .
6 changes: 3 additions & 3 deletions hk.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ local linters: Mapping<String, Step> = 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}}"
}
}

Expand Down
79 changes: 33 additions & 46 deletions mise.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
7 changes: 4 additions & 3 deletions src/Document.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
6 changes: 4 additions & 2 deletions src/Node.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 7 additions & 4 deletions src/parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 3 additions & 3 deletions src/tokenizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub const TokenResult = struct {
};

pub fn iterator(self: TokenResult) Iterator {
return Iterator{
return .{
.tokens = self,
.index = 0,
};
Expand Down Expand Up @@ -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");
4 changes: 2 additions & 2 deletions tools/check_snapshots.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const std = @import("std");

const RepositoryKind = enum { jj, git, unknown };

pub fn main(init: std.process.Init) !void {
Expand Down Expand Up @@ -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");
48 changes: 48 additions & 0 deletions zlint.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading