Commit graph

6613 commits

Author SHA1 Message Date
Boshen
6133a502c6 test(transformer): use a single integration test for faster compilation (#7099) 2024-11-03 12:43:26 +00:00
Boshen
bfdbcf1c6a feat(transformer): add EnvOptions::from_browerslist_query API (#7098) 2024-11-03 12:43:25 +00:00
Boshen
21b8e4988f feat(transformer): add ESTarget (#7091)
closes #6982
2024-11-03 12:21:53 +00:00
Boshen
64e24994e6 test(module_lexer): use a single integration test for faster compilation (#7097) 2024-11-03 12:16:47 +00:00
oxc-bot
2d40b073cb
release(oxlint): v0.11.0 (#7094)
## [0.11.0] - 2024-11-03

- 9fd9f4f linter: [**BREAKING**] Sync sindresorhus/globals; removed
Object.prototype properties from builtin and es* globals (#6991)
(Boshen)

### Features

- 6b619da editor: Listen to config file changes and trigger a
didChangeConfiguration update (#6964) (Nicholas Rayburn)
- 7872927 editor/vscode: Support window/showMessage event (#7085)
(Nicholas Rayburn)
- 2184588 linter: Do not bail for unmatched rules yet (#7093) (Boshen)
- a6fcd81 linter: Add `import/no-commonjs` rule (#6978) (Dmitry
Zakharov)
- 1691cab linter: Support user-configurable secrets for
`oxc-security/api-keys` (#5938) (DonIsaac)
- 610621c linter: Implement `react/style-prop-object` (#6342) (Albert
Kaaman)
- 1e2f012 linter: Add `oxc/no-map-spread` (#6751) (DonIsaac)
- 1c66473 linter: Implement `eslint/prefer-object-has-own` (#6905)
(tomoya yanagibashi)

### Bug Fixes

- ebf3753 editor: Fix onConfigChange to send the correct config for
didChangeConfiguration notification (#6962) (Nicholas Rayburn)
- 79bf74a linter: Check is_reference_to_global_variable in
`no-array-constructor` (#7067) (Naoya Yoshizawa)
- 38d1f78 linter: Remove confusing help text for now (#7081) (Cam
McHenry)
- 147e2e4 linter: Allow replacing rule when none are enabled yet (#7014)
(camchenry)
- 7aa496a linter: Remove unsafe fixer of `no-useless-spread` (#6655)
(dalaoshu)
- f5a7134 linter/no-unused-vars: False positive for discarded reads
within sequences (#6907) (DonIsaac)

### Documentation

- 4551baa linter: Document `rules` (#6983) (Boshen)

### Refactor

- a8dc75d linter: Remove unused CLI result types (#7088) (camchenry)
- 8f1460e linter: Move `LintPlugins` from `LintOptions` to `LintConfig`
(#6932) (DonIsaac)

### Testing

- c35d3f2 linter: Improve test failure output (#6975) (camchenry)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-03 11:27:30 +08:00
Boshen
218458811b
feat(linter): do not bail for unmatched rules yet (#7093)
I intend to make a release today, let's hold onto this behaviour.
2024-11-03 11:18:36 +08:00
Nicholas Rayburn
7872927fca
feat(editor/vscode): Support window/showMessage event (#7085)
Whenever the language server sends a `window/showMessage` event, VS Code
will listen and display a notification or log a message based on the
severity level of the message.

The language server doesn't currently send this event. I'm going to
follow up with a separate PR for that.

Ref https://github.com/oxc-project/oxc/issues/6988
2024-11-03 09:32:27 +08:00
Naoya Yoshizawa
79bf74a1a1
fix(linter): check is_reference_to_global_variable in no-array-constructor (#7067)
Hello,

I am currently reading through the code as I work on contributing by
creating some ESLint rules.
Along the way, I noticed an incompatibility in certain cases within the
`no-array-constructor` rule.

In this PR, I added test cases and modified the code to include a check
for is_reference_to_global_variable.

The relevant ESLint behavior can be verified in the following
playground.


https://eslint.org/play/#eyJ0ZXh0IjoiLyplc2xpbnQgbm8tYXJyYXktY29uc3RydWN0b3I6IFwiZXJyb3JcIiovXG5cbi8vIGlmIGNvbW1lbnQgb3V0IGJlbG93LCBuZXh0IGxpbmUgYXMgZXJyb3JcbnZhciBBcnJheTsgbmV3IEFycmF5KCk7XG5cbm5ldyBBcnJheSgpOyIsIm9wdGlvbnMiOnsicnVsZXMiOnt9LCJsYW5ndWFnZU9wdGlvbnMiOnsic291cmNlVHlwZSI6Im1vZHVsZSIsInBhcnNlck9wdGlvbnMiOnsiZWNtYUZlYXR1cmVzIjp7fX19fX0=
2024-11-02 18:17:48 +00:00
Dunqing
70e2582726 ci(transformer): enable unfinished plugins in benchmark (#7040)
Even the plugins are unfinished, we still want to enable all of them to track the performance changes during the development.
2024-11-02 15:17:21 +00:00
Boshen
001058a8e4
feat(codegen): always print legal comments on its own line (#7089) 2024-11-02 15:55:23 +08:00
camchenry
a8dc75d6ba refactor(linter): remove unused CLI result types (#7088)
It doesn't seem like we should implement type checking or formatting in the `oxlint` binary. Plus, these are unused currently. So I removed them.
2024-11-02 06:17:28 +00:00
Boshen
dd79c1bfb3
refactor(codegen): replace daachorse with string match for annotation comment (#7064) 2024-11-02 14:16:10 +08:00
Boshen
413973df66 feat(codegen): print linked and external legal comment (#7059)
part of #7050
2024-11-02 04:08:14 +00:00
Cam McHenry
38d1f78754
fix(linter): remove confusing help text for now (#7081)
It's possible that the rule may not exist at all, or it's part of a
disabled plugin. The help text doesn't give a clue as to which is the
case currently, so it's probably less confusing to just omit it
completely.
2024-11-02 11:50:42 +08:00
overlookmotel
f543a8d495 refactor(ast)!: remove AstBuilder::*_from_* methods (#7073)
Remove `AstBuilder::*_from_*` methods for constructing enums. In my opinion, it's not a great pattern, and this removes 2000 of lines of code from [ast_builder.rs](https://github.com/oxc-project/oxc/pull/7073/files#diff-e34fd45077ed0a48b7fee440fdbe4c22a01d787a70a311afebfc1d310785fb70).
2024-11-02 01:22:56 +00:00
overlookmotel
97caae16e2 refactor(minifier): do not use AstBuilder::*_from_* methods (#7072)
Preparation for #7073. Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.

Before:

```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```

After:

```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```

Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:56 +00:00
overlookmotel
cea0e6b62f refactor(isolated_declarations): do not use AstBuilder::*_from_* methods (#7071)
Preparation for #7073. Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.

Before:

```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```

After:

```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```

Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:55 +00:00
overlookmotel
d03e622b70 refactor(transformer): do not use AstBuilder::*_from_* methods (#7070)
Preparation for #7073. Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.

Before:

```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```

After:

```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```

Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:55 +00:00
overlookmotel
938ee8724d refactor(traverse): do not use AstBuilder::*_from_* methods (#7069)
Preparation for #7073. Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.

Before:

```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```

After:

```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```

Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:55 +00:00
overlookmotel
fdd480d84c refactor(parser): do not use AstBuilder::*_from_* methods (#7068)
Preparation for #7073. Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.

Before:

```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```

After:

```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```

Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:55 +00:00
overlookmotel
32b4a53692 refactor(ast_tools): remove LateCtx abstraction (#7083)
`LateCtx` is just a wrapper around `Schema`. Remove it and use `Schema` instead.
2024-11-01 22:31:03 +00:00
overlookmotel
2eb9aa9b89 refactor(ast_tools): remove dead code (#7080) 2024-11-01 21:59:28 +00:00
overlookmotel
d89fe2c326 refactor(ast_tools): shorten code (#7079)
Shorten code by importing `rust_ast::Module` at top level.
2024-11-01 21:51:29 +00:00
overlookmotel
00cc156fb5 refactor(ast_tools): simplify module loading (#7078)
Rename var for clarity and remove unnecessary `From` impl.
2024-11-01 21:51:29 +00:00
overlookmotel
f2d10683a8 refactor(ast_tools): remove dead code (#7077) 2024-11-01 21:42:14 +00:00
overlookmotel
248ff18ddd refactor(ast_tools): output progress (#7076)
Flush `stdout` after writing progress.
2024-11-01 21:26:45 +00:00
overlookmotel
9e85b104e2 refactor(parser): add ParserImpl::alloc method (#7063)
Pure refactor. Introduce `ParserImpl::alloc` method. Shorten `self.ast.alloc(...)` to `self.alloc(...)`.

Also reduce `alloc` calls by using `AstBuilder` methods which already allocate where possible.
2024-11-01 17:09:06 +00:00
overlookmotel
9d384ad6db refactor(transformer): use identifier_reference_with_reference_id builder method (#7056)
Similar to #7055.

In transformer, use `AstBuilder::identifier_reference_with_reference_id` function, instead of creating an `IdentifierReference` and then setting the `reference_id` on it afterwards.
2024-11-01 17:09:05 +00:00
overlookmotel
4688a061ae refactor(transformer): use *_with_scope_id builder methods where possible (#7055)
In transformer, use `AstBuilder::function_with_scope_id` and `AstBuilder::arrow_function_expression_with_scope_id` function where possible, rather than creating a function and then setting the `scope_id` on it afterwards.
2024-11-01 17:09:04 +00:00
Boshen
ee27b92465 feat(codegen): print eof legal comments (#7058)
part of https://github.com/oxc-project/oxc/issues/7050
2024-11-01 16:56:57 +00:00
Boshen
6516f9eabc feat(codegen): print inline legal comments (#7054)
part of https://github.com/oxc-project/oxc/issues/7050
2024-11-01 16:56:56 +00:00
overlookmotel
7122e0074b refactor(transformer): use ctx.alloc over ctx.ast.alloc where possible (#7066)
Pure refactor. Just shorten code a little.
2024-11-01 16:51:20 +00:00
overlookmotel
b0211a1f9e refactor(ast): StaticMemberExpression::get_first_object use loop instead of recursion (#7065)
Follow-on after #6969. Pure refactor. Loops are generally cheaper than recursion.
2024-11-01 16:36:25 +00:00
renovate[bot]
4012e6ba0c
chore(deps): update crate-ci/typos action to v1.27.0 (#7061) 2024-11-01 23:46:54 +08:00
Dunqing
a2244ff089 fix(transformer/async-to-generator): output is incorrect when arrow function without params (#7052) 2024-11-01 15:35:57 +00:00
Boshen
e86bbad243
build: node v22.11.0 (#7062) 2024-11-01 23:31:55 +08:00
Boshen
0bb1aa4c64 refactor(codegen): move options to its own file (#7053) 2024-11-01 09:28:59 +00:00
Boshen
7f1d1fe065 refactor(transform): deserialize BabelPreests::env directly (#7051) 2024-11-01 08:09:59 +00:00
Boshen
a3b68b4224 refactor(transformer): flatten dir structure of options/babel/env (#7049) 2024-11-01 07:46:28 +00:00
Boshen
6d92f36ef2 refactor(transformer): deserialize BabelOptions::compiler_assumptions (#7048) 2024-11-01 07:41:01 +00:00
Boshen
f83a760d8a refactor(transformer): deserialize BabelOptions::presets (#7047) 2024-11-01 06:56:27 +00:00
Boshen
52c20d633c refactor(transformer): deserialize BabelOptions::plugins (#7045) 2024-11-01 05:44:57 +00:00
Boshen
4bef99c80b
chore(coverage): update runtime snapshot 2024-11-01 13:05:42 +08:00
tomoya yanagibashi
0601271b2c
fix(ast): Fix StaticMemberExpression.get_first_object (#6969)
I think `get_first_object` does not return expected expression.

For example, in case of `foo.bar.a`, it doesn't return `foo` but
`foo.bar`.

**Expected**
```
{
  "type": "Identifier",
  "start": 0,
  "end": 3,
  "name": "foo"
}
```

**Actual**
```
{
   "type":"StaticMemberExpression",
   "start":0,
   "end":7,
   "object":{
      "type":"Identifier",
      "start":0,
      "end":3,
      "name":"foo"
   },
   "property":{
      "type":"Identifier",
      "start":4,
      "end":7,
      "name":"bar"
   },
   "optional":false
}
```

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-11-01 12:28:48 +08:00
overlookmotel
e23f7e6bc1 refactor(transformer/common): VarDeclarations insert either var or let statements (#7043)
Add ability for `VarDeclarations` to insert `let` declarations as well as `var` declarations. This is required for class properties transform.

Implementation note: `var` and `let` declarators are stored in 2 separate `ArenaVec`s. This allows using those `ArenaVec<Declarator<'a>>`s directly in the AST, rather storing all `Declarator`s in a single `Vec` and having to loop through it when inserting the `var` / `let` statements to split it into 2 `ArenaVec`s of `var` / `let` declarators. I'm not completely sure this is better than using a single `Vec` for both, but I think *probably* it is.
2024-11-01 04:08:59 +00:00
camchenry
1f2a6c666f feat(linter)!: report unmatched rules with error exit code (#7027)
- closes https://github.com/oxc-project/oxc/issues/6988

we now return an error exit code when there are unmatched rules. previously, we would print an error to stderr and continue running. however, this masked errors in some tests that actually had unmatched rules in them. these test cases now trigger a panic (in tests only, not at runtime), and help ensure that we are reporting an error message to the user for unknown rules, which we did not have any tests cases for before.

- fixes https://github.com/oxc-project/oxc/issues/7025

this also fixes https://github.com/oxc-project/oxc/issues/7025, where we were reporting rules as unmatched simply because they had been disabled prior to being configured. similar to https://github.com/oxc-project/oxc/issues/7009.
2024-11-01 03:27:25 +00:00
overlookmotel
86ab091e42 style(transformer/common): Split up StatementInjectorStore methods into blocks (#7042)
Pure refactor. Split up the `impl`s into multiple blocks with comments for each block, to make it clearer.
2024-10-31 19:23:28 +00:00
Boshen
fcaba4a92a feat(transformer): add TransformerOptions::env with EnvOptions (#7037) 2024-10-31 12:30:32 +00:00
Boshen
e921df6199 refactor(transformer): rename EnvOptions to BabelEnvOptions (#7036) 2024-10-31 10:00:52 +00:00
overlookmotel
1d906c64e7 feat(transformer): class properties transform skeleton (#7038)
Skeleton of class properties transform. #7011 contains WIP implementation.
2024-10-31 09:55:41 +00:00