Commit graph

3515 commits

Author SHA1 Message Date
Boshen
4f76cb6f38 refactor(linter): merge deepscan rules into oxc rules (#3327) 2024-05-17 11:56:06 +00:00
Boshen
95e9b6986c fix(linter): fix panic in jest/expect-expect (#3324)
closes #3323
2024-05-17 07:56:02 +00:00
Don Isaac
27030b9eb4
perf(lexer): use bitshifting when parsing known integers (#3296)
## What This PR Does

- perf(lexer): use bit shifting when parsing hex, octal, and binary
integers instead of `mul_add`-ing on `f64`s. Check out the difference in
assembly generated [here](https://godbolt.org/z/zMEKaeYzh)
- perf(lexer): skip redundant utf8 check when parsing BigInts
- refactor(lexer): remove `unsafe` usage (as per @overlookmotel's
request
[here](https://github.com/oxc-project/oxc/pull/3283#issuecomment-2111814598))
- test(lexer): add numeric parsing unit tests

I don't expect this PR to have a large performance improvement, since
the most common case (`Kind::Decimal`) is not affected. We could do
this, however, by splitting `Kind::Decimal` into `Kind::DecimalFloat`
and `Kind::DecimalInt` when the lexer encounters a `.`
2024-05-17 09:39:10 +08:00
rzvxa
712ee0dde8 fix(linter/react): fix false positives for async components in rules_of_hooks (#3307)
related to #3257
2024-05-16 16:38:16 +00:00
rzvxa
0864cd0115 fix(linter/react): better detection for hooks in the rules_of_hooks. (#3306)
related to #3257
2024-05-16 16:38:14 +00:00
rzvxa
95944419ec fix(linter/react): rules_of_hooks add support for property hooks/components. (#3300)
related to #3257
2024-05-16 16:38:12 +00:00
overlookmotel
0c09047111 feat(traverse): mutable access to scopes tree + symbol table (#3314)
Allow mutable access to scopes tree and symbol table.

Closes #3189.

This completes the v1 scopes-in-traverse implementation, and provides all the primitives required to implement the missing APIs listed in https://github.com/oxc-project/oxc/discussions/3251.

Performance is abysmal, as noted in #3304, but we can fix that later on by taking `Semantic` out of the picture, or optimizing it.
2024-05-16 16:21:24 +00:00
overlookmotel
421107aa82 feat(traverse): pass &mut TraverseCtx to visitors (#3312)
Pass `&mut TraverseCtx` to `Traverse::enter_*` and `Traverse::exit_*` visitor methods. Previously was immutable `&TraverseCtx`.

This is a step towards exposing mutable scope tree + symbol table to visitors.
2024-05-16 16:21:23 +00:00
overlookmotel
f8b5e1e2c9 refactor(traverse): move parent method etc into TraverseAncestry (#3308)
Move the ancestry stack into it's own type `TraverseAncestry`, and expose it via `ctx.ancestry` "namespace".

The "namespaced" way of getting parent etc (`ctx.ancestry.parent()` rather than just `ctx.parent()`) will come in useful once we introduce methods which require a `&mut TraverseCtx`.
2024-05-16 16:21:22 +00:00
overlookmotel
05c71d20b1 refactor(traverse): Traverse produce scopes tree using Semantic (#3304)
`Traverse` use `Semantic` to construct scopes tree and expose it to visitors via `TraverseCtx`.

Currently scopes tree is immutable. Will expose it as a mutable in a follow-on.

This is extremely inefficient. Semantic does all kinds of stuff (control flow graph etc) which `Traverse` doesn't need, and `Traverse` just throws away all that work after semantic has done it. Intent here is to get a working implementation first, and then to do another pass later on to improve performance.
2024-05-16 16:21:20 +00:00
overlookmotel
6f3b1c8724 refactor(semantic): semantic populate scope_id fields in AST (#3303)
`oxc_semantic` populate `scope_id` fields in AST nodes as it walks the tree.

This does produce some duplication - scope IDs are stored both in the AST itself, and in `AstNode`. Will clean this up later on.
2024-05-16 16:21:19 +00:00
overlookmotel
723a46fcc0 refactor(ast): store ScopeId in AST nodes (#3302)
Add `scope_id` field to all AST nodes which can constitute a scope (`Program`, `Function`, `BlockStatement` etc).
2024-05-16 16:21:17 +00:00
rzvxa
c8f1f79d27 fix(linter/react): rules_of_hooks resolve false positives with conditional hooks. (#3299)
related to #3071
2024-05-16 16:16:52 +00:00
Yuji Sugiura
7f9d8b71ee
fix(tasks/lint_rules): Integrate react and react-hooks rules (#3315)
Fixes #2174 , now `react-hooks` plugin and its rules are managed by
`react` plugin issue.
2024-05-16 23:22:02 +08:00
Boshen
6dcfc13e02
Publish oxc_module_lexer v0.13.0 2024-05-16 22:14:47 +08:00
Boshen
e4d94dc379 chore(cli): improve help message (#3309)
Added a CLI page https://oxc-project.github.io/docs/guide/usage/linter-cli.html
2024-05-16 11:53:33 +00:00
Boshen
8ab9856dea feat(cli,linter): add --disable-react/unicorn/typescript-plugin (#3305)
closes #1970
2024-05-16 10:15:08 +00:00
Dunqing
9ee962add8 feat(transformer): support from_babel_options in TransformOptions (#3301)
Move `BabelOptions` to Transformer. The `output.json` is a standard babel configuration. We can reuse BabelOptions to read [babel.config.json](https://babeljs.io/docs/configuration#babelconfigjson) or our configuration(maybe oxc.config.json)

The current `from_babel_options` implementation is copied from the `transform_options` in `test_case.rs`, which I'll completely reimplement next
2024-05-16 10:10:39 +00:00
Boshen
bd8a0ddb7f feat(linter): no-barrel-file (#3275)
![image](https://github.com/oxc-project/oxc/assets/1430279/524c8afa-a4c0-45a3-b95d-f8efd359a84f)
2024-05-16 07:54:09 +00:00
Ali Rezvani
d46538ed68
fix(linter/react): fix loop hooks false positives. (#3297)
It is a temporary fix for false positives like
[this](https://github.com/oxc-project/oxc/issues/3257#issuecomment-2110199442).
Uses the node's ancestors for now instead of the cfg.
2024-05-16 11:03:54 +08:00
Boshen
cc1882d221
ci: remove ecosystem ci, moved to https://github.com/oxc-project/oxlint-ecosystem-ci 2024-05-16 01:32:45 +08:00
Boshen
754d9f4c98
Release oxlint and vscode extension v0.3.5 2024-05-15 22:20:29 +08:00
Boshen
33386ef197
perf(ast): inline all ASTBuilder methods (#3295) 2024-05-15 22:16:16 +08:00
Boshen
e12323f4f9 fix(linter/no-direct-mutation-state): false positive when class is declared inside a CallExpression (#3294)
fixes #3290
2024-05-15 14:07:02 +00:00
Dunqing
8ff1ffba74
feat(transformer_conformance): skip some tests that are known to fail (#3293)
I don't think we need to be completely consistent with Babel's output.
Because Babel's output doesn't always make sense.
2024-05-15 22:06:00 +08:00
Dunqing
b9d69ad665
feat(transformer): do not add self attribute in react/jsx plugin (#3287)
follow-up: https://github.com/oxc-project/oxc/pull/3258.
2024-05-15 17:59:57 +08:00
Wang Wenzhe
61281711f0
refactor(linter): rewrite react/require-render-return (#3276)
Closes: #3245

It's gone now, curious about why didn't have performance improvement.

![CleanShot 2024-05-14 at 20 57
17@2x](https://github.com/oxc-project/oxc/assets/33973865/656ef8c6-65f7-4ce4-b8a1-4f3127bb6c36)

This picture generated by running all the rules.
2024-05-15 16:40:46 +08:00
Dunqing
f38d138d97
chore: update the test-transformer command to support passing arguments (#3286) 2024-05-15 12:57:52 +08:00
Don Isaac
a12ed0fd26
fix(codegen): using declaration in for statement (#3285)
Fixes conformance tests for `using` declarations in for statements, e.g.
```ts
for (using x = 1;;) {}
```
2024-05-14 23:10:47 -04:00
Don Isaac
5b2fc391bc
feat(linter): add use-isnan fixer for (in)equality operations (#3284)
Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-15 02:20:52 +00:00
Don Isaac
508dae6f8f
perf(lexer): dedupe numeric separator check (#3283)
## What This PR Does

Updates numeric literal token lexing to record when separator characters
(`_`) are found in a new `Token` flag. This then gets passed to
`parse_int` and `parse_float`, removing the need for a second `_` check
in those two functions.

When run locally, I see no change to lexer benchmarks and minor
improvements to codegen benchmarks. For some reason, semantic and source
map benches seem to be doing slightly worse.

Note that I attempted to implement this with `bitflags!` (making
`escaped` and `is_on_newline` flags as well) and this caused performance
degradation. My best guess is that it turned reads on these flags from a
`mov` to a `mov` + a binary and.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-15 01:48:21 +00:00
overlookmotel
dad47a553e refactor(transformer): improve indentation (#3282)
Improve indentation in code. Not sure why rustfmt didn't do this already.
2024-05-14 17:53:11 +00:00
Boshen
482dcc0aed
chore(traverse): revert the build script 2024-05-15 00:07:56 +08:00
Boshen
6d63f99500
Release crate oxc_traverse v0.13.0 2024-05-14 23:15:27 +08:00
Boshen
23b39169a6
Release crate oxc_ast_macros v0.13.0 2024-05-14 23:15:20 +08:00
Boshen
c395f8641e
Release crates v0.13.0 2024-05-14 23:14:15 +08:00
Dunqing
b4fa27a2ee
fix(transformer): do no add __self when the jsx is inside constructor (#3258) 2024-05-14 16:12:49 +01:00
overlookmotel
65540c0118
fix(traverse): set ScopeFlags::Function bit for class methods (#3277) 2024-05-14 21:33:59 +08:00
overlookmotel
6fd7a3c427
fix(traverse): create scopes for functions (#3273)
Fix bug with:

1. scopes not being created for functions.
2. too many scopes being created for class methods.

i.e. Logic for when `Function` creates a scope was opposite of what it
should be.

Discovered by @Dunqing in
https://github.com/oxc-project/oxc/pull/3258#pullrequestreview-2054259476.
2024-05-14 18:27:18 +08:00
Boshen
530455849b chore(tasks): add commit sha to snapshots to make sure submodules are not outdated (#3267)
If submodules are outdated, it'll panic with the following message

```
Repository is outdated, please run `just submodules` to update it.
```

For us maintainers, we'll need the env `UPDATE_SNAPSHOT` to force an update.
2024-05-14 10:18:00 +00:00
Pig Fang
56346d59da
chore(linter): expose Message:start and Message:end (#3268)
Expose the `start` and `end` field for modification in downstream
projects.
2024-05-14 08:48:05 +00:00
Boshen
b27a905958
refactor(parser): simplify Context passing (#3266) 2024-05-14 12:22:27 +08:00
Boshen
c4ccf9f4d8 fix(parser): parse DecoratorCallExpression when Arguments contains MemberExpression (#3265)
closes #3261
closes #3262

```
DecoratorCallExpression[Yield, Await] :
  DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
```
2024-05-14 03:18:41 +00:00
Jelle van der Waa
3644400aed
feat(linter/eslint): Implement fixer for unicode-bom rule (#3259) 2024-05-14 09:57:01 +08:00
Boshen
f6daf0b7ae
feat(sourcemap): add feature "sourcemap_concurrent" 2024-05-14 00:05:27 +08:00
Dunqing
eefb66f750 feat(ast): add type to AccessorProperty to support TSAbractAccessorProperty (#3256) 2024-05-13 12:35:58 +00:00
Boshen
7193d75e94
Release oxlint and vscode extension v0.3.4 2024-05-13 18:33:04 +08:00
Boshen
6edcae86cd
feat(linter): move react/rules_of_hooks to nursery 2024-05-13 18:33:04 +08:00
Jelle van der Waa
44b16ef79d
feat(linter/eslint): Implement max-classes-per-file (#3241)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/max-classes-per-file)
2024-05-13 17:23:01 +08:00
Boshen
6149e49ef7
Release oxlint and vscode extension v0.3.3 2024-05-13 17:10:13 +08:00