Commit graph

6253 commits

Author SHA1 Message Date
oxc-bot
70c6f24a08
release(oxlint): v0.10.0 (#6661)
## [0.10.0] - 2024-10-18

- 7f6b219 editor/vscode: [**BREAKING**] Unify configuration logic
(#6630) (DonIsaac)

- 782f0a7 codegen: [**BREAKING**] Rename `print_char` method to
`print_ascii_byte` (#6512) (overlookmotel)

- 7645e5c codegen: [**BREAKING**] Remove CommentOptions API (#6451)
(Boshen)

- 5200960 oxc: [**BREAKING**] Remove passing `Trivias` around (#6446)
(Boshen)

- 80266d8 linter: [**BREAKING**] Support plugins in oxlint config files
(#6088) (DonIsaac)

### Features

- 6f22538 ecmascript: Add `ToBoolean`, `ToNumber`, `ToString` (#6502)
(Boshen)
- 1e7fab3 linter: Implement `no-callback-in-promise` (#6157) (dalaoshu)
- c56343d linter: Promote `no_unsafe_optional_chaining` to correctness
(#6491) (Boshen)
- 454874a linter: Implement `react/iframe-missing-sandbox` (#6383) (Radu
Baston)
- c8174e2 linter: Add suggestions for `no-plusplus` (#6376) (camchenry)
- 6e3224d linter: Configure by category in config files (#6120)
(DonIsaac)
- c5e66e1 linter/no-unused-vars: Report own type references within
class, interface, and type alias declarations (#6557) (DonIsaac)
- 8c78f97 linter/node: Implement no-new-require (#6165) (Jelle van der
Waa)

### Bug Fixes

- cf92730 editor: Use human-readable output channel names (#6629)
(DonIsaac)
- d9159a2 editor: Misaligned command prefixes (#6628) (DonIsaac)
- b9c94bb editors/vscode: Temporarily solve oxc_language_server issue on
windows (#6384) (dalaoshu)
- e340424 linter: Support import type with namespaced import in
`import/no-duplicates` (#6650) (Dmitry Zakharov)
- a668397 linter: Panic in `no-else-return` (#6648) (dalaoshu)
- 41dc8e3 linter: Stack overflow in `oxc/no-async-endpoint-handlers`
(#6614) (DonIsaac)
- d07a9b0 linter: Panic in `no-zero-fractions` (#6607) (dalaoshu)
- d6a0d2e linter: Fix file name checking behavior of
`unicorn/filename-case` (#6463) (camchenry)
- 0784e74 linter: Error fixer of `switch-case-braces` (#6474) (dalaoshu)
- e811812 linter: Error diagnostic message based on parameter length of
valid-expect (#6455) (dalaoshu)
- f71c91e linter: Move `eslint/sort-keys` to `style` category (#6377)
(DonIsaac)
- 2b86de9 linter/no-control-regex: False negative for flags in template
literals (#6531) (DonIsaac)
- 685a590 linter/no-control-regex: Better diagnostic messages (#6530)
(DonIsaac)
- 6d5a9f2 linter/no-control-regex: Allow capture group references
(#6529) (DonIsaac)
- ba53bc9 linter/no-unused-vars: False positives in TS type assertions
(#6397) (DonIsaac)
- d3e59c6 linter/no-unused-vars: False positive in some default export
cases (#6395) (DonIsaac)
- e08f956 linter/no-unused-vars: False positive for functions and
classes in arrays (#6394) (DonIsaac)
- b9d7c5f no-unused-vars: Consider functions within conditional
expressions usable (#6553) (Brian Donovan)

### Performance

- 0cbd4d0 linter: Avoid megamorphism in `RuleFixer` methods (#6606)
(DonIsaac)
- 725f9f6 linter: Get fewer parent nodes in
`unicorn/prefer-dom-node-text-content` (#6467) (camchenry)
- c00f669 linter: Use NonZeroUsize for pending module cache entries
(#6439) (DonIsaac)
- a1a2721 linter: Replace `ToString::to_string` with `CompactStr` in
remaining rules (#6407) (camchenry)
- c5c69d6 linter: Use `CompactStr` in `valid-title` (#6406) (camchenry)
- d66e826 linter: Use `CompactStr` in `prefer-lowercase-title` (#6405)
(camchenry)
- 889400c linter: Use `CompactStr` for `get_node_name` in Jest rules
(#6403) (camchenry)
- 9906849 linter: Use `CompactStr` in `no-large-snapshots` (#6402)
(camchenry)
- c382ec4 linter: Use `CompactStr` in `no-hooks` (#6401) (camchenry)
- 24a5d9b linter: Use `CompactStr` in `expect-expect` (#6400)
(camchenry)
- 71dbdad linter: Use `CompactStr` in `no-console` (#6399) (camchenry)
- f5f00a1 linter: Use `CompactStr` in `no-bitwise` (#6398) (camchenry)
- 62afaa9 linter/jsx-no-comment-textnodes: Remove regex for checking
comment patterns (#6534) (camchenry)
- b3d0cce linter/no-unescaped-entities: Add fast path to check if char
should be replaced (#6594) (camchenry)
- ee73f56 linter/no-unused-vars: Do not construct `Regex` for default
ignore pattern (#6590) (camchenry)
- 77ddab8 linter/numeric-separators-style: Replace regex with number
parser (#6546) (camchenry)
- 8f47cd0 linter/react: Remove regex patterns in `no-unknown-property`
(#6536) (camchenry)

### Documentation

- 557f941 linter: Add docs to no-unused-vars and Tester (#6558)
(DonIsaac)

### Refactor

- ecce5c5 linter: Improve recursive argument handling and diagnostics
creation (#6513) (no-yan)
- f960e9e linter: Add suggested file names for `unicorn/filename-case`
(#6465) (camchenry)
- 7240ee2 linter: Make advertised fix kinds consistent (#6461)
(Alexander S.)
- b48c368 linter: `no_global_assign` rule: reduce name lookups (#6460)
(overlookmotel)
- 2566ce7 linter: Remove OxlintOptions (#6098) (DonIsaac)
- 002078a linter: Make Runtime's members private (#6440) (DonIsaac)
- 6a0a533 linter: Move module cache logic out of Runtime (#6438)
(DonIsaac)
- c18c6e9 linter: Split service code into separate modules (#6437)
(DonIsaac)
- 5ea9ef7 linter: Improve labels and help message for
`eslint/no-useless-constructor` (#6389) (DonIsaac)
- 2c32dac linter/no-control-regex: Remove duplicate code (#6527)
(DonIsaac)
- 435a89c oxc: Remove useless `allocator.alloc(program)` calls (#6571)
(Boshen)
- f70e93b oxc: Ban index methods on std::str::Chars (#6075) (dalaoshu)

### Testing

- a6cae98 linter: Make sure all auto-fixing rules have fixer test
(#6378) (DonIsaac)
- 06b09b2 linter/no-unused-vars: Enable now-passing tests (#6556)
(DonIsaac)
- badd11c linter/no-unused-vars: Ignored catch parameters (#6555)
(DonIsaac)
- 84aa2a2 linter/no-useless-constructor: Add cases for initializers in
subclass constructors (#6390) (DonIsaac)

---------

Co-authored-by: DonIsaac <22823424+DonIsaac@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-18 20:34:15 -04:00
Boshen
2ce3e5fefc fix(identifier): add ZWSP to is_irregular_whitespace (#6662)
closes #6646
2024-10-18 22:20:02 +00:00
overlookmotel
458f8f3822 refactor(ast_tools): consistent comments on AstBuilder methods (#6664)
Affects comment style only. Use "Build" consistently, not "Builds" in some places, and correct use of "a" / "an".
2024-10-18 15:57:36 +00:00
overlookmotel
ac77c87cec perf(traverse): optimize TraverseScoping::generate_uid_name (#6663)
Tiny optimization. Move initializing `self.uid_names` to just before `self.uid_names.as_mut().unwrap()` so compiler can see that the `unwrap` is infallible and elide it, even if `get_uid_names` isn't inlined.
2024-10-18 15:43:47 +00:00
overlookmotel
9d43a1124d style(transformer): re-order dependencies (#6659)
Nit. Move `oxc_*` dependencies to first in list.
2024-10-18 14:41:36 +00:00
overlookmotel
683c3443c0 chore(semantic, wasm): re-order dependencies in Cargo.toml files (#6657)
Nit. Move `serde` dependency into more natural place in the list.
2024-10-18 13:40:37 +00:00
Dmitry Zakharov
e3404249a2
fix(linter): support import type with namespaced import in import/no-duplicates (#6650)
got false positive cases, and looks like that not fixed in import lib
too (issue is open).
Also I fix cases for imports without types. But can't fix it due to lack
of understanding that functional style code.

P. S. just installed pre-commit hook for fmt, sorry

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-17 20:32:42 -04:00
dalaoshu
a66839752a
fix(linter): panic in no-else-return (#6648)
closes #6636
2024-10-17 20:30:55 -04:00
Boshen
f4cdc56577 refactor(minifier): use constant folding unary expression from oxc_ecmascript (#6647) 2024-10-17 15:30:38 +00:00
magic-akari
1d3d256db3 fix(transformer): Correctly trim JSX (#6639)
- Closes: #6638
2024-10-17 14:41:02 +00:00
overlookmotel
92812349e5 refactor(transformer): shorten imports (#6643)
Style nit. Shorten `use` statements in transformer.
2024-10-17 09:16:01 +00:00
overlookmotel
f3451d7ec4 docs(transformer/async-to-generator): remove empty lines from doc comment (#6642)
Style nit.
2024-10-17 09:16:00 +00:00
Dunqing
a3dea9c542 feat(transformer/async-to-generator): handle arrow-function correctly (#6640) 2024-10-17 08:47:28 +00:00
Dunqing
390abca29a refactor(transformer/async-to-generator): use helper_call_expr (#6634) 2024-10-17 08:37:05 +00:00
Dunqing
a01a5dfdaf feat(transformer): pass TransformerCtx to async-to-generator plugin (#6633) 2024-10-17 08:25:58 +00:00
Dunqing
2ff917fdac refactor(transformer/async-to-generator): move internal methods below entry points (#6632) 2024-10-17 08:14:29 +00:00
Dunqing
673b66620b chore(transform_conformance): do not extend plugins if current options has plugins (#6627)
I saw many tests were ignored even if they don't contain any unsupported plugins
2024-10-17 02:07:03 +00:00
Boshen
e5ed6a56a8 feat(codegen): print negative numbers (#6624) 2024-10-16 22:38:54 +00:00
DonIsaac
7f6b21925d feat(editor/vscode)!: unify configuration logic (#6630)
> Closes https://github.com/oxc-project/backlog/issues/132

Unify configuration logic into `ConfigService`. This allows for type-checked
config settings. It also lets us make sure config values are synced with what
the user has set in their vscode settings.

This PR is a breaking change since it also unifies config key prefixes (`oxc`
and `oxc_language_server` -> `oxc` only)
2024-10-16 22:31:29 +00:00
DonIsaac
cf9273090a fix(editor): use human-readable output channel names (#6629)
Changes the names of output channels our editor uses to make them friendlier.
2024-10-16 22:31:29 +00:00
DonIsaac
d9159a2445 fix(editor): misaligned command prefixes (#6628)
In the client code, we were registering commands under the `oxc` prefix, but in our `package.json` we were advertising a `oxc_language_server` prefix.
2024-10-16 22:31:28 +00:00
Dmitry Zakharov
25a49a5700
feat(rulegen): add import to rulegen (#6631)
Added for fast rule creation
2024-10-16 17:05:40 -04:00
DonIsaac
87f3b8dc55 refactor(macros): clean up declare_oxc_secret (#5937) 2024-10-16 20:10:10 +00:00
camchenry
b3d0cce2c2 perf(linter/no-unescaped-entities): add fast path to check if char should be replaced (#6594)
Flamegraph shows a lot of time spent hashing here, so I added a faster check to see if it is a char that we need to replace.
2024-10-16 19:59:30 +00:00
camchenry
ee73f568b3 perf(linter/no-unused-vars): do not construct Regex for default ignore pattern (#6590)
Profiling shows that constructing the `Regex` for `no-unused-vars` takes up a good chunk of time for small files. Since the default pattern for ignored variables is just `^_`, we can more simply implement this with `.starts_with('_')`.

<img width="1439" alt="image" src="https://github.com/user-attachments/assets/7a4abb8c-2c0e-4252-8df4-e5b1880e8209">

I decided to create a new `Option`-like enum that has three states: `Some` and `None` which are like the typical `Option` states, and another `Default` state which is a special case. The `Default` state represents that matching code should use the default pattern (if applicable). I decided not to keep using `Option`, because I didn't want to overload the `None` state by confusing whether or not it was the default state, or the user explicitly overrided it as `None`.

The theory here is that most users are not going to pass a custom ignore pattern, so we can avoid needing to create a `Regex` in most cases, which greatly speeds up the initialization for this rule.
2024-10-16 19:59:29 +00:00
overlookmotel
9f555d7c7f docs(allocator): clarify docs for Box (#6625)
Clarify the consequences of storing `Drop` types in `oxc_allocator::Box`.
2024-10-16 15:35:53 +00:00
overlookmotel
2673397122 fix(isolated_declarations): fix potential memory leak (#6622)
`Scope` contains 2 x `FxHashMap`s, which own data outside of the arena. So this data will not be dropped when the allocator is dropped.

The scope for this becoming a memory leak in practice is limited for 2 reasons:

1. All `Scope`s except the root one are popped from the stack by the end of traversal. That last scope's hashmaps are always empty, unless there are unresolved references (references to globals).

2. `oxc_allocator::Vec` is currently `Drop`.

However, `oxc_allocator::Vec` will cease to be `Drop` in future, at which point this would become a real memory leak.

Additionally, it doesn't make sense to store temporary data in the arena, as the arena is intended to hold data that needs to live as long as the AST, which temporary data doesn't.
2024-10-16 15:05:54 +00:00
overlookmotel
3af08406b8 refactor(transformer): HelperLoader: add import immediately (#6601)
Helper loader does not need to store details for import statements and then add them in an `exit_program` visitor. It can add them immediately.

That means `HelperLoader` transform can be removed, and its public methods are implemented directly on `TransformCtx`.
2024-10-16 13:01:57 +00:00
overlookmotel
f81aa7faea refactor(transformer): HelperLoader common transform: comments (#6599)
Just tidy up comments a little.
2024-10-16 06:48:03 +00:00
overlookmotel
679cc68e1f refactor(transformer): HelperLoader common transform: construct string directly in arena (#6596)
Small optimization. Avoid allocating a temporary `String` which then gets copied into the arena, by constructing the string directly in the arena.

We should probably have a dedicated API for doing this, but for now just do it here.
2024-10-16 06:48:02 +00:00
overlookmotel
c346ebb0ca refactor(transformer): HelperLoader common transform: Helper enum (#6595)
`HelperLoaderStore::load` take a `Helper` instead of a string.

`Helper` has 2 purposes:

1. Constrain what helpers you can add to a fixed list (prevent typos).
2. Makes the hashmap lookup cheaper - hashing a single-byte `enum` (`u8`) is cheaper than hashing a string.
2024-10-16 06:48:01 +00:00
DonIsaac
0cbd4d0270 perf(linter): avoid megamorphism in RuleFixer methods (#6606)
Use inner functions with concrete implementations to avoid megamorphism in `RuleFixer` methods. This should help reduce binary sizes and `rustc` codegen times.
2024-10-16 06:41:48 +00:00
DonIsaac
41dc8e314e fix(linter): stack overflow in oxc/no-async-endpoint-handlers (#6614)
Closes #6583
2024-10-16 06:37:11 +00:00
Don Isaac
78fe4af3ad
ci: skip coverage/benchmarks on more unrelated files (#6616)
Enhance file filters that trigger coverage and benchmark jobs by adding
more ignored globs.
2024-10-16 14:36:07 +08:00
DonIsaac
557f94104e docs(linter): add docs to no-unused-vars and Tester (#6558)
Misc doc changes made while authoring the previous PR in this stack.
2024-10-16 06:09:41 +00:00
dalaoshu
1e7fab32fd
feat(linter): implement no-callback-in-promise (#6157) 2024-10-16 02:06:56 -04:00
Jelle van der Waa
8c78f9719b
feat(linter/node): implement no-new-require (#6165)
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-10-15 20:06:23 -04:00
overlookmotel
9e9fa9e741 docs(span): enable lint warnings on missing docs (#6617)
This attribute was added in #6610, but then removed again in #6612. I assume removing it was an accident.
2024-10-15 23:55:49 +00:00
DonIsaac
06e75b032e docs(allocator): enable lint warnings on missing docs, and add missing doc comments (#6613)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 22:50:48 +00:00
DonIsaac
de22b81b83 docs(data-structures): enable lint warnings on missing docs, and add missing doc comments (#6612)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 22:50:47 +00:00
DonIsaac
335b7f22c5 docs(syntax): enable lint warnings on missing docs, and add a lot of documentation (#6611)
Part of https://github.com/oxc-project/backlog/issues/130

I didn't add doc comments to everything; I'm missing context for module-related data types and I have other things to do :P
2024-10-15 22:50:45 +00:00
DonIsaac
28b1b4efe2 chore(span): enable lint warnings on missing docs (#6610)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 22:50:44 +00:00
DonIsaac
3faee66400 refactor(span): remove unused ContentHash::content_hash_slice (#6609)
I've replaced it with impls on `Vec<'a, T>`. I'm hoping this removes some bloat in final binaries.
2024-10-15 22:50:42 +00:00
Don Isaac
a00b43717d
ci: cache compiled dprint plugins (#6605)
Cache downloaded & compiled `dprint` plugins in `autofix.ci` between
runs. It should help shave some time off this pipeline.
2024-10-16 06:48:24 +08:00
DonIsaac
03427af85b chore(parser): enable lint warnings on missing docs (#6608)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 21:51:41 +00:00
dalaoshu
d07a9b0fb3
fix(linter): panic in no-zero-fractions (#6607)
closes #6584 

Only fixed character index errors on the linter side.
2024-10-15 16:48:11 -04:00
DonIsaac
5213ba7fb4 feat(website/linter): render mapped types in config docs (#6604)
Render better types for config properties that accept arbitrary keys. For example, `Record<string, boolean>` instead of `object`.
2024-10-15 20:35:45 +00:00
DonIsaac
dcd4607a40 feat(website/linter): render defaults in config docs (#6603)
Render default values for each section in oxlintrc config docs.
2024-10-15 20:35:45 +00:00
DonIsaac
d4cb7e6f58 fix(website/linter): better md rendering for primitive arrays (#6602)
Improves how config docs are rendered for the website. If a config property is an array of primitive values, we now skip subsection rendering and render a better type, e.g. `string[]` instead of `array`.
2024-10-15 20:35:45 +00:00
Boshen
389d2615d0 fix(minifier): ~~ operator should only work on numbers (#6598) 2024-10-15 16:37:00 +00:00