Commit graph

5484 commits

Author SHA1 Message Date
Dunqing
b9bf54494f fix(isolated-declarations): false positive for setter method in interface (#5681)
close: #5668
2024-09-10 16:22:08 +00:00
Dunqing
6e8409a020 fix(isolated-declarations): bindings referenced in TSModuleDeclaration are removed incorrectly (#5680)
close: #5667
2024-09-10 16:22:07 +00:00
Boshen
afc4548ef4 perf(ast)!: educe byte size of TaggedTemplateExpression::quasi by Boxing it (#5679) 2024-09-10 14:17:29 +00:00
Boshen
7415e85764 perf(ast)!: reduce byte size of TSImportType::attributes by Boxing it (#5678) 2024-09-10 14:07:51 +00:00
Boshen
ee4fb42d70 perf(ast)!: reduce size of WithClause by Boxing it (#5677)
relates #5601
2024-09-10 14:01:36 +00:00
Boshen
f9e3a41dd2 fix(semantic): bind SymbolId to function name in if (foo) function id() {} (#5673) 2024-09-10 11:05:26 +00:00
Boshen
067f9b5a6f refactor(semantic): introduce IsGlobalReference trait (#5672) 2024-09-10 10:12:08 +00:00
Boshen
68c3cf544f feat(minifier): fold void 1 -> void 0 (#5670) 2024-09-10 08:11:10 +00:00
leaysgur
2da42efb6f refactor(regular_expression): Improve AST docs with refactoring may_contain_strings (#5665)
Follow up #5661
2024-09-10 07:32:28 +00:00
Boshen
c6bbf94f4c feat(minifier): constant fold unary expression (#5669) 2024-09-10 07:18:54 +00:00
Boshen
86256ea238 feat(minifier): constant fold typeof (#5666)
closes #5628
2024-09-10 04:43:00 +00:00
DonIsaac
4f70fe5abf refactor(linter): start internal/external split of LintPluginOptions (#5660)
Re-creation of #5142
2024-09-10 03:19:05 +00:00
DonIsaac
5ae9b48509 refactor(linter): start internal/external split of OxlintOptions (#5659)
re-creation of #5141
2024-09-10 03:19:04 +00:00
leaysgur
0511d55aa8 fix(regular_expression): Report more MayContainStrings error in (nested)class (#5661)
Fixes #5632
2024-09-10 01:55:51 +00:00
heygsc
febb29f7f5
perf(formatter): use cow and put cow_ascii on clippy (#5646)
close: #5639 

part of: #5586

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-10 09:38:17 +08:00
overlookmotel
e8013d259e perf(traverse): faster string operations generating UIDs (#5626)
`get_unique_name` perform string manipulation faster, avoiding bounds checks, and use `itoa` crate for faster conversion of integers to strings for postfixes above 100.

No apparent difference on benchmarks, but I imagine that's only because it's outweighed by cost of hashing strings. If measured alone, I believe it would be a perf improvement.
2024-09-10 01:12:22 +00:00
overlookmotel
4996874dda perf(traverse): generate_uid cache available binding names (#5611)
Close #5488.

`generate_uid` previously iterated through every symbol and unresolved reference in the AST to find a unique var name. If the first var name it tried was already in use, it'd iterate again.

Instead build a hash map recording existing var names in use for every name which could clash with a UID (any var name starting with `_`). Once built, use that hash map to generate UIDs without iterating through all symbols again.

I had hoped to make `generate_uid` cheaper still by just recording the highest digits postfix for each var name, and then incrementing that postfix for each UID. i.e. if AST contains vars `_foo1` and `_foo6`, create UIDs starting at one number higher - `_foo7`, `_foo8` etc. This method would be more efficient, but unfortunately it does not match Babel, and so causes some of Babel's tests to fail.
2024-09-10 01:12:19 +00:00
Boshen
e698418d1a feat(napi/transform): align output SourceMap with Rollup's ExistingRawSourceMap (#5657)
closes #5578
2024-09-09 15:55:23 +00:00
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
IWANABETHATGUY
e38114b825
fix(ast_tools): fix ast-tool panic (#5641)
`just ast` panic due to
553262842c,
change the filename to makesure `ast_tool` still working
1. crates/oxc_span/src/source_type/types.rs is removed in
553262842c
2024-09-09 17:57:20 +08:00
Boshen
508cbeafd5
chore(justfile): add just watch-oxlint 2024-09-09 16:57:51 +08: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
DonIsaac
20d006838e refactor(oxlint): move cli-related exports to cli module (#5139) 2024-09-08 15:29:37 +00: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