Commit graph

162 commits

Author SHA1 Message Date
Dunqing
3b4fe0edfd
feat(semantic): allow reserved keyword defined in ts module block (#1907)
https://www.typescriptlang.org/play?target=99#code/PTAEAEBcEMCcHMCmkBcpEGcB2iAekAoECAWwHsATAVwBtE1MAmABkcYBpMd8CiwAHKgCNQAYzJYMkUAGUAKgCUAkgGE5AfQCyAeQAiAUXUA5AIKb9MtDOQAeAGQByKdEgBLUaCmwAfKAC8oPwAFgBm6hjIAISgAN58oAkJAESuJPx0JIhYkBhJ7PGJoCnZiLAh0KKIeQWJSXSQ1cSFSfwVANbQSI1gzfywrgBuLlX5TbV9ZJCIolMU3YVFgkI07vPNzm6ia7UAnq6INHOjYAC+ANy8ePxksNIx5wQU0zRwiKBY0JkYrZWgIWRkWKgAgJcSSaSpdKITLZDBoaBYHZnYGgiRSQLCFaieGI5EgsRoiElMoVeigBFIlGgIawUD1HGU-Fg9E-DpIBl41HgwL9IZTDlMwk8ybTWYCrnojbucUE7l7A4UAUnAhAA
2024-01-06 12:56:27 +08:00
Dunqing
b0569bc8e7
feat(semantic): add current_scope_flags function in SemanticBuilder (#1906) 2024-01-06 12:51:44 +08:00
Dunqing
6c5b22f728
refactor(semantic): improve ClassTable implmention and merge properties and methods to elements (#1902) 2024-01-05 18:38:51 +08:00
Dunqing
f1b433b126
feat(playground): visualize symbol (#1886)
close: https://github.com/oxc-project/oxc/issues/1048
2024-01-04 15:36:31 +08:00
Dunqing
45a7985524
feat(playground): visualize scope (#1882)
Partial support https://github.com/oxc-project/oxc/issues/1048
2024-01-03 16:10:42 +08:00
Dunqing
dae5f628b0
perf(semantic): check duplicate parameters in Binder of FormalParameters (#1840) 2024-01-03 12:57:03 +08:00
Dunqing
bfd5cd92a6
refactor(semantic): improve check function declaration implementation (#1854) 2023-12-31 22:17:56 +08:00
IWANABETHATGUY
4bbc977971
chore: upgrade rustc toolchain to stable 1.75.0 (#1853)
ref: 
https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html
2023-12-29 12:20:51 +08:00
Dunqing
a743d06207
perf(semantic): just need to find the AstKind::FormalParameter in is_in_formal_parameters (#1852)
A bit of performance improvement
<img width="894" alt="image"
src="https://github.com/oxc-project/oxc/assets/29533304/ed687532-df83-4bd8-a893-059e41c8adf3">
2023-12-29 12:18:59 +08:00
Dunqing
0e0f25872f
perf(semantic): reduce calls to span() (#1851) 2023-12-29 03:40:53 +00:00
Dunqing
497a0b8462
refactor(semantic): rename add_node_id to add_current_node_id_to_current_scope (#1847)
https://github.com/oxc-project/oxc/pull/1826#discussion_r1437074750
2023-12-28 13:05:25 +08:00
Dunqing
9c9d882d93
fix(semantic): remove duplicate errors in ModuleDeclaration::ImportDeclaration (#1846)
<img width="653" alt="image"
src="https://github.com/oxc-project/oxc/assets/29533304/7a3ca98e-6c6e-4170-8b79-e9c63b6b9153">
2023-12-28 10:44:53 +08:00
Dunqing
b9bdf361e6
feat(semantic): improve check super implementation, reduce access nodes (#1827)
This improves the performance at which we can check that super is in a non-class.
2023-12-27 22:36:28 +08:00
Dunqing
f7b7f0a512
feat(semantic): support get node id by scope id (#1826)
This is useful when we want to get the ast node that corresponds to the current scope.
2023-12-27 22:30:28 +08:00
Dunqing
f45a3cc2fa
feat(linter): support eslint/no-unused-private-class-members rule (#1820) 2023-12-27 22:24:12 +08:00
Dunqing
d63c50a5ca
refactor(semantic): improve check private identifier implementation (#1794)
The regression case in typescript is as expected since we don't
currently store `AccessorProperty` in `ClassTable`.

The following code is one of those cases

```ts
class C1 {
    accessor #a: any;
    accessor #b = 1;
    static accessor #c: any;
    static accessor #d = 2;

    constructor() {
        this.#a = 3;
        this.#b = 4;
    }

    static {
        this.#c = 5;
        this.#d = 6;
    }
}
```

But there was an error

```shell
Expect to Parse: "conformance/classes/propertyMemberDeclarations/autoAccessor2.ts"
  × Private field 'a' must be declared in an enclosing class
    ╭─[conformance/classes/propertyMemberDeclarations/autoAccessor2.ts:9:1]
  9 │     constructor() {
 10 │         this.#a = 3;
    ·              ──
 11 │         this.#b = 4;
    ╰────
```

Let's leave it alone for now. Because of the `AccessorProperty` I
haven't seen it in any repo.
2023-12-26 20:39:22 +08:00
Dunqing
ca04312130
feat(semantic): add ClassTable (#1793) 2023-12-25 23:59:35 +08:00
Boshen
da67fe1ca2
refactor(semantic): remove unused methods from AstNode 2023-12-21 16:08:14 +08:00
Dunqing
edc6fa4830
feat(semantic): add SymbolFlags::Function for FunctionDeclaration (#1713)
Co-authored-by: Boshen <boshenc@gmail.com>
2023-12-18 11:26:33 +08:00
Dunqing
00806384ff
perf(linter/react): find class node by symbols in get_parent_es6_component (#1657)
This way we can get the class node faster. But I don't know if this is a
good way. In `eslint-plugin-react`, they get class node by scope. But
oxc cannot do the same way
2023-12-13 13:48:53 +08:00
Boshen
8347e2225c
Release crates v0.4.0 2023-12-08 17:20:37 +08:00
Miles Johnson
c6ad6603a4
feat(semantic): support scope descendents starting from a certain scope. (#1629)
@Boshen 

The `ScopeTree.descendants` function would return all scopes starting
from the root, and wasn't truly descendants from a specific scope. To
improve this, I've renamed this function to `descendants_from_root` and
have introduced a new `descendants` function that does support from a
specific scope.

Furthermore, I've introduced helper functions to `SymbolTree` to make
reading symbols/scopes easier.

To verify this functionality, I enabled the `function_name` transformer
(and fixed it), and ran some example transforms. Here's the input:

```js
let fn;

fn = function (a, b, c) {
  const d = "";
};

const func = function (arg) {
  {
    const value = "";
  }
};

const f = function (f) {};
```

And the output using _the old implementation_. Note that all function
names are suffixed with a number, this is incorrect, since it was
inheriting far too many scopes.

```js
let fn;
fn = function fn1(a, b, c) {
	const d = '';
};
const func = function func1(arg) {
	{
		const value = '';
	}
};
const f = function f2(f) {
};
```

And here's the output with the new implementation. Note that only `f` is
suffixed with a number. That's because it has a shadowed argument of the
same name.

```js
let fn;
fn = function fn(a, b, c) {
	const d = '';
};
const func = function func(arg) {
	{
		const value = '';
	}
};
const f = function f1(f) {
};
```
2023-12-07 17:29:11 +08:00
Boshen
6670d94708
chore(rust): remove unnecessary clippy::non_upper_case_globals (#1557) 2023-11-27 14:31:38 +08:00
Shannon Rothe
0115314cf4
feat(ast/semantic): parse jsdoc on PropertyDefinition (#1517)
This should be enough to handle jsdoc comments on class
properties/fields.

See #1506
2023-11-23 18:30:14 +08:00
Boshen
1a576f60a8
refactor(rust): move to workspace lint table (#1444) 2023-11-20 14:38:10 +08:00
Boshen
128406a8ab
Rust v1.74.0 (#1357) 2023-11-16 15:21:45 +00:00
Boshen
be043c37e9
refactor(ast): VariableDeclarationKind::to_string -> as_str (#1321) 2023-11-14 15:28:13 +00:00
Boshen
5f316626f6
feat(prettier): add the basics of comment printing (#1313) 2023-11-14 12:32:03 +00:00
Dunqing
446ba169de
feat(ast): add to_string function to VariableDelcartionKind (#1303)
feat(ast): add to_string function to VariableDelcartionKind

fix: lint error
2023-11-14 20:22:56 +08:00
Boshen
ba603cebb9
Release Oxc v0.3.0 2023-11-06 19:11:16 +08:00
Boshen
203cf37695
feat(transformer/react): read comment pragma @jsxRuntime classic / automatic (#1133)
closes #1120
2023-11-03 11:10:11 +08:00
Boshen
69150d812c
refactor(transformer): move Semantic into Transformer (#1130) 2023-11-02 13:10:15 +08:00
Boshen
af1a76bafa
feat(transformer): implement some of needs_explicit_esm for typescript (#1047)
Co-authored-by: magic-akari <akari.ccino@gmail.com>
2023-10-24 17:30:01 +08:00
Boshen
a442fad3b7
feat(semantic): bind function expression name (#1049)
closes #1018

We'll eventually recover the mangling tests, which should cover this
change.
2023-10-24 17:25:12 +08:00
Cameron
c4a2084f27
fix(linter) Fix panic when linting declaration files (#1014)
When linting declaration files, it panics here 


6628fc8d9c/crates/oxc_linter/src/rules/eslint/no_global_assign.rs (L57)

with this error:
```
index out of bounds: the len is 0 but the index is 0
```

Because it expects the array to have the root scope id inside (non zero
len)


0fcad27515/crates/oxc_semantic/src/scope.rs (L52-L54)
2023-10-21 09:25:32 +08:00
Boshen
dfee8539f0
feat(transformer): add utils to make logical_assignment_operators pass (#1017) 2023-10-20 16:27:23 +08:00
Boshen
678db1d955
feat(transformer): ES2020 Nullish Coalescing Operator (#1004)
The test runner needs an update for reading options.jon, which I'll work
on in the up coming PR.
2023-10-16 21:45:58 +08:00
Boshen
0f72066f2e
feat(transformer): finish 2016 exponentiation operator (#996) 2023-10-16 09:30:04 +08:00
Boshen
1661385c1a
feat(semantic): check non-simple lhs expression of assignment expression (#994) 2023-10-14 23:40:10 +08:00
Cameron
3af35b8048
feat(linter) eslint-unicorn catch error name (#984) 2023-10-12 11:06:46 +01:00
Boshen
903854dac0
refactor(ast): fix the lifetime annotations around Vist and VisitMut (#973) 2023-10-10 17:05:48 +08:00
Boshen
ef8aaa7bf1
feat(minifier): re-enable mangler (#972) 2023-10-10 14:32:58 +08:00
Boshen
0fcad27515 use enter / leave scope from ast visit in SemanticBuilder 2023-10-09 09:59:14 +08:00
Boshen
55b2f031df
feat(minifier): partially re-enable minifier (#963)
closes #949
closes #950
closes #951

All minifier tests are disable from this PR.

We are going to fix the compilation errors first, then the behavioral
errors.
2023-10-08 11:06:42 +08:00
Boshen
817f8c295e
ci: turn off doc tests because they are slow to compile and run (#961) 2023-10-07 17:01:23 +08:00
Don Isaac
b4b39b8aa6
test(semantic): add scoping test cases (#954)
Add test cases to `oxc_semantic` that check scope flag behavior.

Also contains these tweaks:
- fix: allow disabling `with_module` on `SourceType`
- refactor: move `SymbolTester` to a separate file
- chore: add `Expect` trait & implement it on `SymbolTester`
2023-10-03 18:16:01 +13:00
cin
24539545a9
feat(linter): add no-redeclare rule. (#683)
Close: #615 #520 
Rule: [Docs](https://eslint.org/docs/latest/rules/no-redeclare)
2023-09-23 23:54:54 +12:00
Wenzhe Wang
0f02d3783c
fix(semantic): make ExportDeclaration span accurate (#928) 2023-09-17 14:11:25 +00:00
Boshen
38bbc96fb0
Release oxc v0.2.0 2023-09-14 23:41:44 +08:00
Boshen
babbc47d61
perf(parser): lazily build trivia map instead of build in-place (#903)
closes #898
2023-09-12 23:23:56 +08:00