camc314
d6b84ec44e
fix(linter) bug in fixer for no-null ( #5273 )
...
i tested this in the microsoft/vscode repo and there were no syntax errors after running the fixer 🎉
hopefully this is the last fix.
2024-08-28 02:14:38 +00:00
Boshen
e6fd52e2a6
fix(parser): change unterminated regex error to be non-recoverable ( #5285 )
...
closes #5257
2024-08-28 01:57:31 +00:00
leaysgur
cffce11620
fix(regular_expression): Prevent panic on too large number ( #5282 )
...
Partially close #5257
Use `checked_(mul|add)` to prevent panic.
2024-08-28 01:31:54 +00:00
overlookmotel
d71f0ed2d0
refactor(traverse): inline all passthrough methods ( #5279 )
...
Many methods of `TraverseCtx` just delegate to methods of `TraverseAncestry` or `TraverseScoping`. Mark them all `#[inline]`.
2024-08-28 01:07:11 +00:00
overlookmotel
188ce0766f
refactor(traverse): improve safety via type system ( #5277 )
...
Guard against mistakes in `oxc_traverse` codegen by making it impossible to pop from ancestors stack more times than have pushed.
2024-08-28 01:07:11 +00:00
overlookmotel
0f4a8b39d3
refactor(traverse): add debug asserts for safety invariants ( #5272 )
...
Add `debug_assert!`s for unchecked invariants.
2024-08-28 01:07:11 +00:00
overlookmotel
341e42ac4c
refactor(traverse): make Ancestor an owned type ( #5269 )
...
Make the `Ancestor` type used in `oxc_traverse` an owned type. Instead of `TraverseCtx::parent` returning a `&'t Ancestor<'a>`, it now returns an `Ancestor<'a, 't>`.
This allows `Ancestor` to be `Copy`.
The `'t` lifetime plays the same role in both cases - preventing any `Ancestor` from escaping from the `enter_*` / `exit_*` method in which it's obtained.
Same for the `*Without*` types which are `Ancestor` enum's "payloads". Any AST node references obtained from an `Ancestor` are also constrained by same `'t` lifetime - e.g. `&'t Statement<'a>`.
2024-08-28 01:07:10 +00:00
camc314
c8e85323cb
feat(linter/unicorn): add fixer to throw-new-error ( #5275 )
...
got merged into the wrong branch (https://github.com/oxc-project/oxc/pull/5148 ), hence setting to merge when ready (as was already approved)
2024-08-27 20:51:35 +00:00
Kevin Deng 三咲智子
681bd8071a
fix(wasm): reference ast from prettier ( #5268 )
...
regression by cc3332898c
2024-08-27 22:15:26 +08:00
overlookmotel
c23104b2a2
feat(wasm): output symbol IDs in scope tree ( #5266 )
...
`oxc_wasm` include `SymbolId`s in print-out of scopes.
2024-08-27 13:49:44 +00:00
overlookmotel
6a49dc36b2
perf(wasm): generate scope text with visitor ( #5264 )
...
Follow-on after #5232 . `oxc_wasm` build scopes text with a single AST traversal. Previous implementation was O($n^2$).
If we can assume scopes are listed in traversal order, then we could do it a bit more efficiently just from `ScopeTree`, but this approach of using `Visit` will handle out-of-order scope IDs (which you'd get if printing a post-transform `ScopeTree`).
Also reduce creating and discarding `String`s for indentation - reuse a single string instead.
2024-08-27 13:49:42 +00:00
overlookmotel
05d25e2aa3
refactor(semantic): combine add scope methods ( #5262 )
...
#5232 removed `ScopeTree::child_ids`, so it's no longer necessary to have separate `add_scope` and `add_root_scope` methods.
2024-08-27 13:00:21 +00:00
overlookmotel
17d8a88415
fix(wasm): display correct scope IDs ( #5263 )
...
`ScopeId`s were printed incorrectly. `+ 1` used to be correct, but isn't
any more since `ScopeId` became a `NonMaxU32`.
2024-08-27 20:39:07 +08:00
overlookmotel
fdedc0f8b1
refactor(semantic): transform checker: rename SemanticData to Scoping ( #5261 )
...
Pure refactor. Rename type and vars with a more descriptive name.
2024-08-27 11:58:21 +00:00
overlookmotel
10861096e0
refactor(semantic): transform checker do not output spans in errors ( #5260 )
...
Transform checker don't output spans in errors. They're inaccurate because (a) spans refer to the source text pre-transform, and (b) most errors relate to scopes/symbols/references newly created in transformer, which have no span.
2024-08-27 11:58:21 +00:00
overlookmotel
af5713e411
refactor(semantic): transform checker continue checks if missing IDs ( #5259 )
...
Transform checker don't bail out if some IDs missing from AST. Continue to check for other problems.
Also simplify iterating over pairs of IDs.
2024-08-27 11:58:20 +00:00
overlookmotel
943454fa5e
refactor(semantic): update transform checker for no conditional scopes ( #5252 )
...
All scopes are now unconditional (#5008 ). Update transform checker to reflect this.
2024-08-27 08:57:15 +00:00
Kevin Deng 三咲智子
cc3332898c
perf(wasm): reuse parse result for prettier ( #5254 )
2024-08-27 16:56:18 +08:00
overlookmotel
892a7fab60
refactor(semantic): replace ref syntax ( #5253 )
...
Pure code style refactor. Prefer `if let Some(y) = &x.y` over `if let Some(ref y) = x.y`.
2024-08-27 08:13:14 +00:00
overlookmotel
cbb47252ba
refactor(semantic): add comment to transform checker ( #5250 )
...
Add back a doc comment which was accidentally removed in #5232 .
2024-08-27 07:38:52 +00:00
Boshen
fea2746b73
chore: switch playground to https://github.com/oxc-project/playground ( #5249 )
...
playground app: https://oxc-playground.netlify.app/
2024-08-27 15:14:36 +08:00
Boshen
484f0d7579
fix(wasm): fix broken prettier
2024-08-27 14:25:25 +08:00
Kevin Deng 三咲智子
8b53ef9b27
feat(wasm): add option preserve_parens ( #5237 )
2024-08-27 12:10:08 +08:00
Dunqing
9953fa54a4
fix(linter/no-null): incorrect fixer for NullLiteral within ReturnStatement ( #5247 )
...
close : #5194
It’s a long time no contributed to Linter, I'd like to try it
2024-08-27 03:51:56 +00:00
Billy Levin
a6e97690a7
feat(linter/jsx-a11y): add label-has-associated-control ( #5163 )
2024-08-26 23:33:55 -04:00
Boshen
a17cf33dc3
refactor(semantic): remove ScopeTree::child_ids ( #5232 )
...
closes https://github.com/oxc-project/oxc/issues/5244
2024-08-27 01:49:47 +00:00
DonIsaac
5a137f0985
feat(span/source-type): add SourceType factory methods ( #5242 )
2024-08-27 01:19:54 +00:00
DonIsaac
94f60e7748
refactor(span/source-type): make SourceType factories const ( #5241 )
...
I found myself wanting this while writing `no-unused-vars` and while using oxc
in some downstream personal projects.
2024-08-27 01:19:53 +00:00
DonIsaac
f5e05db302
feat(span/source-type): impl Display and Error for UnknownExtension ( #5240 )
2024-08-27 01:19:52 +00:00
DonIsaac
a6bb3b1b98
fix(span/source-type): consider .cjs and .cts files as ModuleKind::Script ( #5239 )
...
- fix: `SourceType::from_path` considers `.cjs` and `.cts` as modules, not scripts
- docs: improve rusdoc for `SourceType::from_path`
- test: add unit tests for `SourceType::from_path`
2024-08-27 01:19:52 +00:00
Kevin Deng 三咲智子
1af7f04a36
feat(wasm): output panic info to console ( #5238 )
...
Playground Preview:
<img width="1769" alt="image"
src="https://github.com/user-attachments/assets/12143fb5-f6a6-48bc-8dee-cf85b6c52392 ">
2024-08-27 09:12:15 +08:00
Kevin Deng 三咲智子
30ecbf649b
refactor(wasm): combine into a options ( #5235 )
2024-08-27 09:11:30 +08:00
Kevin Deng 三咲智子
167f7e452d
fix(wasm): set both scope and symbol ( #5236 )
2024-08-27 09:10:41 +08:00
camc314
b39544e0f2
fix(linter/jest): fixer for prefer-jest-mocked creates invalid LHS expressions ( #5243 )
...
closes #5228
interestingly `eslint-plugin-jest` reports an error on this code, it also immedietly fixes it.
however fixing here is not good as it results in invalid code.
should fix https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/10518058484/job/29247525457
2024-08-27 00:42:01 +00:00
camc314
9f772c9872
fix(linter) bug in fixer for func-names when function name is shadowed ( #5231 )
...
closes #5229
2024-08-26 14:32:42 +00:00
overlookmotel
bc59dd2b29
refactor(parser): improve example for byte_search! macro usage ( #5234 )
...
It's more efficient when reading 2 bytes to use `read2()` than 2 x `read()` calls. Reflect that in example for using `byte_search!` macro.
2024-08-26 14:22:37 +00:00
overlookmotel
a3ddfdd9d7
refactor(parser): improve lexer pointer maths ( #5233 )
...
Small tweaks to pointer maths in lexer which may result in slightly more compact assembly.
2024-08-26 14:22:36 +00:00
camc314
7ccde4b853
feat(linter/unicorn): add fixer to prefer-date-now ( #5147 )
2024-08-26 14:05:01 +00:00
camc314
a58e44845f
feat(linter/eslint): add fixer to no-var ( #5144 )
2024-08-26 13:59:26 +00:00
Kevin Deng 三咲智子
4641034710
fix(wasm): correct ir type ( #5226 )
...
Fixes type error:
https://github.com/oxc-project/playground/actions/runs/10557625323/job/29245568111?pr=22
2024-08-26 21:41:57 +08:00
overlookmotel
12a7607bac
perf(codegen): inline Codegen::print_list ( #5221 )
...
Revert #5192 and add a comment that it's not a perf gain.
This was really surprising to me, but the benchmarks do demonstrate it.
Please see the benchmarks commit-by-commit on this PR. Adding `#[inline]` to the function does give +1% gain, but it's no better than it was before #5192 . So I think preferable to just revert to the simpler original.
I think likely explanation is that the compiler is already performing this optimization itself. And if it does it itself, then it understands the code better, and can then make better decisions about inlining.
https://godbolt.org/z/xzhWWeMoe seems to demonstrate this - there are 2 calls to `Item::gen` in the generated assembly, so it has split the loop into 2.
2024-08-26 10:28:49 +00:00
leaysgur
1686920e23
fix(parser): Span for invalid regex flags ( #5225 )
...
### Before
```
x Flag u is mentioned twice in regular expression literal
,-[1:20]
1 | const a = /\2(.)/uuxig;
: ^
2 | debugger;
`----
x Unexpected flag x in regular expression literal
,-[1:21]
1 | const a = /\2(.)/uuxig;
: ^
2 | debugger;
`----
```
### After
```
x Flag u is mentioned twice in regular expression literal
,-[1:19]
1 | const a = /\2(.)/uuxig;
: ^
2 | debugger;
`----
x Unexpected flag x in regular expression literal
,-[1:20]
1 | const a = /\2(.)/uuxig;
: ^
2 | debugger;
`----
```
2024-08-26 10:24:47 +00:00
oxc-bot
2a001a043c
Release oxlint v0.9.0 ( #5219 )
...
## [0.9.0] - 2024-08-26
- 5946748 linter: [**BREAKING**] Parse and display syntax errors for
regular expressions (#5214 ) (Boshen)
- b894d3b linter: [**BREAKING**] Make `no-unused-vars` correctness
(#5081 ) (DonIsaac)
### Features
- 1ce9630 linter/config: Implement FromIterator for LintPluginOptions
(#5102 ) (DonIsaac)
- 34bfaf6 linter/react: Add fixer to `jsx-props-no-spread-multi` (#5145 )
(camc314)
- 982bd6e linter/unicorn: Add fixer to `require-array-join-separator`
(#5152 ) (camc314)
- a6704bd linter/unicorn: Add fixer to `prefer-set-size` (#5149 )
(camc314)
- ac7edcc linter/unicorn: Add fixer to `prefer-array-some` (#5153 )
(camc314)
- 1d01aa3 linter/unicorn: Add partial fixer for `prefer-array-flat`
(#5143 ) (camc314)
- 22d57f9 linter/unicorn: Add fixer to `prefer-string-slice` (#5150 )
(Cameron)
- 2fe4415 linter/unicorn: Add fixer to `no-redundant-roles` (#5146 )
(Cameron)
- d35c6f5 linter/unicorn: Add fixer to `prefer-regexp-test` (#5151 )
(Cameron)
- 27db769 linter/unicorn: Add fixer to `text-encoding-identifier-case`
(#5154 ) (Cameron)
- f7958c4 linter/unicorn: Add prefer-structured-clone (#5095 ) (Jelle van
der Waa)
- 004ffa0 linter/vitest: Implement `prefer-each` (#5203 ) (dalaoshu)
### Bug Fixes
- aaaf26c linter: Error in fixer for prefer-to-have-length (#5197 )
(dalaoshu)
- 1f5b6b6 linter: Bug in fixer for prefer-to-have-length (#5164 )
(dalaoshu)
- 7eb052e linter: `no-hex-escape` fixer removing regex flags (#5137 )
(Cameron)
- 76c66b4 linter/max-lines: Point span to end of file for disable
directive to work (#5117 ) (Boshen)
- 8ff6f2c linter/no-unused-vars: Panic on UsingDeclarations (#5206 )
(DonIsaac)
- d29042e linter/no-unused-vars: Function expression in implicit arrow
function return (#5155 ) (DonIsaac)
- 36e4a28 linter/no-unused-vars: Panic in variable declarator usage
checks (#5160 ) (DonIsaac)
- ba62a71 linter/react: Fixed false positive with missing key inside
React.Children.toArray() for fragments (#5133 ) (Earl Chase)
- fd1031a linter/unicorn: Breaking fixer in case statements for
`no-null` (#5176 ) (DonIsaac)
- 7b86ed6 linter/unicorn: Handle type casts and parens in `no-null`
(#5175 ) (Don Isaac)
- b629e16 linter/unicorn: Improve diagnostic message for `no-null`
(#5172 ) (DonIsaac)
### Performance
- ce454cf Use simdutf8 to validate UTF-8 when reading files (#5196 )
(dalaoshu)
### Refactor
- 543cad6 codegen: Remove some pub APIs (Boshen)
- 0d3661a linter: Remove meaningless `span0` (#5209 ) (dalaoshu)
- 2a91ef1 linter: `eslint/no_redeclare` rule use `run_on_symbol` not
`run_once` (#5201 ) (overlookmotel)
- 33599b0 linter: Split options into multiple files (#5101 ) (DonIsaac)
- 7ab6152 linter/unicorn: Clean up `no-null` (#5174 ) (DonIsaac)
### Testing
- a877e5a linter/no-unused-vars: Ensure type annotations on property
accessors are considered used (#5183 ) (DonIsaac)
- 7886618 linter/unicorn: Add fixer tests for `no-null` (#5173 )
(DonIsaac)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-26 16:50:15 +08:00
overlookmotel
d4c3778e02
refactor(codegen): rename vars ( #5222 )
...
Rename function params in default methods of `Codegen`. Makes no material difference, just nicer hints in IDE.
2024-08-26 08:40:50 +00:00
leaysgur
46b641b75d
feat(regular_expression): Validate max quantifier value ( #5218 )
...
I've never seen but `/a{9007199254740991}/` is valid and this is the maximum value for quantifier.
\+ left comment about #5210 experiment.
2024-08-26 07:11:04 +00:00
Kevin Deng 三咲智子
b39c0d6122
refactor(wasm): add source_type for parser, replace class options with plain object ( #5217 )
...
- Feat: add `source_type` to `ParserOptions`
- Refactor: use plain objects for options instead of `new
OxcRunOptions()` and `new OxcParserOptions()`, allowing easier
serialization.
2024-08-26 15:08:35 +08:00
Boshen
5946748ca6
feat(linter)!: parse and display syntax errors for regular expressions ( #5214 )
...
cc @leaysgur shipping to production!
This is marked as breaking change because there may be false positives.
2024-08-26 05:23:45 +00:00
Boshen
2fbc283e03
chore: bump rustc to v1.80.1 ( #5211 )
2024-08-26 13:11:29 +08:00
Kevin Deng 三咲智子
1cd5401ad7
fix(wasm): respect camelCase ( #5213 )
2024-08-26 12:51:19 +08:00
dalaoshu
0d3661a23c
refactor(linter): remove meaningless span0 ( #5209 )
...
Yes. Those were added due to a code mod. the number suffixes were to
avoid name collisions.
_Originally posted by @DonIsaac in
https://github.com/oxc-project/oxc/pull/5203#discussion_r1730578314_
2024-08-26 12:29:45 +08:00