Boshen
3e19e4e004
perf(minifier): remove the useless empty statement removal code in statement fusion ( #8646 )
2025-01-22 09:08:56 +08:00
Boshen
5b3c412e26
perf(minifier): only run optimizations on local changes ( #8644 )
...
Previously all code are ran in a fixed point loop when ast changes.
This PR changes running code when a function changes its enclosing ast only.
2025-01-21 23:55:54 +08:00
camc314
b75d4919ee
chore(linter): update doc comment to reflect existance of stylish formatter ( #8645 )
...
after:
```
Output
-f, --format=ARG Use a specific output format (default, json, unix, checkstyle, github,
stylish)
```
2025-01-21 15:38:15 +00:00
sapphi-red
835b25889b
feat(minifier): compress typeof foo === 'object' && foo !== null to typeof foo == 'object' && !!foo ( #8638 )
...
If `typeof foo == 'object'`, then `foo` is guaranteed to be an object or null. In that case, `foo !== null` can be replaced with `!!foo` because objects return `true` for `!!foo` and null returns `false` for it.
**References**
- [Spec of `typeof`](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-typeof-operator )
- [Spec of `!`](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-logical-not-operator )
- [Spec of `ToBoolean`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-toboolean )
2025-01-21 14:59:25 +00:00
sapphi-red
2bcbed2d50
feat(minifier): compress (a = b) === null || a === undefined to (a = b) == null ( #8637 )
2025-01-21 14:59:23 +00:00
overlookmotel
864b8efe1a
refactor(parser): shorten code ( #8640 )
...
Pure refactor. Shorten code by using `AstBuilder` methods which produce the desired type in a single call.
2025-01-21 14:36:00 +00:00
overlookmotel
e66da9fe41
refactor(isolated_declarations, linter, minifier, prettier, semantic, transformer): remove unnecessary ref / ref mut syntax ( #8643 )
...
While working on #8641 , I found a lot of places where we unnecessarily use `ref` / `ref mut` in match arms.
In many cases, we're creating double-references (turning a `&T` into a `&&T`). The compiler should be smart enough to remove them for us, but there doesn't seem much point in explicitly creating double-references when we don't actually want them, and relying on compiler to optimize them out again.
2025-01-21 14:20:07 +00:00
overlookmotel
54d0fac987
refactor(span)!: remove PartialEq impl for &Atom ( #8642 )
...
Remove this unnecessary impl. It's pretty odd to have a method which takes an `&&Atom` (which is essentially a `&&&str`).
2025-01-21 14:20:06 +00:00
overlookmotel
b8d9a51462
refactor(span): deal only in owned Atoms ( #8641 )
...
#8596 made `Atom` a `Copy` type. Now we can deal exclusively in owned `Atom`s. Refactor code to not pass `&Atom` into functions etc.
2025-01-21 14:20:06 +00:00
overlookmotel
20f52b1fee
refactor(span): remove unnecessary lifetimes on Atom impls ( #8639 )
...
Pure refactor. The lifetime of the `Atom` is not relevant in these trait impls. Remove the lifetimes to make that clearer.
2025-01-21 14:20:06 +00:00
overlookmotel
61d96fde64
refactor(transformer/class-properties): correct comments ( #8636 )
2025-01-21 11:18:02 +00:00
Boshen
dcc1f2bcb3
refactor(minifier): rename ast_passes to peephole ( #8635 )
2025-01-21 11:09:53 +00:00
Yuji Sugiura
891a9c2040
feat(tasks/prettier): Visualize test details ( #8634 )
...
For example, if there are 3 tests in 1 spec and all of them fail:
- 💥 💥 💥
After some implementation, if 1 test passes:
- 💥 💥 ✨
However, in this case, the coverage as number does not change.
This PR visualizes these details for better mental well-being. 😃
(But in practice, specs are so detailed, there is not much opportunity
for this...)
2025-01-21 17:01:34 +08:00
Boshen
52458de00b
refactor(minifier): remove unused code and traits ( #8632 )
2025-01-21 05:41:11 +00:00
overlookmotel
c1d243be46
docs(allocator): improve docs for Allocator ( #8623 )
...
Improve docs for `Allocator`:
1. Explain how allocator works.
2. Demonstrate how to achieve good performance by re-using `Allocator`s.
Also fix the doc test for `CloneIn`.
2025-01-21 04:01:41 +00:00
Andrew Powell
8a0eb2abb7
feat(oxlint): add stylish formatter ( #8607 )
...
👋 This implements a reporter for `--format` on `oxlint` which aims to be
visually similar to
https://eslint.org/docs/latest/use/formatters/#stylish
Please note that this is my first time working with Rust and my
knowledge is very limited. I'm unlikely to understand best-practice or
best-pattern references outside of what clippy/cargo lint has already
had me change. If this needs modification, please help me out by making
code suggestions that can be merged to this PR.
Resolves #8422
---------
Co-authored-by: Cameron <cameron.clark@hey.com>
2025-01-21 09:55:07 +08:00
Kevin Deng 三咲智子
178c2322f5
fix(parser): parse intrinsic TS keyword ( #8627 )
2025-01-21 09:54:10 +08:00
Kevin Deng 三咲智子
48717ab87c
fix(parser): parse true as TSLiteralType ( #8626 )
...
closes #8624
2025-01-21 09:50:49 +08:00
overlookmotel
2a2ad53ea6
feat(allocator): add Allocator::capacity and used_bytes methods ( #8621 )
...
Add 2 methods for determining the size of `Allocator`:
* `capacity` returns total size of memory owned by the `Allocator` (including space not yet used).
* `used_bytes` returns total size of data so far allocated in the arena.
2025-01-20 17:11:17 +00:00
Boshen
c9f3c5fc2b
chore(allocator): remove default features from hashbrown ( #8619 )
2025-01-20 16:18:41 +00:00
overlookmotel
6801c81b86
feat(allocator): add Allocator::new and with_capacity methods ( #8620 )
...
Add `Allocator::with_capacity` method to allow specifying initial capacity when creating `Allocator`. Also add `Allocator::new` as an alternative to `Allocator::default` (does the same thing).
2025-01-20 15:21:16 +00:00
Boshen
6f95cd599a
refactor(minifier): remove all the unnecessary fake ast passes ( #8618 )
...
This also removes handling of making cjs-module-lexer to work.
2025-01-20 22:05:51 +08:00
overlookmotel
787aaad977
perf(allocator): make String non-drop ( #8617 )
...
Wrap `bumpalo::collections::String` in `ManuallyDrop` inside our `String` type.
This has 2 advantages:
1. Perf improvement (although it's very minor, because we don't use owned `String` type much).
2. `String`s can be stored in `Allocator` if you want to (#8570 made that impossible, if `String` is `Drop`).
2025-01-20 12:30:20 +00:00
overlookmotel
01a5e5d74a
docs(allocator): improve docs for HashMap ( #8616 )
...
Clarify docs for `HashMap` on `Drop` restriction.
2025-01-20 11:46:13 +00:00
overlookmotel
87568a1942
docs(allocator): reformat docs ( #8615 )
...
Make formatting of doc comments in `oxc_allocator` consistent.
2025-01-20 11:34:29 +00:00
Boshen
d9f5e7fd52
test(minifier): enable passed esbuild tests
2025-01-20 16:39:39 +08:00
Boshen
712cae034c
refactor(minifier): run the compressor on all test cases ( #8604 )
...
Running individual plugins causes too much confusion.
- [x] fix 110 failed tests :-)
2025-01-20 08:11:11 +00:00
翠 / green
8c8b5fa9be
fix(minifier): avoid minifing String(a) into "" + a for symbols ( #8612 )
...
We shouldn't change `String(a)` into `"" + a` if `a` can be a Symbol.
`String(Symbol())` does not throw an error, but `"" + Symbol()` does.
**References**
- [Spec of `ToString` (called for `"" +
variable`)](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tostring )
- [Spec of
`String(a)`](https://tc39.es/ecma262/multipage/text-processing.html#sec-string-constructor-string-value )
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-20 13:34:46 +08:00
Boshen
a78a72fb16
ci: fix overly broad permissions reported by zizmor ( #8611 )
...
https://woodruffw.github.io/zizmor/audits/#excessive-permissions
2025-01-20 13:19:50 +08:00
renovate[bot]
11f33af06b
chore(deps): update npm packages
2025-01-20 03:57:17 +00:00
renovate[bot]
7923971783
chore(deps): update github-actions
2025-01-20 01:06:44 +00:00
Alexander S.
259a47b2ac
refactor(vscode): move commands and findBinary to separate files ( #8605 )
...
pure refactor. wanted to add tests but needs to mocks :/
2025-01-20 09:06:06 +08:00
sapphi-red
997859c42e
refactor(ast): align #[estree(via)] behavior ( #8599 )
...
Follow-on after #8564 . Aligned the behavior of `#[estree(via)]` for fields with `#[estree(via)]` for structs.
2025-01-19 20:44:33 +00:00
Boshen
4ff6e85137
fix(minifier): remove expression statement void 0 ( #8602 )
2025-01-19 14:47:00 +00:00
Alexander S.
1a99d3539e
ci(lint_rules): trigger on utils/mod.rs and on its workflow file ( #8601 )
...
The vitest rules documentation did not get updated after
https://github.com/oxc-project/oxc/pull/8445
2025-01-19 22:38:39 +08:00
Boshen
d966e0adda
perf(codegen): do not check for comments if turned off ( #8598 )
2025-01-19 09:07:24 +00:00
Boshen
8cce69a602
refactor(codegen): remove match_member_expression ( #8597 )
2025-01-19 09:00:25 +00:00
branchseer
ac4f98e376
refactor(span): derive Copy on Atom ( #8596 )
...
Follow up from
https://github.com/oxc-project/oxc/pull/8543#discussion_r1918592423
> I agree. https://github.com/oxc-project/backlog/issues/155
> Originally we were considering some form of interning and
reference-counting, so we didn't make it Copy to leave the door open for
that. But now all strings are stored in the arena anyway, so even if we
did decide to intern strings, reference-counting would be irrelevant -
our bump allocator doesn't allow freeing individual allocations anyway.
Most of the changes are done automatically by `just fix` (`cargo clippy
--fix` && `cargo fmt --all`). See the commit list for the manual edits.
2025-01-19 16:14:23 +08:00
Boshen
066ffe8e8d
fix(tasks/prettier_conformance): fix compile error
2025-01-19 12:17:25 +08:00
Boshen
83caa56926
fix(tasks/prettier_conformance): enable test coverage
2025-01-19 12:07:15 +08:00
Boshen
2a2a2eb5ea
chore(tasks/minsize): enable test coverage
2025-01-19 12:00:40 +08:00
Boshen
9dc65cfa6a
ci: fix release napi script
2025-01-19 10:35:51 +08:00
camc314
93d643e6a4
fix(minifier): keep side effects when folding const conditional exprs ( #8591 )
2025-01-19 01:53:21 +00:00
oxc-bot
8f5be07ed6
release(crates): v0.47.1 ( #8593 )
...
## [0.47.1] - 2025-01-19
### Features
- ee8ee55 napi/parser: Add `.hasChanged()` to `MagicString` (#8586 )
(Boshen)
- 1bef911 napi/parser: Add source map API (#8584 ) (Boshen)
### Bug Fixes
- 7b219a9 minifier: Fix dce shadowed undefined (#8582 ) (Boshen)
- 7421a52 transformer/typescript: Correctly resolve references to
non-constant enum members (#8543 ) (branchseer)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-19 09:44:29 +08:00
oxc-bot
66c8720002
release(oxlint): v0.15.7 ( #8592 )
...
## [0.15.7] - 2025-01-19
### Features
- 01ac773 linter: Support `ignoreTypeOfTestName` for `jest/valid-title`
(#8589 ) (dalaoshu)
- 538b24a linter: Format the configuration documentation correctly
(#8583 ) (Tapan Prakash)
- 7ab14cc linter: Add more Vitest compatible Jest rules (#8445 ) (Anson
Heung)
- d178360 linter: Implement `eslint/prefer-promise-reject-errors`
(#8254 ) (tbashiyy)
- 4ac2e99 oxlint: Implement `--init` cli option (#8453 ) (Tapan Prakash)
### Bug Fixes
- 855c839 codegen: Shorthand assignment target identifier consider
mangled names (#8536 ) (Boshen)
- c15af02 linter: False positive in `eslint/no-lone-blocks` (#8587 )
(dalaoshu)
- 41f2070 linter: Rule `no-restricted-imports` support missing options
(#8076 ) (Alexander S.)
- 869bc73 linter: Enhance `default_param_last` rule to handle optional
parameters (#8563 ) (Tapan Prakash)
- c6260c2 linter: Support rest params for `prefer_promise_reject_errors`
(#8468 ) (Yuichiro Yamashita)
- 2be1e82 linter/no-unused-vars: False positives when variable and type
have same name (#8465 ) (Dunqing)
### Performance
- 250bbd1 linter/react-exhaustive-deps: Use stack of `AstType`s instead
of `AstKind`s (#8522 ) (overlookmotel)
### Refactor
- 40f5165 linter: Improve `eslint/no-lone-blocks` (#8588 ) (dalaoshu)
- b4c87e2 linter: Move DiagnosticsReporters to oxlint (#8454 ) (Alexander
S.)
- bf00f82 linter: Move rule `prefer-each` from vitest to jest +
remapping (#8448 ) (Alexander S.)
- 8dd0013 linter/consistent-function-scoping: Remove `Visit::enter_node`
usage (#8538 ) (overlookmotel)
- 30c0689 linter/no-map-spread: Remove `Visit::enter_node` usage (#8537 )
(overlookmotel)
- b5ed58e span: All methods take owned `Span` (#8297 ) (overlookmotel)
### Styling
- 3789d2f linter/react-exhaustive-deps: Fix indentation (#8520 )
(overlookmotel)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-19 09:00:00 +08:00
dalaoshu
40f51654ec
refactor(linter): improve eslint/no-lone-blocks ( #8588 )
...
The code `let mut lone_blocks = Vec::new();` is unnecessary because it
will contain at most one element throughout its usage.
Additionally, special test cases has been added for when
`parent_node.kind()` is `AstKind::FunctionBody(_)`.
2025-01-18 23:54:17 +00:00
dalaoshu
01ac773d0c
feat(linter): support ignoreTypeOfTestName for jest/valid-title ( #8589 )
...
closes #8531
I'm not sure if we should support it because both `vitest` and `jest`
have this issue
2025-01-18 23:52:51 +00:00
dalaoshu
c15af02e52
fix(linter): false positive in eslint/no-lone-blocks ( #8587 )
...
closes #8515
2025-01-19 00:08:57 +08:00
Boshen
ee8ee55cda
feat(napi/parser): add .hasChanged() to MagicString ( #8586 )
2025-01-18 15:29:17 +00:00
Boshen
1bef911e59
feat(napi/parser): add source map API ( #8584 )
2025-01-18 23:06:42 +08:00