Commit graph

736 commits

Author SHA1 Message Date
Boshen
2786dea164 feat(minifier): add RemoveUnusedCode (#8210) 2025-01-02 12:50:21 +00:00
oxc-bot
d2d90b077b
release(oxlint): v0.15.5 (#8218)
## [0.15.5] - 2025-01-02

### Features

- 0e168b8 linter: Catch more cases in const-comparisons (#8215)
(Cameron)
- bde44a3 linter: Add `statement_span` to `ModuleRecord/ImportEntry`
(#8195) (Alexander S.)
- ccaa9f7 linter: Implement `eslint/new-cap`  (#8146) (Alexander S.)

### Bug Fixes

- 2b14a6f linter: Fix `ignorePattern` config for windows (#8214)
(Alexander S.)

### Testing

- cb709c9 linter: Fix some oxlint tests on windows (#8204) (Cameron)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-02 18:55:31 +08:00
oxc-bot
936623ea45
release(oxlint): v0.15.4 (#8190)
## [0.15.4] - 2024-12-30

### Features

- 47cea9a linter: Implement `eslint/no-extra-label` (#8181) (Anson
Heung)
- ef76e28 linter: Implement `eslint/no-multi-assign` (#8158) (Anson
Heung)
- 384858b linter: Implement `jsx-a11y/no-noninteractive-tabindex`
(#8167) (Tyler Earls)
- afc21a6 linter: Implement `eslint/vars-on-top` (#8157) (Yuichiro
Yamashita)
- 65796c4 linter: Implement `eslint/prefer-rest-params` (#8155)
(Yuichiro Yamashita)
- 5234d96 linter: Implement `eslint/no-nested-ternary` (#8150) (Yuichiro
Yamashita)
- 1c5db72 linter: Implement eslint/no-labels (#8131) (Anson Heung)
- 0b04288 linter: Move `import/named` to nursery (#8068) (Boshen)

### Bug Fixes

- 0794bee editor/vscode: Set minimum supported ver. to `^1.93.0` (#8182)
(Pavel Smirnov)
- f3050d4 linter: Exclude svelte files from `no_unused_vars` rule
(#8170) (Yuichiro Yamashita)
- faf7464 linter: Disable rule `react/rules-of-hook` by file extension
(#8168) (Alexander S.)
- 1171e00 linter: Disable `react/rules-of-hooks` for vue and svelte
files (#8165) (Alexander S.)
- 1b9a5ba linter: False positiver in private member expr in
oxc/const-comparison (#8164) (camc314)
- 6bd9ddb linter: False positive in `typescript/ban-tslint-comment`
(#8094) (dalaoshu)
- 10a1fd5 linter: Rule: `no-restricted-imports` support option
`patterns` with `group` key (#8050) (Alexander S.)
- b3f38ae linter: Rule `no-restricted-imports`: support option
`allowImportNames` (#8002) (Alexander S.)
- 340cc90 linter: Rule `no-restricted-imports`: fix option "importNames"
(#7943) (Alexander S.)
- ec2128e linter: Fix line calculation for `eslint/max-lines` in
diagnostics (#7962) (Dmitry Zakharov)
- 79af100 semantic: Reference flags not correctly resolved when after an
export stmt (#8134) (camc314)

### Performance

- d8d2ec6 linter: Run rules which require typescript syntax only when
source type is actually typescript (#8166) (Alexander S.)
- 2736657 semantic: Allocate `UnresolvedReferences` in allocator (#8046)
(Boshen)

### Refactor

- de8246b language_server: Move structs into own file (#8026) (Alexander
S.)
- 774babb linter: Read `exported_bindings_from_star_export` lazily
(#8062) (Boshen)
- 547c102 linter: Use `RwLock<FxHashMap>` instead of `FxDashMap` for
module record data (#8061) (Boshen)
- 952d7e4 linter: Rename `flat.rs` to `config.rs` (#8033) (camc314)
- 50848ed linter: Simplify `ConfigStore` to prep for nested configs
(#8032) (camc314)
- b2a4a78 linter: Remove unused `with_rules` and `set_rule` methods
(#8029) (camc314)
- 6da0b21 oxlint: Remove unused `git.rs` (#7990) (Boshen)
- 58e7777 oxlint: Remove extra if check in `Walkdir` (#7989) (Boshen)
- 02f968d semantic: Change `Bindings` to a plain `FxHashMap` (#8019)
(Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-30 15:47:06 +08:00
renovate[bot]
11e598ecb1
chore(deps): update rust crates (#8186)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [console](https://redirect.github.com/console-rs/console) |
workspace.dependencies | patch | `0.15.8` -> `0.15.10` |
| [env_logger](https://redirect.github.com/rust-cli/env_logger) |
workspace.dependencies | patch | `0.11.5` -> `0.11.6` |
| [fast-glob](https://redirect.github.com/shulaoda/fast-glob) |
workspace.dependencies | patch | `0.4.0` -> `0.4.3` |
| [glob](https://redirect.github.com/rust-lang/glob) |
workspace.dependencies | patch | `0.3.1` -> `0.3.2` |
|
[oxc-browserslist](https://redirect.github.com/oxc-project/oxc-browserslist)
| workspace.dependencies | patch | `1.1.0` -> `1.1.1` |
| [oxc_resolver](https://redirect.github.com/oxc-project/oxc-resolver) |
workspace.dependencies | patch | `3.0.1` -> `3.0.3` |
| [oxc_sourcemap](https://redirect.github.com/oxc-project/oxc-sourcemap)
| workspace.dependencies | patch | `1.0.5` -> `1.0.6` |
| [quote](https://redirect.github.com/dtolnay/quote) |
workspace.dependencies | patch | `1.0.37` -> `1.0.38` |
| [serde](https://serde.rs)
([source](https://redirect.github.com/serde-rs/serde)) |
workspace.dependencies | patch | `1.0.216` -> `1.0.217` |
| [serde_json](https://redirect.github.com/serde-rs/json) |
workspace.dependencies | patch | `1.0.133` -> `1.0.134` |
| [syn](https://redirect.github.com/dtolnay/syn) |
workspace.dependencies | patch | `2.0.90` -> `2.0.93` |

---

### Release Notes

<details>
<summary>console-rs/console (console)</summary>

###
[`v0.15.10`](https://redirect.github.com/console-rs/console/releases/tag/0.15.10)

[Compare
Source](https://redirect.github.com/console-rs/console/compare/0.15.9...0.15.10)

#### What's Changed

- Remove MSRV badge from README by
[@&#8203;djc](https://redirect.github.com/djc) in
[https://github.com/console-rs/console/pull/228](https://redirect.github.com/console-rs/console/pull/228)

###
[`v0.15.9`](https://redirect.github.com/console-rs/console/releases/tag/0.15.9)

[Compare
Source](https://redirect.github.com/console-rs/console/compare/0.15.8...0.15.9)

#### What's Changed

- Update dependencies by [@&#8203;djc](https://redirect.github.com/djc)
in
[https://github.com/console-rs/console/pull/227](https://redirect.github.com/console-rs/console/pull/227)

</details>

<details>
<summary>rust-cli/env_logger (env_logger)</summary>

###
[`v0.11.6`](https://redirect.github.com/rust-cli/env_logger/blob/HEAD/CHANGELOG.md#0116---2024-12-20)

[Compare
Source](https://redirect.github.com/rust-cli/env_logger/compare/v0.11.5...v0.11.6)

##### Features

-   Opt-in file and line rendering

</details>

<details>
<summary>rust-lang/glob (glob)</summary>

###
[`v0.3.2`](https://redirect.github.com/rust-lang/glob/blob/HEAD/CHANGELOG.md#032---2024-12-28)

[Compare
Source](https://redirect.github.com/rust-lang/glob/compare/0.3.1...v0.3.2)

</details>

<details>
<summary>oxc-project/oxc-browserslist (oxc-browserslist)</summary>

###
[`v1.1.1`](https://redirect.github.com/oxc-project/oxc-browserslist/blob/HEAD/CHANGELOG.md#111---2024-12-14)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-browserslist/compare/oxc-browserslist-v1.1.0...oxc-browserslist-v1.1.1)

##### Other

-   codegen
-   dprint
-   Update README.md
-   *(deps)* update rust crates
-   *(deps)* update rust crates
- *(deps)* update dependency rust to v1.83.0
([#&#8203;78](https://redirect.github.com/oxc-project/oxc-browserslist/issues/78))
-   *(deps)* update rust crates
-   *(deps)* update rust crates to v1.0.215
-   *(deps)* update rust crate thiserror to v2.0.3
-   *(deps)* update rust crate thiserror to v2
-   *(deps)* update rust crates to v1.0.93
-   `cargo autoinherit`
-   *(deps)* update rust crate criterion2 to v2

</details>

<details>
<summary>oxc-project/oxc-resolver (oxc_resolver)</summary>

###
[`v3.0.3`](https://redirect.github.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#303---2024-12-14)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-resolver/compare/oxc_resolver-v3.0.2...oxc_resolver-v3.0.3)

##### <!-- 1 -->Bug Fixes

- try browsers field and alias before resolving directory in
node_modules
([#&#8203;349](https://redirect.github.com/oxc-project/oxc-resolver/issues/349))

###
[`v3.0.2`](https://redirect.github.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#302---2024-12-13)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-resolver/compare/oxc_resolver-v3.0.1...oxc_resolver-v3.0.2)

##### <!-- 1 -->Bug Fixes

- special case for aliasing `@/`
([#&#8203;348](https://redirect.github.com/oxc-project/oxc-resolver/issues/348))
- normalize resolved result on Windows for root
([#&#8203;345](https://redirect.github.com/oxc-project/oxc-resolver/issues/345))

##### <!-- 4 -->Refactor

- replace UnsafeCell with RefCell
([#&#8203;346](https://redirect.github.com/oxc-project/oxc-resolver/issues/346))

</details>

<details>
<summary>oxc-project/oxc-sourcemap (oxc_sourcemap)</summary>

###
[`v1.0.6`](https://redirect.github.com/oxc-project/oxc-sourcemap/blob/HEAD/CHANGELOG.md#106---2024-12-15)

[Compare
Source](https://redirect.github.com/oxc-project/oxc-sourcemap/compare/v1.0.5...v1.0.6)

##### Fixed

- handle non existing token position in visualizer
([#&#8203;14](https://redirect.github.com/oxc-project/oxc-sourcemap/issues/14))

</details>

<details>
<summary>dtolnay/quote (quote)</summary>

###
[`v1.0.38`](https://redirect.github.com/dtolnay/quote/releases/tag/1.0.38)

[Compare
Source](https://redirect.github.com/dtolnay/quote/compare/1.0.37...1.0.38)

- Support interpolating arrays inside of arrays using a repetition
([#&#8203;286](https://redirect.github.com/dtolnay/quote/issues/286))

</details>

<details>
<summary>serde-rs/serde (serde)</summary>

###
[`v1.0.217`](https://redirect.github.com/serde-rs/serde/releases/tag/v1.0.217)

[Compare
Source](https://redirect.github.com/serde-rs/serde/compare/v1.0.216...v1.0.217)

- Support serializing externally tagged unit variant inside flattened
field
([#&#8203;2786](https://redirect.github.com/serde-rs/serde/issues/2786),
thanks [@&#8203;Mingun](https://redirect.github.com/Mingun))

</details>

<details>
<summary>serde-rs/json (serde_json)</summary>

###
[`v1.0.134`](https://redirect.github.com/serde-rs/json/releases/tag/v1.0.134)

[Compare
Source](https://redirect.github.com/serde-rs/json/compare/v1.0.133...v1.0.134)

- Add `RawValue` associated constants for literal `null`, `true`,
`false`
([#&#8203;1221](https://redirect.github.com/serde-rs/json/issues/1221),
thanks [@&#8203;bheylin](https://redirect.github.com/bheylin))

</details>

<details>
<summary>dtolnay/syn (syn)</summary>

###
[`v2.0.93`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.93)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.92...2.0.93)

- Fix expression parsing edge cases: `x as T <<= y`
([#&#8203;1804](https://redirect.github.com/dtolnay/syn/issues/1804)),
`break as T`
([#&#8203;1805](https://redirect.github.com/dtolnay/syn/issues/1805)),
`match x { _ if .. => {} }`
([#&#8203;1807](https://redirect.github.com/dtolnay/syn/issues/1807))
- Fix expression printing edge cases: `|| -> T 'a: {}`
([#&#8203;1806](https://redirect.github.com/dtolnay/syn/issues/1806)),
`if break x {}`
([#&#8203;1808](https://redirect.github.com/dtolnay/syn/issues/1808),
[#&#8203;1810](https://redirect.github.com/dtolnay/syn/issues/1810))

###
[`v2.0.92`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.92)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.91...2.0.92)

- Fix parenthesization of jumps inside ranges
([#&#8203;1798](https://redirect.github.com/dtolnay/syn/issues/1798))

###
[`v2.0.91`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.91)

[Compare
Source](https://redirect.github.com/dtolnay/syn/compare/2.0.90...2.0.91)

- Support parsing `Vec<Arm>` using `parse_quote!`
([#&#8203;1796](https://redirect.github.com/dtolnay/syn/issues/1796),
[#&#8203;1797](https://redirect.github.com/dtolnay/syn/issues/1797))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 11am on monday" in timezone
Asia/Shanghai, Automerge - "before 11am on monday" in timezone
Asia/Shanghai.

🚦 **Automerge**: Enabled.

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

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOS44NS4wIiwidXBkYXRlZEluVmVyIjoiMzkuODUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-12-30 15:25:17 +08:00
Boshen
41ddf60ab0 feat(minfier): add CompressOptions::target (#8179) 2024-12-29 12:27:32 +00:00
翠 / green
9d62284202
chore(tasks): print diff for minify idempotency assertion (#8161)
Made the assertion error output more easier to understand.

Example output:

![image](https://github.com/user-attachments/assets/445910fb-b389-4884-b4c5-70a095bc523f)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-29 00:55:45 +08:00
Boshen
e594c3988d refactor(minifier): clean up peephole_substitute_alternate_syntax.rs (#8111) 2024-12-25 13:54:51 +00:00
oxc-bot
5a1311e76c
release(crates): v0.44.0 (#8110)
## [0.44.0] - 2024-12-25

- ad2a620 ast: [**BREAKING**] Add missing
`AssignmentTargetProperty::computed` (#8097) (Boshen)

### Features

- c2daa20 ast: Add `Expression::into_inner_expression` (#8048)
(overlookmotel)
- 618b6aa codege: Minify whitespace in object getter / setter (#8080)
(Boshen)
- 4727667 codegen: Minify arrow expr `(x) => y` -> `x => y` (#8078)
(Boshen)
- 0562830 codegen: Minify string with backtick when needed (#8095)
(Boshen)
- 6237c05 codegen: Minify more whitespace (#8089) (Boshen)
- 6355b7c codegen: Minify `export { 's' as 's' }` -> `export { 's' }`
(#8093) (Boshen)
- fccfda9 codegen: Minify `class{static[computed]}` (#8088) (Boshen)
- f873139 codegen: Minify `for (_ of [])` -> `for(_ of[])` (#8086)
(Boshen)
- 8b8cbcd codegen: Minify `case "foo"` -> `case"foo"` (#8085) (Boshen)
- 414c118 codegen: Minify `yield "s"` -> `yield"s"` (#8084) (Boshen)
- f8f067b codegen: Minify class method `async*fn(){}` (#8083) (Boshen)
- 1d5ae81 codegen: Minify `const [foo] = bar` -> `const[foo]=bar`
(#8079) (Boshen)
- e3f78fb codegen: `new Foo()` -> `new Foo` when minify (#8077) (Boshen)
- d84d60a codegen: Minify numbers with large exponents (#8074) (Boshen)
- 373279b codegen: Balance string quotes when minify whitespace (#8072)
(Boshen)
- 5397fe9 minifier: Constant fold `undefined?.bar` -> `undefined`
(#8075) (Boshen)
- 1932f1e minifier: Fold `foo === undefined || foo === null` (#8063) (翠
/ green)
- 11c4bd8 span: Implement source type `{file basename}.d.{extension}.ts`
(#8109) (Boshen)
- be4feb4 syntax: Add `SymbolId::new` method (#8041) (overlookmotel)
- e632a7b transformer: Remove typescript symbols after transform (#8069)
(Boshen)

### Bug Fixes

- bdc241d codegen: Disallow template literals in object property key
(#8108) (Boshen)
- 728ed20 codegen: Print `yield * ident` correctly (Boshen)
- b605baa minifier: Constant fold strings with tab char (#8096) (Boshen)
- de82492 parser: Report syntax errors for missing constructor
implementations (#8081) (camc314)
- 55d6eb9 parser: Disallow type parameters on class constructors (#8071)
(injuly)
- be2c60d parser: Parse `import source from from 'mod'` (#8056) (Boshen)
- 708e9cf semantic: Report errors for missing class method impls (#8082)
(camc314)
- 3057686 transformer/class-properties: Unwrap parenthesised expressions
(#8049) (overlookmotel)
- e67cd05 transformer/class-properties: Correctly resolve private fields
pointing to private accessors (#8047) (overlookmotel)
- 6b08c6e transformer/class-properties: Correctly resolve private fields
pointing to private methods (#8042) (overlookmotel)
- 274f117 transformer/nullish-coalescing: Use correct scope id for
binding (#8053) (camc314)

### Performance

- 78d2e83 sourcemap: Improve perf of `search_original_line_and_column`
(#7926) (Cameron)

### Refactor

- 7110c7b codegen: Add `print_quoted_utf16` and `print_unquoted_utf16`
methods (#8107) (Boshen)
- 8b54d89 minifier: Remove parens must happen on enter (#8060) (Boshen)
- 7cb84f3 minifier: Only minify on ast node exit (#8059) (Boshen)
- 77d845a minifier: Fuse DCE AST passes (#8058) (Boshen)
- 6123f5e minifier: Fold statements on exit (#8057) (Boshen)
- cbd5169 transformer/class-properties: Do not recreate private field if
not transforming it (#8044) (overlookmotel)
- 98e8a72 transformer/class-properties: Do not take mut ref when immut
ref will do (#8040) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-25 21:03:09 +08:00
Alexander S.
10a1fd57e5
fix(linter): rule: no-restricted-imports support option patterns with group key (#8050)
one/two wierd tests are not covered

> This is also an object option whose value is an array. This option
allows you to specify multiple modules to restrict using gitignore-style
patterns or regular expressions.

_https://eslint.org/docs/latest/rules/no-restricted-imports#patterns_

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-23 14:52:38 +08:00
oxc-bot
d69de3629d
release(crates): v0.43.0 (#8054)
## [0.43.0] - 2024-12-21

- de4c772 traverse: [**BREAKING**] Rename `Ancestor::is_via_*` methods
to `is_parent_of_*` (#8031) (overlookmotel)

- ed75e42 semantic: [**BREAKING**] Make SymbolTable fields `pub(crate)`
instead of `pub` (#7999) (Boshen)

### Features

- 75b775c allocator: `Vec<u8>::into_string` (#8017) (overlookmotel)
- 8547e02 ast: Implement `allocator_api2` for `Allocator` (#8043)
(Boshen)
- 63a95e4 ast: Add `AstBulder::move_property_key` (#7998)
(overlookmotel)
- 897a1a8 transformer/class-properties: Exit faster from super
replacement visitor (#8028) (overlookmotel)
- 3ea4109 transformer/class-properties: Transform super update
expressions within static prop initializer (#7997) (Dunqing)
- cc57db3 transformer/class-properties: Transform super assignment
expressions within static prop initializer (#7991) (Dunqing)
- 6b6444b traverse: Record current block scope (#8007) (overlookmotel)

### Bug Fixes

- 043252d transformer/class-properties: Replace `this` and class name in
static blocks (#8035) (overlookmotel)
- 273795d transformer/class-properties: Run other transforms on static
properties, static blocks, and computed keys (#7982) (overlookmotel)

### Performance

- c0dd3f8 ast: `move_expression` and `move_statement` produce dummy with
no span (#7995) (overlookmotel)
- 862838f codegen: Remove useless to_owned (#8014) (Dunqing)
- 2736657 semantic: Allocate `UnresolvedReferences` in allocator (#8046)
(Boshen)
- 2e8872c semantic: Allocate child scope in allocator (#8045) (Boshen)
- 414e828 semantic: Allocate symbol data in Allocator (#8012) (Boshen)
- 7aebed0 semantic: Allocate `Bindings` in allocator (#8021) (Boshen)
- 0f9308f transformer/react-refresh: Reduce allocations (#8018)
(overlookmotel)
- 0deb9e6 transformer/react-refresh: Reserve capacity in hook key string
(#8016) (overlookmotel)
- 7b70347 transformer/react-refresh: Avoid allocating string in each
hook call (#8013) (Dunqing)

### Documentation

- df5c341 ast: Improve docs for `AstBuilder::move_*` methods (#7994)
(overlookmotel)

### Refactor

- f1adf9f semantic: `ScopeTree::rename_binding` remove old binding first
(#8020) (overlookmotel)
- 02f968d semantic: Change `Bindings` to a plain `FxHashMap` (#8019)
(Boshen)
- e7476a1 semantic: Remove `serialize` (#8015) (Boshen)
- 1cf7b83 semantic: Simplify handling namespace stack (#7987) (Dunqing)
- 48cb52b semantic: Remove resetting `current_reference_flags` in visit
functions (#7986) (Dunqing)
- 3250a47 semantic: Remove unused current_symbol_flags (#7985) (Dunqing)
- efe96ec semantic: Use `Stack` for function stack node ids (#7984)
(Dunqing)
- ac097e9 transformer/class-properties: Rename file (#8036)
(overlookmotel)
- 059a5dd transformer/class-properties: Do not pass `ScopeId` into
`insert_instance_inits` (#8001) (overlookmotel)
- 0a38eea transformer/class-properties: Use `temp_var_name_base` to
generate temp var names for `super` transform (#8004) (overlookmotel)
- d1b7181 transformer/class-properties: Rename var (#8006)
(overlookmotel)
- 5a23d72 transformer/class-properties: Remove outdated comment (#8000)
(overlookmotel)
- b3a5f3e transformer/class-properties: Mark
`transform_assignment_expression_if_super_member_assignment_target` as
inline (#7993) (Dunqing)

### Testing

- bcb33c0 semantic: Add a test for catch parameters reference (#7988)
(Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-21 15:07:21 +08:00
Boshen
8547e02456 feat(ast): implement allocator_api2 for Allocator (#8043) 2024-12-20 13:26:48 +00:00
overlookmotel
75b775c055 feat(allocator): Vec<u8>::into_string (#8017)
Bumpalo has a method `String::from_utf8_unchecked` to covert a `Vec<u8>` to a `String`. But we can't use it because we use Bumpalo's `String` as our arena string type, but allocator_api2's `Vec` as our arena vec.

Provide the same functionality, that works around this incompatibility. Also use the faster `simdutf8` for checking that `Vec` contains a valid UTF-8 string.
2024-12-19 17:46:30 +00:00
Boshen
7aebed012d perf(semantic): allocate Bindings in allocator (#8021) 2024-12-19 15:16:03 +00:00
Boshen
02f968d02d refactor(semantic): change Bindings to a plain FxHashMap (#8019)
`IndexMap` was needed for the insertion order requirement in mangler.

Bindings (symbol ids) are monotonically increasing by binding
positions, which means we can get insertion order by sorting the symbol ids in
mangler.

Previous attempt: https://github.com/oxc-project/oxc/pull/4228
2024-12-19 14:16:28 +00:00
Boshen
e7476a1a28 refactor(semantic): remove serialize (#8015) 2024-12-19 09:51:12 +00:00
Dunqing
efe96ecc12 refactor(semantic): use Stack for function stack node ids (#7984) 2024-12-18 06:38:59 +00:00
oxc-bot
3631eed975
release(crates): v0.42.0 (#7983)
## [0.42.0] - 2024-12-18

- 84b75a0 semantic: [**BREAKING**] Remove `ScopeFlags::Modifiers`
(#7935) (overlookmotel)

- c071494 semantic: [**BREAKING**] Remove `SymbolTable::rename` method
(#7868) (overlookmotel)

### Features

- 8b7c5ae ast: Add `AstBuilder::atom_from_cow` (#7974) (overlookmotel)
- 46e2e27 data_structures: Implement `Default` for `NonEmptyStack`
(#7946) (overlookmotel)
- db9e93b mangler: Mangle top level variables (#7907) (翠 / green)
- 075bd16 minifier: Fold bitwise operation (#7908) (翠 / green)
- c16a851 napi/transform: Add `jsx: 'preserve'` option (#7965) (Boshen)
- 81eedb1 parser: 'readonly' type modifier is only permitted on array
and tuple literal types. (#7880) (Boshen)
- b9322c6 semantic: Re-export all flags and ID types (#7886)
(overlookmotel)
- c30a982 span: Add `impl From<ArenaString> for Atom` (#7973)
(overlookmotel)
- 02b653c transformer/class-properties: Do not create temp var for
template literal computed key (#7919) (overlookmotel)
- feac02e transformer/class-properties: Only rename symbols if necessary
(#7896) (overlookmotel)
- 6bc530d transformer/class-properties: Transform super call expression
that is inside static prop initializer (#7831) (Dunqing)
- 53e2bc0 traverse: Add `TraverseScoping::rename_symbol` method (#7871)
(overlookmotel)

### Bug Fixes

- 3659e6d cfg: Include export default code in CFG instructions (#7862)
(Jan Olaf Martin)
- 850dd43 codegen: Missing `,` when generating type parameters with jsx
(#7929) (Dunqing)
- 4799471 minfier: Bigint bitwise operation only works with bigint
(#7937) (Boshen)
- de8a86e minifier: Incorrect minification in `try_fold_left_child_op`
(#7949) (翠 / green)
- 9a30910 oxc_transformer: Inject_global_variables should considering
string imported name (#7768) (IWANABETHATGUY)
- 111dc52 parser: Include export token in spans of
TSNamespaceExportDeclaration (#7963) (branchseer)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932) (Dunqing)
- 596aead semantic: Reset references flags when resolved (#7923)
(Dunqing)
- 4924073 semantic: `ScopeTree::rename_binding` preserve order of
bindings (#7870) (overlookmotel)
- bb38065 transformer/class-properties: Do not transform `super.prop` in
nested method within static prop initializer (#7978) (overlookmotel)
- e76fbb0 transformer/class-properties: Fix symbol clashes in instance
prop initializers (#7872) (overlookmotel)
- c0576fa transformer/class-properties: Use UID for `args` in created
class constructor (#7866) (overlookmotel)
- d660d8d transformer/optional-chaining: Do not create unused reference
when `noDocumentAll` assumption (#7847) (overlookmotel)
- 4920c6a transformer/optional-chaining: Avoid creating a useless
reference when `noDocumentAll` is true (#7832) (Dunqing)

### Performance

- a5f04a7 ast: Faster `Comment::is_jsdoc` (#7905) (overlookmotel)
- 4b24335 codegen: Improve printing of statement comments (#7857)
(Boshen)
- 71a40a2 codegen: Guard comment printing comments when there are no
comments (#7856) (Boshen)
- b31f123 transformer/class-properties: Do not re-generate same method
key (#7915) (overlookmotel)
- 8ca8fce transformer/class-properties: Reduce work updating scopes when
transforming static prop initializers (#7904) (overlookmotel)
- 80d0b3e transformer/class-properties: Fast path for instance prop
initializer scope re-parenting (#7901) (overlookmotel)
- 38aafa2 transformer/class-properties: Reduce size of
`transform_call_expression_for_super_member_expr` (#7859)
(overlookmotel)

### Documentation

- e49de81 ast: Document `Expression::is_*` methods (#7853)
(overlookmotel)
- 10a86b9 transformer: Fix comments (#7925) (overlookmotel)
- f4cb5d3 transformer: Clarify comment (#7918) (overlookmotel)
- 41a1456 transformer/class-properties: Correct doc comments (#7966)
(overlookmotel)
- 18441af transformer/class-properties: Remove oudated todo for
assignment expression (#7955) (Dunqing)
- 1317c00 transformer/class-properties: Clarify doc comments (#7914)
(overlookmotel)
- 9989b58 transformer/class-properties: Re-order file list in doc
comment (#7911) (overlookmotel)
- 7390048 transformer/class-properties: Reformat doc comment (#7909)
(overlookmotel)

### Refactor

- beb982a ast: Use exhaustive match for `Argument` to
`ArrayExpressionElement` conversion (#7848) (overlookmotel)
- 3858221 global: Sort imports (#7883) (overlookmotel)
- 1314c97 minifier: Expose dce as an API instead of an option (#7957)
(Boshen)
- 6551dfe semantic: Pass `&str` instead of `Cow` (#7972) (overlookmotel)
- b8d2bd2 semantic: Move determining references flags for export
specifier to `visit_export_named_declaration` (#7924) (Dunqing)
- 98d7946 semantic: Import flags and ID types from `oxc_syntax` (#7887)
(overlookmotel)
- 1cf8f8f semantic: `SymbolTable::set_name` return old name (#7869)
(overlookmotel)
- 5d42df8 semantic: Use `Expression::is_super` (#7851) (overlookmotel)
- 8cf9766 semantic, syntax, wasm: Remove `#![allow(non_snake_case)]`
(#7863) (overlookmotel)
- d59bbae transformer: Remove unneeded lint `#[allow]` (#7971)
(overlookmotel)
- 2c94236 transformer: Improve encapsulation of transforms (#7888)
(overlookmotel)
- 34091b2 transformer: Use `Expression::is_super` (#7852)
(overlookmotel)
- d4d7bc0 transformer/async-to-generator: Avoid allocating unnecessary
`Atom`s (#7975) (overlookmotel)
- 2e5ffd3 transformer/class-properties: Store `temp_var_is_created` on
`ClassBindings` (#7981) (overlookmotel)
- 27cc6da transformer/class-properties: Store `is_declaration` only on
`ClassDetails` (#7980) (overlookmotel)
- ee282f8 transformer/class-properties: Remove `move_expression`s
(#7979) (overlookmotel)
- 94b376a transformer/class-properties: Simplify logic for when to
create temp binding (#7977) (overlookmotel)
- ff9d1b3 transformer/class-properties: Comments about shorter output
(#7976) (overlookmotel)
- 6fc40f0 transformer/class-properties: Pass `BoundIdentifier`s by
reference (#7968) (overlookmotel)
- 69eeeea transformer/class-properties: Methods take `&self` where
possible (#7967) (overlookmotel)
- 98340bb transformer/class-properties: Use stack of `ClassDetails`
(#7947) (overlookmotel)
- 088dd48 transformer/class-properties: Shorten code (#7913)
(overlookmotel)
- 544ffbf transformer/class-properties: Split up code into multiple
files (#7912) (overlookmotel)
- dcaf674 transformer/class-properties: Rename file (#7910)
(overlookmotel)
- 6243980 transformer/class-properties: Instance prop inits visitor use
`Visit` (#7867) (overlookmotel)
- eb47d43 transformer/class-properties: Re-use existing `Vec` (#7854)
(overlookmotel)
- 1380b7b transformer/class-properties: Reduce visibility of method
(#7858) (overlookmotel)
- 0f5e078 transformer/class-properties: Rename `*_owner` to `owned_*`
(#7855) (Dunqing)
- 4ea90d4 transformer/react-refresh: Calculate signature key once
(#7970) (Dunqing)
- 15b9bff transformer/typescript: Reuse `Atom` (#7969) (overlookmotel)

### Styling

- fb897f6 data_structures: Add line break (#7882) (overlookmotel)
- 7fb9d47 rust: `cargo +nightly fmt` (#7877) (Boshen)

### Testing

- 523d48c transformer: Move named test to exports folder (#7922)
(Dunqing)
- e766051 transformer: Skip test which uses filesystem under miri
(#7874) (overlookmotel)
- f39e65e transformer: Prevent lint error when running miri (#7873)
(overlookmotel)

Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
2024-12-18 11:48:12 +08:00
oxc-bot
fc5380442b
release(oxlint): v0.15.3 (#7954)
## [0.15.3] - 2024-12-17

### Features

- 25ddb35 linter: Add the import/no_named_default rule (#7902)
(Guillaume Piedigrossi)
- ee26b44 linter: Enhance `get_element_type` to resolve more element
types (#7885) (dalaoshu)

### Bug Fixes

- 6f41d92 linter: False positive in `unicorn/no-useless-spread` (#7940)
(dalaoshu)
- 0867b40 linter: Fix configuration parser for `no-restricted-imports`
(#7921) (Alexander S.)
- 9c9b73d linter: Fix incorrect fixer for `prefer-regexp-test` (#7898)
(Cameron)
- 32935e6 linter: False positive in
`jsx-a11y/label-has-associated-control` (#7881) (dalaoshu)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932) (Dunqing)

### Refactor

- 3858221 global: Sort imports (#7883) (overlookmotel)
- b99ee37 linter: Move rule "no-restricted-imports" to nursery (#7897)
(Alexander S.)
- ff2a68f linter/yoda: Simplify code (#7941) (overlookmotel)

### Styling

- 7fb9d47 rust: `cargo +nightly fmt` (#7877) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-17 12:24:09 +08:00
oxc-bot
b40c410824
release(oxlint): v0.15.2 (#7876)
## [0.15.2] - 2024-12-14

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-14 13:37:03 +08:00
oxc-bot
1428527da6
release(crates): v0.41.0 (#7846)
## [0.41.0] - 2024-12-13

- fb325dc ast: [**BREAKING**] `span` field must be the first element
(#7821) (Boshen)

- 96a26d3 ast: [**BREAKING**] Rename `is_strict` methods to
`has_use_strict_directive` (#7783) (overlookmotel)

### Features

- 8991f33 ast: Add `visit_span` to `Visit` and `VisitMut` (#7816)
(overlookmotel)
- f7900ab ast: Add `ArrowFunctionExpression::has_use_strict_directive`
method (#7784) (overlookmotel)
- e727ae9 transformer/class-properties: Transform super member
expressions that are inside static prop initializer (#7815) (Dunqing)

### Bug Fixes

- 7610dc1 parser: Parse `import source from 'mod'` (#7833) (Boshen)
- 9479e2b semantic: Missing references when `export {}` references a
type-only binding and a normal (#7812) (Yunfei He)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)
- 4a3bca8 semantic: Fix identifying strict mode arrow functions (#7785)
(overlookmotel)
- 5b7e1ad transformer: Remove span of define value (#7811) (Hiroshi
Ogawa)
- 14896cb transformer/class-properties: Create temp vars in correct
scope (#7824) (overlookmotel)
- 25bb6da transformer/class-properties: Fix `ScopeId`s in instance prop
initializers (#7823) (overlookmotel)
- 65b109a transformer/class-properties: No `raw` for generated
`StringLiteral` (#7825) (overlookmotel)
- 2964a61 transformer/class-properties: Unwrap failed when private field
expression doesn't contain optional expression in `ChainExpression`
(#7798) (Dunqing)
- 6fa6785 transformer/class-properties: Panic when the callee or member
is `ParenthesisExpression` or TS-syntax expressions. (#7795) (Dunqing)
- bb22c67 transformer/class-properties: Fix `ScopeId`s in static prop
initializers (#7791) (overlookmotel)
- caa57f1 transformer/class-properties: Fix scope flags in static prop
initializers (#7786) (overlookmotel)

### Performance

- 4448b63 codegen: Faster writing indentation (#7820) (overlookmotel)
- afaaffa codegen: Fast path for `options.print_comments()` (#7806)
(Boshen)

### Refactor

- 0f367e5 semantic: Improve the logic of resolving references to be
cleaner (#7829) (Dunqing)
- 5710950 semantic: Move export-related reference flags logic to visit
functions (#7828) (Dunqing)
- b290ebd transformer: Handle `<CWD>` in test runner (#7799) (Dunqing)
- e70deb9 transformer/class-properties: Locate instance props insertion
location in separate step (#7819) (overlookmotel)
- afc5f1e transformer/class-properties: De-deduplicate code (#7805)
(overlookmotel)
- 47a91d2 transformer/class-properties: Shorten code (#7804)
(overlookmotel)
- 54ef2b9 transformer/class-properties: Rename
`debug_assert_expr_is_not_parenthesis_or_typescript_syntax` (#7803)
(overlookmotel)
- 3cdc47c transformer/class-properties: `#[inline(always)]` on
`assert_expr_neither_parenthesis_nor_typescript_syntax` (#7802)
(overlookmotel)

### Testing

- d72c888 transformer/replace-global-defines: Remove panicking test
(#7838) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:25:13 +08:00
oxc-bot
bb4a92c80c
release(oxlint): v0.15.1 (#7845)
## [0.15.1] - 2024-12-13

### Features

- 38b1c2e editor: Create a command to apply all auto-fixes for the
current active text editor (#7672) (Nicholas Rayburn)

### Bug Fixes

- 2b187e5 linter: Fix configuration casing for
`typescript/no_this_alias` (#7836) (Boshen)
- 06e6d38 linter: Fix unicorn/prefer-query-selector to use the correct
replacement for getElementsByClassName (#7796) (Nicholas Rayburn)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:23:33 +08:00
Hiroshi Ogawa
5b7e1adc9b
fix(transformer): remove span of define value (#7811)
- Closes https://github.com/oxc-project/oxc/issues/7797

Removing span seems to work, but I'm not sure traversing all the time is
okay.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-13 11:22:49 +00:00
renovate[bot]
358d375bbd
chore(deps): update rust crates (#7787) 2024-12-12 22:45:45 +08:00
oxc-bot
bde753b4ee
release(oxlint): v0.15.0 (#7782)
## [0.15.0] - 2024-12-10

- 39b9c5d linter: [**BREAKING**] Remove unmaintained security plugin
(#7773) (Boshen)

### Features

- 065f7dc linter: Support `expectTypeOf`, `assert` and `assertType` in
`vitest/expect-expect` (#7742) (Yuichiro Yamashita)
- 3d5f0a1 linter/no_restricted_imports: Add the no_restricted_imports
rules (#7629) (Guillaume Piedigrossi)

### Bug Fixes

- ad27b20 linter: Only resolve esm files for import plugin (#7720)
(Boshen)
- 5e6053f linter: False positive in `eslint/yoda` (#7719) (dalaoshu)

### Refactor

- c6a19aa linter: Remove unused `serde` features (#7738) (Boshen)
- b9a2b35 linter: Remove `aho-corasick` (#7718) (Boshen)

### Testing

- 62f0a22 linter: Port `react-jsx-uses-vars` rules to no_unused_vars
(#7731) (Tyler Earls)
- 02f9903 linter: Add regression tests for `import/namespace` (#7723)
(dalaoshu)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-11 00:58:03 +08:00
oxc-bot
bd572c609b
release(crates): v0.40.1 (#7781)
## [0.40.1] - 2024-12-10

### Bug Fixes

- 18d0ce3 napi: Rename `Error` to `OxcError` to avoid name collision
(#7780) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-11 00:35:34 +08:00
oxc-bot
6768f7ded2
release(crates): v0.40.0 (#7775) 2024-12-10 23:04:43 +08:00
Boshen
f3cfa7f3dd feat(napi/parser): add get_line_column_number API (#7765) 2024-12-10 12:49:11 +00:00
Boshen
cf2ee06825 feat(data_structures): add rope (#7764) 2024-12-10 10:30:04 +00:00
Boshen
4bd3d103d3 feat(napi/parser): introduce experimental MagicString (#7529)
Hold magic string instance on the Rust side for utf8 string manipulation.
2024-12-10 08:33:47 +00:00
Boshen
c6a19aa478 refactor(linter): remove unused serde features (#7738) 2024-12-09 09:16:32 +00:00
Boshen
48b1e4ad32 refactor(napi/parser): enable serialize feature for oxc_ast only (#7728) 2024-12-08 15:38:57 +00:00
Boshen
85eec3c82e feat(napi/transform,napi/parser): return structured error object (#7724)
closes #7261
2024-12-08 14:11:56 +00:00
Boshen
b9a2b35e5a refactor(linter): remove aho-corasick (#7718) 2024-12-07 12:34:41 +00:00
oxc-bot
5f4f6d140b
release(oxlint): v0.14.1 (#7692) 2024-12-06 13:06:54 +08:00
oxc-bot
fee2143f4c
release(crates): v0.39.0 (#7643) 2024-12-04 19:43:22 +08:00
Boshen
771c698a81
feat(oxc): remove oxc_napi crate (#7634)
napi has a limitation, it cannot feature gate type exposure.

closes #7623
2024-12-04 10:07:32 +08:00
Boshen
9b803d95d0
chore: bump deps (#7616) 2024-12-04 07:51:53 +08:00
Boshen
b4f3812c4a refactor(oxc_napi): remove source_map - moved to its crate (#7614) 2024-12-03 14:42:34 +00:00
Boshen
bd977cf742 feat(oxc): add oxc_napi crate (#7612) 2024-12-03 14:02:47 +00:00
Boshen
348d4f451a feat(sourcemap): move oxc_sourcemap to github.com/oxc-project/oxc-sourcemap (#7604)
It's mostly stable so we can v1.0.0 it.

And we will create cyclic dependency with StringWizard soon.
2024-12-03 11:59:43 +00:00
Boshen
943462f22c feat(module_lexer)!: remove oxc_module_lexer (#7595)
This crate will no longer be relevant after we export esm information
directly from the parser.

Besides, `ex-module-lexer`'s output data is too limited for plugin
authors to use.
2024-12-03 04:22:51 +00:00
overlookmotel
e62153bdd7 chore(deps): remove memoffset dependency (#7573)
`offset_of!` macro [became stable in Rust 1.77.0](https://doc.rust-lang.org/nightly/core/mem/macro.offset_of.html) which is now within our MSRV. Remove the `memoffset` crate, and use `std::mem::offset_of` instead.
2024-12-01 23:39:27 +00:00
oxc-bot
c61a383e8c
release(oxlint): v0.14.0 (#7563)
## [0.14.0] - 2024-12-01

### Features

- 32f860d linter: Add support for ignorePatterns property within config
file (#7092) (Nicholas Rayburn)
- 053bc08 linter: Implement typescript/no-unused-expressions (#7498)
(camc314)
- 60b28fc linter: Implement typescript/consistent-generic-constructors
(#7497) (camc314)
- bd0693b linter: Allow lint rules with the same name (#7496) (camc314)
- 2ac9f96 linter: Typescript/no-inferrable-types (#7438) (camc314)
- 8d89fdc linter: Add eslint/prefer-spread (#7112) (tbashiyy)

### Bug Fixes

- 123b5b7 linter: False positive in
`typescript/consistent-type-definitions` (#7560) (dalaoshu)
- cc078d6 linter: Add missing error message prefix to
`eslint/no-const-assign` (Boshen)
- 17c0dd8 linter: Fix `jsx_no_script_url` doc failed to build (Boshen)

### Performance

- 6cc7a48 linter: Use `OsString` for module cache hash (#7558) (Boshen)
- 6655345 linter: Use `FxDashMap` for module cache (#7522)
(overlookmotel)

### Documentation

- a6b0100 linter: Fix config example headings (#7562) (Boshen)

### Refactor

- 0f3f67a linter: Add capability of adding semantic data to module
record (#7561) (Boshen)
- 8392177 linter: Clean up the runtime after the module record change
(#7557) (Boshen)
- 823353a linter: Clean up APIs for `ModuleRecord` (#7556) (Boshen)
- f847d0f linter: Call `str::ends_with` with array not slice (#7526)
(overlookmotel)
- 2077ff9 linter: Remove `once_cell` (#7510) (Boshen)
- 169b8bf linter, syntax: Introduce type alias `FxDashMap` (#7520)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-01 16:47:21 +08:00
Boshen
c2ced15dfd feat(parser,linter)!: use a different ModuleRecord for linter (#7554)
The parser returns a simple `ModuleRecord` that is allocated in the arena for performance reasons.

The linter uses a more complicated, `Send` + `Sync` `ModuleRecord` that will hold more cross-module information.

The next step is to return more esm information from the parser to eliminated the need of the `oxc_module_lexer` crate.
2024-11-30 16:02:01 +00:00
Boshen
7e42e71f34
deps: bump wasm-bindgen to 0.2.96 (#7551) 2024-11-30 10:47:03 +08:00
Boshen
b24beeb0f5 refactor(parser): use PropName trait from oxc_ecmascript (#7543) 2024-11-29 09:18:47 +00:00
Boshen
9d6e14bb67 test(ecmascript): move tests to oxc_minifier due to cyclic dependency with oxc_parser (#7542) 2024-11-29 09:18:45 +00:00
Boshen
2077ff9269
refactor(linter): remove once_cell (#7510) 2024-11-28 10:30:52 +08:00
oxc-bot
861ae1581a
release(oxlint): v0.13.2 (#7489) 2024-11-26 15:25:31 +08:00
oxc-bot
00a7372eaf
release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00