This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rome_js_analyze): allow nested func declarations in esm
- Loading branch information
Showing
13 changed files
with
134 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ess/noInnerDeclarations/invalid-module.js → ...ss/noInnerDeclarations/invalid-module.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
if (foo) { | ||
var a; | ||
function foo() {} | ||
} | ||
export {}; | ||
} |
49 changes: 49 additions & 0 deletions
49
crates/rome_js_analyze/tests/specs/correctness/noInnerDeclarations/invalid-module.cjs.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
source: crates/rome_js_analyze/tests/spec_tests.rs | ||
assertion_line: 96 | ||
expression: invalid-module.cjs | ||
--- | ||
# Input | ||
```js | ||
if (foo) { | ||
var a; | ||
function foo() {} | ||
} | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalid-module.cjs:2:2 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This var should be declared at the root of the script. | ||
1 │ if (foo) { | ||
> 2 │ var a; | ||
│ ^^^^^ | ||
3 │ function foo() {} | ||
4 │ } | ||
i The var is accessible in the whole body of the script. | ||
To avoid confusion, it should be declared at the root of the script. | ||
``` | ||
|
||
``` | ||
invalid-module.cjs:3:2 lint/correctness/noInnerDeclarations ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This function should be declared at the root of the script. | ||
1 │ if (foo) { | ||
2 │ var a; | ||
> 3 │ function foo() {} | ||
│ ^^^^^^^^^^^^^^^^^ | ||
4 │ } | ||
i The function is accessible in the whole body of the script. | ||
To avoid confusion, it should be declared at the root of the script. | ||
``` | ||
|
||
|
52 changes: 0 additions & 52 deletions
52
crates/rome_js_analyze/tests/specs/correctness/noInnerDeclarations/invalid-module.js.snap
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...me_js_analyze/tests/specs/correctness/noInnerDeclarations/valid-block-scoped-func-decl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// ensure we are in esm | ||
export {} | ||
|
||
{ | ||
function f() {} | ||
} |
17 changes: 17 additions & 0 deletions
17
..._analyze/tests/specs/correctness/noInnerDeclarations/valid-block-scoped-func-decl.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
source: crates/rome_js_analyze/tests/spec_tests.rs | ||
assertion_line: 96 | ||
expression: valid-block-scoped-func-decl.js | ||
--- | ||
# Input | ||
```js | ||
// ensure we are in esm | ||
export {} | ||
|
||
{ | ||
function f() {} | ||
} | ||
|
||
``` | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.