Commit graph

6845 commits

Author SHA1 Message Date
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
Boshen
514878d927 fix(transform_conformance): only run exec tests when specified (#7359) 2024-11-19 13:13:11 +00:00
Boshen
d60801218e feat(transform_conformance): snapshot our transformed outputs (#7358) 2024-11-19 12:49:44 +00:00
Boshen
84f3bf2f97 refactor(transform_conformance): clean up test execution code (#7357) 2024-11-19 12:22:42 +00:00
Boshen
d0e64fd80a refactor(transform_conformance): remove TestCase trait (#7356) 2024-11-19 10:52:42 +00:00
Dunqing
6cfb5df9b9 feat(transformer): support generate proper binding name from ChainExpression (#7326) 2024-11-19 10:31:54 +00:00
Dunqing
58db9ef322 refactor(codegen): do not print unnecessary parentheses if both sides use the same logical operator (#7325)
As shown by the changing tests, we don't need to print parentheses for them.

### Comparison
In [esbuild](https://esbuild.github.io/try/#dAAwLjI0LjAAAGEgPz8gKGIgPz8gKGMgPz8gZCkpOwooYSA/PyAoYiA/PyAoYyA/PyBkKSkpOwooYSB8fCAoYiB8fCBjKSkgfHwgZDsKYSB8fCAoYiB8fCAoYyB8fCBkKSk7CmEgJiYgKChiICYmIGMpICYmIGQp), it will print parentheses as-is, in [SWC](https://play.swc.rs/?version=1.9.2&code=H4sIAAAAAAAAA0tUsLdX0EgCk8kgMkVT05pLIxGLMES8pgYkDiSTNTVBVIo1F5IgUDFIDKQ2UUFNTUEDKAykkjVBZIomAGEbiHtuAAAA&config=H4sIAAAAAAAAA1VQzW7DIAy%2B9ykin6tlyrHXTb3ttCdA1GmpACPbSIuqvPuAJml6w9%2Bv8ePQdXAXC6fuUZ5lSIYFeZsLIlNU81cQ0CmhWHZJ4biyKpVSztiQ%2BUmAGr6iVhPK8DkMsOJsoozEYd%2BQBb9xdBHPxF%2FeiJwd%2BossuVsVo7G68xXIhUSsv5TZYi27qSY59T1K%2BJBbn56W48vAOaoLTWuyUjDqLCz0%2FPYDTyRVNxovyw4QXHTjtF%2FdUiglIu%2FCKjXx6jf%2FYc1v6RDokhu5HL0etq5U0gLFu8BLuTZu6eDkZ7W3s8%2F%2FYy0r4MUBAAA%3D), we have the same output now
2024-11-19 10:31:53 +00:00
Boshen
65f1e82bd8 refactor(transform_conformance): clean up some code (#7354) 2024-11-19 09:15:14 +00:00
Boshen
4c367b6746
chore(deps): update codecov/codecov-action action to v5 (#7353)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-19 16:01:09 +08:00
overlookmotel
c335f92ada perf(syntax): reorder operator enum variants (#7351)
Re-order enum variants of `AssignmentOperator`, `BinaryOperator` and `UnaryOperator`.

* `Exponential` moved to after `Remainder` (so with the rest of the arithmetic operators).
* `Shift*` operators follow arithmetic operators.
* `AssignmentOperator::Bitwise*` ops moved to before `Logical*` ops (so all ops which correspond to `BinaryOperator`s are together).
* `*Or` always before `*And`.
* Plus/Addition always before Minus/Subtraction.

The purpose is to make the various methods on these types maximally efficient:

1. Group together variants so that `AssignmentOperator::is_*` methods can be executed with the minimum number of operations (essentially `variant - min <= max`).
2. Align the variants of `AssignmentOperator` and `BinaryOperator` so that conversion methods added in #7350 become very cheap too (essentially `if variant - min <= max { Some(variant + offset) } else { None }`).
2024-11-19 01:23:28 +00:00
Dmitry Zakharov
bc0e72c1e2
fix(linter): handle user variables correctly for import/no_commonjs (#7316)
test case found in `typescript/no-require-imports`
2024-11-19 09:23:16 +08:00
Ryan Walker
1d9f528668
feat(linter): implement unicorn/prefer-string-raw lint rule (#7335)
Implements
[unicorn/refer-string-raw](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-raw.md)
for #684
2024-11-19 09:22:40 +08:00
overlookmotel
2534cdecb7 feat(syntax): add AssignmentOperator::to_logical_operator and to_binary_operator methods (#7350)
Add methods to convert `AssignmentOperator` to `LogicalOperator` or `BinaryOperator`. e.g. `+=` -> `+`, `&&=` -> `&&`.
2024-11-19 01:12:11 +00:00
overlookmotel
41a0e60c3e refactor(ast)!: remove impl GetAddress for Function (#7343)
`impl GetAddress for Function` was added as a hack, in the absence of another way to get the `Address` of a `&Function` (https://github.com/oxc-project/backlog/issues/140).

Remove it, and use `Address:from_ptr` instead in JSX Refresh transform, which is only place using it.
2024-11-19 01:05:31 +00:00
Alexander S.
4b8aecc8ed
ci(editor): add lint and compile checks (#7346) 2024-11-19 09:05:19 +08:00