Commit graph

2633 commits

Author SHA1 Message Date
Boshen
1822cfe18d
refactor(ast): fix BigInt memory leak by removing it (#2293)
relates

We'll need to evaluate the value by other means.
2024-02-04 16:47:00 +08:00
Boshen
a574f2852e
chore: ignore git submodules 2024-02-04 16:15:01 +08:00
Boshen
b5e43fbc5d
fix(linter): fix no_dupe_keys false postive on similar key names (#2291)
closes #2287
2024-02-04 14:54:09 +08:00
underfin
2f97b332bd
chore: codegen test skip v8 failed test (#2283)
Because v8 isn't pass some test262 tests, we also need to skip them, you
can find it at
https://chromium.googlesource.com/v8/v8/+/refs/heads/main/test/test262/test262.status.
2024-02-04 14:02:39 +08:00
Tzvi Melamed
0060d6a730
feat(linter): Implement no_this_before_super with cfg (#2254)
Implements `eslint/no-this-before-super` in #479.

Closes #2279
2024-02-04 13:51:04 +08:00
Boshen
d2b304b1f8
Publish crates v0.6.0 2024-02-03 22:35:30 +08:00
Boshen
52e32449b3
Release oxlint and vscode extension v0.2.7 2024-02-03 21:21:23 +08:00
Wenzhe Wang
0c225a49aa
fix(codegen): print space before with clause in import (#2278) 2024-02-02 14:52:32 +00:00
Boshen
3569e42475
ci: install just in conformance 2024-02-02 22:49:15 +08:00
Boshen
b2040ed2ec
ci: use node.js 20 2024-02-02 22:28:23 +08:00
Boshen
54dfd91729
ci: temporary fix git clones 2024-02-02 22:27:15 +08:00
Dunqing
37a2676e1e
fix(linter): AllowFunction doesn't support generator (#2277) 2024-02-02 21:53:44 +08:00
Dunqing
3cb85778bc
ci: incorrect uses value (#2276) 2024-02-02 21:53:10 +08:00
Boshen
d2f7ea2923
chore: manually clone git modules instead of using submodules (#2274)
closes #2231

Submodules are a blocker for beginners, we should make it clone on
demand.

It is also a blocker for people who wants to target this repo as a crate
for testing purposes, cargo will do a full clone if you specify
oxc_parser = { git = "this repo" } in Cargo.toml
2024-02-02 11:56:18 +00:00
Boshen
28daf83b19
feat(semantic): report no class name error (#2273)
closes #2144
2024-02-02 19:05:00 +08:00
kaykdm
2ceba79dcd
feat(tasks): add eslint-plugin-n rulegen (#2272)
related: https://github.com/oxc-project/oxc/issues/493

Support generate rules from
[eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n).
2024-02-02 18:50:58 +08:00
Boshen
d7feadedb4
chore(lint_rules): deprecated eslint no-dupe-args / no-octal / no-with
These are strict mode errors.

Closes #2257
2024-02-02 17:33:54 +08:00
Boshen
6849c047ef
chore(parser): add visitor example (#2271)
closes #2256
2024-02-02 17:08:00 +08:00
Boshen
63dbac764f
chore(wasm): remove console_error_panic_hook
We don't really need it.
2024-02-02 17:02:01 +08:00
Dunqing
8e221cb26e
fix(transformer): update snapshot (#2268) 2024-02-02 17:00:44 +08:00
Dunqing
8ac0202c9a
feat(codegen): keep shorthand in ObjectPattern and ObjectProperty (#2265)
close: #2262

Do I need to add a test for this?
2024-02-02 08:32:51 +00:00
Boshen
d6ba058f77
ci: paths-filter v3 (#2267) 2024-02-02 16:21:34 +08:00
Boshen
650f6c942f
refactor: use our forked version of miette::Reporter for tests (#2266) 2024-02-02 16:15:31 +08:00
Dunqing
da2ffdf7a0
feat(semantic): check parameters property (#2264) 2024-02-02 15:58:32 +08:00
Dunqing
d71175e712
feat(semantic): check optional parameters (#2263) 2024-02-02 15:54:04 +08:00
Boshen
8d99a15ac9
feat(semantic): report error on optional variable declaration in TypeScript (#2261)
closes #2253
closes #2255
2024-02-02 14:13:10 +08:00
Dunqing
2578bb3d64
feat(ast): remove generator property from ArrowFunction (#2260)
ArrowFunction doesn't support generator.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
2024-02-02 04:01:19 +00:00
Boshen
0ae28dd159
feat(npm/oxlint): display target triple when error is thrown (#2259)
To improve debuggability

closes #2196
2024-02-02 11:22:34 +08:00
Boshen
a3df55e7ed
ci: unify the usage of concurrency.group
github.ref refers to the branch
2024-02-02 11:20:44 +08:00
hjio
a95a16c2ae
feat(linter): complete custom components setting (#2234)
- add custom components setting
- let tasks/rulegen generate settings

---------

Co-authored-by: huangjunjie.coder <huangjunjie.coder@bytedance.com>
2024-02-01 23:28:11 +08:00
Dunqing
de6d2f5dc5
refactor(transformer/decorators): optimizing code with ast.private_field (#2249) 2024-02-01 22:30:48 +08:00
Tzvi Melamed
f4674f33b2
fix(oxc_semantic): Handle short-circuiting operators in CFG (#2252)
Closes #2239
2024-02-01 21:04:28 +08:00
Tzvi Melamed
27681951e1
feat(oxc_semantic): Improve sample visualization (#2251)
1. add a `test.js` file to the project root:

```js
class A extends B {
  constructor() {
    try {
      super();
    } finally {
      this.a;
    }
  }
}
```

2. run:

```bash
$ cargo run -p oxc_semantic --example simple
   Compiling oxc_semantic v0.5.0 (/home/tzvipm/src/github.com/tzvipm/oxc/crates/oxc_semantic)
    Finished dev [unoptimized + debuginfo] target(s) in 32.07s
     Running `target/debug/examples/simple`
Wrote AST to: test.ast.txt
Wrote CFG blocks to: test.cfg.txt
Wrote CFG dot diagram to: test.dot
```

3. resulting graph from .dot file:


![image](https://github.com/TzviPM/oxc/assets/1950680/7163deaa-ab75-4bed-a093-946e2d6d2206)
2024-02-01 12:55:56 +00:00
Tzvi Melamed
73ccf8a4da
fix(oxc_semantic): proper traversal of try statements (#2250)
Closes #2227
2024-02-01 20:46:38 +08:00
Dunqing
165f948227
feat(ast): remove expression property from Function (#2247) 2024-02-01 15:23:27 +08:00
Dunqing
02c18d8506
feat(transformer/decorators): support for static and private member decorators (#2246) 2024-02-01 15:19:14 +08:00
Boshen
2beacd3f4d
fix(lexer): correct the span for irregular whitespaces (#2245)
closes #2236
2024-02-01 14:18:47 +08:00
Boshen
589fd0cdd1
chore: omit warning for unused TS_APPEND_CONTENT 2024-02-01 14:07:40 +08:00
Boshen
c0bdd050ee
ci: s/macos-latest/macos-14 (#2244) 2024-02-01 13:30:49 +08:00
Tzvi Melamed
e561457683
feat(semantic): track cfg index per ast node (#2210)
This allows looking up a cfg index from an ast node in a semantics
return. This allows later passes to better make use of the cfg.
2024-02-01 13:27:20 +08:00
Maurice Nicholson
6b2150f3b3
Better report source line and col for multiline annotations (#2242)
Improves diagnostic report source line- and column-number for
**multiline annotations**

Requires #2241
2024-02-01 11:37:28 +08:00
Dunqing
ba85b097e0
feat(transformer/decorators): support method decorator and is not static (#2238) 2024-02-01 11:36:22 +08:00
overlookmotel
d0d708295b
refactor(parser): consume chars when parsing surrogate pair escape (#2243)
This fixes a mistake I made in #2237.

I was confused by the `!(...)` wrapping of the preceding `if` test and
missed that there are definitely 2 chars to consume, so can use
`consume_char()` instead of `next_char()`. This makes no difference to
behavior, but it follows the convention to always prefer
`consume_char()` when possible.

I've also refactored the code which confused me, so hopefully others
won't be confused too!
2024-02-01 11:34:26 +08:00
Maurice Nicholson
9bbdec146f
Use oxc's own graphical reporter for test snapshots (#2241)
Fixes #2217

Previously we were using the miette default, but given ours is a fork,
and for example now prints slightly more relevant line- and
column-numbers vs miette, we should dog-food our own have the tests tell
us if/when the output changes.

I did actually scan all the snapshot deltas and all look correct to me.

One funny one I noticed was this

```diff
diff --git a/crates/oxc_linter/src/snapshots/no_empty_file.snap b/crates/oxc_linter/src/snapshots/no_empty_file.snap
index cfc53e1c..6f001fbd 100644
--- a/crates/oxc_linter/src/snapshots/no_empty_file.snap
+++ b/crates/oxc_linter/src/snapshots/no_empty_file.snap
@@ -2,6 +2,7 @@
 source: crates/oxc_linter/src/tester.rs
 expression: no_empty_file
 ---
+
   ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
    ╭─[no_empty_file.tsx:1:1]
    ╰────
@@ -29,7 +30,7 @@ expression: no_empty_file
   help: Delete this file or add some code to it.
 
   ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
-   ╭─[no_empty_file.tsx:1:1]
+   ╭─[no_empty_file.tsx:0:1]
  0 │ 
    · ▲
    ╰────
@@ -149,4 +150,3 @@ expression: no_empty_file
    ╰────
   help: Delete this file or add some code to it.
 
-
```

...which I suppose is technically correct but also a bit confusing
perhaps? Should we make the line **minimum 1**? If so I can create
another PR for that.

There is a subtle change in whitespace too - each file gains a newline
at the start but looses one at the end. My assumption is that oxc's
reporter is adding a newline at the start of each report (compared to
miette's), plus I removed the extra newline in `tester.rs` or else the
snapshot diffs would have been even larger.

Finally there are no changes to reports with *multi-line* annotations
like this:

```
  ⚠ typescript-eslint(ban-types): Prefer explicitly define the object shape
   ╭─[ban_types.tsx:1:1]
 1 │ ╭─▶ const emptyObj: {
 2 │ │   
 3 │ ╰─▶         } = {foo: "bar"};
   ╰────
  help: This type means "any non-nullish value", which is slightly better than 'unknown', but it's still a broad type
```

Again I can create a separate PR to improve those and we should see
snapshot diffs when I make that change 😄

I'd appreciate a quick review on this one if at all possible, given the
high chance of conflict.
2024-02-01 11:24:00 +08:00
overlookmotel
622a2c37fa
refactor(lexer): don't use lexer.current.chars directly (#2237)
This PR replaces most usages of `lexer.current.chars.next()` with
`lexer.consume_char()`, or a new function `lexer.next_char()`.

This is a preparatory step towards replacing the `Chars` iterator with
something more flexible which can also consume bytes (not `char`s), and
this PR was intended as pure refactor. But surprised to see there is a
small performance bump (no idea why!).

There's an additional benefit: Using `consume_char()` everywhere where
we believe there's definitely a char there to be consumed will make
logic errors produce a panic, rather than silently outputting garbage.
2024-01-31 21:35:46 +08:00
Dunqing
a79988d5e2
feat(transformer/decorators): support static member (#2235) 2024-01-31 19:11:27 +08:00
Dunqing
3b85e1813b
feat(transformer/decorators): ensure property key consistency (#2233) 2024-01-31 19:05:52 +08:00
overlookmotel
5279e8955f
refactor(parser): byte handler for illegal bytes (#2229)
This adds a separate byte handler to the lexer for byte values which
should never be encountered:

1. UTF-8 continuation bytes (i.e. middle of a multi-byte UTF-8 byte
sequence).
2. Bytes values which are illegal in valid UTF-8 strings.

At present, this function is impossible to reach, because
`std::str::Chars` ensures the next byte is always the *start* of a valid
UTF-8 byte sequence. But later changes I intend introducing unsafe code
will make it possible (but highly undesirable!). In the meantime, I
don't think it does any harm to handle this case.
2024-01-31 18:57:47 +08:00
Boshen
bd23c3a058
Release @oxc-parser/wasm v0.0.4 2024-01-31 15:56:04 +08:00
Boshen
9c6c17b9aa
feat(wasm/parser): improve FFI (#2232) 2024-01-31 15:53:32 +08:00