Commit graph

5058 commits

Author SHA1 Message Date
DonIsaac
b629e160db fix(linter/unicorn): improve diagnostic message for no-null (#5172)
This stack was made because of shortcomings I noticed while running `oxlint-eccosystem-ci` tests locally
2024-08-24 21:40:00 +00:00
camc314
dc9e1e233a fix(unicorn/linter) fix multiple false positives in no-useless-promise-resolve-reject (#5178)
more closely follows the implementation from unicorn's repo.

early returns if the parent is not a `return`, `yield`, or an arroy function

Closes #5125
Closes #5126
2024-08-24 21:03:31 +00:00
DonIsaac
d29042e7fc fix(linter/no-unused-vars): function expression in implicit arrow function return (#5155)
Fixes cases such as:
```ts
export const foo = () => function bar() {}
```
2024-08-24 15:49:56 +00:00
Cameron
147b37176b
fix(linter) fix bug in fixer for func names when function is async (#5167) 2024-08-24 11:30:56 -04:00
dalaoshu
1f5b6b6c82
fix(linter): bug in fixer for prefer-to-have-length (#5164) 2024-08-24 11:29:45 -04:00
Boshen
01c0c3e4b2 feat(transformer): add remaining options to transformer options (#5169)
closes #5168
2024-08-24 14:52:03 +00:00
Earl Chase
ba62a71975
fix(linter/react): Fixed false positive with missing key inside React.Children.toArray() for fragments (#5133)
Related: #4421 and #4945
2024-08-24 16:01:50 +08:00
Boshen
c96609151e
fix(coverage): fix cases where source_type is incorrectly set to script 2024-08-24 14:40:05 +08:00
Boshen
e4ca3d3901
chore(coverage): ignore annex-b/disabled tests 2024-08-24 14:20:06 +08:00
Boshen
12c21b2bfd
fix(coverage): do not run generated test cases when filter is applied 2024-08-24 14:03:54 +08:00
Boshen
7b1546bb66
fix(codegen): do not print comments when --minify 2024-08-24 13:49:34 +08:00
Boshen
0410314278
chore(codegen): improve examples 2024-08-24 13:38:19 +08:00
overlookmotel
eb71a32ee7 refactor(ci): transform conformance snapshot include when output mismatch (#5135)
Include "Output mismatch" in transform conformance snapshots when a test also fails due to scopes/symbols mismatches.

At present, many of the tests are failing on scopes/symbols mismatches, so it's hard to see from snapshots which also have an output mismatch. In particular, when working to fix scope mismatches, it's hard to notice if changes you make cause the output to be wrong. These extra messages make that visible.
2024-08-24 04:52:14 +00:00
overlookmotel
be42b1c76b fix(ci): transform conformance do not skip any errors (#5134)
Snapshots generated by transform conformance were missing a few errors (e.g. `declarations/const-enum/input.ts` at bottom of diff). Make sure all errors fail the test.
2024-08-24 04:52:11 +00:00
DonIsaac
36e4a2875c fix(linter/no-unused-vars): panic in variable declarator usage checks (#5160)
Part of #5129
2024-08-24 04:49:30 +00:00
Dunqing
e3561127fe
chore(semantic): remove accidentally left comment (#5162) 2024-08-24 00:41:01 -04:00
Boshen
d5a494023e refactor(semantic): rewrite handling of label statement errors (#5138)
This reverts the previous changes to handling labels so that all tests can pass.

This passes all false postivies found in `monitor-oxc` (node_modules/flow-parser/flow_parser.js)

As it turns out this requires less code and produces better diagnostics.
2024-08-24 02:37:49 +00:00
overlookmotel
960e1d5c60 refactor(ast): rename IdentifierReference::new_with_reference_id (#5157)
The old name `new_read` no longer makes sense as it doesn't set a read-only flag any more, since `flags` field was removed from `IdentifierReference`.
2024-08-24 02:34:18 +00:00
Cameron
22d57f9e5e
feat(linter/unicorn): add fixer to prefer-string-slice (#5150) 2024-08-23 21:37:35 -04:00
camc314
34bfaf6792 feat(linter/react): add fixer to jsx-props-no-spread-multi (#5145) 2024-08-23 23:43:53 +00:00
overlookmotel
5136f011d9 refactor(transformer): remove unnecessary type annotation (#5131)
Remove unnecessary type annotation introduced in #4925.
2024-08-23 23:10:38 +00:00
overlookmotel
f63b568c48 refactor(ast): remove #[non_exhaustive] attr from AstBuilder (#5130)
Partially revert #4925. That PR's description gave no explanation of why this attribute is desirable.
2024-08-23 23:04:28 +00:00
Cameron
2fe44153ac
feat(linter/unicorn): add fixer to no-redundant-roles (#5146) 2024-08-23 17:38:24 -04:00
Cameron
d35c6f5dfc
feat(linter/unicorn): add fixer to prefer-regexp-test (#5151) 2024-08-23 17:34:06 -04:00
Cameron
27db769b8a
feat(linter/unicorn): add fixer to text-encoding-identifier-case (#5154) 2024-08-23 17:29:19 -04:00
Cameron
7eb052e0d4
fix(linter): no-hex-escape fixer removing regex flags (#5137)
closes #5127
2024-08-23 20:32:34 +01:00
DonIsaac
1ce9630c72 feat(linter/config): implement FromIterator for LintPluginOptions (#5102)
Part of #5046
2024-08-23 18:55:58 +00:00
DonIsaac
33599b0064 refactor(linter): split options into multiple files (#5101) 2024-08-23 18:55:57 +00:00
camc314
56a68f542d fix(linter) fix bug in fixer for func-name (#5136)
closes #5128
2024-08-23 18:46:04 +00:00
Boshen
7cc2bbd293
chore(semantic): print errors from examples/simple.rs 2024-08-23 22:57:26 +08:00
Boshen
4c88997727
comment just ast 2024-08-23 21:42:21 +08:00
DonIsaac
b894d3b33e feat(linter)!: make no-unused-vars correctness (#5081)
closes #5080
2024-08-23 13:12:59 +00:00
Dunqing
47e69a8c94 fix(transformer-optional-catch-binding): the unused binding is not in the correct scope (#5066)
Blocked by #5008

In the SemanticBuilder, we insert all CatchClause parameters in the BlockStatement scope, a child-scope of CatchClause

858f510d59/crates/oxc_semantic/src/builder.rs (L709-L718)

So we should do the same thing in this plugin, but because CatchClause has no parameters, SemanticBuilder doesn't create scope for `CatchClause`. This cause we cannot find the `BlockStatement` scope_id.

This PR has changed to the correct logic. Just to wait #5008 solved
2024-08-23 13:02:53 +00:00
overlookmotel
eba5033a58 refactor(traverse): codegen ChildScopeCollector (#5119)
Codegen `ChildScopeCollector`, so that if more types have scopes added, we don't forget to add them (like the problem #5118 fixed).

The methods are in different order in the generated version, but otherwise identical to before this PR.

`visit_finally_clause` has to be added manually, as `oxc_traverse` codegen does not read or understand `#[visit(as)]` attrs.
2024-08-23 12:49:33 +00:00
overlookmotel
25d6e20bba fix(traverse): add missing visitors to ChildScopeCollector (#5118)
`ChildScopeCollector` was missing visitors for a few nodes which have recently had scopes added to them.
2024-08-23 12:49:33 +00:00
overlookmotel
f771d7c402 refactor(traverse): remove unnecessary imports (#5116)
`Atom`, `SourceType` and `Span` from `oxc_span`, and operators from `oxc_syntax` are now re-exported from `oxc_ast` crate. Remove unnecessary `use` statements by importing them all from `oxc_ast`.
2024-08-23 12:49:32 +00:00
overlookmotel
c6590aeee3 refactor(traverse): move generated files into separate folder (#5115)
Move generated files in `oxc_traverse` crate into separate folder, to match `ast_tools`.

Also amend the header on generated files to match files generated by `ast_tools`.
2024-08-23 12:49:31 +00:00
camc314
525d664aa9 fix(linter) false positive in jest/no-untyped-mock-factory (#5123)
part of https://github.com/oxc-project/oxc/issues/5103
2024-08-23 12:45:23 +00:00
camc314
b7ba9c01a1 fix(linter) fix bug in fixer for prefer-function-type when interface is exported (#5122)
part of https://github.com/oxc-project/oxc/issues/5103
2024-08-23 12:45:22 +00:00
Jelle van der Waa
f7958c4cc2
feat(linter/unicorn): add prefer-structured-clone (#5095) 2024-08-23 12:34:52 +01:00
Boshen
ff7fa987db fix(diagnostics): improve "file is too long to fit on the screen" (#5120)
closes #4322

Setting the threshold to 1200 because graphical output may contain ansi escape codes and other decorations.
2024-08-23 11:17:12 +00:00
Boshen
76c66b4326 fix(linter/max-lines): point span to end of file for disable directive to work (#5117)
closes #4101
2024-08-23 10:20:17 +00:00
overlookmotel
fc2e9adeff refactor(traverse): remove support for #[scope(if(...))] attr (#5114)
Closes #5008.

There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `oxc_traverse` codegen - it's no longer needed.
2024-08-23 09:28:18 +00:00
overlookmotel
8650d3e773 refactor(ast_tools): remove support for #[scope(if(...))] attr (#5113)
There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `ast_tools` - it's no longer needed.
2024-08-23 09:28:17 +00:00
overlookmotel
1ba11a34ab refactor(traverse): refactor ChildScopeCollector (#5112)
Refactor `ChildScopeCollector`. Now that all scopes are unconditional, can move shared logic into a common method.
2024-08-23 09:28:15 +00:00
overlookmotel
40e2f6e25c refactor(traverse): remove unnecessary branch in ChildScopeCollector (#5111)
Fix a mistake in `ChildScopeCollector`. `Class` always has a scope. No need to check whether it does.
2024-08-23 09:28:14 +00:00
overlookmotel
c100826b42 refactor(semantic)!: always create a scope for for statements (#5110)
Part of #5008. Make scopes for `ForStatement`, `ForInStatement` and `ForOfStatement` unconditional. i.e. always create a scope, even if there is no lexical binding (e.g. `for (i of a) {}`).
2024-08-23 09:28:13 +00:00
overlookmotel
d304d6f973 refactor(semantic)!: always create a scope for CatchClause (#5109)
Part of #5008. Make scope for `CatchClause` unconditional. i.e. always create a scope, even if there is no catch parameter.
2024-08-23 08:30:27 +00:00
Boshen
dd3ad4d68e
chore(regular_expression): remove circular dependency
Error: Circular dependency detected: oxc_parser -> oxc_regular_expression
2024-08-23 16:16:10 +08:00
Boshen
fc4eba5096
chore: publish oxc_regular_expression 2024-08-23 16:16:10 +08:00