dalaoshu
16cfb96a79
fix(justfile): make submodules work on windows ( #7293 )
...
Related to #7290 , closes #7296
By default, `Windows` encounters the following issue unless the user
installs `PowerShell 7` (pwsh).
```bash
error: Recipe `submodules` could not be run because just could not find the shell: program not found
error: Recipe `init` could not be run because just could not find the shell: program not found
```
Furthermore, I have found a better way to solve this problem.
2024-11-16 00:03:23 +08:00
overlookmotel
f4213b8d12
fix(tools): just test-transform run conformance only once ( #7295 )
...
`--exec` flag also runs the non-exec tests, so it's not required to run
it twice.
2024-11-16 00:02:54 +08:00
Song Gao
ea9ca8ab10
fix(just): make submodules work on windows ( #7290 )
...
Fix #7282
- Change default shell to powershell 7(pwsh) to supports "&&"
- change url from git protocol to https protocol. This does not need a
public token(I do not know what it is...).
- specify different submodule init command for windows
Co-authored-by: Song Gao <songgao@microsoft.com>
2024-11-15 18:55:03 +08:00
Boshen
8d8f34cfb5
chore(tasks/coverage): update runtime.snap
2024-11-15 12:48:56 +08:00
overlookmotel
33ec4e6182
fix(codegen): fix arithmetic overflow printing unspanned NewExpression ( #7289 )
...
`self.span.end - 1` overflows if the `NewExpression` is generated in transformer and has no span, so `self.span.end == 0`.
2024-11-15 02:56:49 +00:00
Song Gao
8da23692fc
build(traverse): generate files in parallel ( #7281 )
...
Create type files in parallel. Although it's already pretty fast, always better to be faster.
2024-11-14 23:04:53 +00:00
overlookmotel
f0dee76a4d
style(ast_tools): fix wonky formatting ( #7288 )
...
Follow-on after #7283 . Pure refactor. `rustfmt` was malfunctioning on this code for some reason. Alter the code slightly so it formats it nicely.
2024-11-14 22:58:16 +00:00
overlookmotel
f0affa20c6
docs(ast): improve docs examples for PropertyDefinition ( #7287 )
2024-11-14 22:28:14 +00:00
Boshen
b57d00d6fb
fix(tasks/compat_data): fix misplaced features ( #7284 )
...
closes #7279
2024-11-14 16:36:16 +00:00
overlookmotel
9f5ae56810
refactor(transformer/nullish-coalescing): split main logic into separate function ( #7273 )
...
Small refactor. Move main logic of the transform into a separate function, to allow `enter_expression` to be inlined.
2024-11-14 16:17:23 +00:00
overlookmotel
345fbb9da3
refactor(transformer/nullish-coalescing): avoid repeated symbol lookups ( #7272 )
...
`clone_expression` was unnecessarily looking up the `SymbolId` of references multiple times. Use `BoundIdentifier` instead to avoid that.
Notes:
* `create_conditional_expression` has to take all parts as `Expression`s just to support `this ?? something`.
* `TraverseCtx::is_static` also handles `Super`, but can skip that in this case as `super ?? something` is not valid syntax.
2024-11-14 16:17:23 +00:00
overlookmotel
5b5c8a9bdb
fix(transformer/nullish-coalescing): correct span ( #7269 )
...
Transformed expression inherit same `Span` as the input.
2024-11-14 16:17:22 +00:00
overlookmotel
e219ae8c94
docs(transformer/nullish-coalescing): clarify doc comment ( #7268 )
...
Expand doc comment for `create_conditional_expression` to clarify what it does.
2024-11-14 16:17:21 +00:00
dalaoshu
a48ebd6295
fix(tasks): cargo clippy error on rust 1.82.0 ( #7283 )
...
I mentioned this clippy issue in the discord help channel. The problem
seems to be related to using the stable rust toolchain, but when I
switched to version `1.81.0`, the issue was resolved.
However, some of the clippy suggestions might still be worth considering
and could be adopted.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-15 00:08:04 +08:00
no-yan
01ddf37843
feat(linter): add allowReject option to no-useless-promise-resolve-reject ( #7274 )
...
followup to #7232 .
2024-11-14 14:06:55 +00:00
overlookmotel
84038ee434
refactor(semantic): shorten code ( #7277 )
...
Tiny refactor. No need for `matches!` here.
2024-11-14 12:50:06 +00:00
overlookmotel
9e85cc10c9
refactor(semantic): remove duplicated code ( #7276 )
...
`if matches!(self.kind, TSModuleDeclarationKind::Global)` at top of function already performed this check, no need to check it again.
2024-11-14 12:50:04 +00:00
no-yan
755a31bda7
feat(linter): support bind function case for compatibility with promise/no-return-wrap ( #7232 )
...
part of #4655
### Summary
Logic has been added to handle bind functions, unifying the
implementations of `unicorn/no-useless-promise-resolve-reject` and
`promise/no-return-wrap`.
This enables detection of the following code:
```javascript
foo().then((function() { return Promise.resolve(4) }).bind(this))
```
Merging this PR will allow this rule to pass all test cases of
promise/no-return-wrap without options. Additionally, merging #7274 will
ensure that all test cases are passed.
2024-11-14 19:33:42 +08:00
Dmitry Zakharov
428770edee
feat(linter): add import/no-namespace rule ( #7229 )
2024-11-14 19:23:56 +08:00
camc314
ff2a1d4937
fix(linter): move exhaustive-deps to react ( #7251 )
...
@Boshen lemme know if this is incorrect, but i noticed that `rules-of-hooks` lives inside `react` not `react-hooks`
1f2a6c666f/crates/oxc_linter/src/config/rules.rs (L291-L292)
1f2a6c666f/crates/oxc_linter/src/options/filter.rs (L254)
2024-11-14 08:02:26 +00:00
Alexander S.
216d533b01
fix(language_server): revalidate files when oxlint config is changing ( #7259 )
...

---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-14 10:45:17 +08:00
overlookmotel
10cdce9b67
style(ast): add line break ( #7271 )
2024-11-13 15:45:44 +00:00
ottomated
897d3b1567
feat(ast): serialize StringLiterals to ESTree without raw ( #7263 )
...
#7211 alternative. Makes the `raw` field on estree literals optional.
2024-11-13 15:37:30 +00:00
overlookmotel
e84ea2c3c6
refactor(traverse)!: remove TraverseCtx::clone_identifier_reference ( #7266 )
...
Remove `TraverseCtx::clone_identifier_reference`.
This API encourages unnecessary repeated lookups of the `SymbolId` for a reference. It is preferable to use `MaybeBoundIdentifier` which only looks up the `SymbolId` once.
2024-11-13 15:12:35 +00:00
overlookmotel
8c754b1b43
feat(traverse): introduce MaybeBoundIdentifier ( #7265 )
...
`MaybeBoundIdentifier` is similar to `BoundIdentifier`, but can be used where the identifier may or may not have have a `SymbolId` (may or may not be bound).
Typical usage:
```rs
// Create `MaybeBoundIdentifier` from an existing `IdentifierReference`
let binding = MaybeBoundIdentifier::from_identifier_reference(ident, ctx);
// Generate `IdentifierReference`s and insert them into AST
assign_expr.left = binding.create_write_target(ctx);
assign_expr.right = binding.create_read_expression(ctx);
```
2024-11-13 15:12:33 +00:00
overlookmotel
de472ca7c0
refactor(ast): move StringLiteral definition higher up ( #7270 )
...
Pure refactor. `StringLiteral` definition was sandwiched in the middle of RegExp-related code. Move it higher up in `literal.rs`.
All the rest of the diff is just re-ordering generated code.
2024-11-13 13:37:37 +00:00
overlookmotel
834c94d9d2
docs(traverse): tidy doc comments for TraverseCtx::is_static ( #7267 )
...
Better describe what this method does in its doc comment, and tidy up wording a little.
2024-11-13 11:40:07 +00:00
overlookmotel
7a4872818e
refactor(traverse): reorder imports ( #7264 )
2024-11-13 11:02:37 +00:00
Orenbek
9c91151603
feat(linter): implement typescript/no-empty-object-type ( #6977 )
2024-11-13 09:31:16 +00:00
DonIsaac
2268a0ef90
feat(linter): support overrides config field ( #6974 )
...
Part of #5653
2024-11-13 05:40:59 +00:00
camchenry
c6a48684c3
refactor(linter): temporarily remove unknown rules checking ( #7260 )
...
I had intended to leave this in until we could rework some of the rule/plugin name resolution code, however this is causing issues with merging https://github.com/oxc-project/oxc/pull/6974 . The mutability of `self` is difficult to resolve in that PR without more drastic changes. Since this isn't currently helping us out, I am simply removing the code for now until we can revisit this.
2024-11-13 03:41:03 +00:00
Cameron A McHenry
df5c535dd0
fix(linter): revert unmatched rule error ( #7257 )
...
- related to https://github.com/oxc-project/oxc/issues/6988
This is causing a lot of errors currently such as
https://github.com/oxc-project/oxc/issues/7233 . I think we need to
handle rule names more robustly first:
- https://github.com/oxc-project/oxc/issues/7240
- https://github.com/oxc-project/oxc/issues/7082
- https://github.com/oxc-project/oxc/discussions/7242
then, I think we can revisit this and maybe implement it as an actual
lint plugin too? https://github.com/oxc-project/oxc/discussions/7086
2024-11-13 09:06:20 +08:00
camc314
c4ed230f8a
fix(linter): fix false positive in eslint/no-cond-assign ( #7241 )
...
fixes #7238
2024-11-12 14:45:38 +00:00
overlookmotel
740ba4bcbd
docs(ast): correct doc comment for StringLiteral ( #7255 )
...
Correct doc comment for `StringLiteral`'s `value` field. The doc comment was wrong.
2024-11-12 13:47:16 +00:00
dalaoshu
ef847dab9c
fix(linter): false positive in jsx-a11y/iframe-has-title ( #7253 )
...
closes #7243
2024-11-12 13:14:50 +00:00
overlookmotel
44375a5662
refactor(ast)!: rename TSEnumMemberName enum variants ( #7250 )
...
Variants of `TSEnumMemberName` were previously only prefixed with `Static` to avoid naming conflicts with the variants inherited from `Expression` for non-static member names. #7219 removed the variants inherited from `Expression`, so all variants are now static. So we can shorten the names again (back to what they were before `inherit_variants!` was introduced).
2024-11-12 12:22:21 +00:00
overlookmotel
d3d58f8ace
refactor(ast): remove inherit_variants! from TSEnumMemberName ( #7248 )
...
#7219 removed all variants of `TSEnumMemberName` except `IdentifierName` and `StringLiteral`. It no longer inherits variants from `Expression`, so we can remove the `inherit_variants!` macro wrapper.
The discriminants no longer need to avoid clashes with `Expression`'s, so they can start at 0.
2024-11-12 12:22:20 +00:00
camc314
62b6327879
fix(linter): react/exhaustive-deps update span for unknown deps diagnostic ( #7249 )
...
Relates to #7246
2024-11-12 11:55:50 +00:00
camc314
3dcac1ae0b
feat(linter): react/exhaustive-deps ( #7151 )
...
Firstly, a massive thanks to @alisnic for starting this (incredibly complicated) lint rule in https://github.com/oxc-project/oxc/pull/2637 !
still a draft. current state:
3x false positives (all todo with refs)
3x false negatives (TS will catch these
13x false negatvies todo with refs
1x false negative TODO
closes #2637
relates to #2174
2024-11-12 11:42:47 +00:00
overlookmotel
c5f4ee7a82
fix(transformer): correct code comments ( #7247 )
...
Follow-on after #7199 . Just correct typos in a couple of comments.
2024-11-12 11:09:22 +00:00
Boshen
20fe3cd6e7
chore(semantic): fix doc
2024-11-12 12:00:16 +08:00
Boshen
4740642926
chore(semantic): rename examples/simple.rs to examples/semantic.rs
2024-11-12 11:55:58 +08:00
Boshen
f54d330eca
feat(tasks/lint_rules): mark eslint/no-undef-init as done ( #7244 )
...
closes #6456
2024-11-12 11:55:37 +08:00
Boshen
1282221e36
fix(codegen): print comments when block is empty ( #7236 )
...
part of #7190
2024-11-11 11:20:25 +00:00
7086cmd
0d6a66aa9e
test(minifier): fix minimize condition tests ( #7222 )
2024-11-11 08:36:19 +00:00
Boshen
080a67be16
test(semantic): semantic checker store conformance pass/fail info in a separate file ( #7235 )
...
closes #6069
2024-11-11 08:13:13 +00:00
Boshen
2e0364e21a
chore(deps): update crate-ci/typos action to v1.27.3 ( #7228 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-10 00:41:21 +08:00
oxc-bot
de107246c8
release(crates): v0.36.0 ( #7227 )
...
## [0.36.0] - 2024-11-09
- b11ed2c ast: [**BREAKING**] Remove useless `ObjectProperty::init`
field (#7220 ) (Boshen)
- 0e4adc1 ast: [**BREAKING**] Remove invalid expressions from
`TSEnumMemberName` (#7219 ) (Boshen)
- 846711c transformer: [**BREAKING**] Change API to take a
`&TransformOptions` instead of `TransformOptions` (#7213 ) (Boshen)
- 092de67 types: [**BREAKING**] Append `rest` field into `elements` for
objects and arrays to align with estree (#7212 ) (ottomated)
- d1d1874 ast: [**BREAKING**] Change `comment.span` to real position
that contain `//` and `/*` (#7154 ) (Boshen)
- 843bce4 ast: [**BREAKING**] `IdentifierReference::reference_id` return
`ReferenceId` (#7126 ) (overlookmotel)
### Features
- cc8a191 ast: Methods on AST nodes to get `scope_id` etc (#7127 )
(overlookmotel)
- dc0215c ast_tools: Add #[estree(append_to)], remove some custom
serialization code (#7149 ) (ottomated)
- 9d6cc9d estree: ESTree compatibility for all literals (#7152 )
(ottomated)
- b74686c isolated-declarations: Support transform TSExportAssignment
declaration (#7204 ) (Dunqing)
- ad3a2f5 tasks/compat_data: Generate our own compat table (#7176 )
(Boshen)
- b4258ee transformer: Add defaulted `Module::Preserve` option (#7225 )
(Boshen)
- 324c3fe transformer: Add `TransformOptions::module` option (#7188 )
(Boshen)
- a166a4a transformer: Add esbuild comma separated target API
`--target=es2020,chrome58` (#7210 ) (Boshen)
- 3a20b90 transformer: Add es target to `engineTargets` (#7193 ) (Boshen)
- 22898c8 transformer: Warn BigInt when targeting < ES2020 (#7184 )
(Boshen)
- a579011 transformer: Add features `ES2018NamedCapturingGroupsRegex`
and `ES2018LookbehindRegex` (#7182 ) (Boshen)
- 8573f79 transformer: Turn on async_to_generator and
async_generator_functions plugins in enable_all (#7135 ) (Dunqing)
- df77241 transformer: Enable `ArrowFunctionConverter` in
`async-to-generator` and `async-generator-functions` plugins (#7113 )
(Dunqing)
- b6a5750 transformer/arrow-function-converter: Move scope to changed
scope for `this_var` if scope have changed (#7125 ) (Dunqing)
- 1910227 transformer/async-to-generator: Support inferring the function
name from the ObjectPropertyValue's key (#7201 ) (Dunqing)
- ffa8604 transformer/async-to-generator: Do not transform await
expression if is not inside async function (#7138 ) (Dunqing)
- e536d47 transformer/babel: Add support for trying to get the `Module`
from `BabelPlugins` (#7218 ) (Dunqing)
- 5cfdc05 transformer/typescript: Support transform `export =` and
`import = require(...)` when module is commonjs (#7206 ) (Dunqing)
### Bug Fixes
- c82b273 transformer/async-generator-functions: Only transform object
method in exit_function (#7200 ) (Dunqing)
- b2a888d transformer/async-generator-functions: Incorrect
transformation for `for await` if it's not placed in a block (#7148 )
(Dunqing)
- 19892ed transformer/async-generator-functions: Transform incorrectly
for `for await` if it's in LabeledStatement (#7147 ) (Dunqing)
- ede10dc transformer/async-to-generator: Incorrect transform when super
expression is inside async method (#7171 ) (Dunqing)
- 293d072 transformer/async-to-generator: Only transform object method
in exit_function (#7199 ) (Dunqing)
- ae692d7 transformer/async_to_generator: Fix checking if function is
class method (#7117 ) (overlookmotel)
- eea4ab8 transformer/helper-loader: Incorrect `SymbolFlags` for default
import when `SourceType` is script (#7226 ) (Dunqing)
### Refactor
- d27e14f ast: `AstKind::as_*` methods take `self` (#5546 )
(overlookmotel)
- fac5042 ast: Use `scope_id` etc methods (#7130 ) (overlookmotel)
- a297765 minifier: Use `map` and `and_then` instead of let else (#7178 )
(7086cmd)
- fc86703 napi/transform: Change test files to TypeScript (#7221 )
(Boshen)
- c5485ae semantic: Add `ancestor_kinds` iterator function (#7217 )
(camchenry)
- abf1602 semantic: Rename `iter_parents` to `ancestors` (#7216 )
(camchenry)
- 42171eb semantic: Rename `ancestors` to `ancestor_ids` (#7215 )
(camchenry)
- de56083 transformer: Add `impl TryFrom<EngineTargets> for EnvOptions`
(#7191 ) (Boshen)
- 0a43c64 transformer: Move `ESTarget` to its own file (#7189 ) (Boshen)
- 0e1f12c transformer: Remove unimplemented `EnvOptions::bugfixes`
(#7162 ) (Boshen)
- a981caf transformer: Add `Engine` enum for `EngineTargets` (#7161 )
(Boshen)
- 8340243 transformer: Rename `Query` to `BrowserslistQuery` (#7143 )
(Boshen)
- 481f7e6 transformer: Change `Targets` to `EngineTargets` (#7142 )
(Boshen)
- 55e6989 transformer: Deserialize engine target strings to specific
keys (#7139 ) (Boshen)
- fdfd9a4 transformer: Use `scope_id` etc methods (#7128 )
(overlookmotel)
- ff8bd50 transformer: Move implementation of ArrowFunction to
common/ArrowFunctionConverter (#7107 ) (Dunqing)
- 4a515be transformer/arrow-function-coverter: Rename function name and
add some comments to explain confusing parts. (#7203 ) (Dunqing)
- c307e1b transformer/arrow-functions: Pass `ArenaBox` as function param
(#7169 ) (overlookmotel)
- 217d433 transformer/arrow-functions: Remove unused `&mut self`
function param (#7165 ) (overlookmotel)
- 426df71 transformer/arrow-functions: Use `scope_id` method (#7164 )
(overlookmotel)
- 11c5e12 transformer/arrow-functions: Correct comments (#7163 )
(overlookmotel)
- 1238506 transformer/async-generator-function: Remove inactive
`#[allow(clippy::unused_self)]` attrs (#7167 ) (overlookmotel)
- 84ee581 transformer/async-generator-functions: Simplify identifying
whether within an async generator function (#7170 ) (overlookmotel)
- 1b12328 transformer/async-generator-functions: Use `clone` not
`clone_in` on `LabelIdentifier` (#7172 ) (overlookmotel)
- cd1006f transformer/async-generator-functions: Do not transform yield
expression where inside generator function (#7134 ) (Dunqing)
- 2c5734d transformer/async-generator-functions: Do not transform await
expression where inside ArrowFunctionExpression (#7132 ) (Dunqing)
- 5ce83bd transformer/async-generator-functions: Remove dead code for
handle await expression (#7131 ) (Dunqing)
- e04ee97 transformer/async-generator-functions: Move handling of
`MethodDefinition`'s value to `exit_function` (#7106 ) (Dunqing)
- b57d5a5 transformer/async-to-generator: Remove unused `&self` function
param (#7166 ) (overlookmotel)
- f80085c transformer/async-to-generator: Move handling of
`MethodDefinition`'s value to `exit_function` (#7105 ) (Dunqing)
- e2241e6 transformer/jsx-self: Remove unused `&self` function params
(#7159 ) (overlookmotel)
- 1dfd241 transformer/optional-catch-binding: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7158 ) (overlookmotel)
- fd9b44c transformer/typescript: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7160 ) (overlookmotel)
- cacfb9b traverse: Use `symbol_id` etc methods (#7129 ) (overlookmotel)
### Styling
- 38a6df6 transformer/arrow-functions: Semicolon after return statements
(#7168 ) (overlookmotel)
- 64b7e3a transformer/async-generator-functions: Import
`oxc_allocator::Vec` as `ArenaVec` (#7173 ) (overlookmotel)
### Testing
- be819dd napi/transform: Add test for not default es transform (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-10 00:31:14 +08:00
Boshen
be819dded1
test(napi/transform): add test for not default es transform
2024-11-10 00:21:26 +08:00
Dunqing
eea4ab830a
fix(transformer/helper-loader): incorrect SymbolFlags for default import when SourceType is script ( #7226 )
2024-11-09 14:32:44 +00:00