What version of Oxlint are you using?
1.69.0
What command did you run?
oxlint .
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
Since checkAllIndexAccess is set to true, I expected errors when accessing the first element of arrays, i.e. index zero. The following does NOT fail:
const item = array[0] // no complaints from unicorn/prefer-at
If the index is greater, it fails. Like for array[1].
The documentation for the checkAllIndexAccess option says array[0] should fail, so therefore I believe this is unexpected behavior:
Check all index access, not just special patterns like array.length - 1. When enabled, array[0], array[1], etc. will also be flagged.
https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-at.html#checkallindexaccess
Inspecting the linter source code, there seems to be some unresolved TODOs from #17632 and the test for accessing the zero index is commented out:
|
// ("array[0]", Some(serde_json::json!([{ "checkAllIndexAccess": true }]))), |
I think the index !=0 check looks suspicious and might be the reason that this specific index is not causing errors:
What version of Oxlint are you using?
1.69.0
What command did you run?
oxlint .
What does your
.oxlintrc.json(oroxlint.config.ts) config file look like?What happened?
Since
checkAllIndexAccessis set totrue, I expected errors when accessing the first element of arrays, i.e. index zero. The following does NOT fail:If the index is greater, it fails. Like for
array[1].The documentation for the
checkAllIndexAccessoption saysarray[0]should fail, so therefore I believe this is unexpected behavior:Inspecting the linter source code, there seems to be some unresolved TODOs from #17632 and the test for accessing the zero index is commented out:
oxc/crates/oxc_linter/src/rules/unicorn/prefer_at.rs
Line 785 in 3170c0e
I think the
index !=0check looks suspicious and might be the reason that this specific index is not causing errors:oxc/crates/oxc_linter/src/rules/unicorn/prefer_at.rs
Line 162 in 3f60de3