Commit graph

979 commits

Author SHA1 Message Date
Boshen
3d8ee2567f
feat(resolver): check for node.js core modules (#794) 2023-08-25 22:33:10 +08:00
Boshen
1bc1418ee6
feat(resolver): implement nested alias field (#795) 2023-08-25 22:32:57 +08:00
Boshen
4ee56576c7
feat(cli): add basic unit tests (#793) 2023-08-25 21:26:14 +08:00
Boshen
1b5ef7cdc8
refactor(cli): remove unused lint/error.rs (#792) 2023-08-25 16:46:26 +08:00
Boshen
592137586c
feat(cli): use insta_cmd for cli snapshot testing (#791)
closes #776
2023-08-25 16:26:34 +08:00
Boshen
33ea85813e
fix(linter): show the escaped span for no-useless-escape (#790)
closes #782
2023-08-25 15:21:17 +08:00
u9g
1c6b87b415
feat(query): Unify spread types, add ExpressionArrayElement, and ancestors is nullish now (#788)
```diff

- ArrayElementAST
- SpreadArrayElement
- SpreadArrayElementAST
- SpreadIntoObject
- SpreadIntoObjectAST

+ ExpressionArrayElement
+ ExpressionArrayElement implements HasSpan
+ ExpressionArrayElement implements ArrayElement
+ ExpressionArrayElement.expression

+ ExpressionArrayElementAST
+ ExpressionArrayElementAST implements ArrayElement
+ ExpressionArrayElementAST implements HasSpan
+ ExpressionArrayElementAST implements ExpressionArrayElement

+ Spread
+ Spread implements ObjectProperty
+ Spread implements ArrayElement
+ Spread implements HasSpan
+ Spread.expression

+ SpreadAST
+ SpreadAST implements ObjectProperty
+ SpreadAST implements HasSpan
+ SpreadAST implements ArrayElement
+ SpreadAST implements ASTNode
+ SpreadAST implements Spread

```
2023-08-25 13:29:06 +08:00
Boshen
ba8ef7bfc7
fix(deps): use one version of textwrap 2023-08-25 12:54:38 +08:00
u9g
e0a85eec01
feat(query): Add fields and new ArrayElement types (#787)
```diff
- Array.elements
+ Array.element

+ ElidedArrayElement
+ ElidedArrayElement implements ArrayElement
+ ElidedArrayElement implements HasSpan

+ ElidedArrayElementAST
+ ElidedArrayElementAST implements ArrayElement
+ ElidedArrayElementAST implements HasSpan
+ ElidedArrayElementAST implements ElidedArrayElement

+ SpreadArrayElement
+ SpreadArrayElement implements ArrayElement
+ SpreadArrayElement implements HasSpan
+ SpreadArrayElement.spread

+ SpreadArrayElementAST
+ SpreadArrayElementAST implements ArrayElement
+ SpreadArrayElementAST implements HasSpan
+ SpreadArrayElementAST implements SpreadArrayElement

+ VariableDeclarationAST.kind

```
2023-08-24 23:46:00 -04:00
u9g
741aa8df1f
feat(ast): Add to ChainExpression and ExpressionArrayElement to ASTKind (#785) 2023-08-25 03:03:53 +00:00
Wenzhe Wang
31d56698f7
refactor(linter): extract is_valid_jest_call (#781) 2023-08-24 23:05:03 +08:00
Boshen
2f0ff28f47
Rust 1.72.0 (#784) 2023-08-24 23:02:19 +08:00
Boshen
531e89a74a
Revert "fix(resolver): fix a case where package name and specifier is the wrong order"
This reverts commit caf1dfbfcd.
2023-08-24 22:03:30 +08:00
Boshen
a272c1ffe4
perf(lexer): reduce checks on ident -> keyword (#783) 2023-08-24 18:43:03 +08:00
Boshen
c8a215ea5e
perf(lexer): jump table (#779) 2023-08-24 15:02:06 +08:00
u9g
4f686b6a75
feat(query): add Paren*Expr* type and add index to Argument type and fix todo in ObjectExpr (#780)
```diff
+ Argument.index

+ ParenthesizedExpression
+ ParenthesizedExpression implements Expression
+ ParenthesizedExpression implements HasSpan
+ ParenthesizedExpression.expression

+ ParenthesizedExpressionAST
+ ParenthesizedExpressionAST implements Expression
+ ParenthesizedExpressionAST implements HasSpan
+ ParenthesizedExpressionAST implements ParenthesizedExpression
+ ParenthesizedExpressionAST implements ASTNode
```
2023-08-24 04:21:02 +00:00
Wenzhe Wang
fd2f8fb12b
feat(linter): detect import (#778)
Support test cases like

```js
import { test } from '@jest/globals';
test('something');
```
2023-08-24 11:34:15 +08:00
u9g
89d115704b
feat(query): Add types & Visit Array in AST for ArrayAST type (#777)
```diff
+ RegExpLiteral
+ RegExpLiteral implements HasSpan
+ RegExpLiteral implements Expression
+ RegExpLiteral.pattern

+ RegExpLiteralAST
+ RegExpLiteralAST implements ASTNode
+ RegExpLiteralAST implements RegExpLiteral
+ RegExpLiteralAST implements HasSpan
+ RegExpLiteralAST implements Expression
```
2023-08-23 09:27:49 -04:00
Maneren
b18a91312e
refactor loss-of-precision rule to remove the slow regex (#775)
This achieves around 2x speedup in the rule execution by using a manual
parser instead of a regex.
2023-08-23 11:16:05 +08:00
Makoto Tateno
9c50bc0b9c
feat(linter): implement no-unsafe-declaration-merging (#748)
Related to https://github.com/web-infra-dev/oxc/issues/503

Implement
https://typescript-eslint.io/rules/no-unsafe-declaration-merging/
2023-08-23 11:12:49 +08:00
u9g
2b1e535e6d
feat(query) add declaration field to VarRef (#774) 2023-08-22 00:18:32 -04:00
Boshen
29f8c02258
refactor(linter): clean up tester with fixes (#773) 2023-08-22 00:12:08 +08:00
Boshen
58d2d1e30d
fix(cli): fix a race condition where the program will hang 2023-08-21 16:21:19 +08:00
Boshen
6eca2adc66
fix(linter): change severity of no-obj-calls to warning 2023-08-21 11:54:36 +08:00
Boshen
dafdc95d81
chore(linter): add rule name to no-instanceof-array 2023-08-21 11:51:16 +08:00
Boshen
4032e4799c
fix(linter): improve error and help message on no-duplicate-enum-values 2023-08-21 11:51:15 +08:00
Boshen
a1c2fa65f7
fix(linter): improve help message on no-namespace 2023-08-21 11:51:15 +08:00
Boshen
cc862536f6
fix(cli): print timing after lint run 2023-08-21 11:51:15 +08:00
Boshen
03df8fcc68
refactor(cli): print the final result; fix plural on number of files 2023-08-21 11:51:15 +08:00
u9g
8e6f84c40d
feat(query): Add new types (#770)
```diff
+ Array
+ Array implements HasSpan
+ Array implements Expression
+ Array.elements

+ ArrayAST
+ ArrayAST implements Expression
+ ArrayAST implements ASTNode
+ ArrayAST implements HasSpan
+ ArrayAST implements Array

+ ArrayElement
+ ArrayElement implements HasSpan

+ ArrayElementAST
+ ArrayElementAST implements HasSpan
+ ArrayElementAST implements ASTNode

+ File.expression

+ StringLiteral
+ StringLiteral implements Expression
+ StringLiteral implements HasSpan

+ StringLiteralAST
+ StringLiteralAST implements Expression
+ StringLiteralAST implements ASTNode
+ StringLiteralAST implements HasSpan
+ StringLiteralAST implements StringLiteral

+ TemplateLiteral
+ TemplateLiteral implements HasSpan
+ TemplateLiteral implements Expression

+ TemplateLiteralAST
+ TemplateLiteralAST implements ASTNode
+ TemplateLiteralAST implements TemplateLiteral
+ TemplateLiteralAST implements Expression
+ TemplateLiteralAST implements HasSpan

```
2023-08-21 03:50:05 +00:00
Boshen
de7735dc1d
fix(cli): fix race condition when resolving paths 2023-08-20 23:13:00 +08:00
Boshen
e5d7618457
fix(linter): reduce the span of no-namespace to the keyword 2023-08-20 18:19:18 +08:00
Boshen
77bc9135f0
fix(linter): no-extra-boolean-cast false positive 2023-08-20 16:28:42 +08:00
Boshen
e44b6b3eee
chore(linter): demote no_undef to nursery 2023-08-20 15:53:36 +08:00
Boshen
a7a834a3f7
fix(linter): fix some race conditions 2023-08-20 15:53:20 +08:00
Boshen
5152b39b17
chore: clean up Cargo.toml with cargo machete (#767) 2023-08-20 15:29:09 +08:00
Boshen
a9a6bb800c
refactor(cli,linter): move path processing logic from cli to linter (#766) 2023-08-20 15:12:08 +08:00
u9g
3b3babed2e
feat(query): Add types and add field to Argument (#765)
```diff
+ Argument.is_spread

+ DoWhileStatement
+ DoWhileStatement implements HasSpan
+ DoWhileStatement implements Statement
+ DoWhileStatement.body
+ DoWhileStatement.condition

+ DoWhileStatementAST
+ DoWhileStatementAST implements HasSpan
+ DoWhileStatementAST implements Statement
+ DoWhileStatementAST implements DoWhileStatement
+ DoWhileStatementAST implements ASTNode

+ ForStatement
+ ForStatement implements HasSpan
+ ForStatement implements Statement
+ ForStatement.body
+ ForStatement.step
+ ForStatement.condition

+ ForStatementAST
+ ForStatementAST implements HasSpan
+ ForStatementAST implements Statement
+ ForStatementAST implements ASTNode
+ ForStatementAST implements ForStatement

+ New
+ New implements Expression
+ New implements HasSpan
+ New.callee
+ New.argument

+ NewAST
+ NewAST implements Expression
+ NewAST implements HasSpan
+ NewAST implements New
+ NewAST implements ASTNode

+ TernaryExpression
+ TernaryExpression implements HasSpan
+ TernaryExpression implements Expression
+ TernaryExpression.condition
+ TernaryExpression.if_true
+ TernaryExpression.if_false

+ TernaryExpressionAST
+ TernaryExpressionAST implements TernaryExpression
+ TernaryExpressionAST implements HasSpan
+ TernaryExpressionAST implements ASTNode
+ TernaryExpressionAST implements Expression

+ Throw
+ Throw implements HasSpan
+ Throw implements Expression
+ Throw.to_throw

+ ThrowAST
+ ThrowAST implements HasSpan
+ ThrowAST implements Throw
+ ThrowAST implements ASTNode
+ ThrowAST implements Expression

```
2023-08-20 14:54:25 +08:00
Boshen
324acfccc8
refactor(cli,linter): move the lint runner from cli to linter (#764) 2023-08-20 00:59:49 +08:00
Boshen
275124068b
refactor(cli,diagnostics): implement DiagnosticService (#762) 2023-08-19 18:18:09 +08:00
Yunfei He
e7c2313817
feat(ast): add SymbolId and ReferenceId (#755)
Closes #510
2023-08-19 18:09:47 +08:00
u9g
fd3fa6ca84
feat(query): Add some new types (#761)
```diff
+ BlockStatement
+ BlockStatement implements HasSpan
+ BlockStatement implements Statement
+ BlockStatement.statement

+ BlockStatementAST
+ BlockStatementAST implements BlockStatement
+ BlockStatementAST implements Statement
+ BlockStatementAST implements ASTNode
+ BlockStatementAST implements HasSpan

+ ExpressionStatement
+ ExpressionStatement implements HasSpan
+ ExpressionStatement implements Statement
+ ExpressionStatement.expression

+ ExpressionStatementAST
+ ExpressionStatementAST implements HasSpan
+ ExpressionStatementAST implements ExpressionStatement
+ ExpressionStatementAST implements ASTNode
+ ExpressionStatementAST implements Statement

+ VarRef
+ VarRef implements HasSpan
+ VarRef implements Expression
+ VarRef.name

+ VarRefAST
+ VarRefAST implements HasSpan
+ VarRefAST implements Expression
+ VarRefAST implements VarRef
+ VarRefAST implements ASTNode

+ WhileStatement
+ WhileStatement implements Statement
+ WhileStatement implements HasSpan
+ WhileStatement.condition
+ WhileStatement.body

+ WhileStatementAST
+ WhileStatementAST implements ASTNode
+ WhileStatementAST implements Statement
+ WhileStatementAST implements WhileStatement
+ WhileStatementAST implements HasSpan

```
2023-08-19 16:15:22 +08:00
Boshen
1fdce7e517
refactor(cli): split out group options (#760) 2023-08-19 12:09:35 +08:00
Boshen
6f1daa67b2
refactor(cli): clean up lint and cli options (#759) 2023-08-19 00:06:12 +08:00
Boshen
5bcd736ae9
fix(cli): correctly parse clippy like filters "-A rule -D rule" (#758) 2023-08-18 22:00:05 +08:00
Boshen
772f71f191
refactor(cli): add WalkOptions for walk logic (#757) 2023-08-18 18:09:11 +08:00
Boshen
a9c4fddb6d
refactor(cli): use bpaf instead clap (#756) 2023-08-18 17:14:06 +08:00
u9g
61bf583333
feat(query): New types added (#754)
```diff
+ LogicalExpression
+ LogicalExpression implements HasSpan
+ LogicalExpression implements Expression
+ LogicalExpression.operator
+ LogicalExpression.left
+ LogicalExpression.right

+ LogicalExpressionAST
+ LogicalExpressionAST implements LogicalExpression
+ LogicalExpressionAST implements ASTNode
+ LogicalExpressionAST implements Expression
+ LogicalExpressionAST implements HasSpan

+ Parameter implements HasSpan

+ UnaryExpression
+ UnaryExpression implements HasSpan
+ UnaryExpression implements Expression
+ UnaryExpression.operator
+ UnaryExpression.value

+ UnaryExpressionAST
+ UnaryExpressionAST implements ASTNode
+ UnaryExpressionAST implements Expression
+ UnaryExpressionAST implements HasSpan
+ UnaryExpressionAST implements UnaryExpression
```
2023-08-18 00:04:52 -04:00
Boshen
3110490f36
refactor(cli,linter): move LintOptions from cli to linter (#753)
This also simplifies the Runner trait.
2023-08-17 22:28:34 +08:00
阿良仔
5a73f0e1b5
feat(formatter): add EndOfLine (#747) 2023-08-17 19:04:23 +08:00
Kei Sakamoto
2fde2255f9
feat(linter): implement eslint-plugin-unicorn/no-instanceof-array (#752)
implement
[eslint-plugin-unicorn/no-instanceof-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-instanceof-array.md).
Related issue: #684
2023-08-17 17:08:03 +08:00
Boshen
6ab4ce0a6b
feat(resolver): implement tsconfig-paths (#750)
This PR includes 3 core functinalies of tsconfig-paths:

* matching tsconfig.compilerOptions.paths
* use tsconfig.compilerOptions.baseUrl
* extend tsconfig with tsconfig.extends

This PR does not include tsconfig.references
2023-08-17 16:24:46 +08:00
Boshen
9fa52fa61c
chore: run just fmt 2023-08-17 14:58:59 +08:00
u9g
b346a9ad6d
feat(query): New types and new fields for existing types (#746)
```diff
+ Argument.value
+ Argument implements HasSpan
+ ArgumentAST

- FnCall.arguments
+ FnCall.argument
- FnCallAST.arguments
+ FnCallAST.argument

+ interface Function
+ Function.is_async
+ Function.is_generator
+ Function.parameter
+ Function implements Expression
+ Function implements HasSpan

+ Parameter
+ Parameter.is_readonly
+ Parameter.assignment
+ Parameter.type_annotation
+ Parameter implements HasSpan
+ ParameterAST

+ ArrowFunction implements Function
+ ArrowFunction implements Expression
+ ArrowFunctionAST implements Function
+ ArrowFunctionAST implements Expression


+ FnDeclaration implements Function
+ FnDeclaration implements Expression
+ FnDeclarationAST implements Function
+ FnDeclarationAST implements Expression
```
2023-08-16 00:56:43 -04:00
Lqxc
f4d16c2166
fix(linter): perf @eslint/no-shadow-restricted-names check (#617) (#743)
In previous implements, when facing "undefined = <expr>", the lint will
search all nodes to check if undefined was declared. In this
implementation, the lint will only run once and check all nodes.
2023-08-16 12:24:52 +08:00
Wenzhe Wang
3022655965
feat(linter): add no-commented-out-tests (#723)
port
[no-commented-out-tests](e894f51a0d/docs/rules/no-commented-out-tests.md)
2023-08-16 12:23:46 +08:00
Yunfei He
ec85fd8b7d
fix(eslint/no-obj-calls): should resolve non-global binding correctly (#745)
Fixes #744
2023-08-15 18:37:40 +08:00
u9g
5dc69ea4ec
feat(query): Add many types (#742) 2023-08-15 03:30:59 -04:00
Devin-Yeung
607fa6a2a4
feat(linter): implement typescript-eslint/ban-ts-comment (#741)
related to #503, marked as nursery(though all tests pass) since we use
rust `regex` crate to parse the regex, may have compatibility problems
with ECMA regex.
2023-08-15 13:32:41 +08:00
Sg
fae9a7c28b
feat(formatter): add "Quote Props" option (#652)
For #634. 



This PR prepares for the fix of #634, adding an option to formatter to
control whether to quote object properties. After this PR, the rulegen
script can use oxc-formatter to output JSON-like object literal.

The `Quote Props` option is from Prettier. For detail:
https://prettier.io/docs/en/options.html#quote-props

> Change when properties in objects are quoted.
> Valid options:
> "as-needed" - Only add quotes around object properties where required.
> "consistent" - If at least one property in an object requires quotes,
quote all properties.
> "preserve" - Respect the input use of quotes in object properties.

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2023-08-15 11:40:38 +08:00
Boshen
b466de522b
fix(ast_lower): remove wrong usage of SymbolFlags::Function (#680)
closes #678

SymbolFlags::Function means something else (the whole function
declaration stored as a anonymous symbol) in TypeScript
2023-08-15 11:37:50 +08:00
Boshen
4fa6aafa3e
feat(resolver): handle path alias with # (#739)
`#` can be:

* an actual path fragment `path#fragment`
* esm import module specifier `#import-path`
* part of a path `path/to/#/fragment`
* part of path alias `#` -> `./path/alias`

This is driving me crazy.
2023-08-14 15:04:09 +08:00
Boshen
7c3e29d421
feat(resolver): expose raw package_json value; improve print debug (#738) 2023-08-14 11:57:17 +08:00
u9g
99a7ad4319
feat(query): add FnCall and Argument types (#737) 2023-08-14 10:25:03 +08:00
Boshen
f6e3b654b1
feat(resolver): implement configurable exports_fields option (#733) 2023-08-14 10:18:57 +08:00
u9g
087abd3cf1
feat(query): Add Reassignment type and add str property to span (#731) 2023-08-13 22:18:41 +08:00
Lqxc
6f00461c9d
feat(linter): implement @eslint/no-shadow-restricted-names (#617) (#728)
related issue: #617
2023-08-12 23:58:13 +08:00
Kei Sakamoto
4f5e4c1bac
feat(linter): implement @typescript-eslint/no-duplicate-enum-values (#726)
implement
[@typescript-eslint/no-duplicate-enum-values](https://typescript-eslint.io/rules/no-duplicate-enum-values)
Related issue: #503.
2023-08-12 23:55:26 +08:00
Boshen
37efbd7af3
feat(resolver): resolve # as path instead of a fragment (#727) 2023-08-12 23:51:37 +08:00
Wenzhe Wang
0c645170a8
feat(linter): valid-describe-callback(eslint-plugin-jest) (#706) 2023-08-12 16:47:49 +08:00
u9g
9566378119
feat(query): add many types to oxc_query (#724)
Adds `Name(AST)?`, `IfStatementAST`, `SpreadIntoObject(AST)?`,
`ObjectEntry(AST)?`, `DotProperty(AST)?` types

Fixes `ObjectLiteral`'s value field's output type

Added `entry` field to `ObjectLiteral(AST)?`
2023-08-12 16:43:58 +08:00
Boshen
9935eb1259 feat(resolver): pass on query string from alias fields 2023-08-11 19:46:57 +08:00
Boshen
17e525cc0f feat(resolver): complete browser_field implementation 2023-08-11 19:46:57 +08:00
Boshen
fdf288c685
refactor: improve code coverage in various places (#721) 2023-08-11 15:17:49 +08:00
u9g
c6ed90900c
feat(query): Add name to class (#720) 2023-08-11 14:36:40 +08:00
u9g
97c5cd379e
feat(query): Add right to VariableDeclaration (#718) 2023-08-11 05:40:35 +00:00
u9g
9c05866cc1
feat(query): add NumberLiteral type (#717) 2023-08-11 05:37:29 +00:00
u9g
c7fc1d99b5
feat(query): add name to interface (#716) 2023-08-11 05:22:12 +00:00
u9g
a953a96529
fix(query): make ObjectLiteralAST implement ObjectLiteral (#715) 2023-08-11 05:15:22 +00:00
Boshen
8c7109b24e
feat(resolver): check for infinite recursion (#714) 2023-08-11 12:53:42 +08:00
u9g
99a4816ce7
feat(website): add query playground (#698) 2023-08-11 10:53:21 +08:00
Boshen
17a6f63c31
refactor(resolver): remove the leading dot trim on extensions 2023-08-10 21:05:48 +08:00
Boshen
11954326b3 feat(resolver): implement main_fields 2023-08-10 19:48:30 +08:00
Boshen
f717cb02e3 feat(resolver): add exports_fields and main_fields for logging purposes. 2023-08-10 19:48:30 +08:00
Boshen
caf1dfbfcd fix(resolver): fix a case where package name and specifier is the wrong order 2023-08-10 19:48:30 +08:00
Boshen
66c9d764d1 fix(resolver): add a case with multi-dot filename 2023-08-10 19:48:30 +08:00
Boshen
8ae345bde0
chore(parser): add an AST Send example (#712)
relates #709

The allocator and lifetime gets in the way if we want to parse in
parallel but process them in a single thread.

This example uses `ouroboros` to provide a safe API for working with
this unsafe behavior.
2023-08-10 15:56:31 +08:00
Kei Sakamoto
3adca1ce08
feat(linter): implement @typescript-eslint/prefer-as-const (#707)
implement @typescript-eslint/prefer-as-const
Related issue: #503.
2023-08-10 15:48:24 +08:00
Boshen
2f48bdf26f
fix(parser,semantic): make semantic own Trivias (#711)
closes #708

Making the parser return Rc<Trivias> is not a good API, and ideally
`Semantic` should just own `Trivias` so it can process or mutate it.
2023-08-10 15:30:32 +08:00
Boshen
9714e46a02
feat(resolver): add tracing (#710) 2023-08-10 13:51:28 +08:00
Boshen
909d037f0d
refactor(resolver): clean up some code and tests 2023-08-09 23:21:03 +08:00
Alexandr Metreniuc
f8358a148a
feat(linter): @typescript-eslint/no-namespace (#703) 2023-08-09 23:02:24 +08:00
Boshen
17acbc4e02
fix(resolver): add derive to serde 2023-08-09 21:53:19 +08:00
Boshen
08a9ba3d5e
refactor(resolver): clean up the tests a little bit 2023-08-09 21:21:56 +08:00
Boshen
fdded5e97c
refactor(resolver): remove the identity-hash crate 2023-08-09 19:01:26 +08:00
Boshen
341c678b2f
fix(resolver): fix a case with multi-dot file extensions (#704) 2023-08-09 18:31:17 +08:00
Boshen
09761b4f8b
refactor(resolver): add a EnforceExtension tri state 2023-08-09 16:49:34 +08:00
Boshen
7c5ff9e27d
refactor(resolver): make Resolution::full_path not owned 2023-08-09 16:03:07 +08:00
Boshen
91fd375a3b
refactor(resolver): return package json error immediately instead of saving it (#702)
The error is propagated so there is no need to save it.
2023-08-09 14:28:44 +08:00
Boshen
89b49bdb07
doc(ast): document why Directive.directive is a raw string 2023-08-09 14:06:25 +08:00
Yunfei He
35167599bc
refactor(ast): use atom for Directive and Hashbang (#701)
The main reason is using Atom to remove the lifetime for convenience.

And after removing the lifetime of these nodes, the `Program<'a>`
doesn't rely on `&'a source` anymore, which allows us to [specify more
accurate
lifetimes](https://github.com/web-infra-dev/oxc/discussions/700).
2023-08-09 13:52:56 +08:00
Boshen
f5b8690309
refactor(resolver): improve code by looking at the code coverage (#697) 2023-08-08 15:44:37 +08:00
Boshen
f4ba5d48e6
feat(resolver): implement recursive alias, file as alias and exports field with query / fragment (#695) 2023-08-07 21:10:49 +08:00
Makoto Tateno
c6245f855a
feat(linter): implement no-undef (#672)
Closes https://github.com/web-infra-dev/oxc/issues/619

I have tried to implement https://eslint.org/docs/latest/rules/no-undef

Note: Unsupported items are excluded from test cases in this PR by
commenting them out..
2023-08-07 21:02:56 +08:00
Boshen
9b2d3fce6b
feat(resolver): implement resolveToContext (#694) 2023-08-07 14:30:32 +08:00
Boshen
59f5dc1906
feat(resolver): implement restrictions (path only) (#693) 2023-08-07 13:50:42 +08:00
Don Isaac
38fb4c296a
test(semantic): test harness (#679)
A test harness for checking results of semantic analysis.

I got tired of writing ad-hoc test cases when finding bugs in semantic
analysis, so I made this.
2023-08-07 10:43:05 +08:00
Boshen
3bfa314e95
refactor(resolver): clean some code (#692) 2023-08-06 21:42:54 +08:00
阿良仔
8a915cec5c
feat: vscode extension (#690)
related: #688 .
There are some unfinished things that need to be finalised by Boshen.

1. Official icon and description for the package.
2. Publishing strategy ( It's probably not a good idea to use
`package.json` as a probe to publish extension, as there's too much
vscode configuration coupled to it, a git tag like `vscode_v0.0.x` might
be worth considering ).
3. License for the extension.
2023-08-06 21:28:49 +08:00
Boshen
658ef676f6
feat(resolver): implement the basics of ESM (#691) 2023-08-05 22:04:57 +08:00
Makoto Tateno
c5ff534b08
feat(semantic): add node_id to Reference (#689)
Closes #685 

Intend to use this in the following ways in #672.
```rs
let node = ctx.nodes().get_node(reference.node_id());
if !self.type_of && has_typeof_operator(node, ctx) {
    return;
}
```
2023-08-05 12:45:22 +08:00
Alexandr Metreniuc
d1531cd144
feat(linter): add no-extra-boolean-cast rule (#677)
Closes https://github.com/web-infra-dev/oxc/issues/596

Rule: [Docs](https://eslint.org/docs/latest/rules/no-extra-boolean-cast)
|
[Source](https://github.com/eslint/eslint/blob/main/lib/rules/no-extra-boolean-cast.js)
| [Tests
](https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-extra-boolean-cast.js)
2023-08-04 18:46:50 +08:00
Boshen
d21307827d
feat(resolver): implement fully specified (#687)
This is for turning off ESM's forced extension functionality.
2023-08-04 17:50:43 +08:00
Boshen
702d5b0120
refactor(resolver): change internal funcs to non-pub by moving to unit tests (#682) 2023-08-02 16:24:16 +08:00
Boshen
2e3934db49
feat(resolver): imports field (#681) 2023-08-02 15:54:07 +08:00
Don Isaac
e7d8d4ba46
feat(linter): enable module record builder 2023-08-02 11:44:27 +08:00
Boshen
c4669e1f78
feat(resolver): finish most of exports field (#674)
Found a behaviour mismatch: when an array is provided in exports field,
enhanced-resolve will try to read the file and try the next one if it
fails. But in the spec, the path is not read, it's only tested against
"invalid package target".

```
For each item targetValue in target, do
1. Let resolved be the result of PACKAGE_TARGET_RESOLVE( packageURL, targetValue, patternMatch, isImports, conditions), continuing the loop on any Invalid Package Target error.
2. If resolved is undefined, continue the loop.
3. Return resolved.
```

I tested against node.js and verifies node.js conforms to the spec.
2023-08-01 15:53:31 +08:00
Boshen
98e4240fe1
refactor(linter): manually declare lint rules because cargo fmt breaks (#671) 2023-07-31 15:16:21 +08:00
Devin-Yeung
ba8dbf5446
fix(linter): fix false positives in loss-of-precision lint (#664)
Almost rewrite the no-loss-of-precision lint, fix known false positives,
close #656

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2023-07-31 14:48:00 +08:00
Boshen
c956f7e897
refactor(cli): remove experimental code "module_tree_handler" (#670)
This code will eventually be superseded by
https://github.com/web-infra-dev/oxc/pull/530, removing this for now so
others don't have to touch this.
2023-07-31 12:40:14 +08:00
EliLichtblau
5e54bd0537
Adding types to the symbol table - consistent export type sample rule implemented (#667)
Fixes 11 TS conformance tests and 18 babel tests.

Adds types to the symbol table functionally conformant to TS behavior
but symbol flags implemented slightly differently.

Symbol redeclaration check is also not entirely conformant but fixing
this seems like a separate PR.

For testing purposes - consistent-export-type was also implemented
(WIP).
2023-07-31 12:33:47 +08:00
Don Isaac
d3accc1ee3
fix(semantic): nested references (#661)
Addresses #660
2023-07-31 12:29:15 +08:00
u9g
8b7b1381b5
chore(query): abstract away testing boilerplate (#669) 2023-07-31 10:05:24 +08:00
Don Isaac
47541339a9
feat(ast): AstKind::debug_name() (#665)
Adds `AstKind::debug_name()`, which returns the name of an AstKind
struct with a few minor details as applicable. I intentionally did not
make `AstKind` implement `Display`, as this method returns minimal
information. Additionally, this method only exists in debug builds. I've
hidden it behind a `#[cfg(debug_assertions)]`, so it won't affect
release builds.

This code was extracted from #642, where it as created while debugging
iteration over ancestor nodes. I figured it belonged in its own PR and
may be useful to other devs.
2023-07-31 10:04:52 +08:00
u9g
08e78bce16
feat(query): add ast counterpart to JSXOpeningElement (#668) 2023-07-30 19:51:25 -04:00
u9g
228cab9269
feat(query): add ast counterpart to ObjectLiteral (#666) 2023-07-30 18:15:57 -04:00
u9g
29ddca52b7
chore(query): condense XAST and X resolvers into one (#663)
No need to needlessly duplicate code.

**Future work:**

1. remove any breakout function that calls getspan...
2. maybe: make every type that can implement span (why don't we already)
2023-07-30 11:34:34 -04:00
Wenzhe Wang
3cf08a256c
feat(linter): no-focused-test(eslint-jest-plugin) (#609) 2023-07-30 20:57:30 +08:00
Boshen
3b9cc474e9
feat(resolver): port the rest of the exports field tests (#659) 2023-07-30 01:03:10 +08:00
阿良仔
e090b560be
feat(minifier): initialize conditions folding (#658)
related: #401
2023-07-30 01:02:32 +08:00
Boshen
4b34c447f4
chore(linter): only check no-this-alias in TypeScript 2023-07-29 12:42:35 +08:00
Boshen
92348f1830
chore(linter): change no-loss-of-precision to nursery 2023-07-29 12:40:57 +08:00
Don Isaac
6628fc8d9c
perf(linter): reduce mallocs (#654)
Reduces mallocs via `clones()` (particularly of `Atom`s), and vec
allocations.

Affects the following rules:
- [x] eslint/no-dupe-keys
- [x] eslint/no-global-assign
- [x] eslint/no-loss-of-precision _(only partially optimized, needs more
work later)_
~- [ ] typescript-eslint/ajacent-overload-signatures~ (_will be
addressed in following pr_)
2023-07-29 12:02:53 +08:00
Boshen
976aa28f67
chore(linter): move no-var-requires to restriction
The code is not wrong, nor useless, it is just a restriction in typescript
2023-07-29 11:49:07 +08:00
Boshen
c42a61f34f feat(cli): separate warnings and errors numbers and print separately 2023-07-29 11:02:51 +08:00
Boshen
f23a0347fd chore(linter): move adjacent-overload-signatures to style
Per the typescript-eslint v6 change
2023-07-29 11:02:51 +08:00
Boshen
f5c9908550 fix(linter): improve the span for no-inner-declarations 2023-07-29 11:02:51 +08:00
Boshen
e4020d6fb2 fix(linter): change no-control-regex to severity warning 2023-07-29 11:02:51 +08:00
Boshen
fe54b1fbc9 chore(linter): move no-return-await to pedantic
Since this is not a eslint recommended rule
2023-07-29 11:02:51 +08:00
Boshen
1bc564eafc feat(linter): add style category and change no-empty-interface to style
It's officially change in typescript-eslint
2023-07-29 11:02:51 +08:00
Boshen
ad51157ea9 fix(linter): make disable directives work with plugin rule names 2023-07-29 11:02:51 +08:00
Boshen
edb3f8b634 fix(cli): improve the TIMING=1 table alignment 2023-07-29 11:02:51 +08:00
Devin-Yeung
72afdf6d19
feat(linter): eslint/no-loss-of-precision (#649)
Close #613
2023-07-28 20:59:20 +08:00
Boshen
217997bd7c
chore(rust): run cargo fmt --all -- crates/**/*.rs 2023-07-28 13:57:12 +08:00
SoonIter
786cf8252f
feat(linter): implement no-global-assign (#624)
closes #598
2023-07-28 10:20:38 +08:00
Boshen
6631336f5c
feat(resolver): implement more of exports field (#648) 2023-07-28 10:19:29 +08:00
Boshen
252d3342a1
feat(linter): add a run_once callback (#647)
For situations where you want to inspect the scopes and trivias.
2023-07-27 18:15:15 +08:00
Boshen
14164b22ed
chore(oxc): remove mention of nightly 2023-07-27 14:14:56 +08:00
Boshen
1012d8300c
chore: release crates as v0.1.0 2023-07-27 13:54:17 +08:00
Boshen
d587065436
chore(rust): update crate info, add minimal rust-version, add categories 2023-07-27 13:33:18 +08:00
Boshen
45c1650631
chore(oxc_query): do not publish yet, it is not ready 2023-07-27 13:17:33 +08:00
Boshen
fa82f940f0 chore: stable Rust
closes #626
2023-07-27 13:11:46 +08:00
Boshen
b34ef4f07a chore: reformat 2023-07-27 13:11:46 +08:00
Boshen
608ee9116b
refactor(parser): remove portable simd because it is not stable Rust (#645)
related #626
2023-07-27 12:43:11 +08:00
Boshen
f2df32d1c0
fix(taplo): adjust the include glob so it doesn't time out searching for files 2023-07-27 12:30:34 +08:00
u9g
34f25b7067
feat(query): adapter invariant test (#644)
Checks for invariants in the adapter that would certainly error out real
usage, doesn't actually use the data provided to the adapter
2023-07-26 23:59:02 -04:00
u9g
5b0449507e
chore(query): move tests to their own file (#643) 2023-07-27 03:41:55 +00:00
Sg
453edd27eb
feat(linter): eslint/no-empty-character-class (#635)
closes #559
2023-07-27 11:32:43 +08:00
u9g
451667acfc
feat(query): impl ASTNode for VariableDeclarationAST (#639)
also changes from using entire_span to just span so we don't have to
have two properties point at the same span
2023-07-27 11:30:15 +08:00
阿良仔
d8bfe148ba
refactor(linter): remove Box::leak (#641) 2023-07-27 11:29:59 +08:00
u9g
997eb26d3e
feat(query): impl Typename for VariableDeclaration (#638) 2023-07-27 09:46:49 +08:00
Matthew "strager" Glazar
318d55806f refactor: format code
Removing uses of let_chains now allows rustfmt to format some files.
Run 'cargo fmt' to reformat these files.
2023-07-27 09:44:57 +08:00
Matthew "strager" Glazar
ad00720d75 refactor: avoid unstable let_chains
The let_chains Rust feature is unstable, preventing Oxc from using a
stable Rust compiler. Refactor the code to avoid let_chains.
2023-07-27 09:44:57 +08:00
Sg
2203d08199
refactor: remove unstable feature slice_as_chunks (#632) 2023-07-26 19:21:35 +08:00
Sg
fbb8aa3338
refactor: remove unstable feature const_trait_impl & const_slice_index & slice_group_by (#629) 2023-07-26 17:37:09 +08:00
Boshen
32b8ad2b57
feat(resolver): initialize implementation of package.json exports field (#630) 2023-07-26 16:54:54 +08:00
u9g
1d504ac94a
Add oxc_query crate (#625) 2023-07-26 13:03:00 +08:00
Boshen
b78b1ebdca
perf(resolver): reduce memory allocation when resolving node_modules (#608) 2023-07-25 20:06:44 +08:00
Boshen
f094d5881e
perf(resolver): hash once for the get + insert case (#606) 2023-07-25 16:47:17 +08:00
Boshen
1d7f171309
refactor(resolver): use DashSet for the cache (#605) 2023-07-25 15:17:07 +08:00
Shannon Rothe
21f8abe273
feat(cli): add support for TIMING env var (#535) 2023-07-25 11:14:36 +08:00
Boshen
5b23ab30b0
perf(resolver): allocate less when resolving extensions (#603) 2023-07-24 21:04:44 +08:00
Boshen
eafad4dfd1
perf(resolver): reduce the total number of hashes by passing the cached value around (#602) 2023-07-24 20:42:09 +08:00
Boshen
3cda165af7
perf(resolver): do not read package_json of a file (#601) 2023-07-24 15:49:41 +08:00
Boshen
b21b3b8528
chore(resolver): add a alias test and check resolution is the same in benchmark (#600) 2023-07-24 15:35:10 +08:00
Don Isaac
87e65ac0f7
refactor(semantic): symbol declarations and references (#594) 2023-07-24 10:55:56 +08:00
Boshen
b3d70c5c7f
refactor(resolver): make the global cache hold less memory (#593) 2023-07-24 00:15:42 +08:00
Boshen
8ab2a7f322
refactor(resolver): improve browser_field lookup (#592)
This makes everything slow because every file read now needs to
check package.json for the browser field, but we'll improve the
package.json look up soon by reusing the values from the cache.
2023-07-23 23:41:27 +08:00
Boshen
65f22f9ba1
refactor(resolver): s/request_str/request 2023-07-23 20:06:17 +08:00
Boshen
cfdeb3416d
chore(resolver): improve documentation (#591) 2023-07-23 18:48:51 +08:00
Boshen
c0d06c5598
feat(resolver): check for directory before loading a directory (#590) 2023-07-23 18:10:06 +08:00
Boshen
53242c0e51
refactor(resolver): improve how browser field is resolved (#589) 2023-07-23 17:57:03 +08:00
Boshen
7b7e3a2032
chore(resolver): add multi-threaded benchmark (#588) 2023-07-23 12:40:52 +08:00
Boshen
ca96ff84a6
chore(resolver): add more data to benchmark (#586) 2023-07-23 10:55:33 +08:00
Boshen
378505f244
perf(resolver): improve cache hit for package.json (#585)
perf(resolver): implement proper file system caching
2023-07-23 01:06:40 +08:00
Boshen
2bb8edb13c
perf(resolver): cache canonicalized path (#584) 2023-07-22 21:13:59 +08:00
Boshen
585e48fe9b
feat(resolver): implement symlinks (#582) 2023-07-21 19:10:59 +08:00
Boshen
3c5333c828
perf(resolver): use fs::symlink_metadata, which doesn't traverse symlinks (#581) 2023-07-21 17:54:55 +08:00
Boshen
2330099a34
deps(rust): bump dependencies 2023-07-21 11:38:12 +08:00
Boshen
06aac508f8
fix(linter): change no-var-requires to severity warning 2023-07-21 11:08:33 +08:00
阿良仔
3c76cef11c
feat(minifier): fold NaN comparison (#580) 2023-07-21 11:00:21 +08:00
Makoto Tateno
52c3c37b2b
feat(linter): implement no-var-requires (#575) 2023-07-21 10:58:25 +08:00
阿良仔
836d430a10
feat(linter): implement adjacent-overload-signature (#578) 2023-07-21 10:56:41 +08:00
Boshen
fa20844802
feat(resolver): complete query and fragment parsing (#579) 2023-07-20 17:48:51 +08:00
Boshen
30b9731843
feat(resolver): add preferRelative and preferAbsolute (#577) 2023-07-20 15:41:06 +08:00
Boshen
beb0ae9d8e
feat(resolver): implement roots (#576) 2023-07-20 14:23:25 +08:00
Boshen
6089898bf0
fix(linter): change severity of no-this-alias from error to warning 2023-07-20 11:23:47 +08:00
Boshen
3875ebc6cb
refactor(resolver): check against Result for better assertion message (#573) 2023-07-20 11:10:56 +08:00
Boshen
3f07306be0
feat(resolver): implement fallback (#572) 2023-07-19 14:42:43 +08:00
Boshen
05b77a5a15
Release @oxidation-compiler/napi v0.1.0 2023-07-19 13:15:04 +08:00