Commit graph

2441 commits

Author SHA1 Message Date
Ali Rezvani
51de41cc7a
fix(index): add example_generated to create the docs. (#3106)
This dummy feature is for generating the documentations made by macros, I've missed it in my initial fork.
2024-04-26 20:37:38 +08:00
Ali Rezvani
df2beb2d75
chore: make oxc_index dependency on serde optional. (#3103)
nothing fancy here, just a simple change.
2024-04-26 20:34:59 +08:00
Yuji Sugiura
5866086d17
feat(linter/jsdoc): Implement no-defaults rule (#3098)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#repos-sticky-header
2024-04-26 00:03:21 +08:00
overlookmotel
0185eb2edc
refactor(ast): remove duplicate TSNamedTupleMember representation (#3101)
Removes duplicate representation of a `TSTupleElement` which is a
`TSNamedTupleMember`.

Closes #3100.
2024-04-25 19:16:24 +08:00
Boshen
78875b79fe
feat(transformer): implement typescript namespace (#3025)
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-04-25 10:26:11 +00:00
Ali Rezvani
ac72d08592
chore: cleanup the dependencies on static_assertions and oxc_index. (#3095)
We used to export `static_assertions` as part of the `oxc_index`. It
would've made sense back when it was only a vessel for exporting other
crates - although even then it wouldn't make much sense other than being
convenient - Now with it turning into a port of `index_vec` and
potentially getting bigger as the result of specific needs of the
project; It makes much more sense to stop exporting it from `oxc_index`
and use the crate directly in places that used to use what `oxc_index`
were exporting.


PS: we may want to follow up this with an `oxc_asset` crate containing
our own set of assertion tools which would also export
`static_assertions`.
2024-04-25 16:56:23 +08:00
Ali Rezvani
8618f6b32a
chore(index): fork index_vec crate. (#3092)
related to #3086
2024-04-25 06:09:53 +00:00
Dunqing
2dd96df847
feat(semantic): report namespace related errors (#3093)
See
https://www.typescriptlang.org/play/?target=99#code/GYVwdgxgLglg9mABAIzgEwJ4AoCUiDeAUIomAIYC2ApgM4AOZEViAIgQL6HtA
2024-04-25 14:01:58 +08:00
Yuji Sugiura
fa3d9d23a0
feat(linter/jsdoc): Implement implements-on-classes rule (#3081)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md

`contexts` option is not supported for now.
2024-04-25 10:14:28 +08:00
Ali Rezvani
08b2612245
improvement(linter/unicorn): use root_node method in the no_process_exit rule. (#3091) 2024-04-25 09:13:38 +08:00
Ali Rezvani
a43054bec5
improvement(linter/unicorn): use root_node method in the no_empty_file rule. (#3090) 2024-04-25 09:07:40 +08:00
Ali Rezvani
71da1a1d72
improvement(linter/tree_shaking): use root_node in the no_side_effects_in_initialization rule. (#3089) 2024-04-25 09:01:41 +08:00
Ali Rezvani
69e464b19a
improvement(linter/ts): use root_node method in the triple_slash_reference rule. (#3088) 2024-04-25 08:55:29 +08:00
Ali Rezvani
c49f6922c2
improvement(linter/nextjs): use root_node method in no_async_client_component rule. (#3087) 2024-04-25 08:49:30 +08:00
Ali Rezvani
dcb2528861
fix(semantic): revert test code pushed to the main by accident. (#3085)
I'm terribly sorry, I've reverted the wrong commit in #3084.
2024-04-25 08:43:49 +08:00
Ali Rezvani
8d17ab36c3
fix(semantic): allow root_node to be empty for empty trees. (#3084)
related to #3082, #3030 and #3069
2024-04-25 01:10:59 +08:00
Wang Wenzhe
8de7399b08
chore(tasks): observe nursery rule in benchmark (#3082) 2024-04-24 23:03:52 +08:00
Wang Wenzhe
88ded0cef5
feat(linter/tree-shaking): support ForStatement (#3078) 2024-04-24 00:32:47 +08:00
Yuji Sugiura
d109767330
feat(linter/jsdoc): Implement check-tag-names rule (#3029)
Part of #1170 

-
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#user-content-check-tag-names-options-definedtags

(This time, I'm less confident that I have implemented correctly. 😓 )
2024-04-24 00:32:14 +08:00
Ali Rezvani
ac1a40fb43
feat(ast): add callee_name method to the CallExpression. (#3076)
Adds a simple way to get the name of a given `CallExpression`.
2024-04-23 09:47:23 +08:00
Wang Wenzhe
c3ec710b3d
feat(linter/tree-shaking): support ExportNamedDeclaration (#3072) 2024-04-23 02:19:34 +08:00
overlookmotel
942b2ba084
refactor(ast): add array element Elision type (#3074)
Pure refactor. This change does nothing except makes it more consistent
with other types which are also just a wrapper around `Span` e.g.
`NullLiteral` and `TSThisType`.
2024-04-23 02:05:11 +08:00
overlookmotel
81f90fd8b0
fix(ast): do not include trailing_comma in JSON AST (#3073)
Don't include `trailing_comma` fields in JSON AST, for compat with
ESTree (#2854).
2024-04-23 02:04:32 +08:00
谭光志
be9cdfcd83
feat(linter): eslint/no-await-in-loop (#3070)
[no-await-in-loop](https://eslint.org/docs/latest/rules/no-await-in-loop)
2024-04-22 21:43:32 +08:00
Boshen
a5a73517f8
fix(linter): fix unwanted plugin rules being enabled 2024-04-22 16:00:17 +08:00
Boshen
559bca86c5
Release crates v0.12.5 2024-04-22 12:52:17 +08:00
Boshen
b88dfd7cee
fix(linter): support -D all -D nursery 2024-04-22 12:43:12 +08:00
Boshen
8d17bb4052
feat(linter): --deny all should not enable nursery rules
closes #3067
2024-04-22 12:34:32 +08:00
Todor Andonov
c2ad8f82de
feat(linter): implement fixer for typescript-eslint/consistent-type-definitions (#3045)
This is a continuation of https://github.com/oxc-project/oxc/pull/2885.

closes https://github.com/oxc-project/oxc/issues/2933

Note for reviewers: please take a look at how the new test cases are
defined. I just copy-pasted them from
[here](c33f497ad8/packages/eslint-plugin/tests/rules/consistent-type-definitions.test.ts (L67))
and I'm not sure if this is how it should be done. I also added a few
more test cases.
2024-04-22 12:13:33 +08:00
Boshen
5241e1e127
refactor(cli): improve --help documentation 2024-04-22 11:14:51 +08:00
Boshen
023c1acfd0
chore(linter): remove unused "timing" variable 2024-04-22 11:08:50 +08:00
Boshen
ae72be1964
feat(linter): remove all ESLint Stylistic rules
They are out of scopes of this project.

closes #3066
closes #3040
2024-04-22 11:05:13 +08:00
Boshen
58d6438efb
feat(linter): change no-empty-static-block to correctness 2024-04-22 11:05:13 +08:00
Ali Rezvani
7e4beb0118
refactor(linter/import/no_cycle): use ModuleGraphVisitor. (#3064)
Uses #3062 to avoid having multiple implementations for the same idea(shared with #3030).
2024-04-22 10:26:40 +08:00
Ali Rezvani
5cf55c212e
feat(linter): no barrel file. (#3030)
closes #3004 

I've based it on [this plugin](https://github.com/thepassle/eslint-plugin-barrel-files/blob/main/lib/rules/avoid-barrel-files.js) instead of [biome](4130ff0e4c/crates/biome_js_analyze/src/lint/performance/no_barrel_file.rs (L70)) Since the original plugin is less likely to detect a false positive.

I didn't understand your statement [here](https://github.com/oxc-project/oxc/issues/3004#issue-2245574895), Where you've mentioned:

> In oxlint, we can do better when --import-plugin is enabled, by displaying the total number of dependencies pulled into a given file by walking

I would appreciate it if you expand upon it.

------

#### Edit:

I've added it under `eslint-plugin-import` even though it is not; I wasn't sure If I should create a whole new category for this single rule, It is a different story if we would like to adopt the other rules in [here](https://github.com/thepassle/eslint-plugin-barrel-files/tree/main/lib/rules).

Also, check my diagnosis messages; It is my first contribution to the linters so I'm just not familiar enough with the conventions of messages, rules, etc.
2024-04-22 10:18:33 +08:00
Ali Rezvani
e6d11c6190
feat(syntax): module graph visitor. (#3062)
I've tried too hard to make it into a full-fledged depth first iterator, But had no success with it; It is the next best thing that I could've thought of.

Provides a way to visit the module graph from a ModuleRecord as its entry point.
2024-04-22 10:10:27 +08:00
Wang Wenzhe
1a1ba11a3b
feat(linter/tree-shaking): support ExportDefaultDeclaration (#3052) 2024-04-22 10:00:55 +08:00
Ali Rezvani
6c8296164e
perf(ast): box typescript enum variants. (#3065)
Similar to #3058 and #3061 it is a continuation of #3047.

Handles these enum types:

> TSEnumMemberName
> Variant sizes: 16, 24, 24, 40
> Unboxed variants: IdentifierName (struct), StringLiteral (struct),
NumericLiteral (struct)
> Dependents: TSEnumMember (struct)
> => Box all variants.
>
> TSModuleReference 
> Variant sizes: 16, 32
> Unboxed variants: TSExternalModuleReference (struct)
> Dependents: Box<TSModuleReference> in TSImportEqualsDeclaration
> => Box all variants. Replace Box<TSModuleReference> with
TSModuleReference in TSImportEqualsDeclaration.
>
> TSTypePredicateName 
> Variant sizes: 8, 24
> Unboxed variants: IdentifierName (struct), TSThisType (struct)
> Dependents: TSTypePredicate (struct)
> => Box Identifier variant. Do not box This variant as only 8 bytes
(just contains Span).
>
> TSTypeQueryExprName 
> Variant sizes: 16, 88
> Unboxed variants: TSImportType (struct)
> Dependents: TSTypeQuery (struct)
> => Box TSImportType variant. Do not box TSTypeName variant, as is
another enum.
2024-04-22 09:54:53 +08:00
overlookmotel
48e20880d4
perf(ast): box enum variants (#3058)
Box all enum variants for JSX types (`JSXAttributeName`,
`JSXAttributeValue`, `JSXChild`, `JSXElementName`,
`JSXMemberExpressionObject`). Part of #3047.

I'm not sure how to interpret the benchmark results. As I said on #3047:

> I imagine it may cost a little in performance in the parser due to
extra calls to `alloc`, but in return traversing the AST should be
cheaper, as the data is more compact, so less cache misses.

Sure enough, there is a small impact (1%) on the 2 parser benchmarks for
JSX files. However, the other benchmarks have too much noise in them to
see whether this is repaid in a speed up on transformer etc, especially
as the transformer benchmarks also include parsing.

What do you think @Boshen?
2024-04-22 09:09:30 +08:00
overlookmotel
383b449d4e
perf(ast): box ImportDeclarationSpecifier enum variants (#3061)
Part of #3047.

As with #3058, it's hard to interpret the benchmark results here. But in
this case I think it's easier to see from "first principles" that this
should be an improvement - `ImportSpecifier` is pretty massive (80
bytes) vs `ImportDefaultSpecifier` (40 bytes), and the latter (e.g.
`import React from 'react'`) is common in JS code.
2024-04-22 09:06:39 +08:00
overlookmotel
2804e7dbf6
perf(ast): reduce indirection in AST types (#3051)
Fixes #3048.

No apparent change on benchmarks. Likely these TS features are not much
used in the benchmark fixtures.
2024-04-22 09:05:25 +08:00
overlookmotel
6bc18e15e0
refactor(bench): reuse allocator in parser + lexer benchmarks (#3053)
Re-use allocator in parser + lexer benchmarks.

I believe this is the recommended usage when parsing a bunch of files -
to re-use one allocator rather than create a fresh one for each run, so
it makes sense to me that this is what the benchmark should measure.

Doesn't show much difference on CodSpeed because it only runs the
benchmark once, and it treats allocations as free anyway. But I imagine
the difference may show up a bit more in a standard criterion benchmark.
2024-04-22 09:03:26 +08:00
Boshen
84c43c8282
fix(semantic): correctly resolve identifiers inside catch parameter initializers (#3050)
closes #2499
2024-04-21 23:53:38 +08:00
Boshen
92d709bf21
feat(ast): add CatchParameter node (#3049) 2024-04-21 23:43:39 +08:00
Boshen
1f7033e7ab
fix(semantic): correctly resolve identifiers inside parameter initializers (#3046)
close: #2644
This fixes function parameters. I think we need an extra AST node to fix catch parameters, which will be the next PR.
2024-04-21 23:38:31 +08:00
Boshen
ee1c0e5df7
feat(cli): implement --format checkstyle (#3044)
closes #2355
2024-04-21 16:30:28 +08:00
overlookmotel
27102df476
refactor(napi): remove unnecessary custom Serialize impl for Atom (#3041)
Custom `Serialize` impl on `Atom` is not required - can just use serde
derive.
2024-04-21 13:04:51 +08:00
Boshen
4425b961cd
feat(cli): implement --format unix (#3039)
closes #1462
2024-04-21 01:24:22 +08:00
Boshen
ae1f15ac1e
feat(linter): support eslint globals (#3038)
closes #3019
2024-04-20 23:01:59 +08:00
Boshen
53c0ff5135
refactor(linter): improve the ergonomics around ESlintConfig (#3037) 2024-04-20 20:02:22 +08:00