Commit graph

5672 commits

Author SHA1 Message Date
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
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
2386d7fca2
chore(dprint): format yaml files (#5598) 2024-09-08 14:05:46 +08:00
Boshen
0571a37022
chore(justfile): add dprint to just init 2024-09-08 14:02:24 +08:00
Boshen
553262842c
refactor(span): put types and impl in the same mod file 2024-09-08 14:00:25 +08:00
renovate[bot]
69da677f00
chore(deps): update crate-ci/typos action to v1.24.5 (#5596)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [crate-ci/typos](https://redirect.github.com/crate-ci/typos) | action
| patch | `v1.24.3` -> `v1.24.5` |

---

### Release Notes

<details>
<summary>crate-ci/typos (crate-ci/typos)</summary>

###
[`v1.24.5`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.24.5)

[Compare
Source](https://redirect.github.com/crate-ci/typos/compare/v1.24.4...v1.24.5)

#### \[1.24.5] - 2024-09-04

##### Features

-   *(action)* Support windows

###
[`v1.24.4`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.24.4)

[Compare
Source](https://redirect.github.com/crate-ci/typos/compare/v1.24.3...v1.24.4)

#### \[1.24.4] - 2024-09-03

##### Fixes

-   Offer a correction for `grather`

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-08 05:52:04 +00:00
Boshen
955e83ec41
ci: add dprint to autofix (#5597) 2024-09-08 13:46:30 +08:00
Boshen
dc741e471f
chore: do not format napi generated files 2024-09-08 13:42:15 +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
Boshen
be63a2cafc
chore: add dprint 2024-09-08 13:24:58 +08:00