Commit graph

2780 commits

Author SHA1 Message Date
Boshen
1634586934 refactor(ast): s/TSTypeOperatorType/TSTypeOperator to align with estree 2024-02-21 22:25:04 +08:00
Boshen
9087f71765 refactor(ast): s/TSThisKeyword/TSThisType to align with estree 2024-02-21 22:25:04 +08:00
Boshen
d08abc638e refactor(ast): s/NumberLiteral/NumericLiteral to align with estree 2024-02-21 21:41:08 +08:00
Boshen
e6b391a24f refactor(ast): s/ArrowExpression/ArrowFunctionExpression to align estree 2024-02-21 21:41:08 +08:00
zhangrunzhao
ff6a337453
feat(linter): typescript-eslint: prefer-function-type (#2337)
Ref: #2180 

- doc:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-function-type.md
- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/prefer-function-type.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/prefer-function-type.test.ts

Co-authored-by: 张润钊 <zhangrunzhao@bytedance.com>
2024-02-21 20:15:40 +08:00
Boshen
30392c96e8
Release oxlint and vscode extension v0.2.10 2024-02-21 18:10:37 +08:00
Boshen
35608c8eb1
chore: fix all docs 2024-02-21 18:06:37 +08:00
Boshen
4f22eaaf96
ci: check cargo doc for all crates 2024-02-21 18:03:49 +08:00
tudorbarbu
f7e15769da
feat(linter): eslint no-nonoctal-decimal-escape (#2428)
Rule
[source](https://github.com/eslint/eslint/blob/main/lib/rules/no-nonoctal-decimal-escape.js)
Rule
[tests](https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-nonoctal-decimal-escape.js)

I created a basic sticky regex implementation based on what I could find
about it, since rust does not have support for that.
There might be a better place to keep it instead of this rule file

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 07:02:20 +00:00
Boshen
c76312359c
chore: enable the ignored valid_expect::test_1 test 2024-02-21 14:54:44 +08:00
alakhpc
9d69167d96
feat(linter) eslint: no-new-wrappers (#2413)
Part of: #479 

docs: https://eslint.org/docs/latest/rules/no-new-wrappers

I am unsure of what do do with 2 of the eslint tests that use
`languageOptions: { globals: { String: "off" } }` and `/* global
Boolean:off */`.

I've commented them out as of now.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 06:43:37 +00:00
Andrew McClenaghan
6b3b260dcc
feat(Codegen): Improve codegen (#2460)
This gets all the new TS types working to the same level TS output was
before and fixes a bunch of other codegen

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 14:41:57 +08:00
Dunqing
197fa16613
feat(semantic): add check for duplicate class elements in checker (#2455)
1. Remove the check implementation of the parser
2. Implement it to semantic checker
3. Support typescript's check for duplicate class elements

Support checking for duplicate class elements in semantic checker is
easier to support typescript checking rules.
2024-02-21 14:10:19 +08:00
Dunqing
65571d73a7
fix(vscode): incorrect diagnostic position (#2461)
fix: #2456
2024-02-21 12:11:16 +08:00
Yuto Yoshino
e7ce633d8c
linter: implement from_configuration for jsx-a11y anchor-is-valid (#2425)
- fix: #2361 

Created the `from_configuration` function to recognize links written
during testing as valid. This function takes a JSON configuration and
generates an `AnchorIsValidConfig` object, which determines whether
specific hrefs are valid. This change allows us to easily specify valid
hrefs in our tests, ensuring that our link validation logic works as
expected.
2024-02-20 20:17:10 +08:00
Boshen
a2c173de57
refactor: remove panic! from examples (#2454)
relates #2308
2024-02-20 16:18:39 +08:00
Dunqing
cd48e1e9d9
refactor(linter): simplify getting ImportDefaultSpecifier (#2453) 2024-02-20 16:16:02 +08:00
Boshen
d0d0d9d7bb
feat(diagnostics): implement json reporter (#2452) 2024-02-20 15:33:28 +08:00
Boshen
195d76e6a5
feat(cli,diagnostics): add json reporter (#2451) 2024-02-20 15:28:27 +08:00
Boshen
399c3a6234
feat(cli): add --format option (#2450) 2024-02-20 15:23:37 +08:00
Dunqing
2a2bb2b7dd
refactor(linter): improve implementation of no_dupe_class_members based on ClassTable (#2446) 2024-02-20 13:12:32 +08:00
Dunqing
950298d960
feat(semantic): add static property, ElementKind::Getter, ElementKind::Setter in ClassTable (#2445) 2024-02-20 13:07:48 +08:00
Boshen
9cfc97c30d
refactor(cli): move --rules into LintOptions (#2449) 2024-02-20 12:59:07 +08:00
Boshen
fca6e02f84
refactor(cli): remove the codeowners feature (#2448)
I should've done a better job at selecting features. Every feature
requires more than just code to get it right.

linting by codeowners' files sounds good on paper but actually not that
useful.
2024-02-20 12:54:16 +08:00
Boshen
6b18b7c198
refactor(cli): split the command files (#2447) 2024-02-20 12:43:13 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen (#2443)
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to 
    - Function
    - FormalParameter
    - BindingPattern
 - Adds basic tests for TS generation

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
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