Commit graph

7045 commits

Author SHA1 Message Date
camc314
e824501a21 fix(linter): false positive in exhaustive-deps (#7626) 2024-12-04 01:58:25 +00:00
camc314
8a68ef4c3b fix(linter): update reporting spans for exhaustive-deps (#7625) 2024-12-04 01:58:23 +00:00
camc314
543df6e3a8 fix(linter): fix false positives in exhaustive-deps (#7615)
part of https://github.com/oxc-project/oxc/issues/7246
2024-12-03 23:54:22 +00: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
adee0d1876
chore(npm/oxc-parser): update README 2024-12-03 22:37:49 +08:00
Boshen
4eb87eadbf feat(linter): RulesOfHooks from nursery to correctness (#7607) 2024-12-03 14:15:43 +00:00
Boshen
bd977cf742 feat(oxc): add oxc_napi crate (#7612) 2024-12-03 14:02:47 +00:00
IWANABETHATGUY
6af8659624 fix(oxc_transformer): correct generate ThisExpr and import.meta in jsx pragma (#7553) 2024-12-03 13:54:15 +00:00
camc314
6dd71c6d05 test(linter): port eslint tests to no-unused-expressions (#7611) 2024-12-03 13:15:49 +00:00
overlookmotel
eb825edee2 fix(transformer/class-properties): replace references to class name with temp var in static prop initializers (#7610)
Similar to #7516. Fix class properties transform to replace references to class name in static prop initializers with temp var.

Input:

```js
class C {
  static getSelf = () => C;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.
2024-12-03 12:43:21 +00:00
overlookmotel
7d1c12e5e2 refactor(transformer/class-properties): rename misleadingly-named method (#7609)
This method replaces `this` with class temp var, not reference to class name. Name the method accordingly, and update comments.
2024-12-03 12:43:21 +00:00
overlookmotel
206de912dc feat(semantic): add SymbolTable::add_resolved_reference method (#7608)
Add `SymbolTable::add_resolved_reference` method to add a reference for a symbol.
2024-12-03 12:43:20 +00:00
camc314
e80214c74f fix(linter): fix false positives in rules-of-hooks (#7606)
closes https://github.com/oxc-project/oxc/issues/7572

should remove all false positives from this rule
2024-12-03 12:19:00 +00:00
Boshen
40792b4440 feat(napi/parser): change parse API to accept mandatory filename and optional lang (#7605) 2024-12-03 12:09:48 +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
7c62a33a06 feat(napi/parser): return esm info (#7602)
The parser now returns import / export statement information, which can be used for parser plugins.
2024-12-03 11:21:54 +00:00
Yuji Sugiura
521df425de
refactor(prettier): Unified method of Doc generation (#7600)
Before:

- `Doc::Xxx()` + `XXX.with_xxx()`
- `macro!()`
- `p.xxx()`

After:

- `p.xxx()` with `p_vec!` macro
2024-12-03 17:27:55 +08:00
翠 / green
58643529d1
feat(napi/transform): add TransformerOptions::assumptions (#7601)
so that I can use `setPublicClassFields` for #6735 when it's ready.
2024-12-03 17:25:18 +08:00
overlookmotel
802233d151 refactor(transformer/class-properties): remove pointless method (#7592)
#7516 removed the need for a special method to handle `export default class {}`. Delete it.
2024-12-03 07:46:05 +00:00
overlookmotel
0eadd9f6de fix(transformer/class-properties): create temp var for class where required (#7516)
Fix class properties transform to create a temp var for class when it's required.

Input:

```js
class C {
  static getSelf = () => this;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.

The logic around when a temp var is required and when it's not, and when/where it's referenced is ridiculously complicated. So add some debug assert mechanisms to double-check the logic.
2024-12-03 07:46:04 +00:00
overlookmotel
a07f278dfd refactor(transformer/class-properties): PrivatePropsStack type (#7589)
Pure refactor. Move all logic and types related to storing details of what private properties classes have into a separate file `private_props.rs`. Introduce a type `PrivatePropsStack` to represent the stack of classes.
2024-12-03 07:46:03 +00:00
overlookmotel
370d4b9176 docs(transformer/class-properties): add missing docs (#7588)
Docs only. Add mention of what `static_prop.rs` does to the main doc comment for the transform.
2024-12-03 07:46:02 +00:00
overlookmotel
7bd6350978 refactor(transformer/class-properties): move creating temp var out of main loop (#7587)
Small optimization. Move code out of the loop which determines if class property transform has nothing to do and can bail out early. This also clears the way for correcting the logic around when temp vars are/aren't created in #7516.
2024-12-03 07:46:01 +00:00
overlookmotel
ebd11fb5e9 refactor(transformer/class-properties): exit transform_class faster if nothing to do (#7586)
Small optimization. Class properties transform doesn't have to do anything if the class has no properties, which will often be the case. Exit sooner in this case.
2024-12-03 07:46:00 +00:00
overlookmotel
dccff38afe refactor(transformer/class-properties): ResolvedPrivateProp type (#7532)
Pure refactor. `lookup_private_property` returns a tuple of 3 items, and future changes will make that 4. That's silly. Create a type `ResolvedPrivateProp` for it to return, so the various parts can have descriptive names.
2024-12-03 07:45:59 +00:00
overlookmotel
367b6c8053 refactor(transformer/class-properties): shortcut_static_class take SymbolId (#7531)
Pure refactor. `shortcut_static_class` method take `SymbolId` of class name, instead of the `&BoundIdentifier`. This change is in preparation for later PRs fixing class properties transform.
2024-12-03 07:45:58 +00:00
overlookmotel
ab1214d33c refactor(transformer/class-properties): rename class_binding (#7533)
Pure refactor. Just rename a variable. `class_binding` is preferable, since this binding isn't always for the class *name*.
2024-12-03 07:45:57 +00:00
翠 / green
71b3437a4c
test(oxc_transformer): define works differently with esbuild (#7593)
See https://github.com/oxc-project/oxc/issues/7594

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-03 15:23:40 +08:00
Boshen
16adaf9afd refactor(napi/parser): clean up code (#7596) 2024-12-03 04:48:51 +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
Kevin Deng 三咲智子
be2293a1b5
fix(napi/transform): respect options.sourcemap for id (#7590)
Don't pass `source_map_path` if `options.sourcemap` is undefined or
false; then, `IsolatedDeclarationsResult.map` should be undefined.

Downstream issue
https://github.com/unplugin/unplugin-isolated-decl/issues/42

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-03 11:57:44 +08:00
overlookmotel
b553d6ff9c fix(span): fix clippy warning (#7591)
Fix clippy warning. Only triggers when running clippy in `--release` mode.
2024-12-03 02:18:57 +00:00
Cameron
3dc46a80c9
fix(linter): no-unused-expressions false positive with arrow fn expressions (#7585)
fixes https://github.com/oxc-project/oxc/issues/7584
2024-12-03 09:48:50 +08:00
Alexander S.
810671a4a0
fix(linter): detect vitest jest alias rules (#7567)
closes #7240
2024-12-03 09:46:05 +08:00
Boshen
33e5a49c78 feat(syntax): add statement span to ImportEntry and ExportEntry (#7583) 2024-12-02 14:20:30 +00:00
IWANABETHATGUY
a784a82f4f feat(oxc_transformer): support jsx pragma that are long member expressions (#7538)
related tests:

d34e79e2a9/internal/bundler_tests/bundler_default_test.go (L6188-L6236)
2024-12-02 14:02:38 +00:00
Boshen
f0e7acc68b refactor(syntax): change ModuleRecord::not_esm to has_module_syntax (#7579) 2024-12-02 09:32:57 +00:00
Boshen
18519dea33 refactor(syntax): remove ModuleRecord::export_default (#7578)
This value can be derived.
2024-12-02 09:17:57 +00:00
Boshen
d476660b0b refactor(syntax): remove ModuleRecord::exported_bindings_duplicated because it is a syntax error (#7577) 2024-12-02 08:48:01 +00:00
Boshen
17663f55d3 refactor(syntax): remove ModuleRecord::export_default_duplicated because it is a syntax error (#7576) 2024-12-02 08:19:59 +00:00
camc314
275d6256bb feat(linter): output rules to json array (#7574)
closes #7517

cc @Sysix
2024-12-02 03:17:57 +00:00
camc314
4e3044e225 fix(linter): rules-of-hooks fix false positive with default export (#7570)
closes #7555
2024-12-02 03:09:30 +00:00
camc314
cb1f8e6e03 chore(linter): update rules_of_hooks test cases (#7569)
updates test cases based on what's currently in react's repo
2024-12-02 03:09:30 +00:00
dalaoshu
9761e94176
fix(apps/oxlint): incorrect matching in .oxlintignore (#7566)
The issue was discovered while updating test cases in `rolldown`.

In the `.oxlintignore` file, we have:
```ignore
tests/**
```

When running the command by `lint-staged`:

```bash
oxlint -c .oxlintrc.json --ignore-path=.oxlintignore --deny-warnings "tests/function/main.js"
```

The file `main.js` gets linted despite being ignored. This happens
because, before using `Gitignore::new`, we converted paths to absolute
paths, causing the pattern `tests/**` to not match
`D:/rolldown/tests/function/main.js` correctly.


c61a383e8c/apps/oxlint/src/lint.rs (L60-L78)
2024-12-02 11:06:20 +08: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
Boshen
79014ffb1d refactor(syntax): clean up ModuleRecord (#7568) 2024-12-01 14:49:04 +00:00
Boshen
bf16668de7 feat(transform_conformance): keep exec snapshot files (#7565)
closes #7564
2024-12-01 10:13:47 +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
a6b0100501
docs(linter): fix config example headings (#7562)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-01 16:31:22 +08:00