oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
12.6k stars 466 forks source link

New Tool: es-check #1010

Open Boshen opened 1 year ago

Boshen commented 1 year ago

See https://github.com/yowainwright/es-check

Usecases:

Approach:

oxc_parser parses esnext, which means we are not going to add a ecmaVersion option to the parser. Instead we are just going to add a special linter. The the code setup can be copied from https://github.com/web-infra-dev/oxc/blob/main/crates/oxc_linter/examples/linter.rs

magic-akari commented 1 year ago

Something related: esbuild marks used features in the parser https://github.com/evanw/esbuild/blob/427ee6054401042f509c2b3a2d31bc6eebca655c/internal/js_parser/js_parser_lower.go#L42

byteHulk commented 11 months ago

hi @Boshen can I take on this issue?

Boshen commented 11 months ago

hi @Boshen can I take on this issue?

Have fun! Please be aware of our rules https://oxc-project.github.io/docs/contribute/rules.html and sure that you submit smaller PRs!

byteHulk commented 11 months ago

hi @Boshen Is it possible to do this just by checking(handwriting rules) the AST parsed by oxc_parser for new syntax for a particular version here?

And Do I still need to use the oxc_transformer package?

https://github.com/oxc-project/oxc/blob/774a257a66ca06b141a286c4e1336a81a6534be1/crates/oxc_linter/examples/linter.rs#L41

Boshen commented 11 months ago

hi @Boshen Is it possible to do this just by checking(handwriting rules) the AST parsed by oxc_parser for new syntax for a particular version here?

And Do I still need to use the oxc_transformer package?

https://github.com/oxc-project/oxc/blob/774a257a66ca06b141a286c4e1336a81a6534be1/crates/oxc_linter/examples/linter.rs#L41

It should be similar to how the linter is written, see

byteHulk commented 11 months ago

I see, but do I need to write the syntax matching rules by hand, or has someone else already done that part and I can just bring them in?

Like this?


AstKind::VariableDeclaration(stmt)
                if ecma_version < 6
                    && (stmt.kind == VariableDeclarationKind::Const
                        || stmt.kind == VariableDeclarationKind::Let) =>
            {
                The let declaration is not yet supported in the es5 environment.
                // errors...;
            }```
Boshen commented 11 months ago

I see, but do I need to write the syntax matching rules by hand, or has someone else already done that part and I can just bring them in?

Like this?

AstKind::VariableDeclaration(stmt)
                if ecma_version < 6
                    && (stmt.kind == VariableDeclarationKind::Const
                        || stmt.kind == VariableDeclarationKind::Let) =>
            {
                The let declaration is not yet supported in the es5 environment.
                // errors...;
            }```

do I need to write the syntax matching rules by hand

Yes, you need to write them by hand. All the tests from https://github.com/yowainwright/es-check/tree/main/tests has to be passed.

Boshen commented 10 months ago

I'm going to move this to another repository, in private for some experimentation.

byteHulk commented 10 months ago

我将把它转移到另一个存储库,私下进行一些实验。

ok

Boshen commented 7 months ago

We need this for the transformer after finishing Milestone 1 @Dunqing

Boshen commented 5 months ago

Ok this isn't the right direction, closing again.

Boshen commented 1 week ago

Reopen again because I need this to validate the transformer.