Commit graph

4108 commits

Author SHA1 Message Date
overlookmotel
c8bc6f0549 refactor(linter): use std::ptr::eq (#5649)
Follow-on after #5577.

`!std::ptr::eq(x, y)` is more idiomatic than `std::ptr::from_ref(x) != std::ptr::from_ref(y)`.
2024-09-09 15:28:10 +00:00
overlookmotel
19cdcc565c refactor(traverse): revert changes to walk.rs (#5652)
Revert the changes to `oxc_traverse` made in #5577.

Those changes may well have been good, but...

The soundness of `Traverse` is a finely balanced thing, and the pointer gymnastics are subtle, so I think it's best to be extremely conservative about changes. I last ran Miri on it with the original formulation (`as *mut _` etc) and it passed. Currently it's not possible to usefully run Miri on the transformer because it contains known unsound code (#3483). So until we're able to check soundness with Miri, I think it's best to avoid changes, as it'd be easy to trigger UB unintentionally.
2024-09-09 14:48:10 +00:00
overlookmotel
2de6ea02c0 refactor(index, traverse): remove unnecessary type annotations (#5650)
Follow-on after #5577. These type annotations are not required. Probably they were suggested by clippy.
2024-09-09 14:07:56 +00:00
Boshen
a37c064565 refactor(linter): use ContentHash for no_duplicate_case; remove calculate_hash (#5648)
closes #5600
2024-09-09 14:01:29 +00:00
dalaoshu
bfe9186611
perf(linter): use cow_replace instead of replace (#5643)
Related to #5586
2024-09-09 22:00:33 +08:00
overlookmotel
e52d006fc8 style(traverse): fix formatting of traverse codegen (#5651)
`dprint` rather mangled indentation of these files.
2024-09-09 13:54:00 +00:00
Boshen
6dcaae5cd8 chore(linter): move typescript/no-magic-numbers to eslint/no-magic-numbers (#5640)
closes #5614
2024-09-09 08:53:52 +00:00
leaysgur
41582ea00c fix(regular_expression): Improve RegExp to_string() results (#5635)
Hopefully fixes #5487

- `/^([a-zA-Z]+:)?[\p{L}0-9@/.\-_\\]+$/u`
- e3bc0ddcba/packages/cli-tools/src/launchEditor.ts (L53-L57)
2024-09-09 08:17:55 +00:00
heygsc
e3ae5dbb02
perf(linter): use cow_to_ascii_lowercase/uppercase (#5637)
part of #5586 

In addition, can a similar situation in the
[formatter](https://github.com/oxc-project/oxc/blob/main/crates/oxc_prettier/src/format/mod.rs#L1406-L1409)
be handled in this way?
2024-09-09 16:13:53 +08:00
DonIsaac
0b3c1d72a3 refactor(linter): start internal/external split of OxlintConfig (#5595)
Re-creation of #5140
2024-09-09 07:17:51 +00:00
overlookmotel
89bdf5536f refactor(linter): inline Rule trait default methods (#5619)
Hopefully compiler is already inlining these trivial/empty methods, but mark them `#[inline]` to make sure.
2024-09-09 07:13:55 +00:00
heygsc
a0370bf506
perf(linter): use cow_utils in no_script_url (#5633)
part of #5586 

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-09 15:06:50 +08:00
DonIsaac
023c1607b0 feat(linter): impl Serialize for OxlintConfig (#5594)
Re-creation of #5331
2024-09-09 05:13:19 +00:00
leaysgur
28aad281b6 fix(regular_expression): Handle - in /[\-]/u as escaped character (#5631)
Fixes #5487
2024-09-09 04:14:17 +00:00
DonIsaac
af6d240559 fix(linter): panic in consistent-function-scoping (#5613)
Closes #5608
2024-09-09 01:21:49 +00:00
overlookmotel
d22a9b72e0 refactor(semantic): SymbolTable::is_empty use is_empty (#5622)
Nit. `is_empty()` is sometimes more performant than `len() == 0`.
2024-09-09 01:07:34 +00:00
overlookmotel
1fa3e5687a refactor(semantic)!: rename SymbolTable::iter to symbol_ids (#5621)
`symbol_ids` is a more descriptive name.
2024-09-09 01:07:33 +00:00
overlookmotel
96a15526aa refactor(semantic)!: remove SymbolTable::iter_rev (#5620)
#5615 removed the only usage of this method, so it's now dead code.
2024-09-09 01:07:33 +00:00
overlookmotel
37e922c00f perf(linter): eslint/no_shadow_restricted_names use run_on_symbol (#5618)
This rule was implemented as a `run_once` method which just iterated over symbols. Implement using `run_on_symbol` instead to avoid the additional iteration.
2024-09-09 01:07:32 +00:00
overlookmotel
0b7fccf000 perf(linter): react/no_set_state + react/no_string_refs rules reduce iteration over ancestors (#5616)
`get_parent_es5_component` and `get_parent_es6_component` were always used together. Combine the two into a single function to only iterate over ancestors once, instead of twice.
2024-09-09 01:07:31 +00:00
overlookmotel
54e2e76d17 fix(linter): react/no_set_state + react/no_string_refs rules find correct parent (#5615)
`get_parent_es6_component` was finding *any* binding which is inside a class component, rather than parent of current node, leading to false positives.

The added test cases were not behaving correctly previously.
2024-09-09 01:07:31 +00:00
overlookmotel
2e367c999d test(traverse): enable tests for oxc_traverse crate (#5625)
Tests were disabled for some reason.
2024-09-09 00:18:44 +00:00
overlookmotel
afea8d5dea refactor(linter): rename Rule trait method params (#5617)
Makes no real difference. Just produces nicer naming hints in IDEs.
2024-09-08 18:36:36 +00:00
dalaoshu
4e748b5930
refactor(linter): replace ast "compare by hash" to "compare by content" (#5602)
relates #5600
2024-09-09 00:23:26 +08:00
Boshen
f49e6ebd41 fix(span): treat .js as module file (reverts the previous breaking change) (#5612)
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.

This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
overlookmotel
b3cbd56520 feat(span): format_compact_str! macro (#5610)
Add `format_compact_str!` macro to create a `CompactStr`, like `format!`.
2024-09-08 14:15:05 +00:00
overlookmotel
3d190a5728 refactor(span): move CompactStr into separate file (#5609)
Pure refactor. Split `atom.rs` into 2 files.
2024-09-08 14:15:04 +00:00
Boshen
4a8aec1605 feat(span)!: change SourceType::js to SourceType::cjs and SourceType::mjs (#5606) 2024-09-08 14:11:02 +00:00
overlookmotel
1c051ae9ae docs(traverse): correct code comment 2 (#5607)
Numbering UIDs skips 1 i.e. `_foo`, `_foo2`, `_foo3`, etc. Correct comment to reflect this.
2024-09-08 09:36:03 +00:00
overlookmotel
2e24a15075 docs(traverse): correct code comment (#5604)
`name_is_unique` originally searched through references, but it doesn't any more, so this comment is outdated.
2024-09-08 09:03:01 +00:00
overlookmotel
97e99bd167 style(traverse): remove excess line break (#5603) 2024-09-08 08:57:01 +00:00
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
553262842c
refactor(span): put types and impl in the same mod file 2024-09-08 14:00:25 +08:00
Boshen
c370694716
chore: fix npm/oxlint/configuration_schema.json mismatch 2024-09-08 13:34:53 +08:00
Boshen
d00a1f6511
chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
DonIsaac
8e79f8d72d test(linter): add class method test cases for oxc/no-async-await (#5550)
Adds tests for class and object methods. Diagnostics for the former have incorrect spans.

```javascript
class Foo {
   // span covers `() {}`
  async foo() {}
}
```
2024-09-08 03:15:01 +00:00
DonIsaac
bac03e3b6c refactor(linter): make fields of LintServiceOptions private (#5593)
Re-creation of #5326
2024-09-08 03:10:02 +00:00
Brian Donovan
8c9179d58a
docs(linter): fix typos (#5591) 2024-09-07 18:14:38 +01:00
IWANABETHATGUY
2661d8b505 refactor(linter): jest prefer_strict_equal (#5588)
simplify code
2024-09-07 16:44:27 +00:00
Boshen
919d17fc5c fix(transform_conformance): only print semantic mismatch errors when output is correct (#5589)
closes #5166

Had to rerun for mismatch errors :-/
2024-09-07 16:32:53 +00:00
Boshen
24d6a47f8b feat(linter): implement eslint/no-invalid-regexp (#5443)
closes #611

@leaysgur Kicking of `no-invalid-regexp`, feel free to take over and claim the bounty on #611 😁

I can continue if you wanna work on other stuff (getting confused in prettier land ;-))
2024-09-07 14:09:33 +00:00
Boshen
2c3f3fe9e4 perf(linter): make jsx_key slightly faster (#5585) 2024-09-07 14:03:26 +00:00
Boshen
cd81d12624 perf(linter): add should_run to check path only once to nextjs/no_typos (#5584) 2024-09-07 13:03:23 +00:00
Boshen
3835189785
test(linter): add test case for no_unused_vars in 3b87ac4 2024-09-07 20:45:40 +08:00
Boshen
3b87ac48ce fix(linter): fix no_unused_vars panic when encountering unicode (#5582)
closes #4887
2024-09-07 12:37:51 +00:00
Boshen
5f275516eb test(linter): add a passing case to no_undef (#5580)
closes #2093
2024-09-07 11:08:26 +00:00
Boshen
1bc08e296e fix(coverage): parse babel unambiguously (#5579) 2024-09-07 10:49:00 +00:00
Boshen
603817bef9 feat(oxc)!: add SourceType::Unambiguous; parse .js as unambiguous (#5557)
See https://babel.dev/docs/options#misc-options for background on `unambiguous`

Once `SourceType::Unambiguous` is parsed, it will correctly set the returned `Program::source_type` to either `module` or `script`.
2024-09-07 10:48:58 +00:00
IWANABETHATGUY
08d2b7d761 feat(oxc_wasm): add controlFlowDotString to oxc_wasm (#5571) 2024-09-07 10:41:00 +00:00
夕舞八弦
26d9235319
refactor: enable clippy::ref_as_ptr (#5577)
#5567 
`clippy::borrow_as_ptr` is also enabled in
`oxc_traverse/src/generated/walk.rs`.
2024-09-07 18:18:55 +08:00