From 9723a97a7e662a52b75603c19a63aa4e3e449667 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:40:48 +0000 Subject: [PATCH 01/25] Add JSON Schema validation tests for oxlintrc Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com> --- Cargo.lock | 512 +++++++++++++++++- crates/oxc_linter/Cargo.toml | 1 + .../invalid/env_wrong_type.json | 3 + .../invalid/invalid_category.json | 5 + .../invalid/invalid_plugin.json | 5 + .../invalid/invalid_severity.json | 5 + .../invalid/plugins_wrong_type.json | 3 + .../invalid/unknown_field.json | 3 + .../valid/basic_plugins.json | 7 + .../schema_validation/valid/empty_config.json | 1 + .../schema_validation/valid/env_config.json | 7 + .../schema_validation/valid/full_config.json | 35 ++ .../valid/ignore_patterns.json | 7 + .../schema_validation/valid/rules_config.json | 7 + .../valid/valid_categories.json | 7 + .../tests/schema_validation_test.rs | 124 +++++ libcheck_api.rlib | Bin 0 -> 5732 bytes 17 files changed, 721 insertions(+), 11 deletions(-) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/env_wrong_type.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_category.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_plugin.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_severity.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/plugins_wrong_type.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/basic_plugins.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/empty_config.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/env_config.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/rules_config.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json create mode 100644 crates/oxc_linter/tests/schema_validation_test.rs create mode 100644 libcheck_api.rlib diff --git a/Cargo.lock b/Cargo.lock index b361d6f0251f3..49be9bd821091 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,20 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "serde", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.4" @@ -56,6 +70,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.5.0" @@ -107,6 +127,21 @@ dependencies = [ "virtue", ] +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + [[package]] name = "bitflags" version = "2.10.0" @@ -173,6 +208,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + [[package]] name = "bytes" version = "1.10.1" @@ -531,6 +572,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-encoding" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" + [[package]] name = "deranged" version = "0.5.5" @@ -643,6 +690,15 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" +dependencies = [ + "serde", +] + [[package]] name = "encode_unicode" version = "1.0.0" @@ -703,6 +759,17 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "fancy-regex" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + [[package]] name = "fast-glob" version = "1.0.0" @@ -759,6 +826,17 @@ dependencies = [ "ref-cast", ] +[[package]] +name = "fluent-uri" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + [[package]] name = "fnv" version = "1.0.7" @@ -786,6 +864,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fraction" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f158e3ff0a1b334408dc9fb811cd99b446986f4d8b741bb08f9df1604085ae7" +dependencies = [ + "lazy_static", + "num", +] + [[package]] name = "futures" version = "0.3.31" @@ -903,9 +991,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "wasip2", + "wasm-bindgen", ] [[package]] @@ -1009,6 +1099,29 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.10.1" @@ -1024,6 +1137,51 @@ dependencies = [ "libm", ] +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "icu_collections" version = "2.1.1" @@ -1220,6 +1378,22 @@ dependencies = [ "walkdir", ] +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_ci" version = "1.2.0" @@ -1299,6 +1473,34 @@ dependencies = [ "memchr", ] +[[package]] +name = "jsonschema" +version = "0.37.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73c9ffb2b5c56d58030e1b532d8e8389da94590515f118cf35b5cb68e4764a7e" +dependencies = [ + "ahash", + "bytecount", + "data-encoding", + "email_address", + "fancy-regex", + "fraction", + "getrandom 0.3.4", + "idna", + "itoa", + "num-cmp", + "num-traits", + "percent-encoding", + "referencing", + "regex", + "regex-syntax", + "reqwest", + "serde", + "serde_json", + "unicode-general-category", + "uuid-simd", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -1407,7 +1609,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a7deb98ef9daaa7500324351a5bab7c80c644cfb86b4be0c4433b582af93510" dependencies = [ "bitflags", - "fluent-uri", + "fluent-uri 0.3.2", "percent-encoding", "serde", "serde_json", @@ -1447,6 +1649,17 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + [[package]] name = "napi" version = "3.8.1" @@ -1561,6 +1774,20 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -1571,6 +1798,21 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-cmp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1586,6 +1828,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-modular" version = "0.6.1" @@ -1601,6 +1854,17 @@ dependencies = [ "num-modular", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2045,6 +2309,7 @@ dependencies = [ "itertools", "javascript-globals", "json-strip-comments", + "jsonschema", "language-tags", "lazy-regex", "markdown", @@ -2899,6 +3164,21 @@ dependencies = [ "syn", ] +[[package]] +name = "referencing" +version = "0.37.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4283168a506f0dcbdce31c9f9cce3129c924da4c6bca46e46707fcb746d2d70c" +dependencies = [ + "ahash", + "fluent-uri 0.4.1", + "getrandom 0.3.4", + "hashbrown 0.16.0", + "parking_lot", + "percent-encoding", + "serde_json", +] + [[package]] name = "regex" version = "1.12.2" @@ -2928,6 +3208,40 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +[[package]] +name = "reqwest" +version = "0.12.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6eff9328d40131d43bd911d42d79eb6a47312002a4daefc9e37f17e74a7701a" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "ring" version = "0.17.14" @@ -3175,6 +3489,18 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha1" version = "0.10.6" @@ -3283,6 +3609,16 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" +[[package]] +name = "socket2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + [[package]] name = "sort-package-json" version = "0.0.7" @@ -3357,6 +3693,9 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -3471,8 +3810,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" dependencies = [ "bytes", + "libc", + "mio", "pin-project-lite", + "socket2", "tokio-macros", + "windows-sys 0.61.2", ] [[package]] @@ -3548,6 +3891,25 @@ dependencies = [ "futures-util", "pin-project-lite", "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", "tower-layer", "tower-service", ] @@ -3641,6 +4003,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.19.0" @@ -3653,6 +4021,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "unicode-general-category" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f" + [[package]] name = "unicode-id" version = "0.3.6" @@ -3767,6 +4141,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "uuid-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8" +dependencies = [ + "outref", + "vsimd", +] + [[package]] name = "valuable" version = "0.1.1" @@ -3822,6 +4206,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -3850,6 +4243,19 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.105" @@ -3882,6 +4288,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "web-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "1.0.4" @@ -4047,7 +4463,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -4056,7 +4472,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", ] [[package]] @@ -4074,14 +4499,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -4099,48 +4541,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + [[package]] name = "winnow" version = "0.7.13" diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index d9660995c7fe2..ed518c4eaba5e 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -76,5 +76,6 @@ url = { workspace = true } [dev-dependencies] insta = { workspace = true } +jsonschema = { version = "0.37" } markdown = { workspace = true } project-root = { workspace = true } diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/env_wrong_type.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/env_wrong_type.json new file mode 100644 index 0000000000000..f4ebc3bc54c4d --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/env_wrong_type.json @@ -0,0 +1,3 @@ +{ + "env": "not-an-object" +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_category.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_category.json new file mode 100644 index 0000000000000..9bd75be1d4cfd --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_category.json @@ -0,0 +1,5 @@ +{ + "categories": { + "invalid": "off" + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_plugin.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_plugin.json new file mode 100644 index 0000000000000..fb245477a8968 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_plugin.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + "invalid" + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_severity.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_severity.json new file mode 100644 index 0000000000000..5969bed9d2d15 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_severity.json @@ -0,0 +1,5 @@ +{ + "categories": { + "correctness": "invalid-severity" + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/plugins_wrong_type.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/plugins_wrong_type.json new file mode 100644 index 0000000000000..175ffc44e605a --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/plugins_wrong_type.json @@ -0,0 +1,3 @@ +{ + "plugins": "not-an-array" +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json new file mode 100644 index 0000000000000..6faa2eb2ee0ec --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json @@ -0,0 +1,3 @@ +{ + "unknownField": true +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/basic_plugins.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/basic_plugins.json new file mode 100644 index 0000000000000..e9fa8e688576e --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/basic_plugins.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "import", + "typescript", + "unicorn" + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/empty_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/empty_config.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/empty_config.json @@ -0,0 +1 @@ +{} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/env_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/env_config.json new file mode 100644 index 0000000000000..5c9b772d3549e --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/env_config.json @@ -0,0 +1,7 @@ +{ + "env": { + "browser": true, + "node": true, + "es2021": true + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json new file mode 100644 index 0000000000000..50b12f200caa5 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json @@ -0,0 +1,35 @@ +{ + "plugins": [ + "import", + "typescript", + "unicorn" + ], + "env": { + "browser": true + }, + "globals": { + "foo": "readonly" + }, + "settings": {}, + "rules": { + "eqeqeq": "warn", + "import/no-cycle": "error", + "react/self-closing-comp": [ + "error", + { + "html": false + } + ] + }, + "overrides": [ + { + "files": [ + "*.test.ts", + "*.spec.ts" + ], + "rules": { + "@typescript-eslint/no-explicit-any": "off" + } + } + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json new file mode 100644 index 0000000000000..a09859d6ed047 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json @@ -0,0 +1,7 @@ +{ + "ignorePatterns": [ + "dist", + "node_modules", + "*.min.js" + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/rules_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/rules_config.json new file mode 100644 index 0000000000000..1996555324806 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/rules_config.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-unused-vars": "error", + "eqeqeq": ["warn"], + "no-console": ["error", { "allow": ["warn", "error"] }] + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json new file mode 100644 index 0000000000000..71616c6c7f3ff --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json @@ -0,0 +1,7 @@ +{ + "categories": { + "correctness": "warn", + "suspicious": "error", + "pedantic": "off" + } +} diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs new file mode 100644 index 0000000000000..a7270fd123e06 --- /dev/null +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -0,0 +1,124 @@ +//! Test to ensure JSON Schema validation is working correctly +//! +//! This test validates that the generated JSON schema for oxlintrc configuration +//! files correctly validates both valid and invalid configurations. This helps +//! prevent regressions in the schema generation process. + +use std::fs; +use std::path::PathBuf; + +use jsonschema::Validator; +use oxc_linter::Oxlintrc; +use project_root::get_project_root; + +/// Get the path to the test fixtures directory +fn get_fixtures_path() -> PathBuf { + get_project_root() + .unwrap() + .join("crates/oxc_linter/tests/fixtures/schema_validation") +} + +/// Load the generated JSON schema +fn load_schema() -> Validator { + let schema_json = Oxlintrc::generate_schema_json(); + let schema: serde_json::Value = serde_json::from_str(&schema_json) + .expect("Failed to parse generated schema as JSON"); + + Validator::new(&schema) + .expect("Failed to compile JSON schema") +} + +/// Test that valid configuration files pass schema validation +#[test] +fn test_valid_configs_pass_validation() { + let schema = load_schema(); + let valid_dir = get_fixtures_path().join("valid"); + + let test_files = [ + "basic_plugins.json", + "valid_categories.json", + "full_config.json", + "env_config.json", + "rules_config.json", + "ignore_patterns.json", + "empty_config.json", + ]; + + for file_name in &test_files { + let file_path = valid_dir.join(file_name); + let content = fs::read_to_string(&file_path) + .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); + + let instance: serde_json::Value = serde_json::from_str(&content) + .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); + + // Use iter_errors to get all validation errors + let errors: Vec<_> = schema.iter_errors(&instance).collect(); + + if !errors.is_empty() { + let error_messages: Vec = errors + .iter() + .map(|e| format!(" - {}", e)) + .collect(); + panic!( + "Valid config '{}' failed schema validation:\n{}", + file_name, + error_messages.join("\n") + ); + } + } +} + +/// Test that invalid configuration files fail schema validation +#[test] +fn test_invalid_configs_fail_validation() { + let schema = load_schema(); + let invalid_dir = get_fixtures_path().join("invalid"); + + let test_files = [ + "invalid_plugin.json", + "invalid_category.json", + "invalid_severity.json", + "plugins_wrong_type.json", + // NOTE: "unknown_field.json" is removed because JSON Schema Draft 7 + // allows additional properties by default unless explicitly forbidden + "env_wrong_type.json", + ]; + + for file_name in &test_files { + let file_path = invalid_dir.join(file_name); + let content = fs::read_to_string(&file_path) + .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); + + let instance: serde_json::Value = serde_json::from_str(&content) + .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); + + // Use iter_errors to check for validation errors + let errors: Vec<_> = schema.iter_errors(&instance).collect(); + + assert!( + !errors.is_empty(), + "Invalid config '{}' unexpectedly passed schema validation", + file_name + ); + } +} + +/// Test that the schema itself is valid JSON Schema Draft 7 +#[test] +fn test_schema_is_valid() { + let schema_json = Oxlintrc::generate_schema_json(); + let schema: serde_json::Value = serde_json::from_str(&schema_json) + .expect("Failed to parse generated schema as JSON"); + + // Check that the schema has the expected $schema field + assert_eq!( + schema.get("$schema").and_then(|v| v.as_str()), + Some("http://json-schema.org/draft-07/schema#"), + "Schema should declare JSON Schema Draft 7" + ); + + // Check that we can compile it (this validates the schema structure) + Validator::new(&schema) + .expect("Generated schema should be valid JSON Schema"); +} diff --git a/libcheck_api.rlib b/libcheck_api.rlib new file mode 100644 index 0000000000000000000000000000000000000000..b6d61bceb29718a6e5669ecd380fc5124d14e3fa GIT binary patch literal 5732 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 G%Krn;MIO%p literal 0 HcmV?d00001 From 6f78aba5c775725acd79cb1532375a08740dad4c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:41:26 +0000 Subject: [PATCH 02/25] Remove accidentally committed rlib file Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com> --- libcheck_api.rlib | Bin 5732 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 libcheck_api.rlib diff --git a/libcheck_api.rlib b/libcheck_api.rlib deleted file mode 100644 index b6d61bceb29718a6e5669ecd380fc5124d14e3fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5732 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 G%Krn;MIO%p From 627094c256def2a6d83892e6c7b772bb18955fa1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:42:25 +0000 Subject: [PATCH 03/25] Update .gitignore to exclude Rust build artifacts Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com> --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 90eb6dbb41f8d..aad5e555b1a88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Rust target/ **/*.rs.bk +*.rlib +*.a +*.o # Wasm **/*.wasm From 67483fa1de20d8415860e550b07220b6708351f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:43:24 +0000 Subject: [PATCH 04/25] Format schema validation test file --- .../tests/schema_validation_test.rs | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index a7270fd123e06..c8f523b3ed0d4 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -13,19 +13,16 @@ use project_root::get_project_root; /// Get the path to the test fixtures directory fn get_fixtures_path() -> PathBuf { - get_project_root() - .unwrap() - .join("crates/oxc_linter/tests/fixtures/schema_validation") + get_project_root().unwrap().join("crates/oxc_linter/tests/fixtures/schema_validation") } /// Load the generated JSON schema fn load_schema() -> Validator { let schema_json = Oxlintrc::generate_schema_json(); - let schema: serde_json::Value = serde_json::from_str(&schema_json) - .expect("Failed to parse generated schema as JSON"); - - Validator::new(&schema) - .expect("Failed to compile JSON schema") + let schema: serde_json::Value = + serde_json::from_str(&schema_json).expect("Failed to parse generated schema as JSON"); + + Validator::new(&schema).expect("Failed to compile JSON schema") } /// Test that valid configuration files pass schema validation @@ -33,7 +30,7 @@ fn load_schema() -> Validator { fn test_valid_configs_pass_validation() { let schema = load_schema(); let valid_dir = get_fixtures_path().join("valid"); - + let test_files = [ "basic_plugins.json", "valid_categories.json", @@ -43,23 +40,20 @@ fn test_valid_configs_pass_validation() { "ignore_patterns.json", "empty_config.json", ]; - + for file_name in &test_files { let file_path = valid_dir.join(file_name); let content = fs::read_to_string(&file_path) .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); - + let instance: serde_json::Value = serde_json::from_str(&content) .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); - + // Use iter_errors to get all validation errors let errors: Vec<_> = schema.iter_errors(&instance).collect(); - + if !errors.is_empty() { - let error_messages: Vec = errors - .iter() - .map(|e| format!(" - {}", e)) - .collect(); + let error_messages: Vec = errors.iter().map(|e| format!(" - {}", e)).collect(); panic!( "Valid config '{}' failed schema validation:\n{}", file_name, @@ -74,7 +68,7 @@ fn test_valid_configs_pass_validation() { fn test_invalid_configs_fail_validation() { let schema = load_schema(); let invalid_dir = get_fixtures_path().join("invalid"); - + let test_files = [ "invalid_plugin.json", "invalid_category.json", @@ -84,18 +78,18 @@ fn test_invalid_configs_fail_validation() { // allows additional properties by default unless explicitly forbidden "env_wrong_type.json", ]; - + for file_name in &test_files { let file_path = invalid_dir.join(file_name); let content = fs::read_to_string(&file_path) .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); - + let instance: serde_json::Value = serde_json::from_str(&content) .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); - + // Use iter_errors to check for validation errors let errors: Vec<_> = schema.iter_errors(&instance).collect(); - + assert!( !errors.is_empty(), "Invalid config '{}' unexpectedly passed schema validation", @@ -108,17 +102,16 @@ fn test_invalid_configs_fail_validation() { #[test] fn test_schema_is_valid() { let schema_json = Oxlintrc::generate_schema_json(); - let schema: serde_json::Value = serde_json::from_str(&schema_json) - .expect("Failed to parse generated schema as JSON"); - + let schema: serde_json::Value = + serde_json::from_str(&schema_json).expect("Failed to parse generated schema as JSON"); + // Check that the schema has the expected $schema field assert_eq!( schema.get("$schema").and_then(|v| v.as_str()), Some("http://json-schema.org/draft-07/schema#"), "Schema should declare JSON Schema Draft 7" ); - + // Check that we can compile it (this validates the schema structure) - Validator::new(&schema) - .expect("Generated schema should be valid JSON Schema"); + Validator::new(&schema).expect("Generated schema should be valid JSON Schema"); } From 8471c37304c30d495647a783c8877bc41711a0c7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:44:34 +0000 Subject: [PATCH 05/25] Remove unused unknown_field.json test fixture Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com> --- .../fixtures/schema_validation/invalid/unknown_field.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json deleted file mode 100644 index 6faa2eb2ee0ec..0000000000000 --- a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/unknown_field.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unknownField": true -} From 118bcb5e0f3b2792f8d9cb14a8f9c782297f0baf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:56:31 +0000 Subject: [PATCH 06/25] Address PR feedback and fix clippy warnings - Remove *.a and *.o from .gitignore (not needed) - Add more patterns to ignore_patterns.json test fixture including **/*.ts - Add jsPlugins configuration to full_config.json test fixture - Fix clippy uninlined_format_args warnings in test file Co-authored-by: connorshea <2977353+connorshea@users.noreply.github.com> --- .gitignore | 2 -- .../schema_validation/valid/full_config.json | 4 ++++ .../schema_validation/valid/ignore_patterns.json | 3 ++- .../oxc_linter/tests/schema_validation_test.rs | 16 +++++++--------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index aad5e555b1a88..643970e7c57ba 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,6 @@ target/ **/*.rs.bk *.rlib -*.a -*.o # Wasm **/*.wasm diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json index 50b12f200caa5..239d559dee821 100644 --- a/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/full_config.json @@ -4,6 +4,10 @@ "typescript", "unicorn" ], + "jsPlugins": [ + "eslint-plugin-foo", + "eslint-plugin-bar" + ], "env": { "browser": true }, diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json index a09859d6ed047..a8d64cb415d2e 100644 --- a/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/ignore_patterns.json @@ -2,6 +2,7 @@ "ignorePatterns": [ "dist", "node_modules", - "*.min.js" + "*.min.js", + "**/*.ts" ] } diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index c8f523b3ed0d4..8de15c3184dff 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -44,19 +44,18 @@ fn test_valid_configs_pass_validation() { for file_name in &test_files { let file_path = valid_dir.join(file_name); let content = fs::read_to_string(&file_path) - .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); + .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); let instance: serde_json::Value = serde_json::from_str(&content) - .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); + .unwrap_or_else(|e| panic!("Failed to parse {file_name} as JSON: {e}")); // Use iter_errors to get all validation errors let errors: Vec<_> = schema.iter_errors(&instance).collect(); if !errors.is_empty() { - let error_messages: Vec = errors.iter().map(|e| format!(" - {}", e)).collect(); + let error_messages: Vec = errors.iter().map(|e| format!(" - {e}")).collect(); panic!( - "Valid config '{}' failed schema validation:\n{}", - file_name, + "Valid config '{file_name}' failed schema validation:\n{}", error_messages.join("\n") ); } @@ -82,18 +81,17 @@ fn test_invalid_configs_fail_validation() { for file_name in &test_files { let file_path = invalid_dir.join(file_name); let content = fs::read_to_string(&file_path) - .unwrap_or_else(|e| panic!("Failed to read {}: {}", file_name, e)); + .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); let instance: serde_json::Value = serde_json::from_str(&content) - .unwrap_or_else(|e| panic!("Failed to parse {} as JSON: {}", file_name, e)); + .unwrap_or_else(|e| panic!("Failed to parse {file_name} as JSON: {e}")); // Use iter_errors to check for validation errors let errors: Vec<_> = schema.iter_errors(&instance).collect(); assert!( !errors.is_empty(), - "Invalid config '{}' unexpectedly passed schema validation", - file_name + "Invalid config '{file_name}' unexpectedly passed schema validation" ); } } From 34a25fe6343d153bb1686f74c930cd0c69318b1b Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:05:03 -0700 Subject: [PATCH 07/25] Add a few more test files to the schema validation tests. --- .../invalid/globals_writeable_not_allowed.json | 5 +++++ .../schema_validation/invalid/globals_wrong_value.json | 5 +++++ .../fixtures/schema_validation/valid/globals_config.json | 7 +++++++ crates/oxc_linter/tests/schema_validation_test.rs | 3 +++ 4 files changed, 20 insertions(+) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_writeable_not_allowed.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_wrong_value.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/globals_config.json diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_writeable_not_allowed.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_writeable_not_allowed.json new file mode 100644 index 0000000000000..cbad0f235d177 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_writeable_not_allowed.json @@ -0,0 +1,5 @@ +{ + "globals": { + "Foo": "writeable" + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_wrong_value.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_wrong_value.json new file mode 100644 index 0000000000000..aded9ebc69ee1 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/globals_wrong_value.json @@ -0,0 +1,5 @@ +{ + "globals": { + "Foo": "foobar" + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/globals_config.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/globals_config.json new file mode 100644 index 0000000000000..67cf3076bb7af --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/globals_config.json @@ -0,0 +1,7 @@ +{ + "globals": { + "Foo": "writable", + "Bar": "readonly", + "Baz": "off" + } +} diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 8de15c3184dff..9f7d9380c1e80 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -35,6 +35,7 @@ fn test_valid_configs_pass_validation() { "basic_plugins.json", "valid_categories.json", "full_config.json", + "globals_config.json", "env_config.json", "rules_config.json", "ignore_patterns.json", @@ -73,6 +74,8 @@ fn test_invalid_configs_fail_validation() { "invalid_category.json", "invalid_severity.json", "plugins_wrong_type.json", + "globals_wrong_value.json", + "globals_writeable_not_allowed.json", // NOTE: "unknown_field.json" is removed because JSON Schema Draft 7 // allows additional properties by default unless explicitly forbidden "env_wrong_type.json", From e0fb06e45351230e8dd0001119e28b00d12207a0 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:08:21 -0700 Subject: [PATCH 08/25] Ensure all categories are included in the valid categories test file. --- .../fixtures/schema_validation/valid/valid_categories.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json index 71616c6c7f3ff..2e75a9c280a56 100644 --- a/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_categories.json @@ -2,6 +2,10 @@ "categories": { "correctness": "warn", "suspicious": "error", - "pedantic": "off" + "pedantic": "off", + "style": "warn", + "perf": "error", + "nursery": "error", + "restriction": "off" } } From 4ad294d69fdfd40ccd9a8f8f3f558e00e3fd7d3b Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:14:08 -0700 Subject: [PATCH 09/25] Simplify the schema loading by grabbing the schema from the repo. --- .../tests/schema_validation_test.rs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 9f7d9380c1e80..116ffe642522d 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -8,7 +8,6 @@ use std::fs; use std::path::PathBuf; use jsonschema::Validator; -use oxc_linter::Oxlintrc; use project_root::get_project_root; /// Get the path to the test fixtures directory @@ -16,11 +15,19 @@ fn get_fixtures_path() -> PathBuf { get_project_root().unwrap().join("crates/oxc_linter/tests/fixtures/schema_validation") } -/// Load the generated JSON schema +fn schema_content() -> String { + // Load the generated schema from the expected location + let schema_json = get_project_root() + .unwrap() + .join("npm/oxlint/configuration_schema.json"); + + fs::read_to_string(&schema_json).expect("Failed to read generated schema") +} + +/// Load the JSON schema from 'npm/oxlint/configuration_schema.json' fn load_schema() -> Validator { - let schema_json = Oxlintrc::generate_schema_json(); let schema: serde_json::Value = - serde_json::from_str(&schema_json).expect("Failed to parse generated schema as JSON"); + serde_json::from_str(&schema_content()).expect("Failed to parse generated schema as JSON"); Validator::new(&schema).expect("Failed to compile JSON schema") } @@ -69,6 +76,9 @@ fn test_invalid_configs_fail_validation() { let schema = load_schema(); let invalid_dir = get_fixtures_path().join("invalid"); + // TODO: Add another invalid test case to ensure that unknown fields are caught. + // `additionalProperties` needs to be set to false for this to work and we need + // to explicitly allow the "$schema" field. let test_files = [ "invalid_plugin.json", "invalid_category.json", @@ -76,8 +86,6 @@ fn test_invalid_configs_fail_validation() { "plugins_wrong_type.json", "globals_wrong_value.json", "globals_writeable_not_allowed.json", - // NOTE: "unknown_field.json" is removed because JSON Schema Draft 7 - // allows additional properties by default unless explicitly forbidden "env_wrong_type.json", ]; @@ -102,9 +110,8 @@ fn test_invalid_configs_fail_validation() { /// Test that the schema itself is valid JSON Schema Draft 7 #[test] fn test_schema_is_valid() { - let schema_json = Oxlintrc::generate_schema_json(); let schema: serde_json::Value = - serde_json::from_str(&schema_json).expect("Failed to parse generated schema as JSON"); + serde_json::from_str(&schema_content()).expect("Failed to parse generated schema as JSON"); // Check that the schema has the expected $schema field assert_eq!( From b8c5b5d48d53e7cda03bba931db2b40f79c7c625 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:15:13 +0000 Subject: [PATCH 10/25] [autofix.ci] apply automated fixes --- crates/oxc_linter/tests/schema_validation_test.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 116ffe642522d..08aea93dce64f 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -17,9 +17,7 @@ fn get_fixtures_path() -> PathBuf { fn schema_content() -> String { // Load the generated schema from the expected location - let schema_json = get_project_root() - .unwrap() - .join("npm/oxlint/configuration_schema.json"); + let schema_json = get_project_root().unwrap().join("npm/oxlint/configuration_schema.json"); fs::read_to_string(&schema_json).expect("Failed to read generated schema") } From e06985e07eaa94dc25530f3454ca91e187d2ae10 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:23:20 -0700 Subject: [PATCH 11/25] Add a few more complex configs to the fixtures. --- .../valid/combined_sources.json | 79 ++++++++++++++ .../valid/complex_nested.json | 101 ++++++++++++++++++ .../valid/extends_and_overrides.json | 61 +++++++++++ .../tests/schema_validation_test.rs | 3 + 4 files changed, 244 insertions(+) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/combined_sources.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/complex_nested.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/extends_and_overrides.json diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/combined_sources.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/combined_sources.json new file mode 100644 index 0000000000000..a69509b2c1c93 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/combined_sources.json @@ -0,0 +1,79 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "env": { + "browser": true, + "node": true + }, + "globals": { + "globalThis": "readonly", + "window": "readonly" + }, + "plugins": [ + "typescript", + "jest", + "unicorn" + ], + "rules": { + "curly": [ + "error", + "all" + ], + "no-shadow": "warn", + "jest/valid-title": "warn", + "unicorn/prefer-string-replace-all": "warn", + "typescript/no-explicit-any": "off" + }, + "overrides": [ + { + "files": [ + "src/**" + ], + "env": { + "browser": true + }, + "rules": { + "no-console": [ + "warn", + { + "allow": [ + "warn", + "error" + ] + } + ] + } + }, + { + "files": [ + "server/**" + ], + "env": { + "node": true + }, + "globals": { + "__dirname": "readonly" + }, + "rules": { + "no-console": "off", + "unicorn/no-process-exit": "off" + } + }, + { + "files": [ + "tests/**" + ], + "env": { + "jest": true + }, + "rules": { + "jest/no-identical-title": "error", + "jest/no-conditional-expect": "warn" + } + } + ], + "ignorePatterns": [ + "**/.cache/**", + "**/dist/**", + "**/coverage/**" + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/complex_nested.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/complex_nested.json new file mode 100644 index 0000000000000..575eb426657d8 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/complex_nested.json @@ -0,0 +1,101 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "typescript", + "jest", + "unicorn" + ], + "env": { + "browser": true, + "node": true, + "jest": true + }, + "globals": { + "__DEV__": "readonly", + "process": "readonly", + "Buffer": "readonly" + }, + "ignorePatterns": [ + "**/dist/**", + "**/build/**", + "**/.cache/**", + "coverage/**" + ], + "rules": { + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], + "no-console": [ + "warn", + { + "allow": [ + "warn", + "error" + ] + } + ], + "eqeqeq": "error", + "unicorn/prefer-query-selector": "off", + "jest/no-disabled-tests": "warn", + "typescript/no-explicit-any": [ + "warn", + { + "ignoreRestArgs": true + } + ] + }, + "overrides": [ + { + "files": [ + "**/*.ts", + "**/*.tsx" + ], + "env": { + "browser": true + }, + "rules": { + "typescript/explicit-module-boundary-types": "off", + "typescript/no-non-null-assertion": "warn" + } + }, + { + "files": [ + "**/*.test.ts", + "**/*.spec.ts" + ], + "env": { + "jest": true + }, + "rules": { + "no-console": "off", + "jest/expect-expect": [ + "warn", + { + "assertFunctionNames": [ + "expect" + ] + } + ] + } + }, + { + "files": [ + "scripts/**" + ], + "env": { + "node": true + }, + "globals": { + "__DEV__": "writable" + }, + "rules": { + "no-process-exit": "off", + "no-console": "off" + } + } + ] +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/extends_and_overrides.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/extends_and_overrides.json new file mode 100644 index 0000000000000..fb9dbe2a0a0f7 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/extends_and_overrides.json @@ -0,0 +1,61 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "extends": [ + "oxlint:recommended", + "plugin:typescript/recommended", + "plugin:unicorn/recommended" + ], + "plugins": [ + "typescript", + "unicorn" + ], + "rules": { + "no-debugger": "error", + "no-alert": "error" + }, + "overrides": [ + { + "files": [ + "**/*.js" + ], + "rules": { + "typescript/no-explicit-any": "off", + "unicorn/filename-case": [ + "warn", + { + "case": "kebabCase" + } + ] + } + }, + { + "files": [ + "**/*.ts", + "**/*.tsx" + ], + "env": { + "browser": true + }, + "rules": { + "no-unused-vars": [ + "warn", + { + "vars": "all", + "args": "none" + } + ], + "typescript/no-explicit-any": [ + "warn", + { + "ignoreRestArgs": true + } + ] + } + } + ], + "ignorePatterns": [ + "**/vendor/**", + "**/fixtures/**", + "**/generated/**" + ] +} diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 08aea93dce64f..a51613c44e2a6 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -45,6 +45,9 @@ fn test_valid_configs_pass_validation() { "rules_config.json", "ignore_patterns.json", "empty_config.json", + "complex_nested.json", + "extends_and_overrides.json", + "combined_sources.json", ]; for file_name in &test_files { From 4ff6a10737c01a46aebb09e4810216554b02f5a0 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:27:23 -0700 Subject: [PATCH 12/25] Add snapshots for the schema validation test results. Ensure that the snapshots exist and can display the validation results. --- crates/oxc_linter/tests/schema_validation_test.rs | 12 +++++++++++- ...test__invalid_env_wrong_type.json_errors.snap.new | 6 ++++++ ...lobals_writeable_not_allowed.json_errors.snap.new | 6 ++++++ ..._invalid_globals_wrong_value.json_errors.snap.new | 6 ++++++ ...st__invalid_invalid_category.json_errors.snap.new | 6 ++++++ ...test__invalid_invalid_plugin.json_errors.snap.new | 6 ++++++ ...st__invalid_invalid_severity.json_errors.snap.new | 6 ++++++ ...__invalid_plugins_wrong_type.json_errors.snap.new | 6 ++++++ 8 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new create mode 100644 crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index a51613c44e2a6..b723cc6a20c7b 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -7,6 +7,7 @@ use std::fs; use std::path::PathBuf; +use insta::assert_snapshot; use jsonschema::Validator; use project_root::get_project_root; @@ -98,13 +99,22 @@ fn test_invalid_configs_fail_validation() { let instance: serde_json::Value = serde_json::from_str(&content) .unwrap_or_else(|e| panic!("Failed to parse {file_name} as JSON: {e}")); - // Use iter_errors to check for validation errors + // Collect validation errors let errors: Vec<_> = schema.iter_errors(&instance).collect(); + // Ensure there are errors assert!( !errors.is_empty(), "Invalid config '{file_name}' unexpectedly passed schema validation" ); + + // Snapshot the human-readable error messages for this invalid file + let error_messages: String = + errors.iter().map(|e| format!("- {e}")).collect::>().join("\n"); + + // Name snapshots by file to keep them stable and readable + let snap_name = format!("invalid_{file_name}_errors"); + assert_snapshot!(snap_name, error_messages); } } diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new new file mode 100644 index 0000000000000..71a16ba4618ea --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- "not-an-object" is not of type "object" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new new file mode 100644 index 0000000000000..4a89dc73fb096 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- "writeable" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new new file mode 100644 index 0000000000000..d8d401e758965 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- "foobar" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new new file mode 100644 index 0000000000000..def368b8f458d --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- Additional properties are not allowed ('invalid' was unexpected) diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new new file mode 100644 index 0000000000000..344b2c0cc3fcc --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- ["invalid"] is not valid under any of the schemas listed in the 'anyOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new new file mode 100644 index 0000000000000..5658097e06756 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- "invalid-severity" is not valid under any of the schemas listed in the 'oneOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new new file mode 100644 index 0000000000000..2a66651d3c5d7 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new @@ -0,0 +1,6 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +assertion_line: 117 +expression: error_messages +--- +- "not-an-array" is not valid under any of the schemas listed in the 'anyOf' keyword From 6a89a90758f3d4f1b48869fe2fb3d3051d8843aa Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:35:41 -0700 Subject: [PATCH 13/25] Remove assertion line. --- crates/oxc_linter/tests/schema_validation_test.rs | 4 +++- ...rrors.snap.new => invalid_env_wrong_type.json_errors.snap} | 1 - ...=> invalid_globals_writeable_not_allowed.json_errors.snap} | 1 - ....snap.new => invalid_globals_wrong_value.json_errors.snap} | 1 - ...ors.snap.new => invalid_invalid_category.json_errors.snap} | 1 - ...rrors.snap.new => invalid_invalid_plugin.json_errors.snap} | 1 - ...ors.snap.new => invalid_invalid_severity.json_errors.snap} | 1 - ...s.snap.new => invalid_plugins_wrong_type.json_errors.snap} | 1 - 8 files changed, 3 insertions(+), 8 deletions(-) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_env_wrong_type.json_errors.snap.new => invalid_env_wrong_type.json_errors.snap} (87%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new => invalid_globals_writeable_not_allowed.json_errors.snap} (88%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new => invalid_globals_wrong_value.json_errors.snap} (88%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_invalid_category.json_errors.snap.new => invalid_invalid_category.json_errors.snap} (88%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_invalid_plugin.json_errors.snap.new => invalid_invalid_plugin.json_errors.snap} (89%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_invalid_severity.json_errors.snap.new => invalid_invalid_severity.json_errors.snap} (90%) rename crates/oxc_linter/tests/snapshots/{schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new => invalid_plugins_wrong_type.json_errors.snap} (89%) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index b723cc6a20c7b..f141bdc63dd35 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -114,7 +114,9 @@ fn test_invalid_configs_fail_validation() { // Name snapshots by file to keep them stable and readable let snap_name = format!("invalid_{file_name}_errors"); - assert_snapshot!(snap_name, error_messages); + insta::with_settings!({ prepend_module_to_snapshot => false }, { + assert_snapshot!(snap_name, error_messages); + }); } } diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap similarity index 87% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap index 71a16ba4618ea..093b0858d5839 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_env_wrong_type.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - "not-an-object" is not of type "object" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap similarity index 88% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap index 4a89dc73fb096..b57e778bd1e4f 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_writeable_not_allowed.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - "writeable" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap similarity index 88% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap index d8d401e758965..723ae286ab1f7 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_globals_wrong_value.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - "foobar" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap similarity index 88% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap index def368b8f458d..d39e9934193aa 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_category.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - Additional properties are not allowed ('invalid' was unexpected) diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap similarity index 89% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap index 344b2c0cc3fcc..3aa6f56b4d2ad 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_plugin.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - ["invalid"] is not valid under any of the schemas listed in the 'anyOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap similarity index 90% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap index 5658097e06756..0f21d29f2130f 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_invalid_severity.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - "invalid-severity" is not valid under any of the schemas listed in the 'oneOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new b/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap similarity index 89% rename from crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new rename to crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap index 2a66651d3c5d7..1f839af975049 100644 --- a/crates/oxc_linter/tests/snapshots/schema_validation_test__invalid_plugins_wrong_type.json_errors.snap.new +++ b/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -assertion_line: 117 expression: error_messages --- - "not-an-array" is not valid under any of the schemas listed in the 'anyOf' keyword From 02e5b3e0f348c06281fa352e721fad0332dbd57e Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:39:38 -0700 Subject: [PATCH 14/25] Add the config contents being tested to each snap. --- crates/oxc_linter/tests/schema_validation_test.rs | 10 ++++++++-- .../invalid_env_wrong_type.json_errors.snap | 10 +++++++++- ...id_globals_writeable_not_allowed.json_errors.snap | 12 +++++++++++- .../invalid_globals_wrong_value.json_errors.snap | 12 +++++++++++- .../invalid_invalid_category.json_errors.snap | 12 +++++++++++- .../invalid_invalid_plugin.json_errors.snap | 12 +++++++++++- .../invalid_invalid_severity.json_errors.snap | 12 +++++++++++- .../invalid_plugins_wrong_type.json_errors.snap | 10 +++++++++- 8 files changed, 81 insertions(+), 9 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index f141bdc63dd35..45663c3f469b4 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -108,14 +108,20 @@ fn test_invalid_configs_fail_validation() { "Invalid config '{file_name}' unexpectedly passed schema validation" ); - // Snapshot the human-readable error messages for this invalid file + // Snapshot the invalid JSON content and human-readable error messages together let error_messages: String = errors.iter().map(|e| format!("- {e}")).collect::>().join("\n"); + let snapshot_body = format!( + "File: {file_name}\n\n.oxlintrc.json:\n{json}\nErrors:\n{errors}\n", + json = content, + errors = error_messages + ); + // Name snapshots by file to keep them stable and readable let snap_name = format!("invalid_{file_name}_errors"); insta::with_settings!({ prepend_module_to_snapshot => false }, { - assert_snapshot!(snap_name, error_messages); + assert_snapshot!(snap_name, snapshot_body); }); } } diff --git a/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap index 093b0858d5839..e06c79187016b 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_env_wrong_type.json_errors.snap @@ -1,5 +1,13 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: env_wrong_type.json + +.oxlintrc.json: +{ + "env": "not-an-object" +} + +Errors: - "not-an-object" is not of type "object" diff --git a/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap index b57e778bd1e4f..7e154516574b6 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_globals_writeable_not_allowed.json_errors.snap @@ -1,5 +1,15 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: globals_writeable_not_allowed.json + +.oxlintrc.json: +{ + "globals": { + "Foo": "writeable" + } +} + +Errors: - "writeable" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap index 723ae286ab1f7..008e31106c9d6 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_globals_wrong_value.json_errors.snap @@ -1,5 +1,15 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: globals_wrong_value.json + +.oxlintrc.json: +{ + "globals": { + "Foo": "foobar" + } +} + +Errors: - "foobar" is not one of "readonly", "writable" or "off" diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap index d39e9934193aa..d13d5bd3c102e 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_category.json_errors.snap @@ -1,5 +1,15 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: invalid_category.json + +.oxlintrc.json: +{ + "categories": { + "invalid": "off" + } +} + +Errors: - Additional properties are not allowed ('invalid' was unexpected) diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap index 3aa6f56b4d2ad..2e324c0ac0d9d 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_plugin.json_errors.snap @@ -1,5 +1,15 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: invalid_plugin.json + +.oxlintrc.json: +{ + "plugins": [ + "invalid" + ] +} + +Errors: - ["invalid"] is not valid under any of the schemas listed in the 'anyOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap index 0f21d29f2130f..28dc220949c20 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_severity.json_errors.snap @@ -1,5 +1,15 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: invalid_severity.json + +.oxlintrc.json: +{ + "categories": { + "correctness": "invalid-severity" + } +} + +Errors: - "invalid-severity" is not valid under any of the schemas listed in the 'oneOf' keyword diff --git a/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap index 1f839af975049..95b8bbdd3d1d9 100644 --- a/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap +++ b/crates/oxc_linter/tests/snapshots/invalid_plugins_wrong_type.json_errors.snap @@ -1,5 +1,13 @@ --- source: crates/oxc_linter/tests/schema_validation_test.rs -expression: error_messages +expression: snapshot_body --- +File: plugins_wrong_type.json + +.oxlintrc.json: +{ + "plugins": "not-an-array" +} + +Errors: - "not-an-array" is not valid under any of the schemas listed in the 'anyOf' keyword From 0882c932c72aa5b8b4b9c52982b1feed5fc5c4cc Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:44:01 -0700 Subject: [PATCH 15/25] Resolve lint violation. --- crates/oxc_linter/tests/schema_validation_test.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 45663c3f469b4..aa5573ef44277 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -112,11 +112,8 @@ fn test_invalid_configs_fail_validation() { let error_messages: String = errors.iter().map(|e| format!("- {e}")).collect::>().join("\n"); - let snapshot_body = format!( - "File: {file_name}\n\n.oxlintrc.json:\n{json}\nErrors:\n{errors}\n", - json = content, - errors = error_messages - ); + let snapshot_body = + format!("File: {file_name}\n\n.oxlintrc.json:\n{content}\nErrors:\n{error_messages}\n"); // Name snapshots by file to keep them stable and readable let snap_name = format!("invalid_{file_name}_errors"); From 274441946d02cd50dd86b803eca8c353a13c1f5a Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:50:04 -0700 Subject: [PATCH 16/25] Generate the list of fixtures to run on by pulling files from the repo. --- .../tests/schema_validation_test.rs | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index aa5573ef44277..590b82d50110f 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -31,28 +31,29 @@ fn load_schema() -> Validator { Validator::new(&schema).expect("Failed to compile JSON schema") } +/// Return a sorted list of JSON files in `dir` +fn list_json_files(dir: &PathBuf) -> Vec { + let mut files: Vec = fs::read_dir(dir) + .unwrap_or_else(|e| panic!("Failed to read dir {}: {e}", dir.display())) + .filter_map(|entry| entry.ok().map(|e| e.path())) + .filter(|p| p.extension().and_then(|s| s.to_str()) == Some("json")) + .collect(); + + files.sort_by_key(|p| p.file_name().map(|s| s.to_string_lossy().to_string())); + files +} + /// Test that valid configuration files pass schema validation #[test] fn test_valid_configs_pass_validation() { let schema = load_schema(); let valid_dir = get_fixtures_path().join("valid"); - let test_files = [ - "basic_plugins.json", - "valid_categories.json", - "full_config.json", - "globals_config.json", - "env_config.json", - "rules_config.json", - "ignore_patterns.json", - "empty_config.json", - "complex_nested.json", - "extends_and_overrides.json", - "combined_sources.json", - ]; - - for file_name in &test_files { - let file_path = valid_dir.join(file_name); + // Get all json files in the valid fixture directory. + let test_files = list_json_files(&valid_dir); + + for file_path in &test_files { + let file_name = file_path.file_name().and_then(|s| s.to_str()).unwrap(); let content = fs::read_to_string(&file_path) .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); @@ -81,18 +82,11 @@ fn test_invalid_configs_fail_validation() { // TODO: Add another invalid test case to ensure that unknown fields are caught. // `additionalProperties` needs to be set to false for this to work and we need // to explicitly allow the "$schema" field. - let test_files = [ - "invalid_plugin.json", - "invalid_category.json", - "invalid_severity.json", - "plugins_wrong_type.json", - "globals_wrong_value.json", - "globals_writeable_not_allowed.json", - "env_wrong_type.json", - ]; - - for file_name in &test_files { - let file_path = invalid_dir.join(file_name); + // Get all json files in the invalid fixture directory. + let test_files = list_json_files(&invalid_dir); + + for file_path in &test_files { + let file_name = file_path.file_name().and_then(|s| s.to_str()).unwrap(); let content = fs::read_to_string(&file_path) .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); From a2eae81c041ecd04e83166419746dea3ab5891fc Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sat, 13 Dec 2025 23:51:00 -0700 Subject: [PATCH 17/25] Fix lint. --- crates/oxc_linter/tests/schema_validation_test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_linter/tests/schema_validation_test.rs b/crates/oxc_linter/tests/schema_validation_test.rs index 590b82d50110f..68b9362a0d7df 100644 --- a/crates/oxc_linter/tests/schema_validation_test.rs +++ b/crates/oxc_linter/tests/schema_validation_test.rs @@ -54,7 +54,7 @@ fn test_valid_configs_pass_validation() { for file_path in &test_files { let file_name = file_path.file_name().and_then(|s| s.to_str()).unwrap(); - let content = fs::read_to_string(&file_path) + let content = fs::read_to_string(file_path) .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); let instance: serde_json::Value = serde_json::from_str(&content) @@ -87,7 +87,7 @@ fn test_invalid_configs_fail_validation() { for file_path in &test_files { let file_name = file_path.file_name().and_then(|s| s.to_str()).unwrap(); - let content = fs::read_to_string(&file_path) + let content = fs::read_to_string(file_path) .unwrap_or_else(|e| panic!("Failed to read {file_name}: {e}")); let instance: serde_json::Value = serde_json::from_str(&content) From ba0d6fbf2a834acd11fb6c99f10b5a69bad011ac Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 14 Dec 2025 00:02:05 -0700 Subject: [PATCH 18/25] Add another test file. --- .../invalid_overrides_without_files.json | 12 ++++++++++ ...d_overrides_without_files.json_errors.snap | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_without_files.json create mode 100644 crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_without_files.json_errors.snap diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_without_files.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_without_files.json new file mode 100644 index 0000000000000..5af53b250cdca --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_without_files.json @@ -0,0 +1,12 @@ +{ + "rules": { + "curly": "off" + }, + "overrides": [ + { + "rules": { + "no-console": "error" + } + } + ] +} diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_without_files.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_without_files.json_errors.snap new file mode 100644 index 0000000000000..37816667cf672 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_without_files.json_errors.snap @@ -0,0 +1,22 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +expression: snapshot_body +--- +File: invalid_overrides_without_files.json + +.oxlintrc.json: +{ + "rules": { + "curly": "off" + }, + "overrides": [ + { + "rules": { + "no-console": "error" + } + } + ] +} + +Errors: +- "files" is a required property From 56adde6fccd7b35ab403c0512043e8321606ab42 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 14 Dec 2025 00:09:01 -0700 Subject: [PATCH 19/25] Ensure that no unknown fields are allowed in OxlintOverride struct. Add test to validate that this fails when there is an unknown field in an override config. --- .../invalid_overrides_with_categories.json | 18 ++++++++++++ ...overrides_with_categories.json_errors.snap | 28 +++++++++++++++++++ npm/oxlint/configuration_schema.json | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_with_categories.json create mode 100644 crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_with_categories.json_errors.snap diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_with_categories.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_with_categories.json new file mode 100644 index 0000000000000..5ce08eb1759be --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_overrides_with_categories.json @@ -0,0 +1,18 @@ +{ + "rules": { + "curly": "off" + }, + "overrides": [ + { + "files": [ + "**/*.js" + ], + "rules": { + "no-console": "error" + }, + "categories": { + "perf": true + } + } + ] +} diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_with_categories.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_with_categories.json_errors.snap new file mode 100644 index 0000000000000..6d35a16ae58aa --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_overrides_with_categories.json_errors.snap @@ -0,0 +1,28 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +expression: snapshot_body +--- +File: invalid_overrides_with_categories.json + +.oxlintrc.json: +{ + "rules": { + "curly": "off" + }, + "overrides": [ + { + "files": [ + "**/*.js" + ], + "rules": { + "no-console": "error" + }, + "categories": { + "perf": true + } + } + ] +} + +Errors: +- Additional properties are not allowed ('categories' was unexpected) diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index 46d66f94861c0..f78e3ddcac8e6 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -721,4 +721,4 @@ } }, "markdownDescription": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json --import-plugin`\n\n::: danger NOTE\n\nOnly the `.json` format is supported. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json\n{\n\"$schema\": \"./node_modules/oxlint/configuration_schema.json\",\n\"plugins\": [\"import\", \"typescript\", \"unicorn\"],\n\"env\": {\n\"browser\": true\n},\n\"globals\": {\n\"foo\": \"readonly\"\n},\n\"settings\": {\n},\n\"rules\": {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\n\"overrides\": [\n{\n\"files\": [\"*.test.ts\", \"*.spec.ts\"],\n\"rules\": {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n}\n```" -} \ No newline at end of file +} From 7d9bd2eb748a58f923666930c523427983d120c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:04:43 +0000 Subject: [PATCH 20/25] Revert addition of *.rlib to .gitignore As requested, removing the *.rlib pattern from .gitignore. Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com> --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 643970e7c57ba..90eb6dbb41f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Rust target/ **/*.rs.bk -*.rlib # Wasm **/*.wasm From 5c2de9c56ed7187c232173114649a8257ecbd010 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 18 Dec 2025 22:06:57 +0000 Subject: [PATCH 21/25] [autofix.ci] apply automated fixes --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 49be9bd821091..d8c9f1f5a73c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3173,7 +3173,7 @@ dependencies = [ "ahash", "fluent-uri 0.4.1", "getrandom 0.3.4", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "parking_lot", "percent-encoding", "serde_json", From c2534ab6634d5d8db66ebcf85229349a34edff6e Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 21 Dec 2025 14:21:50 -0700 Subject: [PATCH 22/25] Update AGENTS.md with a few more details. --- AGENTS.md | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 590026e98a4d5..a5798f2803187 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -138,7 +138,8 @@ Oxc uses multiple testing approaches tailored to each crate: - **Unit/Integration tests**: Standard Rust tests in `tests/` directories - **Conformance tests**: Against external suites (Test262, Babel, TypeScript, Prettier) -- **Snapshot tests**: Track failures and expected outputs using `insta` +- **Snapshot tests**: Track failures and expected outputs using `cargo insta` + ### Quick Test Commands @@ -146,6 +147,8 @@ Oxc uses multiple testing approaches tailored to each crate: just test # Run all Rust tests just conformance # Run all conformance tests (alias: cargo coverage) cargo test -p # Test specific crate +cargo insta test # Run snapshot tests +cargo insta review # Review/update snapshots after running test # Conformance for specific tools cargo coverage -- parser # Parser conformance @@ -181,6 +184,8 @@ fn test() { } ``` +- **Fixer**: Use `expect_fix(fix)` method after `test_and_snapshot()` for auto-fix tests in rules. + #### oxc_formatter - **Prettier conformance** only (no unit tests) @@ -290,18 +295,18 @@ Tests are TypeScript files in each package's `test/` directory. ### Where to Add Tests -| Crate | Location | -| --------------------- | --------------------------------------- | -| Parser | `tasks/coverage/misc/pass/` or `fail/` | -| Linter | Inline in rule files | -| Formatter | Prettier conformance suite | -| Minifier | `tests/` subdirectories | -| Transformer | `tests/integrations/` or Babel fixtures | -| Codegen | `tests/integration/` | -| Isolated Declarations | `tests/fixtures/*.ts` | -| Semantic | `tests/` directory | -| NAPI packages | `test/` directory (Vitest) | -| Language Server | Inline and `/fixtures` | +| Crate | Location | +| --------------------- | ----------------------------------------------------------- | +| Parser | `tasks/coverage/misc/pass/` or `fail/` | +| Linter | Inline in rule files and `tests/` subdirectory for fixtures | +| Formatter | Prettier conformance suite | +| Minifier | `tests/` subdirectories | +| Transformer | `tests/integrations/` or Babel fixtures | +| Codegen | `tests/integration/` | +| Isolated Declarations | `tests/fixtures/*.ts` | +| Semantic | `tests/` directory | +| NAPI packages | `test/` directory (Vitest) | +| Language Server | Inline and `/fixtures` | ## Notes From 82293660b05dbde33ac60f2835828df8447b80b1 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 21 Dec 2025 14:22:35 -0700 Subject: [PATCH 23/25] Remove extra line. --- crates/oxc_linter/tests/rule_configuration_test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/oxc_linter/tests/rule_configuration_test.rs b/crates/oxc_linter/tests/rule_configuration_test.rs index 096f12680baca..0897f1dfe75a8 100644 --- a/crates/oxc_linter/tests/rule_configuration_test.rs +++ b/crates/oxc_linter/tests/rule_configuration_test.rs @@ -54,7 +54,6 @@ fn test_rule_default_matches_from_configuration_null() { "Rule '{plugin_name}/{rule_name}' has different configurations between default() and from_configuration(null).\n\ Default: {default_debug}\n\ From null: {null_debug}", - )); } } From d2158cbd8d5007a842b07f3476b1b19d41b5c388 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 21 Dec 2025 14:25:31 -0700 Subject: [PATCH 24/25] Add a few more schema tests, for the react version setting. --- .../invalid/invalid_settings.json | 11 ++++++++++ .../invalid_settings_react_version.json | 11 ++++++++++ .../valid/valid_settings.json | 11 ++++++++++ .../invalid_invalid_settings.json_errors.snap | 21 +++++++++++++++++++ ...id_settings_react_version.json_errors.snap | 21 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings_react_version.json create mode 100644 crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_settings.json create mode 100644 crates/oxc_linter/tests/snapshots/invalid_invalid_settings.json_errors.snap create mode 100644 crates/oxc_linter/tests/snapshots/invalid_invalid_settings_react_version.json_errors.snap diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings.json new file mode 100644 index 0000000000000..84037789cc7cc --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings.json @@ -0,0 +1,11 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "react" + ], + "settings": { + "react": { + "version": "invalid" + } + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings_react_version.json b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings_react_version.json new file mode 100644 index 0000000000000..97ab9aaa1d49c --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/invalid/invalid_settings_react_version.json @@ -0,0 +1,11 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "react" + ], + "settings": { + "react": { + "version": "5.10.9.1" + } + } +} diff --git a/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_settings.json b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_settings.json new file mode 100644 index 0000000000000..a37c588b294c6 --- /dev/null +++ b/crates/oxc_linter/tests/fixtures/schema_validation/valid/valid_settings.json @@ -0,0 +1,11 @@ +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "react" + ], + "settings": { + "react": { + "version": "19.1.0" + } + } +} diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_settings.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_settings.json_errors.snap new file mode 100644 index 0000000000000..d6c770cd2add0 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_settings.json_errors.snap @@ -0,0 +1,21 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +expression: snapshot_body +--- +File: invalid_settings.json + +.oxlintrc.json: +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "react" + ], + "settings": { + "react": { + "version": "invalid" + } + } +} + +Errors: +- "invalid" does not match "^[1-9][0-9]*(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?$" diff --git a/crates/oxc_linter/tests/snapshots/invalid_invalid_settings_react_version.json_errors.snap b/crates/oxc_linter/tests/snapshots/invalid_invalid_settings_react_version.json_errors.snap new file mode 100644 index 0000000000000..836f21d8c0b66 --- /dev/null +++ b/crates/oxc_linter/tests/snapshots/invalid_invalid_settings_react_version.json_errors.snap @@ -0,0 +1,21 @@ +--- +source: crates/oxc_linter/tests/schema_validation_test.rs +expression: snapshot_body +--- +File: invalid_settings_react_version.json + +.oxlintrc.json: +{ + "$schema": "../../../../../../npm/oxlint/configuration_schema.json", + "plugins": [ + "react" + ], + "settings": { + "react": { + "version": "5.10.9.1" + } + } +} + +Errors: +- "5.10.9.1" does not match "^[1-9][0-9]*(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?$" From decfb4e6586dff36f39f8167a9d540eba47cab5b Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 21 Dec 2025 21:26:42 +0000 Subject: [PATCH 25/25] [autofix.ci] apply automated fixes --- AGENTS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index a5798f2803187..902d6ba34fe27 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -140,7 +140,6 @@ Oxc uses multiple testing approaches tailored to each crate: - **Conformance tests**: Against external suites (Test262, Babel, TypeScript, Prettier) - **Snapshot tests**: Track failures and expected outputs using `cargo insta` - ### Quick Test Commands ```bash