Commit graph

1444 commits

Author SHA1 Message Date
Boshen
6d23488ce4
Release oxidation-compiler 0.2.1 2023-08-21 14:28:17 +08:00
Boshen
3c375c413e
ci: use node v18 for npm project provenance 2023-08-21 14:27:02 +08:00
Boshen
be64f5240d
Release oxidation-compiler 0.2.0 2023-08-21 12:31:39 +08:00
Boshen
0c51b6cac9
chore: add publish to npm with project provenance 2023-08-21 12:25:51 +08:00
Boshen
bfe3e9a507
Release oxlint v0.0.8 2023-08-21 12:19:29 +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
EYHN
1781318f44
fix(rulegen): handle join('\n') style test code (#763)
# 1. Support join('\n')

I'm trying to run `just new-rule no-unexpected-multiline`, It found
rulegen not support test code pieced together using `array.json("\n")`,
like

```js
{
  code: [
      "const x = aaaa<",
      "  test",
      ">/*",
      "test",
      "*/`foo`"
  ].join("\n")
}
```

I found this kind of code widely in the eslint codebase, so it will be
great if we can support this.


![](https://github.com/web-infra-dev/oxc/assets/13579374/195ed4ba-1efb-4c3f-9e49-0ebdb5527506)

# 2. remove extra `,`

And I found when meet unsupported code, rulegen will generate an extra
`,`, so I added a filter at


45cf5fc3da/tasks/rulegen/src/main.rs (L363)

# 3. handle escape string

The escape `/` and trailing `/` in the javascript code will break
rulegen. example: `"\"abc\\\n(123)\""`

I made the following changes:

```diff
- test_code.replace('\n', "\n\t\t\t")
+ test_code.replace('\n', "\n\t\t\t").replace('\\', "\\\\").replace('\"', "\\\"")
```
2023-08-19 23:19:51 +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
Boshen
6e074a39fd
chore(README): reference licenses 2023-08-17 14:10:54 +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
Devin-Yeung
c0b06a5700
feat(rulegen): automatically detect proxy (#740)
detect `HTTP_PROXY/HTTPS_PROXY/ALL_PROXY` environments automatically,
since visiting https://raw.githubusercontent.com sometimes need proxy,
upstream PR
[algesten/ureq#649](https://github.com/algesten/ureq/pull/649)
2023-08-15 13:32:09 +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
Devin-Yeung
a041fbd96b
fix(rulegen): import thiserror correctly (#735)
close #734
2023-08-14 10:20:25 +08:00