Commit graph

6859 commits

Author SHA1 Message Date
overlookmotel
971c91a2e8 feat(traverse): add methods to BoundIdentifier + MaybeBoundIdentifier to create SimpleAssignmentTargets (#7418)
We had methods to create `AssignmentTarget`s. Add methods to create `SimpleAssignmentTarget`s too.
2024-11-22 12:31:29 +00:00
overlookmotel
eb39a50a2e refactor(transformer/logic-assignment): shorten code (#7419)
Use `create_spanned_read_expression` instead of `create_spanned_expression`, as it's shorter than specifying `ReferenceFlags` manually.
2024-11-22 11:42:03 +00:00
overlookmotel
be5f843a12 docs(traverse): fix docs for BoundIdentifier + MaybeBoundIdentifier (#7417) 2024-11-22 10:58:34 +00:00
Dunqing
27b2268a6c refactor(semantic)!: remove SymbolFlags::Export (#7414)
close: #7338
close: #7344

The `SymbolFlags::Export` is Initially used to solve `ExportSpecifier` that is not `IdentifierReference` that causes we cannot determine whether a Binding is not used everywhere by `Semantic`.

Since #3820 this problem is solved, so we don't need `SymbolFlags::Export` no longer. Also, removing this can help us easier to pass the `Semantic` check in `Transformer`
2024-11-22 09:17:37 +00:00
Dunqing
c90537f1f0 refactor(linter/only-used-in-recursion): improve implementation to remove using SymbolFlags::Export (#7413)
part of #7414
2024-11-22 09:17:36 +00:00
Dunqing
c8adc46a08 refactor(linter/no-unused-vars): improve implementation to remove using SymbolFlags::Export (#7412)
part of #7414
2024-11-22 09:17:35 +00:00
Dunqing
7ff9f13973 fix(transformer): correct all ReferenceFlags (#7410) 2024-11-22 09:10:55 +00:00
Dunqing
6f0fe38bff fix(semantic)!: correct all ReferenceFlags::Write according to the spec (#7388)
close #7323

According to the specification re-design the JavaScript-part ReferenceFlags inferring approach.

* https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation
* https://tc39.es/ecma262/#sec-postfix-increment-operator-runtime-semantics-evaluation
* https://tc39.es/ecma262/#sec-runtime-semantics-restdestructuringassignmentevaluation
* ... See references of https://tc39.es/ecma262/#sec-putvalue

### Changes

1. The left-hand of `AssignmentExpression` is always `ReferenceFlags::Write`
```js
let a = 0;
console.log(a = 0);
            ^ Write only
```

2. The `argument` of `UpdateExpression` is always `ReferenceFlags::Read | Write`
```js
let a = 0;
a++;
^ Read and Write
```

This change might cause some trouble for `Minfier` to remove this code, because ‘a’ is not used elsewhere. I have taken a look at `esbuild` and `Terser`. Only the `Terser` can remove this code.
2024-11-22 06:08:30 +00:00
Dmitry Zakharov
6730e3effe
docs(linter): add more examples for unicorn/prefer-array-some (#7411) 2024-11-22 14:06:46 +08:00
overlookmotel
f4fda2dba6 test(transformer): add --debug option to transform conformance (#7400)
Add `--debug` command line option for transformer conformance runner, same as for `cargo coverage`. It prints the paths of test fixtures before running them.
2024-11-22 02:23:10 +00:00
no-yan
4ad26b952f
feat(linter): add no-promise-in-callback (#7307)
related: #4655

This PR implements a rule to detect Promises inside error-first
callbacks, preventing the mixed usage of callbacks and Promises.

Example of problematic code:
```javascript
a(function(err) { doThing().then(a) });
                  ^^^^^^^^^^^^^^
```


[Original
implementation](266ddbb030/rules/no-promise-in-callback.js)
2024-11-22 10:21:26 +08:00
Dmitry Zakharov
9002e97e12
fix(linter): add proper support for findIndex and findLastIndex for unicorn/prefer-array-some (#7405)
closes #7404
2024-11-22 10:12:13 +08:00
Song Gao
f2cfed198b
chore: make editor respect space as indent (#7401)
#7337

Copy editrconfig from rust-analyzer

Tab is causing some trouble, and it seems a better choice to unify
indent style

This is part work of #7362, split it to make meaningful change merged
quickly
2024-11-22 10:00:58 +08:00
oxc-bot
0918e520cf
release(crates): v0.37.0 (#7399) 2024-11-21 22:27:55 +08:00
oxc-bot
4b5a176630
release(oxlint): v0.13.0 (#7398)
## [0.13.0] - 2024-11-21

- 7bf970a linter: [**BREAKING**] Remove tree_shaking plugin (#7372)
(Boshen)
- 7f8747d linter: Implement `react/no-array-index-key` (#6960)
(BitterGourd)

### Features

- be152c0 linter: Add `typescript/no-require-imports` rule (#7315)
(Dmitry Zakharov)
- 849489e linter: Add suggestion for no-console (#4312) (DonIsaac)
- 8cebdc8 linter: Allow appending plugins in override (#7379)
(camchenry)
- 8cfea3c oxc_cfg: Add implicit return instruction (#5568)
(IWANABETHATGUY)
- e6922df parser: Fix incorrect AST for `x?.f<T>()` (#7387) (Boshen)

### Bug Fixes

- e91c287 linter: Fix panic in react/no-array-index-key (#7395) (Boshen)
- a32f5a7 linter/no-array-index-key: Compile error due to it uses a
renamed API (#7391) (Dunqing)
- 666b6c1 parser: Add missing `ChainExpression` in optional
`TSInstantiationExpression` (#7371) (Boshen)

### Documentation

- df143ca linter: Add docs for config settings (#4827) (DonIsaac)
- ad44cfa linter: Import/first options (#7381) (Zak)

### Refactor

- c34d649 linter: Use `scope_id` etc methods (#7394) (overlookmotel)
- 466f395 vscode: Split `ConfigService` and `Config` (#7376) (Alexander
S.)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-21 22:21:32 +08:00
Boshen
1550ffc5b5 fix(tasks/lint_rules): map prefix node to n (#7397)
The `eslint-plugin-n` page is not showing any rules implemented.
2024-11-21 13:58:53 +00:00
Boshen
e91c2878d8 fix(linter): fix panic in react/no-array-index-key (#7395) 2024-11-21 13:35:21 +00:00
overlookmotel
c34d649176 refactor(linter): use scope_id etc methods (#7394)
Utilize the methods added in #7127 in `oxc_linter`.
2024-11-21 12:29:57 +00:00
Boshen
224775c056 feat(transformer): transform object rest spread (#7003)
https://babel.dev/docs/babel-plugin-transform-object-rest-spread
2024-11-21 11:33:26 +00:00
overlookmotel
b3d5802ef1 docs(syntax): more comments for ReferenceFlags (#7392)
Add more docs to `ReferenceFlags`, mainly to include the runtime test in https://github.com/oxc-project/oxc/issues/5165#issuecomment-2488333549.
2024-11-21 11:20:28 +00:00
Dunqing
a32f5a73d3 fix(linter/no-array-index-key): compile error due to it uses a renamed API (#7391)
Fix: https://github.com/oxc-project/oxc/pull/6960#issuecomment-2490754348
2024-11-21 10:46:21 +00:00
BitterGourd
7f8747dd6a
feat(linter): implement react/no-array-index-key (#6960)
Implement not recommended rule `no-array-index-key` (#1022 )
2024-11-21 10:29:40 +00:00
IWANABETHATGUY
8cfea3c5b6
feat(oxc_cfg): add implicit return instruction (#5568)
1. Adding a new InstructionKind `ImplicitReturn`
2. Adding a new `ImplicitReturn` instruction for each function body,
just like biome

![image](https://github.com/user-attachments/assets/1511a64a-96d8-47b6-a394-11cd40e98b85)
2024-11-21 16:18:51 +08:00
Dmitry Zakharov
be152c01c5
feat(linter): add typescript/no-require-imports rule (#7315) 2024-11-21 16:15:49 +08:00
DonIsaac
df143ca7bb docs(linter): add docs for config settings (#4827) 2024-11-21 08:08:30 +00:00
DonIsaac
849489e8b4 feat(linter): add suggestion for no-console (#4312)
Part of #4179
2024-11-21 07:46:29 +00:00
Dmitry Zakharov
6d50ee01e4
chore: add vscode recommended extensions (#6739)
This will make it easier to contribute for newbie rust developers if
they not have proper extensions.
2024-11-21 15:46:05 +08:00
Boshen
5145a5009b
ci: remove oxc_sourcemap from wasm test because insta is not supported 2024-11-21 15:23:43 +08:00
Hiroshi Ogawa
3d66929fa2
fix(sourcemap): improve source map visualizer (#7386)
- Related https://github.com/rolldown/rolldown/issues/2737

Probably this is still an approximation of what
https://github.com/evanw/source-map-visualization does, but I tried to
get some ideas from it.

For comparison, I added an example from their site
https://evanw.github.io/source-map-visualization/ as a snapshot in
`crates/oxc_sourcemap/tests/fixtures/esbuild/visualizer.snap`. I'll
mention a few notable changes in the comments.

Snapshot change in rolldown repo can be found in
- https://github.com/rolldown/rolldown/pull/2829
2024-11-21 14:35:56 +08:00
Boshen
e6922df3bb feat(parser): fix incorrect AST for x?.f<T>() (#7387) 2024-11-21 06:10:48 +00:00
Boshen
885e37f8eb feat(transformer): Optional Chaining (#6990)
close: #6958
2024-11-21 03:12:18 +00:00
Boshen
0c1fb96760 fix(tasks/coverage): run runtime tasks concurrently to avoid timeout (#7384) 2024-11-21 03:05:20 +00:00
Alexander S.
466f395816
refactor(vscode): split ConfigService and Config (#7376)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-21 09:57:09 +08:00
camchenry
8cebdc8129 feat(linter): allow appending plugins in override (#7379)
follow up to https://github.com/oxc-project/oxc/issues/6896

for improved compatibility with ESLint, this tries to match the behavior of plugin overrides so that plugins can be enabled for certain paths. this does not allow disabling plugins.
2024-11-21 01:46:28 +00:00
Zak
ad44cfa840
docs(linter): import/first options (#7381)
Fix the docs for
[import-first](https://oxc.rs/docs/guide/usage/linter/rules/import/first.html#import-first)
which mentions the option `"absolute-import"` rather than
`"absolute-first"`
2024-11-21 09:46:12 +08:00
overlookmotel
42496ed16f
chore: assign ast_tools to @overlookmotel code owner (#7378)
In the absence of Rez, it's mine! 😄
2024-11-21 00:01:02 +08:00
Boshen
f059b0e655 fix(ast)!: add missing ChainExpression from TSNonNullExpression (#7377)
closes #7375

* `foo?.bar!`
* `foo?.[bar]!`

`TSNonNullExpression` was not wrapped inside `ChainExpression`.
2024-11-20 15:54:28 +00:00
Boshen
ddb2ced5dd
chore: add CODEOWNERS (#7374) 2024-11-20 21:14:43 +08:00
Boshen
878189c407 feat(parser,linter)!: add ParserReturn::is_flow_language; linter ignore flow error (#7373)
closes #7123
2024-11-20 12:50:24 +00:00
Boshen
666b6c104c fix(parser): add missing ChainExpression in optional TSInstantiationExpression (#7371) 2024-11-20 11:51:55 +00:00
Boshen
7bf970a4b6 refactor(linter)!: remove tree_shaking plugin (#7372)
This rule has been in `nursery` for a long time and I don't see it
coming out of `nursery` in the foreseeable future.

closes #7031
clsoes #7057
2024-11-20 11:46:29 +00:00
Boshen
6a98ef1a0c feat(transformer): add CompilerAssumptions to TransformContext (#7369) 2024-11-20 09:27:29 +00:00
renovate[bot]
b3965bbff0
chore(deps): update npm packages (#7364) 2024-11-20 17:26:48 +08:00
Boshen
9b9d02078c docs(semantic): document the meaning of ReferenceFlags::Read and Write (#7368)
closes #5165
2024-11-20 09:18:25 +00:00
Boshen
82773cb455 feat(codegen): remove underscore from bigint (#7367)
closes #7285
closes #7286
2024-11-20 09:08:51 +00:00
oxc-bot
b6d5c0f33e
release(oxlint): v0.12.0 (#7366)
## [0.12.0] - 2024-11-20

- 20d9080 linter: [**BREAKING**] Override plugins array when passed in
config file (#7303) (camchenry)

### Features

- 1d9f528 linter: Implement `unicorn/prefer-string-raw` lint rule
(#7335) (Ryan Walker)
- d445e0f linter: Implement `unicorn/consistent-existence-index-check`
(#7262) (Ryan Walker)
- 01ddf37 linter: Add `allowReject` option to
`no-useless-promise-resolve-reject` (#7274) (no-yan)
- 755a31b linter: Support bind function case for compatibility with
`promise/no-return-wrap` (#7232) (no-yan)
- 428770e linter: Add `import/no-namespace` rule (#7229) (Dmitry
Zakharov)
- 9c91151 linter: Implement typescript/no-empty-object-type (#6977)
(Orenbek)
- 2268a0e linter: Support `overrides` config field (#6974) (DonIsaac)
- 3dcac1a linter: React/exhaustive-deps (#7151) (camc314)
- d3a0119 oxlint: Add `cwd` property to `LintRunner` (#7352) (Alexander
S.)

### Bug Fixes

- ba0b2ff editor: Reload workspace configuration after change (#7302)
(Alexander S.)
- bc0e72c linter: Handle user variables correctly for import/no_commonjs
(#7316) (Dmitry Zakharov)
- bf839c1 linter: False positive in `jest/expect-expect` (#7341)
(dalaoshu)
- ff2a1d4 linter: Move `exhaustive-deps` to `react` (#7251) (camc314)
- df5c535 linter: Revert unmatched rule error (#7257) (Cameron A
McHenry)
- c4ed230 linter: Fix false positive in eslint/no-cond-assign (#7241)
(camc314)
- ef847da linter: False positive in `jsx-a11y/iframe-has-title` (#7253)
(dalaoshu)
- 62b6327 linter: React/exhaustive-deps update span for unknown deps
diagnostic (#7249) (camc314)

### Documentation

- 4c124a8 editor/vscode: Update VS Code readme with installation
instructions and available features (#7306) (Nicholas Rayburn)

### Refactor

- c6a4868 linter: Temporarily remove unknown rules checking (#7260)
(camchenry)

### Testing

- 5190b7f editor: Add test setup (#7361) (Alexander S.)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-20 15:45:24 +08:00
Alexander S.
5190b7fb28
test(editor): add test setup (#7361)
Tried it with `vitest`, but there was too many problems with `vscode`
integration.
That why I followed the official guide:
-
https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode
-
https://code.visualstudio.com/api/working-with-extensions/continuous-integration
2024-11-20 12:46:01 +08:00
Alexander S.
d3a0119a42
feat(oxlint): add cwd property to LintRunner (#7352)
allows to use multiple `LintRunner` in one file targeting multiple
directory.
The current problem is for the test in #7348 we can not change
`env::current_dir`,
so as a workaround I introduce a new property :) 

See more info here:
https://discord.com/channels/1079625926024900739/1117322804291964931/1308179827576016897
2024-11-20 12:44:50 +08:00
overlookmotel
234c7b9fef feat(traverse): implement GatherNodeParts for member expression types (#7363)
`GatherNodeParts` was missing support for these types as entry points for collection.
2024-11-20 03:58:48 +00:00
Dunqing
c587dd3cd6 fix(codegen): do not print parenthesis for in expression in ArrowFunctionExpression (#7360)
Please check out [esbuild](https://esbuild.github.io/try/#dAAwLjI0LjAAACgpID0+ICIiIGluIHt9)
2024-11-19 14:29:18 +00:00