Commit graph

2845 commits

Author SHA1 Message Date
Yuji Sugiura
1391e4a86b
refactor(semantic/jsdoc): Misc fixes for JSDoc related things (#2531)
Sorry for the rather large size of PR. 😓 But essentially, not changed so
much.

#### 1. Reorganize directories and namings

```
src/jsdoc
├── builder.rs 👈🏻 for SemanticBuilder
├── finder.rs  👈🏻 `semantic.jsdoc()`
├── mod.rs
└── parser
   ├── jsdoc.rs     👈🏻 `JSDoc` struct which has `comment` and `tags`
   ├── jsdoc_tag.rs 👈🏻 `JSDocTag` struct
   ├── mod.rs
   ├── parse.rs     👈🏻 parsing logic by `JSDocParser`
   └── utils.rs
```

Now `mod.rs` has only export things.

#### 2. Introduce `JSDocTagKind::Unknown(name)`

We need to keep their name as-is to check valid tag names are used.(e.g.
`jsdoc/check-tag-names` rule)

#### 3. Support multiline description

- Comment for JSDoc
- Comment for each JSDocTag

```js
/**
 * @foo this comment continues
 * here but leading * should be ignored!!
 */
```

- - -

Please correct me if I am doing something wrong... 🐰
2024-02-29 17:28:14 +08:00
Dunqing
fe777f330f
feat(linter/import): partial support namespace check (#2538) 2024-02-29 15:40:53 +08:00
overlookmotel
5a13714a18
perf(parser): faster lexing template strings (#2541)
Speed up lexing template strings.

This was the last use of `AutoCow` remaining in the lexer, and it's now removed.

Implementation is quite complex, to avoid repeatedly branching on whether an unescaped string is required or not (the way `AutoCow` did). I tried to simplify it down to a single function, but this hurt performance significantly.

Benchmarks do not show much movement, but I believe that's because there aren't many template strings in the benchmarks. Where there are template strings, I believe this speeds up lexing them significantly.
2024-02-29 13:28:30 +08:00
overlookmotel
9d7ea6b3f0
refactor(parser): single function for all string slicing (#2540)
Pure refactor. Move all string-slicing in `lexer::Source` into a single function.
2024-02-29 13:22:55 +08:00
Boshen
32e5a3aae7
Release napi oxc-parser@v0.7.0 2024-02-28 18:41:14 +08:00
Boshen
ab13504612
Release oxlint and vscode extension v0.2.12 2024-02-28 18:39:55 +08:00
Boshen
d41dcc316e
feat(linter): remove all commonjs logic for import plugin (#2537) 2024-02-28 18:13:44 +08:00
Boshen
3efbbb2e1f
feat(ast): add "abstract" type to MethodDefinition and PropertyDefinition (#2536)
closes #2532

```
pub enum PropertyDefinitionType {
    PropertyDefinition,
    TSAbstractPropertyDefinition,
}

pub enum MethodDefinitionType {
    MethodDefinition,
    TSAbstractMethodDefinition,
}
```
2024-02-28 17:33:11 +08:00
Dunqing
3807d83767
feat(wasm): call build module record when symbol is true (#2533)
symbols depend on module record
2024-02-28 14:47:34 +08:00
Dunqing
2c2256a82f
refactor(transformer/typescript): improve implementation of remove import/export (#2530) 2024-02-28 14:41:43 +08:00
Arnaud Barré
d181209759
fix(ast): add Function to generated TS types and fix ModifierKind serialization (#2534) 2024-02-28 14:40:14 +08:00
overlookmotel
24ded3cb15
perf(parser): lex JSX strings with memchr (#2528)
Simplify lexing JSX string attributes. As the search is purely for 1
byte value (the closing quote), and so doesn't require a byte table, use
`memchr`.

This change doesn't really register on benchmarks, but it's one step
closer to removing `AutoCow`, and transitioning all the searches in the
lexer to byte-by-byte.
2024-02-28 14:39:23 +08:00
Dunqing
f760108094
feat(transformer): call build module record (#2529) 2024-02-28 14:35:35 +08:00
overlookmotel
0ddfc856d2
refactor(parser): remove unsafe code (#2527)
Remove some unnecessary unsafe code.
2024-02-27 20:28:21 +08:00
Boshen
02c82c3f78
feat(cli,linter): provide tsconfig path from the cli (#2526)
closes #891
2024-02-27 20:00:11 +08:00
Boshen
27052ebfed
refactor(span): remove AtomImpl (#2525) 2024-02-27 13:45:58 +08:00
Boshen
903f17c0df
refactor(span): move base54 method to mangler (#2523) 2024-02-27 13:34:33 +08:00
Arnaud Barré
6d5ec6dedd
fix(ast): few serialization issues (#2522)
A few more I missed in #2506. Re #2463.

Only remaining snake_case in the current types of the AST:
`trailing_comma` in ArrayExpression, ObjectExpression &
ArrayAssignmentTarget.
2024-02-27 13:04:13 +08:00
Arnaud Barré
76add55031
Support file type in playground (#2520)
<img width="1514" alt="Screenshot 2024-02-27 at 00 16 21"
src="https://github.com/oxc-project/oxc/assets/14235743/32fee380-a2c1-41b3-a564-351597d4a60e">

Not sure about the bindgen thing.

I made the filename optional but given the impact on parsing I think it
could be great for external users to not depend on the tsx default in
the future
2024-02-27 12:54:38 +08:00
Boshen
46e779194a
chore: fix clippy warnings (#2519) 2024-02-26 23:55:18 +08:00
Boshen
570ca68b1e
chore: bump Minimum Supported Rust Version to 1.74
closes #2514
2024-02-26 23:25:03 +08:00
Boshen
351a0572be
chore(parser): print both AST and errors in examples/parser 2024-02-26 23:20:46 +08:00
Boshen
c56b6cb643
refactor: replace InlinableString with CompactString for Atom (#2517)
relates #2516
2024-02-26 23:11:46 +08:00
Dunqing
1519b9000b
fix(semantic): incorrect scope for switch statement (#2513)
close: #2501
2024-02-26 22:54:19 +08:00
Boshen
be6b8b7ce6
[BREAKING CHANGE] Change Atom to Atom<'a> to make it safe (#2497)
Part of #2295

This PR splits the `Atom` type into `Atom<'a>` and `CompactString`.

All the AST node strings now use `Atom<'a>` instead of `Atom` to signify
it belongs to the arena.

It is now up to the user to select which form of the string to use.

This PR essentially removes the really unsafe code 


93742f89e9/crates/oxc_span/src/atom.rs (L98-L107)

which can lead to 

![image](https://github.com/oxc-project/oxc/assets/1430279/8c513c4f-19b0-4b63-b61c-e07c187c95b5)
2024-02-26 19:34:40 +08:00
Boshen
4fabe66621
Publish crates v0.8.0 2024-02-26 19:01:51 +08:00
Boshen
a0f23baea7
Release oxlint and vscode extension v0.2.11 2024-02-26 18:41:04 +08:00
Boshen
d980b0bef2
Release napi oxc-parser@v0.6.0 2024-02-26 18:40:26 +08:00
keita hino
93742f89e9
fix(linter): Correct configuration file parsing for jsx-no-useless-fragment (#2512)
fix: #2484 

I fixed the configuration parsing for jsx-no-useless-fragment.
2024-02-26 15:49:50 +08:00
Dunqing
cd75c1ca59
feat(transformer/decorators): insert only one private in expression (#2486) 2024-02-26 15:48:47 +08:00
Dunqing
4c2e2bdf61
fix(semantic): add export symbol flag to identifiers in export declarations (#2508)
Related PR: #2335
2024-02-26 15:48:05 +08:00
Dunqing
432791679f
fix(codegen): remove redundant semicolon in PropertyDefinition (#2511) 2024-02-26 15:15:19 +08:00
Yuji Sugiura
f66fb886b3
fix(tasks/rulegen): Parse 'export default' test file for plugin-jsdoc (#2510) 2024-02-26 14:31:51 +08:00
Boshen
540f917f3a
refactor(ast): remove TSEnumBody (#2509) 2024-02-26 12:44:38 +08:00
Arnaud Barré
b8764a8eb8
Fix few serialization issues (#2506)
Re: #2463
2024-02-26 12:25:17 +08:00
renovate[bot]
0bdace187a
chore(deps): update website npm packages (#2505) 2024-02-26 10:38:26 +08:00
renovate[bot]
29b213eac7
chore(deps): update rust crates (#2503) 2024-02-26 10:38:11 +08:00
renovate[bot]
77f3ab0496
chore(deps): update vscode npm packages (#2504) 2024-02-26 10:37:25 +08:00
Dunqing
70295a5552
feat(ast): update arrow_expression to arrow_function_expression (#2496) 2024-02-25 14:39:34 +00:00
Boshen
fba66dcc75
fix(linter): improve import/no-named-as-default (#2494) 2024-02-25 21:24:08 +08:00
Boshen
f5aadc767f
feat(linter): handle cjs `module.exports = {} as default export (#2493) 2024-02-25 00:11:48 +08:00
Boshen
f64c7e04a3
feat(linter): handle cjs module.exports.foo = bar and exports.foo = bar (#2492) 2024-02-24 23:54:43 +08:00
Boshen
d0a9c465f7
feat(linter): handle top-level require for import plugin (#2491) 2024-02-24 21:48:23 +08:00
Yuji Sugiura
04f4621ed8
fix(semantic): Should return nearest JSDoc (#2490)
Follow up #2437 ( 🙇🏻 )
2024-02-24 20:35:57 +08:00
Boshen
ef5713d600
chore(linter): add tests no import/no-deprecated (#2489) 2024-02-24 17:50:30 +08:00
Boshen
3e1794d6c0
feat(syntax): implement Debug for ModuleRecord (#2488) 2024-02-24 17:34:42 +08:00
Yuji Sugiura
bc22ae569e
fix(semantic): Refactor jsdoc finding (#2437)
Partial fix for #168 

- [x] Fix general finding behavior for leading comments
- [x] Accept multiple jsdoc comments per node
- [x] Provide `get_one` and also `get_all` 
- [x] Add `iter_all()` for non-node related usage
- [x] Limit AST node kinds to parse
2024-02-24 17:24:01 +08:00
Alex Yip
696818ad08
feat(linter): implement @typescript-eslint/prefer-ts-expect-error (#2435)
Implement @typescript-eslint/prefer-ts-expect-error

Issue: https://github.com/oxc-project/oxc/issues/2180

Documentation:
https://typescript-eslint.io/rules/prefer-ts-expect-error/
Rule source:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-24 09:23:50 +00:00
Boshen
7a796c4b5f
feat(ast): add TSModuleDeclaration.kind (#2487)
closes #2395
2024-02-24 17:09:31 +08:00
Boshen
5212f7b51e
fix(parser): fix missing end span from TSTypeAliasDeclaration (#2485)
closes #2483
2024-02-24 16:51:00 +08:00