Commit graph

6722 commits

Author SHA1 Message Date
Boshen
f54d330eca
feat(tasks/lint_rules): mark eslint/no-undef-init as done (#7244)
closes #6456
2024-11-12 11:55:37 +08:00
Boshen
1282221e36 fix(codegen): print comments when block is empty (#7236)
part of #7190
2024-11-11 11:20:25 +00:00
7086cmd
0d6a66aa9e test(minifier): fix minimize condition tests (#7222) 2024-11-11 08:36:19 +00:00
Boshen
080a67be16 test(semantic): semantic checker store conformance pass/fail info in a separate file (#7235)
closes #6069
2024-11-11 08:13:13 +00:00
Boshen
2e0364e21a
chore(deps): update crate-ci/typos action to v1.27.3 (#7228)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-10 00:41:21 +08:00
oxc-bot
de107246c8
release(crates): v0.36.0 (#7227)
## [0.36.0] - 2024-11-09

- b11ed2c ast: [**BREAKING**] Remove useless `ObjectProperty::init`
field (#7220) (Boshen)

- 0e4adc1 ast: [**BREAKING**] Remove invalid expressions from
`TSEnumMemberName` (#7219) (Boshen)

- 846711c transformer: [**BREAKING**] Change API to take a
`&TransformOptions` instead of `TransformOptions` (#7213) (Boshen)

- 092de67 types: [**BREAKING**] Append `rest` field into `elements` for
objects and arrays to align with estree (#7212) (ottomated)

- d1d1874 ast: [**BREAKING**] Change `comment.span` to real position
that contain `//` and `/*` (#7154) (Boshen)

- 843bce4 ast: [**BREAKING**] `IdentifierReference::reference_id` return
`ReferenceId` (#7126) (overlookmotel)

### Features

- cc8a191 ast: Methods on AST nodes to get `scope_id` etc (#7127)
(overlookmotel)
- dc0215c ast_tools: Add #[estree(append_to)], remove some custom
serialization code (#7149) (ottomated)
- 9d6cc9d estree: ESTree compatibility for all literals (#7152)
(ottomated)
- b74686c isolated-declarations: Support transform TSExportAssignment
declaration (#7204) (Dunqing)
- ad3a2f5 tasks/compat_data: Generate our own compat table (#7176)
(Boshen)
- b4258ee transformer: Add defaulted `Module::Preserve` option (#7225)
(Boshen)
- 324c3fe transformer: Add `TransformOptions::module` option (#7188)
(Boshen)
- a166a4a transformer: Add esbuild comma separated target API
`--target=es2020,chrome58` (#7210) (Boshen)
- 3a20b90 transformer: Add es target to `engineTargets` (#7193) (Boshen)
- 22898c8 transformer: Warn BigInt when targeting < ES2020 (#7184)
(Boshen)
- a579011 transformer: Add features `ES2018NamedCapturingGroupsRegex`
and `ES2018LookbehindRegex` (#7182) (Boshen)
- 8573f79 transformer: Turn on async_to_generator and
async_generator_functions plugins in enable_all (#7135) (Dunqing)
- df77241 transformer: Enable `ArrowFunctionConverter` in
`async-to-generator` and `async-generator-functions` plugins (#7113)
(Dunqing)
- b6a5750 transformer/arrow-function-converter: Move scope to changed
scope for `this_var` if scope have changed (#7125) (Dunqing)
- 1910227 transformer/async-to-generator: Support inferring the function
name from the ObjectPropertyValue's key (#7201) (Dunqing)
- ffa8604 transformer/async-to-generator: Do not transform await
expression if is not inside async function (#7138) (Dunqing)
- e536d47 transformer/babel: Add support for trying to get the `Module`
from `BabelPlugins` (#7218) (Dunqing)
- 5cfdc05 transformer/typescript: Support transform `export =` and
`import = require(...)` when module is commonjs (#7206) (Dunqing)

### Bug Fixes

- c82b273 transformer/async-generator-functions: Only transform object
method in exit_function (#7200) (Dunqing)
- b2a888d transformer/async-generator-functions: Incorrect
transformation for `for await` if it's not placed in a block (#7148)
(Dunqing)
- 19892ed transformer/async-generator-functions: Transform incorrectly
for `for await` if it's in LabeledStatement (#7147) (Dunqing)
- ede10dc transformer/async-to-generator: Incorrect transform when super
expression is inside async method (#7171) (Dunqing)
- 293d072 transformer/async-to-generator: Only transform object method
in exit_function (#7199) (Dunqing)
- ae692d7 transformer/async_to_generator: Fix checking if function is
class method (#7117) (overlookmotel)
- eea4ab8 transformer/helper-loader: Incorrect `SymbolFlags` for default
import when `SourceType` is script (#7226) (Dunqing)

### Refactor

- d27e14f ast: `AstKind::as_*` methods take `self` (#5546)
(overlookmotel)
- fac5042 ast: Use `scope_id` etc methods (#7130) (overlookmotel)
- a297765 minifier: Use `map` and `and_then` instead of let else (#7178)
(7086cmd)
- fc86703 napi/transform: Change test files to TypeScript (#7221)
(Boshen)
- c5485ae semantic: Add `ancestor_kinds` iterator function (#7217)
(camchenry)
- abf1602 semantic: Rename `iter_parents` to `ancestors` (#7216)
(camchenry)
- 42171eb semantic: Rename `ancestors` to `ancestor_ids` (#7215)
(camchenry)
- de56083 transformer: Add `impl TryFrom<EngineTargets> for EnvOptions`
(#7191) (Boshen)
- 0a43c64 transformer: Move `ESTarget` to its own file (#7189) (Boshen)
- 0e1f12c transformer: Remove unimplemented `EnvOptions::bugfixes`
(#7162) (Boshen)
- a981caf transformer: Add `Engine` enum for `EngineTargets` (#7161)
(Boshen)
- 8340243 transformer: Rename `Query` to `BrowserslistQuery` (#7143)
(Boshen)
- 481f7e6 transformer: Change `Targets` to `EngineTargets` (#7142)
(Boshen)
- 55e6989 transformer: Deserialize engine target strings to specific
keys (#7139) (Boshen)
- fdfd9a4 transformer: Use `scope_id` etc methods (#7128)
(overlookmotel)
- ff8bd50 transformer: Move implementation of ArrowFunction to
common/ArrowFunctionConverter (#7107) (Dunqing)
- 4a515be transformer/arrow-function-coverter: Rename function name and
add some comments to explain confusing parts. (#7203) (Dunqing)
- c307e1b transformer/arrow-functions: Pass `ArenaBox` as function param
(#7169) (overlookmotel)
- 217d433 transformer/arrow-functions: Remove unused `&mut self`
function param (#7165) (overlookmotel)
- 426df71 transformer/arrow-functions: Use `scope_id` method (#7164)
(overlookmotel)
- 11c5e12 transformer/arrow-functions: Correct comments (#7163)
(overlookmotel)
- 1238506 transformer/async-generator-function: Remove inactive
`#[allow(clippy::unused_self)]` attrs (#7167) (overlookmotel)
- 84ee581 transformer/async-generator-functions: Simplify identifying
whether within an async generator function (#7170) (overlookmotel)
- 1b12328 transformer/async-generator-functions: Use `clone` not
`clone_in` on `LabelIdentifier` (#7172) (overlookmotel)
- cd1006f transformer/async-generator-functions: Do not transform yield
expression where inside generator function (#7134) (Dunqing)
- 2c5734d transformer/async-generator-functions: Do not transform await
expression where inside ArrowFunctionExpression (#7132) (Dunqing)
- 5ce83bd transformer/async-generator-functions: Remove dead code for
handle await expression (#7131) (Dunqing)
- e04ee97 transformer/async-generator-functions: Move handling of
`MethodDefinition`'s value to `exit_function` (#7106) (Dunqing)
- b57d5a5 transformer/async-to-generator: Remove unused `&self` function
param (#7166) (overlookmotel)
- f80085c transformer/async-to-generator: Move handling of
`MethodDefinition`'s value to `exit_function` (#7105) (Dunqing)
- e2241e6 transformer/jsx-self: Remove unused `&self` function params
(#7159) (overlookmotel)
- 1dfd241 transformer/optional-catch-binding: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7158) (overlookmotel)
- fd9b44c transformer/typescript: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7160) (overlookmotel)
- cacfb9b traverse: Use `symbol_id` etc methods (#7129) (overlookmotel)

### Styling

- 38a6df6 transformer/arrow-functions: Semicolon after return statements
(#7168) (overlookmotel)
- 64b7e3a transformer/async-generator-functions: Import
`oxc_allocator::Vec` as `ArenaVec` (#7173) (overlookmotel)

### Testing

- be819dd napi/transform: Add test for not default es transform (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-10 00:31:14 +08:00
Boshen
be819dded1
test(napi/transform): add test for not default es transform 2024-11-10 00:21:26 +08:00
Dunqing
eea4ab830a fix(transformer/helper-loader): incorrect SymbolFlags for default import when SourceType is script (#7226) 2024-11-09 14:32:44 +00:00
Boshen
b4258ee58e feat(transformer): add defaulted Module::Preserve option (#7225) 2024-11-09 12:55:13 +00:00
oxc-bot
68dc899887
release(oxlint): v0.11.1 (#7224)
## [0.11.1] - 2024-11-09

### Features

- 4dd9b60 editor/vscode: Replace existing output channel and trace
output channel with a single LogOutputChannel (#7196) (Nicholas Rayburn)
- 1fcd709 linter: Add jsx support for only-used-in-recursion (#7120)
(no-yan)
- 4d577cf linter: Add `import/first` rule (#7180) (Dmitry Zakharov)
- 9b8973f linter: Add `import/unambiguous` rule (#7187) (Dmitry
Zakharov)
- 5ab1ff6 linter: Implement @typescript-eslint/no-unsafe-function-type
(#6989) (Orenbek)

### Bug Fixes

- eea8879 editor/vscode: Update language client id to fix the resolution
of the oxc.trace.server setting (#7181) (Nicholas Rayburn)
- b73cfd9 linter: Fix `is_method_call` with parentheses and chain
expression (#7095) (tbashiyy)

### Refactor

- 8c0a362 linter: Use `ctx.source_range(comment.content_span())` API
(#7155) (Boshen)
- c5485ae semantic: Add `ancestor_kinds` iterator function (#7217)
(camchenry)
- abf1602 semantic: Rename `iter_parents` to `ancestors` (#7216)
(camchenry)
- 42171eb semantic: Rename `ancestors` to `ancestor_ids` (#7215)
(camchenry)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-09 19:57:08 +08:00
Boshen
c62e192a68
ci: fix oxlint-ecosystem-ci 2024-11-09 19:56:07 +08:00
7086cmd
a2977655c8 refactor(minifier): use map and and_then instead of let else (#7178)
For the test case, Closure Compiler doesn't handle this at all in the REPL! If it's necessary, I will turn it back.

This PR uses builtin `and_then` and `map` method, which is better instead of a lot of `if let Some`.
2024-11-09 11:48:48 +00:00
overlookmotel
d27e14f065 refactor(ast): AstKind::as_* methods take self (#5546)
Make `AstKind::as_*` methods (e.g. `AstKind::as_boolean_literal`) take `self`, not `&self`.

`AstKind` is `Copy`.

See: https://github.com/oxc-project/oxc/issues/5506#issuecomment-2332912976
2024-11-09 09:39:13 +00:00
Dunqing
5cfdc05d06 feat(transformer/typescript): support transform export = and import = require(...) when module is commonjs (#7206)
close: #7141
2024-11-09 09:32:28 +00:00
Boshen
fc86703933
refactor(napi/transform): change test files to TypeScript (#7221) 2024-11-09 17:32:15 +08:00
BitterGourd
94865a9390
feat(rulegen): support outdent and dedent tagged template expressions (#6866)
close #6645

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-11-09 17:26:27 +08:00
Boshen
24c585a20a
feat(napi/parser): reexport @oxc-project/types (#7214)
closes #7207
2024-11-09 17:24:07 +08:00
no-yan
1fcd70932d
feat(linter): add jsx support for only-used-in-recursion (#7120)
close #5530

This PR adds support for handling recursive JSX components, allowing
detect functions like the one below:

```javascript
function ListItem({ depth }) {
    return <ListItem depth={depth} />
}
```

Some logic is duplicated with the non-JSX case. But the refactor will be
complicated and affects over-all, so we can make it in another PR.

cc: @DonIsaac @camc314

---------

Co-authored-by: Cam McHenry <camchenry@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-09 17:11:27 +08:00
Dmitry Zakharov
4d577cf69f
feat(linter): add import/first rule (#7180) 2024-11-09 17:10:59 +08:00
Boshen
b11ed2cf7b refactor(ast)!: remove useless ObjectProperty::init field (#7220)
closes https://github.com/oxc-project/backlog/issues/143
2024-11-09 09:00:29 +00:00
Boshen
0e4adc15dd feat(ast)!: remove invalid expressions from TSEnumMemberName (#7219) 2024-11-09 08:48:14 +00:00
Dunqing
e536d47e56 feat(transformer/babel): add support for trying to get the Module from BabelPlugins (#7218)
When configuring a `transform-modules-commonjs` plugin in `options.json`, we should treat it as a `CommonJS` module
2024-11-09 08:38:15 +00:00
Boshen
324c3fe184 feat(transformer): add TransformOptions::module option (#7188) 2024-11-09 08:38:15 +00:00
camchenry
c5485ae7ee refactor(semantic): add ancestor_kinds iterator function (#7217)
for convenience, I've added a new function called `ancestor_kinds` which loops overall `ancestors` and gets their `AstKind`. this is a common pattern in a couple of places. I also did some somewhat related refactoring to remove places where we were manually calling `AstNode::kind` instead of using `ancestor_kinds` or calling `parent_kind`.
2024-11-09 08:04:38 +00:00
camchenry
abf1602f33 refactor(semantic): rename iter_parents to ancestors (#7216)
for consistency with the `ancestor_ids` function, this changes it to use the same terminology but make it clear it actually returns the node, not just the ID.

this is pure refactor, no functional changes here.
2024-11-09 07:07:26 +00:00
camchenry
42171eba94 refactor(semantic): rename ancestors to ancestor_ids (#7215)
pure refactor, renaming this method to make it more clear that it returns only IDs, not nodes. in preparation for the next PR.
2024-11-09 07:00:15 +00:00
Boshen
846711cf41 feat(transformer)!: change API to take a &TransformOptions instead of TransformOptions (#7213)
closes #7185

`TransformOption`s has an initialization cost, it should be initialized once and shared across files.
2024-11-09 06:01:13 +00:00
ottomated
092de67c47 fix(types)!: append rest field into elements for objects and arrays to align with estree (#7212)
Fixes https://github.com/oxc-project/oxc/pull/7149#discussion_r1831677446 and removes the need for some manual typescript.
2024-11-09 05:23:53 +00:00
Boshen
a166a4abd7 feat(transformer): add esbuild comma separated target API --target=es2020,chrome58 (#7210) 2024-11-08 14:09:20 +00:00
Dunqing
b74686c598 feat(isolated-declarations): support transform TSExportAssignment declaration (#7204)
part of #7141
2024-11-08 11:51:41 +00:00
Dunqing
4a515be24e refactor(transformer/arrow-function-coverter): rename function name and add some comments to explain confusing parts. (#7203)
close: #7174
2024-11-08 08:18:46 +00:00
Dunqing
ede10dc030 fix(transformer/async-to-generator): incorrect transform when super expression is inside async method (#7171)
After transformation, super expressions have moved to unexpected places. This PR replaces super expression to call expression, and then inserts the super methods to the top of the method body.

For example:

Before:
```js
class G {
  async method() {
    super.foo()
  }
}
```

After:
```js
class G {
  method() {
    var _superprop_getFoo = () => super.foo,
      _this = this;
    return _asyncToGenerator(function* () {
      _superprop_getFoo().call(_this);
    })();
  }
}```
2024-11-08 08:18:45 +00:00
Dunqing
1910227590 feat(transformer/async-to-generator): support inferring the function name from the ObjectPropertyValue's key (#7201)
Support for inferring function name from ObjectPropertyValue's key

For example:
```js
({ foo: async function() {} })
```

After this, we will able to infer `foo` for the object method
2024-11-08 08:18:44 +00:00
Boshen
3a20b906f4 feat(transformer): add es target to engineTargets (#7193) 2024-11-08 03:25:21 +00:00
Dunqing
c82b273154 fix(transformer/async-generator-functions): only transform object method in exit_function (#7200)
close: #7175
2024-11-08 03:15:28 +00:00
Dunqing
293d072e77 fix(transformer/async-to-generator): only transform object method in exit_function (#7199)
part of #7175
2024-11-08 03:03:27 +00:00
Dunqing
b4cb587477 chore(transformer_conformance): only ignore root fixtures directory (#7198)
This blocks us from adding tests for plugins.

See the URL a2244ff089/tasks/transform_conformance/tests/babel-plugin-transform-async-to-generator/test/fixtures/arrow
2024-11-08 02:36:22 +00:00
Huáng Jùnliàng
9a6423a9f8
test(coverage): enable Babel es2022 tests (#7194)
Enabled the Babel es2022 tests. Previously they were skipped probably
because ES2022 was not yet supported at that time.
2024-11-08 09:29:36 +08:00
Nicholas Rayburn
4dd9b60f5a
feat(editor/vscode): Replace existing output channel and trace output channel with a single LogOutputChannel (#7196)
I don't think we need two separate channels for output. This replaces
the 2 existing channels with a single channel that allows configuring
the log level.

Ref #7136
2024-11-08 09:23:16 +08:00
Dmitry Zakharov
9b8973f425
feat(linter): add import/unambiguous rule (#7187) 2024-11-08 08:54:37 +08:00
Orenbek
5ab1ff6f06
feat(linter): implement @typescript-eslint/no-unsafe-function-type (#6989)
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-11-07 17:14:19 +00:00
Boshen
6e1abde5ef chore(transform_conformance): omit tests that we cannot pass right now (#7192) 2024-11-07 14:20:30 +00:00
Boshen
de560837eb refactor(transformer): add impl TryFrom<EngineTargets> for EnvOptions (#7191) 2024-11-07 14:12:31 +00:00
Boshen
0a43c640e6 refactor(transformer): move ESTarget to its own file (#7189) 2024-11-07 11:52:32 +00:00
Boshen
22898c855a feat(transformer): warn BigInt when targeting < ES2020 (#7184)
closes #5822
2024-11-07 08:29:03 +00:00
Boshen
a579011e37 feat(transformer): add features ES2018NamedCapturingGroupsRegex and ES2018LookbehindRegex (#7182) 2024-11-07 07:39:33 +00:00
Boshen
ad3a2f518e feat(tasks/compat_data): generate our own compat table (#7176) 2024-11-07 07:39:33 +00:00
Boshen
14ce0eef44 feat(tasks/compat_data): init compat data task (#7156) 2024-11-07 07:39:32 +00:00
Dmitry Zakharov
500effe5bb
chore(linter): correct links to docs in rules (#7183) 2024-11-07 15:20:47 +08:00
Nicholas Rayburn
eea8879642
fix(editor/vscode): Update language client id to fix the resolution of the oxc.trace.server setting (#7181)
Currently `oxc-vscode.trace.server` needs to be used to enable trace
logging for the language server. This fixes it so that
`oxc.trace.server` can be used. I can't find any guidance on what should
be used for the language client id. The VS Code ESLint plugin uses
"ESLint", so I think this change should be fine.

Ref https://github.com/oxc-project/oxc/issues/7136.
2024-11-07 13:29:52 +08:00