Commit graph

3749 commits

Author SHA1 Message Date
overlookmotel
3d0e790401
improve(transformer): create Atom for react import source lazily (#3578)
In JSX transform:

* Don't generate an `Atom` for react importer unless it's needed.
* Re-use the same string slice as `jsx_runtime_importer`.
* Reduce size of `Bindings`.
2024-06-07 16:18:46 +08:00
Yuji Sugiura
4a075cccd6
feat(linter/jsdoc): Implement require-param rule (#3554)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md

NOTE: `config.useDefaultObjectProperties` is not implemented for now.
2024-06-07 15:58:16 +08:00
Dunqing
a939ddd096 feat(transformer/typescript): remove more typescript ast nodes (#3563)
Remove more TypeScript related AST
2024-06-07 05:04:28 +00:00
Dunqing
5c8e16c976 feat(coverage): second transformer build does not print typescript (#3561)
Currently, we lack a test to check if the TS AST has been completely deleted. I have thought of a way to test it. Let's have our idempotency test print the TypeScript code the first time and the second time print the JavaScript code only. If the two results do not match, it means that there are still undeleted TS ASTs or other bugs. Since ideally the TS ASTs are completely deleted, the two results should be the same.
2024-06-07 05:04:25 +00:00
Dunqing
e8a20f8d50 feat(transformer/typescript): remove typescript ast nodes (#3559)
According to Babel tests feedback, remove some known ts AST nodes.
There are still many TS AST nodes that need to be deleted
2024-06-07 05:04:22 +00:00
overlookmotel
37cdc13030 perf(transformer): faster checks if JSX plugin enabled (#3577)
Checks for whether JSX transforms are enabled are on a hot path. Make them as fast as possible:

1. Only check a single bool.
2. Store flags directly in `self` rather than behind a reference.
2024-06-07 03:16:41 +00:00
overlookmotel
f2113aea27
refactor(transformer): reduce cloning and referencing Rcs (#3576)
Similar to #3550. Avoid cloning an `Rc` in one place and pass `Rc`s as
values not references in others.
2024-06-07 01:24:01 +08:00
Boshen
1dbc23417d
chore: regenerate changelogs with commit id and author 2024-06-07 01:22:28 +08:00
Boshen
7ddd3a6d11
chore: change no-constructor-return to pedantic 2024-06-07 00:13:47 +08:00
Boshen
101d0ccefa
ci: trigger ecosystem ci and website task from prepare_release_oxlint 2024-06-07 00:09:42 +08:00
Boshen
08fdb267b4
chore: update CHANGELOG.md 2024-06-06 20:24:19 +08:00
Boshen
2cdc4085f7
ci: only run "update rules" when rules.rs changes 2024-06-06 16:04:41 +08:00
Boshen
604b7cf92b
ci: prepare release oxlint 2024-06-06 16:04:41 +08:00
rzvxa
60f89d1fcf improvement(semantic/cfg): better throw control flow. (#3473)
https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9306698136
2024-06-06 07:55:50 +00:00
rzvxa
987a3f36a8 improvement(linter/react): use CFG for detecting cyclic subgraphs in rules-of-hooks. (#3454) 2024-06-06 07:55:44 +00:00
rzvxa
61bae74f76 improvement(semantic/cfg): better CFG API (#3472) 2024-06-06 07:55:37 +00:00
rzvxa
3c7ee85ce4 improvement(semantic/cfg): better break and continue flow. (#3462)
This PR adds a new edge type called `Jump` to distinguish between normal edges and jumps.
There is also a control flow context which is used to keep track of cfg scopes and labels. It replaces the old `preserve_state` and `restore_state`.
It corrects some mistakes - such as labeled blocks especially labeled continue which wasn't easy to implement with the old approach - in the old control flow but other than that it is mostly refactored to have a more declarative API instead of a procedural approach.
2024-06-06 07:55:31 +00:00
Boshen
769227b7b4
chore: regenerate changelogs 2024-06-06 15:51:53 +08:00
Dunqing
0007ee47be
chore(coverage, transformer_conformance): print all AST whether or not they are Typecript AST (#3556)
We have a conclusion that codegen will print whatever is in the AST,
instead of having an option to enable printing TypeScript syntax. I plan
to remove codegen's `enable_typescript` option after we strip out all
typescript AST in the transformer typescript plugin.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 15:45:20 +08:00
Boshen
6db4d7dc09
chore: update cliff.toml 2024-06-06 15:09:07 +08:00
Boshen
509ed2bcf3
ci: update prepare release crates; regenerate the changelogs 2024-06-06 14:28:51 +08:00
Yuji Sugiura
747500ac5a
feat(linter/jsdoc): Implement require-returns-type rule (#3458)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md
2024-06-06 14:11:39 +08:00
Don Isaac
1fb9d234a6
feat(linter): add fixer for no-useless-fallback-in-spread rule (#3544) 2024-06-06 13:59:42 +08:00
rzvxa
ff3f37dbbd improvement(semantic/cfg): better control flow for ForStatements. (#3453)
similar to #3451 and #3452
2024-06-06 05:41:08 +00:00
rzvxa
91c999546c improvement(semantic/cfg): better control flow for DoWhileStatements. (#3452)
similar to #3451
2024-06-06 05:41:06 +00:00
rzvxa
0012094188 improvement(semantic/cfg): better control flow for WhileStatements. (#3451)
Fixes a simple cfg issue, previously it wouldn't follow the body subgraph correctly.
2024-06-06 05:41:04 +00:00
rzvxa
209a99d49f improvement(semantic/cfg): rework basic blocks. (#3381)
I've replaced the `BasicBlockElement` with an `Instruction` type which would keep both the instruction kind and its associated AstNodeId.
I also removed the register scheme in the control flow in favor of a simpler approach using explicit enums.

https://github.com/oxc-project/oxc/pull/3381#issuecomment-2126622774
2024-06-06 05:41:01 +00:00
Dunqing
646b9937ee feat(coverage/transformer): handle @jsx option (#3553)
if has`@jsx: react`, configure transformer options to match `@jsx: react` behavior
2024-06-06 05:34:22 +00:00
Dunqing
3ba2a932d6 refactor(coverage): use code without meta options in TypeScriptSuite (#3552)
The `@jsx: react` is a typescript option. The `Babel` typescript plugin handles @jsx as well, but this is different. `@jsx` in babel is a [pragma](https://babeljs.io/docs/babel-plugin-transform-react-jsx#pragma) option. So we should use code without these meta options to avoid Babel parsing `@jsx` incorrectly
2024-06-06 05:34:18 +00:00
overlookmotel
f6939cbd92 fix(transformer): store react_importer in Bindings in JSX transform (#3551)
Fix a small bug in React JSX transform. If `import_source` is invalid, the default value `"react"` is used for JSX runtime imports. But for importing React alone, it was still using the old invalid value.

This also allowed removing `ReactOptions` from `Bindings` and just storing `is_development` instead.
2024-06-06 03:19:53 +00:00
overlookmotel
09481244c0 refactor(transformer): pass Rcs by value (#3550)
`Rc<T>` is already a pointer, so passing `&Rc<T>` to functions adds unnecessary indirection (reference to a reference).
2024-06-06 03:19:50 +00:00
overlookmotel
7982b93fb5 fix(transformer): correct spans for JSX transform (#3549)
Correct spans in output of React JSX transform, so it should produce correct source maps.

Have copied which AST nodes have spans and which don't from Babel.
2024-06-06 03:19:47 +00:00
overlookmotel
e4d74ac3ee refactor(transformer): remove update_fragment from JSX transform (#3541)
Fix #3464.

Import of fragment has to be done late in order to replicate the order of imports in Babel's output. But do that in a simpler way.
2024-06-06 03:19:44 +00:00
overlookmotel
73b78643f2 refactor(transformer): combine import and usage in JSX transform (#3540)
React JSX transform contains some confusing logic (ported directly from Babel) where in automatic mode, imports are inserted in one place, and then used in another.

Logic for which imports are needed is duplicated in both places, and it's hard to figure out whether they're in sync or not (I don't think they are in all cases).

This PR unifies the logic in one place. Imports are now added as and when they're used.

The `Bindings` enum is responsible for creating imports and also holds the state of which "mode" the plugin is working in:

1. Classic
2. Automatic script
3. Automatic module

Combining the two choices classic/automatic and script/module into a single enum:

1. clarifies the logic
2. reduces branching
3. reduces lookups on `ReactJsx::options` (which is behind an `Rc` and therefore costly to read from).
2024-06-06 03:19:41 +00:00
overlookmotel
4586f0bf5c improve(transformer): validate JSX import source option (#3537)
Validate `import_source` option for React JSX transform - disallow empty string.
2024-06-06 03:19:38 +00:00
overlookmotel
14c00a5c1d improve(transformer): validate JSX pragma options (#3536)
Validate React JSX `pragma` and `pragma_frag` options. Don't allow:

* empty string
* `foo.bar.qux`
* `foo.`
* `.bar`
* `.`

If options provided are invalid, raise an error and use the defaults.

Also fast path the defaults.
2024-06-06 03:19:34 +00:00
Don Isaac
6506d086b3
feat(linter): add fixer for no-single-promise-in-promise-methods (#3531)
Fixes look like this:

```rs
let fix = vec![
    ("Promise.all([null]).then()", "Promise.resolve(null).then()", None),
    ("let x = await Promise.all([foo()])", "let x = await foo()", None),
    ("let x = await (Promise.all([foo()]))", "let x = await (foo())", None),
];
```

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 01:40:03 +08:00
Boshen
0674604d7a
chore: regenerate changelog 2024-06-06 01:29:38 +08:00
Don Isaac
1d3c0d7879
docs(span): add doc comments to oxc_span::Span (#3543) 2024-06-06 01:05:34 +08:00
Boshen
dd42f279f7
chore: change website url to https://oxc.rs 2024-06-05 22:05:08 +08:00
overlookmotel
9f467b8479
perf(transformer): avoid fragment update where possible (#3535)
Due to needing to align output with Babel, React JSX transform has to
perform imports for fragments after dealing with the fragments'
children.

Transform generates a dummy identifier initially, and then generates a
UID later on and replaces the dummy.

The PR avoids that process 2-stage process unless we have to. If the UID
was already generated for a previous fragment, we can just use it
straight away.
2024-06-05 19:35:07 +08:00
overlookmotel
ac394f0ec3
perf(transformer): JSX parse pragma only once (#3534)
Currently React JSX transform in classic mode with a custom
`options.pragma` value parses `options.pragma` on every JSX node, and
inserts new `Atom`s into arena every time.

This PR makes it parse `options.pragma` only once at the start of the
transform pass, and re-use the same `Atom`s for each JSX node.
2024-06-05 18:42:43 +08:00
Dunqing
6978269be0 refactor(transformer/typescript): replace reference collector with symbols references (#3533)
https://github.com/oxc-project/oxc/pull/3524 handled the references correctly, now we can remove the reference collector.
2024-06-05 09:02:51 +00:00
Dunqing
ee9a215a21 feat(transformer/typescript): handle namespace directive correctly (#3532) 2024-06-05 09:02:49 +00:00
Boshen
30ba828bc3
Update README.md 2024-06-05 16:35:38 +08:00
Dunqing
affb2c864e
fix(codegen): print indentation before directive (#3512) 2024-06-05 16:32:12 +08:00
overlookmotel
c00598b9d4
fix(transformer): JSX set reference_id on refs to imports (#3524)
Set `reference_id` for references to new imported bindings. e.g. `_jsx`
in `_jsx(Foo, {})` where JSX transform has inserted `import {jsx as
_jsx} from "react/jsx-runtime";`.
2024-06-05 10:57:05 +08:00
IWANABETHATGUY
9fe0863479
chore(oxc_codegen): Pass trivias reference instead of ownership in CommentGenRelated (#3529)
1. Avoid clone or move the ownership when generate comment with `oxc`
2024-06-04 23:21:06 +08:00
Boshen
19bc7eb20f
ci: fix mac build in release_napi_parser 2024-06-04 18:40:24 +08:00
Boshen
119d87510d
ci: fix release crate push tag permission 2024-06-04 18:22:22 +08:00