Skip to content

Add check-json5 as builtin hooks#1367

Merged
j178 merged 5 commits intomasterfrom
json5
Jan 16, 2026
Merged

Add check-json5 as builtin hooks#1367
j178 merged 5 commits intomasterfrom
json5

Conversation

@j178
Copy link
Owner

@j178 j178 commented Jan 16, 2026

Closes #823

@j178 j178 added the enhancement New feature or request label Jan 16, 2026
@github-actions
Copy link

github-actions bot commented Jan 16, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (22.3 MiB → 22.3 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 72.3KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 54.7KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.9KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 46.8KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.4KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.0KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.9KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.3% 27.6KiB         prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 21.6KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.3KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.1KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.8%  8.2MiB              And 19623 smaller methods. Use -n N to show more.
39.9% 100.0%  8.9MiB              .text section size, the file size is 22.3MiB

Base Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.9KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 53.3KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.4KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 47.0KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.4KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.7KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.3% 27.6KiB         prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.3KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.1KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.8%  8.1MiB              And 19605 smaller methods. Use -n N to show more.
39.9% 100.0%  8.9MiB              .text section size, the file size is 22.3MiB

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 97.36842% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (29464fb) to head (8f4f345).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ates/prek/src/hooks/pre_commit_hooks/check_toml.rs 0.00% 4 Missing ⚠️
crates/prek/src/hooks/builtin_hooks/check_json5.rs 98.70% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1367      +/-   ##
==========================================
+ Coverage   90.04%   90.23%   +0.19%     
==========================================
  Files          80       81       +1     
  Lines       15928    15952      +24     
==========================================
+ Hits        14342    14395      +53     
+ Misses       1586     1557      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@j178 j178 changed the title json5 Add check-json5 as builtin hooks Jan 16, 2026
@j178 j178 marked this pull request as ready for review January 16, 2026 06:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for check-json5 as a builtin hook to validate JSON5 files, addressing issue #823. JSON5 is an extension of JSON that allows comments, unquoted keys, trailing commas, and other features that make configuration files more human-friendly.

Changes:

  • Added check-json5 builtin hook with full validation support for JSON5 files
  • Refactored multiple hook implementations to use a new shared run_concurrent_file_checks helper function
  • Updated documentation to list the new check-json5 hook
  • Added comprehensive tests for the new hook

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/prek/src/hooks/builtin_hooks/check_json5.rs New module implementing JSON5 validation logic with unit tests
crates/prek/src/hooks/builtin_hooks/mod.rs Registered check-json5 hook in the builtin hooks enum and manifest
crates/prek/src/hooks/mod.rs Added reusable run_concurrent_file_checks helper function
crates/prek/tests/builtin_hooks.rs Added integration test for check-json5 hook
docs/builtin.md Updated documentation to include check-json5 in supported hooks list
Cargo.toml, crates/prek/Cargo.toml Added json5 dependency
Cargo.lock Lock file updates for json5 and ucd-trie dependencies
Multiple hook files Refactored to use new run_concurrent_file_checks helper

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"#};
let file_path = create_test_file(&dir, "duplicate.json5", content.as_bytes()).await?;
let (code, output) = check_file(dir.path(), &file_path).await?;
assert_eq!(code, 0);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test for duplicate keys expects the check to pass (code 0), but the check-json hook explicitly fails on duplicate keys. This inconsistency may be intentional if JSON5 allows duplicate keys by spec, but it should be documented. Consider adding a comment explaining why duplicate keys are acceptable in JSON5 but not in JSON, or if this is a limitation of the json5 library being used.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Jan 16, 2026

@j178 I've opened a new pull request, #1368, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Add documentation explaining duplicate key behavior in JSON5

Co-authored-by: j178 <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: j178 <[email protected]>
@j178 j178 merged commit 352685f into master Jan 16, 2026
17 checks passed
@j178 j178 deleted the json5 branch January 16, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please support check-json5?

3 participants