overlookmotel
22d56bdcac
fix(semantic): do not resolve references after FormalParameters in TS type ( #4241 )
...
Semantic resolves references when exiting `FormalParameters` to ensure references in param initializers don't get bound to bindings inside the function body.
However, it shouldn't do this for `FormalParameters` in TS types e.g. `TSTypeAnnotation` because they don't have their own scopes.
2024-07-13 02:43:01 +00:00
Boshen
7eb960d6e9
feat(transformer): decode xml character entity &#xhhhh and &#nnnn; ( #4235 )
2024-07-13 02:38:07 +00:00
mysteryven
9df60da6f3
fix(linter): correct find first non whitespace logic in @typescript-eslint/consistent-type-imports ( #4198 )
2024-07-13 02:33:03 +00:00
DonIsaac
7089a3d67b
refactor(linter): split up fixer code into separate files ( #4222 )
...
refactor(linter): split up fixer code into separate files
refactor: mark Fix as non_exhaustive
2024-07-13 02:26:00 +00:00
lucab
d7ab0b8413
refactor(semantic)!: simplify node creation ( #4226 )
...
This tweaks AST node creation and tree manipulation, directly
building new nodes with a valid node ID.
2024-07-13 02:19:02 +00:00
mysteryven
67240dce85
fix(linter): not ignore adjacent spans when fixing ( #4217 )
...
fixes : #4204
2024-07-13 02:11:40 +00:00
underfin
205c259119
feat(sourcemap): support SourceMapBuilder#token_chunks ( #4220 )
...
Because the `token_chunks` need to pre-visit tokens and collect, it
could be done at add tokens phase. So here export it let rolldown could
be improve `renderChunks` sourcemap encode.
2024-07-13 10:11:14 +08:00
Boshen
c65198fa15
fix(codegen): choose the right quote for jsx attribute string ( #4236 )
2024-07-12 17:30:24 +00:00
Boshen
be82c286d6
fix(codegen): print JSXAttributeValue::StringLiteral directly ( #4231 )
...
jsx attribute string is interpreted as is without escaping.
The transformer is responsible for converting it to plain js string.
2024-07-12 16:17:23 +00:00
Jaden Rodriguez
6fb808febf
feat(linter): add typescript-eslint/no-confusing-non-null-assertion ( #4224 )
...
Added logic for
https://typescript-eslint.io/rules/no-confusing-non-null-assertion
Left comments for when Suggest feature is added
---------
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-07-12 11:12:43 -04:00
IWANABETHATGUY
66b455a2b2
fix(oxc_codegen): avoid print same pure comments multiple time ( #4230 )
...
## Before
```bash
Original:
const builtInSymbols = new Set(
/*#__PURE__*/
Object.getOwnPropertyNames(Symbol)
.filter(key => key !== 'arguments' && key !== 'caller')
)
Printed:
const builtInSymbols = new Set(/*#__PURE__*/ /*#__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller"));
Minified:
const builtInSymbols=new Set(Object.getOwnPropertyNames(Symbol).filter((key)=>key!=="arguments"&&key!=="caller"))
```
## After
```bash
Original:
const builtInSymbols = new Set(
/*#__PURE__*/
Object.getOwnPropertyNames(Symbol)
.filter(key => key !== 'arguments' && key !== 'caller')
)
Printed:
const builtInSymbols = new Set(/*#__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller"));
Minified:
const builtInSymbols=new Set(Object.getOwnPropertyNames(Symbol).filter((key)=>key!=="arguments"&&key!=="caller"))
```
2024-07-12 23:07:43 +08:00
lucab
81ed5885a8
refactor(semantic): convert scope fields to IndexVecs ( #4208 )
...
Closes: https://github.com/oxc-project/backlog/issues/10
2024-07-12 09:43:58 +00:00
Dunqing
92ee77487f
feat(semantic): add ScopeFlags::CatchClause for use in CatchClause ( #4205 )
2024-07-12 03:47:07 +00:00
cinchen
126b66c4f8
feat(linter): support eslint-plugin-vitest/valid-describe-callback ( #4185 )
...
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/valid-describe-callback.ts )
---------
Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-12 11:35:00 +08:00
rzvxa
aab7aaaa06
refactor(ast/visit): fire node events as the outermost one. ( #4203 )
...
I'm going to be AFK today(till about 9 PM UTC). Meanwhile, I Didn't want to be a blocker so here we go.
It would fix the #4200 merge if you guys find it in the correct order otherwise feel free to close it.
2024-07-12 03:27:59 +00:00
cinchen
05b9a7375a
feat(linter): support eslint-plugin-vitest/valid-expect ( #4183 )
...
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/valid-expect.ts )
---------
Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-12 11:24:57 +08:00
Boshen
83c2c62f7b
feat(codegen): add option for choosing quotes; remove slow choose_quot method ( #4219 )
2024-07-12 03:08:22 +00:00
cinchen
3e56b2bd16
feat(linter): support eslint-plugin-vitest/no-test-prefixes ( #4182 )
...
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/no-test-prefixes.ts )
2024-07-12 11:03:39 +08:00
overlookmotel
cb15303644
perf(semantic): reduce memory copies ( #4216 )
...
Reduce memory copies when resolving references in `Semantic`.
If parent scope has no unresolved references for `name`, there is no need to generate a new `Vec<ReferenceId>` for `name` and copy in contents from current scope. Just move the existing `Vec` to the parent.
2024-07-12 02:05:22 +00:00
overlookmotel
ef4c1f4e32
perf(semantic): reduce lookups ( #4214 )
...
Small performance optimization (I hope) to resolving references in `Semantic`. Look up current bindings once rather than on every turn of the loop.
2024-07-12 01:41:28 +00:00
overlookmotel
f23e54f97b
perf(semantic): recycle unresolved references hash maps ( #4213 )
...
Closes #4169 .
Reduce allocations while building `Semantic` by recycling hash maps used for tracking unresolved references, rather than creating a new one for every scope.
2024-07-12 01:41:27 +00:00
DonIsaac
3016f03578
feat(linter): let fixer functions return a None fix ( #4210 )
...
Part of #4187 .
Adds `CompositeFix::None`, which enables fixer functions to decide not to fix some code.
While I was in the area, I took the liberty of adding some doc comments.
2024-07-12 01:12:42 +00:00
Jelle van der Waa
dd07a5475b
fix(linter): global variables should always check the builtin variables ( #4209 )
...
This fixes commit dbbb6fca56 .
Closes #3374
2024-07-11 13:22:34 -04:00
Boshen
91dc0f7866
chore(benchmark): add codegen benchmark ( #4207 )
2024-07-11 23:58:37 +08:00
lucab
2602ce2b71
perf(semantic): reuse existing map of unresolved refs ( #4206 )
2024-07-11 15:35:22 +00:00
Burlin
bbe6137dc9
feat(linter): implement unicorn/no-useless-undefined ( #4079 )
...
Resolves #3870
Hey there, thought I'd give this a try as it's tagged "good first issue"
:) Let me know if there's anything that needs to change
Another part of the code also needs modification:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/no-useless-undefined.js#L95
I tried to modify it. If there are any issues with these modifications,
please let me know.
```
fn is_has_function_return_type(node: &AstNode, ctx: &LintContext<'_>) -> bool {
let Some(parent_node) = ctx.nodes().parent_node(node.id()) else {
return false;
};
match parent_node.kind() {
AstKind::ArrowFunctionExpression(arrow_func_express) => {
arrow_func_express.return_type.is_some()
}
AstKind::Function(func) => func.return_type.is_some(),
_ => is_has_function_return_type(parent_node, ctx),
}
}
```
2024-07-11 22:09:25 +08:00
Boshen
bc2631c500
chore(README): update
2024-07-11 21:15:33 +08:00
Boshen
8a190eb166
feat(oxc): export oxc_mangler
2024-07-11 21:15:32 +08:00
Boshen
33e96e23e4
feat(tasks/minsize): include esbuild minified size ( #4202 )
2024-07-11 13:02:32 +00:00
Boshen
bb646f2bf9
feat(tasks/minsize): show target size for easier comparison ( #4201 )
2024-07-11 12:38:45 +00:00
IWANABETHATGUY
1c117eb20d
fix: avoid print extra semicolon after accessor property ( #4199 )
...
## Before
```js
export default class Foo { @x @y accessor #aDef = 1 }
```
**output**
```bash
Original:
export default class Foo { @x @y accessor #aDef = 1 }
Printed:
export default class Foo {
accessor #aDef=1;;
}
```
2024-07-11 20:16:02 +08:00
Boshen
e3e663bae4
feat(mangler): initialize crate and integrate into minifier ( #4197 )
2024-07-11 10:35:13 +00:00
Dunqing
bbe5dede07
refactor(semantic): set current_scope_id to scope_id in enter_scope ( #4193 )
...
close : #4170
2024-07-11 08:45:35 +00:00
Dunqing
7f1adddaf0
refactor(semantic): correct scope in CatchClause ( #4192 )
...
close : #4186
CatchClause has two scopes. The first one is `CatchClause`, which will add a `CatchParameter` to it. The second one is `Block`, which will add binding that declares in the current block scope.
The spec has a syntax error about `CatchParameter`
- It is a Syntax Error if any element of the BoundNames of CatchParameter also occurs in the LexicallyDeclaredNames of Block.
2024-07-11 08:45:30 +00:00
Boshen
aa22073736
refactor(codegen): improve print API ( #4196 )
2024-07-11 08:41:04 +00:00
github-actions[bot]
4f26e51b74
Release oxlint v0.6.0 ( #4194 )
...
## [0.6.0] - 2024-07-11
- 5731e39 ast: [**BREAKING**] Store span details inside comment struct
(#4132 ) (Luca Bruno)
### Features
- fb549e1 linter: Add vitest/no-focused-tests rule (#4178 ) (mysteryven)
- 6c49007 linter: Add fixer for
@typescript-eslint/consistent-type-imports (#3984 ) (mysteryven)
- 278c3e9 linter: Add fixer for jsx-a11y/aria-props (#4176 ) (DonIsaac)
- 2188144 linter: Eslint-plugin-jest/prefer-hooks-in-order (#4052 )
(cinchen)
- cc58614 linter: Better schemas for allow/warn/deny (#4150 ) (DonIsaac)
- c5b4be0 linter: Add fixer for prefer-node-protocol (#4129 ) (DonIsaac)
- 7ec0c0b linter/eslint: Implement no-label-var (#4087 ) (Jelle van der
Waa)
### Bug Fixes
- ed4c54c eslint/radix: Detect yield Number.parseInt variant (#4110 )
(Jelle van der Waa)
- e9ad03b linter: Fixer for no-debugger creates incorrect code (#4184 )
(DonIsaac)
- bd69571 linter: Fix top level return panic in
eslint/array_callback_return (#4167 ) (Boshen)
- c8f5664 linter: Fix panic with unicode in
unicorn/prefer_dom_node_dataset (#4166 ) (Boshen)
- f2b3273 linter: Fix fixer panic in
typescript/consistent_indexed_object_style (#4165 ) (Boshen)
- 2334515 linter: Panic in `get_enclosing_function` (#4121 ) (DonIsaac)
- 1b91d40 linter: Incorrect fixer for `no-unused-labels` (#4123 ) (Don
Isaac)
- 1729249 linter: Incorrect fix in
`no-single-promise-in-promise-methods` rule; (#4094 ) (DonIsaac)
- cc7e893 linter/tree-shaking: Avoid recursive function stackoverflow
(#4191 ) (mysteryven)
- 28eeee0 parser: Fix asi error diagnostic pointing at invalid text
causing crash (#4163 ) (Boshen)
- 0f02608 semantic: Bind `TSImportEqualsDeclaration`s (#4100 ) (Don
Isaac)
### Performance
- ddfa343 diagnostic: Use `Cow<'static, str>` over `String` (#4175 )
(DonIsaac)
### Refactor
- 2687ebc react: Use find_binding helper for finding React binding
(#4108 ) (Jelle van der Waa)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-11 14:38:41 +08:00
mysteryven
fb549e1288
feat(linter): add vitest/no-focused-tests rule ( #4178 )
...
Rule detail: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
2024-07-11 05:37:04 +00:00
mysteryven
cc7e893634
fix(linter/tree-shaking): avoid recursive function stackoverflow ( #4191 )
...
fixes : #4164
2024-07-11 05:28:35 +00:00
mysteryven
6c49007b27
feat(linter): add fixer for @typescript-eslint/consistent-type-imports ( #3984 )
...
This rule's fixer is complicated, I do line by line copy as possible.
7b13dae347/packages/eslint-plugin/src/rules/consistent-type-imports.ts
2024-07-11 04:48:04 +00:00
Boshen
c8184723f4
feat(minifier): dce conditional expression && or || ( #4190 )
2024-07-11 04:40:23 +00:00
DonIsaac
e9ad03bb62
fix(linter): fixer for no-debugger creates incorrect code ( #4184 )
...
Part of #4179 .
Fixes cases like:
```js
if (foo) debugger
// got fixed into
if (foo)
// but now gets fixed to
if (foo) {}
```
2024-07-11 04:33:43 +00:00
DonIsaac
278c3e9313
feat(linter): add fixer for jsx-a11y/aria-props ( #4176 )
...
Part of #4179 .
Adds a fixer for some common typos.
2024-07-11 04:33:37 +00:00
Jelle van der Waa
7ec0c0bdd4
feat(linter/eslint): Implement no-label-var ( #4087 )
...
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-label-var )
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-07-10 23:22:31 -04:00
github-actions[bot]
2a169d1969
Release crates v0.20.0 ( #4189 )
...
## [0.20.0] - 2024-07-11
- 5731e39 ast: [**BREAKING**] Store span details inside comment struct
(#4132 ) (Luca Bruno)
### Features
- 67fe75e ast, ast_codegen: Pass the `scope_id` to the `enter_scope`
event. (#4168 ) (rzvxa)
- 54cd04a minifier: Implement dce with var hoisting (#4160 ) (Boshen)
- 44a894a minifier: Implement return statement dce (#4155 ) (Boshen)
- 725571a napi/transformer: Add `jsx` option to force parsing with jsx
(#4133 ) (Boshen)
### Bug Fixes
- 48947a2 ast: Put `decorators` before everything else. (#4143 ) (rzvxa)
- 7a059ab cfg: Double resolution of labeled statements. (#4177 ) (rzvxa)
- 4a656c3 lexer: Incorrect lexing of large hex/octal/binary literals
(#4072 ) (DonIsaac)
- 28eeee0 parser: Fix asi error diagnostic pointing at invalid text
causing crash (#4163 ) (Boshen)
### Performance
- ddfa343 diagnostic: Use `Cow<'static, str>` over `String` (#4175 )
(DonIsaac)
- 2203143 semantic: Store unresolved refs in a stack (#4162 ) (lucab)
- fca9706 semantic: Faster search for leading comments (#4140 ) (Boshen)
### Documentation
- bdcc298 ast: Update the note regarding the `ast_codegen` markers.
(#4149 ) (rzvxa)
### Refactor
- 03ad1e3 semantic: Tweak comment argument type (#4157 ) (lucab)
Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-11 11:05:49 +08:00
Boshen
8c54a2f1ed
fix(tasks/ast_codegen): run cargo fmt synchronously ( #4181 )
...
relates #4152
This is my wild guess, because it works in my other script 143685deb1/xtask/src/main.rs (L21)
2024-07-11 02:59:30 +00:00
Boshen
07506ece83
ci: add a git diff check after running tests
2024-07-11 10:18:56 +08:00
DonIsaac
ddfa343475
perf(diagnostic): use Cow<'static, str> over String ( #4175 )
...
Allows us to use `&'static str` for error and help messages without allocating them into `String`s.
2024-07-11 01:44:13 +00:00
rzvxa
7a059ab53a
fix(cfg): double resolution of labeled statements. ( #4177 )
...
Fixes #4173
2024-07-11 01:39:28 +00:00
Boshen
ca0b4fa08a
refactor(tasks): clean up test files and remove libs.txt ( #4172 )
2024-07-10 17:38:06 +00:00
Boshen
083fe38971
chore(codegen): add a for loop special case
2024-07-11 01:35:05 +08:00