Commit graph

3538 commits

Author SHA1 Message Date
mysteryven
d7849f8865 refactor(linter): find return statement by using CFG in react/require-render-return (#3353)
Maybe currently Class components are relatively few in quantity, didn't performance changed.
2024-05-19 14:59:12 +00:00
Dunqing
8a30a98465 fix(semantic) incorrect reference flag caused by MemberExpression (#3354)
fix: https://github.com/oxc-project/oxc/issues/3326#issuecomment-2118858837
2024-05-19 14:55:18 +00:00
Boshen
89a1f97320
refactor(parser): improve expression parsing (#3352) 2024-05-19 21:28:16 +08:00
Boshen
e818fba21c refactor(parser): improve parse_simple_arrow_function_expression (#3349) 2024-05-19 06:05:39 +00:00
Boshen
d2e1dbc82a perf(coverage): run test cases in parallel (#3348) 2024-05-19 03:24:08 +00:00
overlookmotel
938ae12203 refactor(ast): fix clippy lint on nightly (#3346)
Clippy on nightly produces a warning for `&t as *const _`.

This warning is spurious in this case - we know `t` is valid, because we just created it. But change it, to keep Clippy happy!
2024-05-18 17:43:51 +00:00
Boshen
1e802c71d5
refactor(parser): clean up ParserState (#3345) 2024-05-19 01:30:16 +08:00
Dunqing
e2c6fe0cb1
feat(transformer): report errors when options have unknown fields (#3322) 2024-05-19 01:19:40 +08:00
Boshen
46cb5f97a0
perf(parser): use FxHashSet for not_parenthesized_arrow (#3344) 2024-05-19 01:13:56 +08:00
Boshen
899a52bf28
fix: fix some nightly warnings 2024-05-19 00:54:52 +08:00
Boshen
0742081921 refactor(parser): improve is_parenthesized_arrow_function_expression (#3343) 2024-05-18 16:39:51 +00:00
Boshen
6b3d019631 refactor(paresr): move some structs to js module (#3341) 2024-05-18 14:41:32 +00:00
Boshen
9ced605487
refactor(parser): start porting arrow function parsing from tsc (#3340)
relates #3320
2024-05-18 22:35:29 +08:00
Boshen
17f4b199b9 feat(cli): add --silent to disable all diagnostics printing (#3338) 2024-05-18 10:22:51 +00:00
Boshen
c9d84af44e
refactor(diagnostics): s/warning/warn 2024-05-18 17:55:05 +08:00
Boshen
f13fe8a18b
feat!(linter): enforce rule severity from the cli and configuration file (#3337)
closes #2059

Breaking change:

* `--deny` / `-D` from the CLI and `error` from configuration file will
report diagnostics as severity "error".
* `--warn` / `-W` from the CLI and `warn` from configuration file will
report diagnostics as severity "warning".
2024-05-18 17:45:19 +08:00
Boshen
8388c7bd21
perf(linter): use usize for RuleEnum hash (#3336) 2024-05-18 14:12:32 +08:00
Boshen
8383b6e046 refactor(linter): remove with_rule_name from the tight loop (#3335) 2024-05-18 01:43:08 +00:00
Boshen
e4b3a3c06a feat(linter): backward compability for react-hooks and deepscan plugins (#3334)
closes #3317
2024-05-17 16:09:20 +00:00
mysteryven
a23bbf9016 fix(linter): avoid infinite loop in jest/expect-expect (#3332)
fix: #3324

I just replace `name` with a `set`, feel like this can catch more cases. And this rule needs to be [rewritten](https://github.com/oxc-project/oxc/issues/3323#issuecomment-2117623621).
2024-05-17 14:45:22 +00:00
Boshen
6c3d99a951 fix(linter/jsx-no-undef): check for globals when an identifier is undefined (#3331)
closes #3319
2024-05-17 14:20:08 +00:00
mysteryven
385965f2ff fix(linter): avoid infinite loop when traverse ancestors in jest/no_conditional_expect (#3330)
closes: #3325
2024-05-17 14:12:28 +00:00
Boshen
e241136f91 feat(cli,linter): add --disable-oxc-plugin (#3328)
closes #3316
2024-05-17 12:11:17 +00:00
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