Commit graph

2425 commits

Author SHA1 Message Date
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
overlookmotel
d44301c871
fix(parser): fix comment typos (#3036)
Fix 2 typos in comments.
2024-04-20 13:13:25 +03:30
Boshen
598bbbaddc
fix(linter): fix crashing with unwrap in import/no-cycle (#3035)
closes #3034
2024-04-20 16:59:13 +08:00
Ali Rezvani
57ad6c4aa7
feat(semantic): add root node to the AstNodes structure. (#3032)
Adds a way to fetch the root node without iterating over all ancestors
which has a nondeterministic time - best case O(1) worst case O(n!) - It
is only possible to set this field in the semantic builder.
2024-04-20 13:36:20 +08:00
overlookmotel
1249c6c326
refactor(ast): implement same traits on all fieldless enums (#3031)
Implement same traits on all AST fieldless enums, for consistency. Just
a little bit of tidying.
2024-04-20 01:53:48 +08:00
Ali Rezvani
0d770f57ff
refactor: remove redundant imports to fix some of clippy warnings. (#3028)
These are raising warnings in nightly, And are in fact redundant.
2024-04-19 21:02:23 +08:00
overlookmotel
0b9470eeb8
refactor(ast): shorten code (#3027)
Shorten code for getting span. Refactor only, no substantive change.
2024-04-19 18:30:58 +08:00
overlookmotel
04005ff62d
refactor(prettier): simplify import (#3026)
Just a tiny simplification. No substantive change.
2024-04-19 18:11:08 +08:00
Boshen
a05c4e39b8
Release crates v0.12.4 2024-04-19 16:40:05 +08:00
Boshen
fd670d542a
chore(linter): add error message to unicorn/no-single-promise-in-promise-methods 2024-04-19 15:53:49 +08:00
Boshen
2bac1d5384
feat(linter): support oxlint-disable alongside eslint-disable (#3024)
closes #2999
2024-04-19 15:39:13 +08:00
Boshen
fa08abe20a
feat(linter): remove import/no-unresolved (#3023)
closes #3015

This plugin will always contain false positives due to module resolution
complexity.
2024-04-19 12:45:50 +08:00
谭光志
9b4e87a102
feat(linter): eslint/max-len (#2874)
Co-authored-by: Wang Wenzhe <mysteryven@gmail.com>
2024-04-19 12:35:37 +08:00
Boshen
3f9f4670e2
chore(transformer): enable clippy::print_stdout 2024-04-19 10:34:50 +08:00
Yuji Sugiura
2c325ef3d6
fix(semantic/jsdoc): Skip parsing @ inside of backticks (#3017)
This PR aims to support these cases.

````js
/**
 * This is normal comment, `@xxx` should not parsed as tag.
 *
 * @example ```ts
    // @comment
    @decoratorInComment
    class Foo { }
   ```
 */
````

Only `@example` should be parsed as tag.
2024-04-18 19:18:46 +08:00
Yuji Sugiura
395ad76410
feat(linter/jsdoc): Update settings.jsdoc method (#3016)
Add `list_preferred_tag_names()` to enumerate user defined tag names in
`tagNamePreferences`.
2024-04-18 18:57:00 +08:00
Dunqing
3831147b6d
feat(transformer/typescript): report error for export = <value> (#3021) 2024-04-18 18:56:29 +08:00