Commit graph

2754 commits

Author SHA1 Message Date
overlookmotel
a78303d5a6
refactor(parser): continue_if in byte_search macro not unsafe (#2440)
#2439 made using `continue_if` in `byte_search!` macro safe, as it no longer continues the main loop after a match, so no danger of reading out of bounds if `continue_if` code fast-forwards the current position.

This follow-on PR removes the unsafe blocks, and uses that fast-forward ability in a couple of places.
2024-02-20 10:45:31 +08:00
overlookmotel
a5a3c695f7
refactor(parser): correct comment (#2441)
Just correcting a typo in a comment, and moving comment to a better
place.
2024-02-20 10:43:12 +08:00
overlookmotel
996a9d27eb
perf(parser): byte_search macro always unroll main loop (#2439)
Refactor `byte_search!` macro to move logic out of the main loop. This ensures the compiler unrolls the loop.

This speeds up lexing single-line comments by 20%-25% on the benchmarks which contain enough comments for the change to register. Presumably the loop wasn't unrolled previously.

The code required to do this is a little odd. It adds an extra `loop {}` which always exits on the first turn (so not really a useful loop), but is required to be able to use `break` to exit that "loop", making 2 different paths for (1) matching byte found and (2) `for` loop completed without finding any match.

This is only way I could find to produce this behavior without using a macro. Is there a more "normal" way to get the same logic?
2024-02-20 10:39:52 +08:00
Dunqing
27b2c212c4
refactor(transformer/decorators): if it is a private method definition, transform it (#2427) 2024-02-19 19:17:11 +08:00
Dunqing
60db720fa6
feat(parser): parse import attributes in TSImportType (#2436)
close: #2394 

64d2eeea7b/src/compiler/types.ts (L2177-L2185)

The corresponding test cases were skipped, so I manually added some
cases to misc

f5db48237f/tasks/coverage/src/typescript.rs (L118-L121)
2024-02-19 12:26:42 +08:00
Dunqing
5bd2ce6ecf
fix(semantic): incorrect reference flag for MemberExpression assign (#2433)
fix: #2432
2024-02-19 10:33:51 +08:00
renovate[bot]
daaea40d0e
chore(deps): update rust crate env_logger to 0.11.2 (#2430) 2024-02-19 10:32:34 +08:00
renovate[bot]
6b5788bc4f
chore(deps): update website npm packages (#2431) 2024-02-19 10:29:42 +08:00
Dunqing
3cbe786b18
refactor(ast): update TSImportType parameter to argument (#2429)
In typescript it's named argument, so we should keep it consistent

64d2eeea7b/src/compiler/types.ts (L2180)
2024-02-19 10:29:24 +08:00
Dunqing
4b11183732
refactor(transformer/decorators): move get_decorator_info inside the decorators (#2426) 2024-02-18 17:37:07 +08:00
Boshen
0fd945fdad
chore: fix publish to open vsx 2024-02-18 17:33:59 +08:00
Boshen
4cd5f1a05e
Release oxlint and vscode extension v0.2.9 2024-02-18 16:55:59 +08:00
Boshen
160498be18
ci: add publish to open vsx registry 2024-02-18 16:55:22 +08:00
overlookmotel
90f9266d00
chore(deps): update bumpalo crate (#2417)
Latest version of `bumpalo` includes a couple of performance fixes for
`String` (e.g. https://github.com/fitzgen/bumpalo/pull/229) which may
help the parser a little.
2024-02-18 11:49:31 +08:00
Dunqing
67d7a4677f
refactor(linter): get arrow expression by scope_id in no_render_return_value (#2424) 2024-02-17 21:06:28 +08:00
Dunqing
7c2d868dc7
refactor(semantic): delete the redundant code in binder (#2423) 2024-02-17 21:02:45 +08:00
Yuji Sugiura
0b9e122de8
feat(linter): Implement unicorn/no-process-exit rule (#2410)
Part of #684 

- docs:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-process-exit.md
- source:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/no-process-exit.js
- tests:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/test/no-process-exit.mjs
2024-02-16 13:37:22 +00:00
Dunqing
8110288bf4
perf(semantic): reduce visit parent nodes in resolve_reference_usages (#2419) 2024-02-16 20:52:35 +08:00
overlookmotel
cc2ddbee77
refactor(parser): catch all illegal UTF-8 bytes (#2415)
Catch all illegal UTF-8 bytes with the `UER` byte handler.

From https://datatracker.ietf.org/doc/html/rfc3629:

> The octet values C0, C1, F5 to FF never appear.

This change *should* make no difference at all, as a valid `&str` may not contain any of these byte values anyway. But it's possible if user has e.g. created the string with `str::from_utf8_unchecked` and not obeyed the safety contraints. This will at least contain the damage if that's happened, and panic rather than lead to UB. And since we're already catching other error conditions, may as well catch them all.
2024-02-16 20:49:01 +08:00
Dunqing
c6767fa598
refactor(semantic): reduce allocation in resolve_references_for_current_scope (#2414) 2024-02-16 20:48:03 +08:00
Dunqing
3ff3495126
fix(playground): syntax check does not work (#2412) 2024-02-15 20:05:14 +08:00
Dunqing
28ba28f64c
refactor(semantic): check directive by current_scope_id (#2411) 2024-02-14 23:21:24 +08:00
tudorbarbu
8e0277e510
feat: add Typescript ban-tslint-comment (#2371)
Rule source:
[link](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/ban-tslint-comment.ts)
Rule tests:
[link](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts)
2024-02-13 23:14:13 +08:00
Yuji Sugiura
6a2586490b
fix(linter/jsx_a11y): Refactor jsx-a11y related utils and its usage (#2389)
Fixes #2360 

To make `jsx-a11y/anchor-has-content` test pass,

- [x] Use `utils::get_element_type(ctx, el)` in
`utils::is_hidden_from_screen_reader` and
`utils::object_has_accessible_child`
- [x] `utils::object_has_accessible_child` should handle both `null` and
`undefined`

and on the way...,

- [x] `utils::get_element_type` should be used only in `jsx_a11y/*`
rules
- [x] Use those utils everywhere(remove manual implementation)
2024-02-13 23:13:43 +08:00
tudorbarbu
cb1ae36317
linter: implement from_configuration for jsx-a11y autocomplete-valid (#2404)
This closes #2362
2024-02-13 23:12:22 +08:00
Wenzhe Wang
d9f073e122
feat(linter): detect jest file by default glob pattern (#2408)
closes: #2397
2024-02-13 22:56:28 +08:00
Dunqing
b5deb9a708
fix(codegen): when async is on the left-hand side of a for-of, wrap it in parentheses (#2407)
Refer to
55e1127a49/internal/js_printer/js_printer.go (L3097-L3104)
2024-02-13 22:42:23 +08:00
Boshen
83cb78fbb0
feat(coverage): add prettier idempotency test (#2403)
feat(coverage): add prettier idempotency test

closes #1329

feat(prettier_conformance): enable TypeScript
2024-02-12 16:20:09 +08:00
Boshen
1cbd7539fb
feat(coverage): add prettier idempotency test (#2402)
closes #1329
2024-02-12 15:30:16 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
Boshen
3ea6c95371
fix(playground): only lint when there are no syntax errors (#2400) 2024-02-12 13:44:44 +08:00
Boshen
5cf7550b40
chore(ast): add some documentation links (#2399) 2024-02-12 13:20:45 +08:00
renovate[bot]
e5fcf82b93
chore(deps): update rust crates (#2396) 2024-02-12 11:42:57 +08:00
Boshen
c4b169e5d6
refactor(prettier): add call_arguments.rs (#2393) 2024-02-11 23:16:07 +08:00
Boshen
7e99e52bbc
refactor(prettier): function parameters (#2392) 2024-02-11 23:01:19 +08:00
Dunqing
73e116e8a1
fix(parser): incorrect parsing of class accessor property name (#2386) 2024-02-11 22:57:13 +08:00
Wenzhe Wang
384d5acd7a
fix(codegen): lower the level of precedence in TaggedTemplateExpression (#2391) 2024-02-11 22:56:32 +08:00
Boshen
747de8cfd4
refactor(prettier): improve Group API (#2390) 2024-02-11 21:53:02 +08:00
keita hino
8d6202f946
feat(linter): eslint-plugin-jest require-to-throw-message (#2384)
partof: #492 

docs:
https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/require-to-throw-message.md
code:
https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/require-to-throw-message.ts
test:
https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/__tests__/require-to-throw-message.test.ts
2024-02-11 20:38:24 +08:00
Boshen
9ff7986610
feat(prettier): handle binaryish expression in return statement (#2388) 2024-02-11 20:01:25 +08:00
Boshen
871a73afdd
fix(prettier): semi colon after class property (#2387) 2024-02-11 19:25:38 +08:00
Dunqing
0df7e296f9
feat(tasks/codegen): check node version >= 20 (#2385)
This syntax only works on node >= 20
`import value from './json-value-array_FIXTURE.json' with { type: 'json'
};`
2024-02-11 19:23:11 +08:00
overlookmotel
383f5b3081
perf(parser): consume multi-line comments faster (#2377)
Consume multi-line comments faster.

* Initially search for `*/`, `\r`, `\n` or `0xE2` (first byte of
irregular line breaks).
* Once a line break is found, switch to faster search which only looks
for `*/`, as it's not relevant whether there are more line breaks or
not.

Using `memchr` for the 2nd simpler search, as it's efficient for a
search with only one "needle".

Initializing `memchr::memmem::Finder` is fairly expensive, and tried
numerous ways to handle it. This is most performant way I could find.
Any ideas how to avoid re-creating it for each Lexer pass? (it can't be
a `static` as `Finder::new` is not a const function, and `lazy_static!`
is too costly)
2024-02-11 12:43:14 +08:00
Boshen
24a9255610
Release napi oxc-parser@v0.4.0 2024-02-11 12:37:44 +08:00
Boshen
5723690fdf
Release napi oxc-parser@v0.4.0-alpha.0 2024-02-11 11:56:46 +08:00
Boshen
15a8857927
refactor(prettier): improve print_statement_sequence (#2383) 2024-02-11 00:16:26 +08:00
Boshen
82a6dc17d3
feat(pretter): implement print_binaryish_expressions (#2382) 2024-02-10 23:18:56 +08:00
Boshen
4e8fcb5110
refactor(prettier): remove BinaryishLeft (#2381) 2024-02-10 23:10:33 +08:00
Yunfei He
7d7a3fcef8
perf(lint/no_var_requires): quicker way to check if the IdentifierReference point to a global variable (#2376)
The old code use this function to do the checking, which is too much for
this simple checking


ef336cb66b/crates/oxc_linter/src/ast_util.rs (L267-L276)
2024-02-10 22:46:02 +08:00
cinchen
92afbb102e
feat(linter): eslint-plugin-jest: prefer-equality-matcher (#2358)
Rule detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-equality-matcher.ts)
2024-02-10 19:30:28 +08:00