Fix a bug introduced in https://github.com/oxc-project/oxc/pull/1966.
Ideally, the rules in eslintrc should be merged into final rules as
described:
> The rules will start with the categories we apply, and then merge all
the configurations stated in the rules field.
>
> For example, if we begin with -D correctness with 80 rules, then
>
> "no-empty-file": "off" will remove the rule, yielding 79 rules
> "no-empty": "error" (restriction) will add the rule, yield 81 rules
> ""no-empty": ["error", { "allowEmptyCatch": true }]` add the rule's
configuration
However, the implementation did not include the newly added rules in the
eslintrc. As a test case and example, I added a new fixture to
`crates/oxc_cli/fixtures/no_undef`. No warn or deny will be found
without this PR.
This is my first Rust PR ever. Any nitpicking suggestions are welcome.
Thanks! 😊
Here implementing the es2015 new target transform, see detail at
https://babel.dev/docs/babel-plugin-transform-template-new-target.
Here has three kinds need to be distinguished.
- `NewTargetKind::Method`, it from `AstKind::ObjectMethod` or
`AstKind::MethodDefinitionKind::Get/Set/Method`. It will be transformed
to `void 0`.
- `NewTargetKind::Constructor`, is from `
AstKind::MethodDefinitionKind::Constructor`. It will be transformed to
`this.constructor`.
- `NewTargetKind::Function`, is from ` AstKind::Function`, here the
function is not the above function. It will be transformed to `this
instanceof _target ? this.constructor : void 0`, here `_target` comes
from the function name or is created by scope uid ident.
Previously if .eslintrc.json contains
```
{
"rules": {
"no-empty": "off"
}
}
```
Then no rules will be enabled.
---
This PR changes how we configure oxlint's rules.
The rules will start with the categories we apply, and then merge all
the configurations stated in the `rules` field.
For example, if we begin with `-D correctness` with 80 rules, then
* `"no-empty-file": "off"` will remove the rule, yielding 79 rules
* `"no-empty": "error"` (restriction) will add the rule, yield 81 rules
* ""no-empty": ["error", { "allowEmptyCatch": true }]` add the rule's
configuration
This PR fixes the plugin parsing logic when reading a config file.
Specifically, the plugin names defined in `RuleEnum`s use snake-case
("jsx_a11y") while in the config file they are written as "jsx-a11y".
This inconsistency causes some rules to be filtered out.
I tested the change with the config json file provided in #1969.
- Before the change: `Finished in 21ms on 1 file with 157 rules using 8
threads.`
- After the change: `Finished in 23ms on 1 file with 178 rules using 8
threads.`
Related issue: #1969
Hello. 👋🏻
This PR makes `just new-jsdoc-rule xxxx` command works.
---
Initially, I planned to implement some basic rules later.
However, after struggling for half a day, I realized that it would be
challenging for a beginner like me to do it now. 😓
Once I have looked for something else I can do, and/or read more into
the codebase, I hope to be able to try again at some point.
Part of #1880
`Token` size is reduced from 32 to 16 bytes by changing the previous
token value `Option<&'a str>` to a u32 index handle.
It would be nice if this handle is eliminated entirely because
the normal case for a string is always
`&source_text[token.span.start.token.span.end]`
Unfortunately, JavaScript allows escaped characters to appear in
identifiers, strings and templates. These strings need to be unescaped
for equality checks, i.e. `"\a" === "a"`.
This leads us to adding a `escaped_strings[]` vec for storing these
unescaped and allocated
strings.
Performance regression for adding this vec should be minimal because
escaped strings are rare.
Background Reading:
* https://floooh.github.io/2018/06/17/handles-vs-pointers.html
This was incorrectly using raw for dynamically generated numbers like in
the minifier (
6e0bd52af1/crates/oxc_minifier/src/compressor/fold.rs (L280)
).
This ensures they are dynamically generated during codegen.
This does not investigate why `just example minifier` does not take the
`if MINIFY` branch.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
This PR is part of #1880.
`Token` size is reduced from 48 to 40 bytes.
To reconstruct the regex pattern and flags within the parser , the regex
string is
re-parsed from the end by reading all valid flags.
In order to make things work nicely, the lexer will no longer recover
from a invalid regex.
This PR partially fixes#1803 and is part of #1880.
BigInt is removed from the `Token` value, so that the token size can be
reduced once we removed all the variants.
`Token` is now also `Copy`, which removes all the `clone` and `drop`
calls.
This yields 5% performance improvement for the parser.