Commit graph

2421 commits

Author SHA1 Message Date
Boshen
3b40fbdbac
fix(linter): false positive for filename_case where filename doesn't have a proper casing (#2032) 2024-01-15 14:36:48 +08:00
Boshen
68606c4d6d
fix(linter): keep rules disabled if the rule is not enabled in the config (#2031)
relates #1969
2024-01-15 05:32:51 +00:00
Bradley Farias
3490111c56
Commutative undefined minify (#2003)
this should probably be squashed, i'm not familiar with code commit
norms here. we can expand a bunch of the commutative compressions later.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-01-15 02:51:53 +00:00
Yuto Yoshino
530d1bea56
feat(linter): eslint-plugin-jsx-a11y no-redundant-roles rule (#1981)
Part of: https://github.com/oxc-project/oxc/issues/1141

Based on:
- doc: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/no-redundant-roles.md
- code: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/no-redundant-roles.js
- test: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/no-redundant-roles-test.js
2024-01-14 21:03:58 +00:00
overlookmotel
b4d76f0b0d
refactor(parser): remove noop code (#2028)
This PR removes some code from the lexer which doesn't do anything.
2024-01-14 23:48:35 +08:00
keita hino
198f0e5d73
feat(linter): eslint-plugin-jsx-a11y aria-activedescendant-has-tabindex (#2012)
Part of: #1141

Based on:
- docs: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/aria-activedescendant-has-tabindex.md
- code: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/aria-activedescendant-has-tabindex.js
- test: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/aria-activedescendant-has-tabindex-test.js
2024-01-14 11:34:07 +00:00
overlookmotel
60a927d8f5
perf(parser): lexer match byte not char (#2025)
2 related changes to lexer's `read_next_token()`:

1. Hint to branch predictor that unicode identifiers and non-standard
whitespace are rare by marking that branch `#[cold]`.

2. The branch is on whether next character is ASCII or not. This check
only requires reading 1 byte, as ASCII characters are always single byte
in UTF8. So only do the work of getting a `char` in the cold path, once
it's established that character is not ASCII and this work is required.
2024-01-14 18:50:11 +08:00
kaykdm
a356918d83
feat(linter): eslint-plugin-next: no-document-import-in-page (#1997)
Part of: https://github.com/oxc-project/oxc/issues/1929

Based on:
- https://github.com/vercel/next.js/blob/canary/packages/eslint-plugin-next/src/rules/no-document-import-in-page.ts
-  https://nextjs.org/docs/messages/no-document-import-in-page

---------

Co-authored-by: Cameron <cameron.clark@hey.com>
2024-01-13 17:52:47 +00:00
kaykdm
c70a065191
feat(linter): eslint-plugin-next: no-head-element (#2006)
Part of: https://github.com/oxc-project/oxc/issues/1929

Based on:

- code: https://github.com/vercel/next.js/blob/canary/packages/eslint-plugin-next/src/rules/no-head-element.ts
- test: https://github.com/vercel/next.js/blob/canary/test/unit/eslint-plugin-next/no-head-element.test.ts
- doc: https://nextjs.org/docs/messages/no-head-element

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-01-13 17:47:32 +00:00
kaykdm
8f0f824a6a
feat(linter): eslint-plugin-next: no-typos (#1978)
Part of: https://github.com/oxc-project/oxc/issues/1929

Based on:
https://github.com/vercel/next.js/blob/canary/packages/eslint-plugin-next/src/rules/no-typos.ts
2024-01-13 17:42:11 +00:00
Dunqing
ac4b3a4f8d
feat(ast): visit TSTypeQuery (#2021)
```ts
type Bar = typeof Foo;
```
2024-01-14 00:38:18 +08:00
magic-akari
9b77d0e6e6
fix(prettier): Correctly print export declaration (#2014)
Before this PR:
<img width="912" alt="image"
src="https://github.com/oxc-project/oxc/assets/7829098/78605f25-3320-4bed-8a31-3ffa7604cdc7">

https://oxc-project.github.io/oxc/playground/?code=3YCAAICUgICAgICAgICyHorESipoTXBToMuz4zZHvH%2B4MPS3Y6F%2FfvvogA%3D%3D
2024-01-13 21:26:33 +08:00
Dunqing
6c7f983de5
feat(transformer/typescript): remove export specifier that import_kind is type (#2015) 2024-01-13 21:25:59 +08:00
magic-akari
869643b03b
fix(prettier): Correctly format call expression arguments (#2018) 2024-01-13 21:25:26 +08:00
Yuji Sugiura
04540f749d
feat(linter): eslint-plugin-jsx-a11y click-events-have-key-events (#1976)
( #1974  was lost due to mishandling. 🙈 )

Part of #1141 

### Refs
-
4c7e7815c1/docs/rules/click-events-have-key-events.md
-
4c7e7815c1/src/rules/click-events-have-key-events.js
-
4c7e7815c1/__tests__/src/rules/click-events-have-key-events-test.js

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-01-13 09:27:26 +00:00
Dunqing
ead4e8df1f
feat(transformer/typescript): remove import if only have type reference (#2001) 2024-01-13 08:52:14 +00:00
Boshen
b386177af2
refactor(linter): move away from tuples for test cases (#2011)
closes #1956
2024-01-13 16:23:16 +08:00
Boshen
1886a5b838
perf(parser): reduce Token size from 16 to 12 bytes (#2010)
I also had to change how the string for private identifiers are built,
otherwise they will always be allocated.
2024-01-13 12:42:39 +08:00
overlookmotel
6996948825
refactor(parser): remove extraneous code from regex parsing (#2008)
This PR removes some code in parsing regexp flags which is extraneous:

```rs
if !ch.is_ascii_lowercase() {
  self.error(diagnostics::RegExpFlag(ch, self.current_offset()));
  continue;
}
```

Which is followed by:

```rs
let flag = if let Ok(flag) = RegExpFlags::try_from(ch) {
  flag
} else {
  self.error(diagnostics::RegExpFlag(ch, self.current_offset()));
  continue;
};
```

`!ch.is_ascii_lowercase()` is equivalent to `ch < 'a' || ch > 'z'`. The
compiler implements `RegExpFlags::try_from(ch)` as `ch < 'd' || ch >
'y'` and then a jump table. So `ch.is_ascii_lowercase()` does nothing
that `RegExpFlags::try_from(ch)` doesn't do already.

https://godbolt.org/z/51GPPY9nx

(this PR built on top of #2007 for ease)
2024-01-13 02:34:05 +00:00
Cameron
107a32ea48
fix(linter): fix false positive for erasing-op in 0/0 case (#2009) 2024-01-13 10:32:26 +08:00
overlookmotel
712e99cf9b
fix(parser): restore regex flag parsing (#2007)
As discussed in
https://github.com/oxc-project/oxc/pull/1999#issuecomment-1888916383,
this PR restores some of regex parsing behavior to as it was prior to
#1926.
2024-01-13 03:19:33 +08:00
Boshen
1ecdeaa662
fix(MAINTENANCE): fix publish ordering 2024-01-12 23:39:35 +08:00
Boshen
61f37ea973
Publish crates v0.5.0 2024-01-12 23:33:47 +08:00
Boshen
feceac9388
chore(minifier,semantic): don't publish tests directory 2024-01-12 22:37:11 +08:00
Boshen
e621e9b843
Release oxlint and vscode extension v0.2.0 2024-01-12 22:29:25 +08:00
Boshen
c342875b55
chore(linter): change react/no-unknown-property to restriction
There's a lot of false positives in non-standard jsx usages.

For example the usage of `css` or `class` attribute.
2024-01-12 20:44:04 +08:00
Boshen
aa91fde1d9
refactor(parser): only allocate for escaped template strings (#2005) 2024-01-12 18:56:36 +08:00
Boshen
38f86b0cac
refactor(parser): remove string builder from number parsing (#2002)
The builder was used to build an allocated string for numbers with
underscores, this is no longer required because it is now allocated on
demand.


0d77e1e788/crates/oxc_parser/src/lexer/number.rs (L32)
2024-01-12 17:01:51 +08:00
Boshen
39f026f3e2
chore(benchmark): remove custom allocators because they are flaky (#2004) 2024-01-12 16:05:47 +08:00
underfin
0d77e1e788
fix: default visitor should visit prop init at visit_object_property (#2000)
The `visit_object_property` should visit `prop.int` node.
2024-01-12 13:43:12 +08:00
Dunqing
6a7e4be06c
feat(transformer): call enter_node/leave_node in visit_xxx (#1990) 2024-01-12 11:37:17 +08:00
overlookmotel
c7316856db
refactor(parser): reduce work parsing regexps (#1999)
#1926 produced a small performance regression because when parsing a
regexp, some work is repeated.
2024-01-12 11:36:30 +08:00
Boshen
74dfa3be8b
fix(webpack): update pnpm lock file 2024-01-12 11:30:51 +08:00
Dunqing
0a086860da
feat(ast): visit TSModuleReference (#1998)
### Failed cases:

* 7c29fbc4db/packages/babel-plugin-transform-typescript/test/fixtures/imports/elision-qualifiedname/input.ts
* 7c29fbc4db/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react/input.ts

We need to distinguish whether a reference is a type or a js variable
2024-01-11 23:29:29 +08:00
Dunqing
afb2c501f5
feat(transformer): support for transform TSImportEqualsDeclaration (#1994) 2024-01-11 23:24:28 +08:00
luhc228
b1de10fbfd
docs: fix oxc-parser README demo error (#1993)
The type of `ret.program` is `string`, it need to parse it first to get
the `body`.
2024-01-11 23:19:09 +08:00
cin
d51c9f19f9
feat(linter): eslint-plugin-jest: no-test-return-statement (#1979)
Rule Detail:
[link](https://github.com/eryue0220/eslint-plugin-jest/blob/main/src/rules/no-test-return-statement.ts)
2024-01-11 23:01:52 +08:00
Boshen
ea22d3ceb8
fix(diagnostics): always print without considering the --max-warnings option (#1996)
closes #1958

`--max-warnings` is only used to control the exit code, it does not
affect diagnostic printing.
2024-01-11 20:41:06 +08:00
RiESAEX
ef67e08c6a
fix(playground): correct diagnostic position (#1995)
before

![image](https://github.com/oxc-project/oxc/assets/89718456/bca4d61e-b45f-4523-ab02-ccabfb761abc)
after

![image](https://github.com/oxc-project/oxc/assets/89718456/6fc7e41f-a985-417e-975f-66bc9af29498)
2024-01-11 20:23:16 +08:00
Boshen
fb5d0a740c
feat(linter): add support for same rule name but different plugin names (#1992)
e.g.

```
{
  "rules": {
    "semi": "off",
    "@typescript-eslint/semi": "error"
  }
}
```

closes #1975
2024-01-11 18:05:05 +08:00
Boshen
b7ea4e53fb
feat(linter): support vue generic component (#1989)
closes #1938
2024-01-11 15:48:56 +08:00
Dunqing
4e7b7dad78
feat(task): handle expected runtime error correctly (#1987) 2024-01-11 15:04:28 +08:00
Dunqing
6417d2ce9c
feat(task): test codegen runtime in run_async (#1980)
<img width="460" alt="image" src="https://github.com/oxc-project/oxc/assets/29533304/4f2d05a1-4d3e-422e-9722-0c77d4ff989d">
2024-01-11 14:59:29 +08:00
Dunqing
ee286a0a48
feat(task): support run async in suite (#1973) 2024-01-11 14:54:30 +08:00
Dunqing
633b21c5d2
feat(task): skips some cases we don't care about in codegen-runtime (#1986)
#1977
2024-01-11 14:50:39 +08:00
Boshen
0f6674563e
chore: remove DSL based linter plugin (#1985)
Due to maintenance issues, we are going to stop exploring a linter based
DSL plugins.
2024-01-11 04:54:39 +00:00
fi3ework
e0da12a868
fix(linter): allow eslintrc to add rule when overriding (#1984)
Fix a bug introduced in https://github.com/oxc-project/oxc/pull/1966.
Ideally, the rules in eslintrc should be merged into final rules as
described:

> The rules will start with the categories we apply, and then merge all
the configurations stated in the rules field.
>
> For example, if we begin with -D correctness with 80 rules, then
>
> "no-empty-file": "off" will remove the rule, yielding 79 rules
> "no-empty": "error" (restriction) will add the rule, yield 81 rules
> ""no-empty": ["error", { "allowEmptyCatch": true }]` add the rule's
configuration

However, the implementation did not include the newly added rules in the
eslintrc. As a test case and example, I added a new fixture to
`crates/oxc_cli/fixtures/no_undef`. No warn or deny will be found
without this PR.

This is my first Rust PR ever. Any nitpicking suggestions are welcome.
Thanks! 😊
2024-01-11 11:43:02 +08:00
kaykdm
c5887bcb2b
feat(linter): implement @typescript-eslint/triple-slash-reference (#1903)
implement @typescript-eslint/triple-slash-reference
Related issue: https://github.com/oxc-project/oxc/issues/503

original
- doc:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/triple-slash-reference.md
- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/triple-slash-reference.ts
2024-01-11 11:12:46 +08:00
Maurice Nicholson
d4acd140ad
fix(linter): jsx-key: handle anonymous functional components in arrays that have a function body (#1983)
Closes #1982
2024-01-10 22:46:17 +00:00
underfin
78b427bc50
feat(transform): support es2015 new target (#1967)
Here implementing the es2015 new target transform, see detail at
https://babel.dev/docs/babel-plugin-transform-template-new-target.

Here has three kinds need to be distinguished.

- `NewTargetKind::Method`, it from `AstKind::ObjectMethod` or
`AstKind::MethodDefinitionKind::Get/Set/Method`. It will be transformed
to `void 0`.
- `NewTargetKind::Constructor`, is from `
AstKind::MethodDefinitionKind::Constructor`. It will be transformed to
`this.constructor`.
- `NewTargetKind::Function`, is from ` AstKind::Function`, here the
function is not the above function. It will be transformed to `this
instanceof _target ? this.constructor : void 0`, here `_target` comes
from the function name or is created by scope uid ident.
2024-01-10 23:59:56 +08:00