Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const topLevelConstant = 1;
let topLevelLet = 2;
var topLevelVar = 3;

function topLevelFunction() {
function innerFunction() {
function nestedFunction() {
'use strict';
}
}
return Object;
}

module.exports = topLevelFunction();
152 changes: 150 additions & 2 deletions apps/oxlint/test/fixtures/sourceCode_scope_methods/output.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,154 @@

# stdout
```
x scope-plugin(scope): getDeclaredVariables(): topLevelConstant
,-[files/index.cjs:1:1]
1 | const topLevelConstant = 1;
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | let topLevelLet = 2;
`----

x scope-plugin(scope): isGlobalReference(topLevelConstant): false
,-[files/index.cjs:1:7]
1 | const topLevelConstant = 1;
: ^^^^^^^^^^^^^^^^
2 | let topLevelLet = 2;
`----

x scope-plugin(scope): getDeclaredVariables(): topLevelLet
,-[files/index.cjs:2:1]
1 | const topLevelConstant = 1;
2 | let topLevelLet = 2;
: ^^^^^^^^^^^^^^^^^^^^
3 | var topLevelVar = 3;
`----

x scope-plugin(scope): isGlobalReference(topLevelLet): false
,-[files/index.cjs:2:5]
1 | const topLevelConstant = 1;
2 | let topLevelLet = 2;
: ^^^^^^^^^^^
3 | var topLevelVar = 3;
`----

x scope-plugin(scope): getDeclaredVariables(): topLevelVar
,-[files/index.cjs:3:1]
2 | let topLevelLet = 2;
3 | var topLevelVar = 3;
: ^^^^^^^^^^^^^^^^^^^^
4 |
`----

x scope-plugin(scope): isGlobalReference(topLevelVar): false
,-[files/index.cjs:3:5]
2 | let topLevelLet = 2;
3 | var topLevelVar = 3;
: ^^^^^^^^^^^
4 |
`----

x scope-plugin(scope): getScope(topLevelFunction):
| type: function
| isStrict: false
| variables: [arguments, innerFunction]
| through: [Object]
| upper type: global
,-[files/index.cjs:5:1]
4 |
5 | ,-> function topLevelFunction() {
6 | | function innerFunction() {
7 | | function nestedFunction() {
8 | | 'use strict';
9 | | }
10 | | }
11 | | return Object;
12 | `-> }
13 |
`----

x scope-plugin(scope): isGlobalReference(topLevelFunction): false
,-[files/index.cjs:5:10]
4 |
5 | function topLevelFunction() {
: ^^^^^^^^^^^^^^^^
6 | function innerFunction() {
`----

x scope-plugin(scope): getScope(innerFunction):
| type: function
| isStrict: false
| variables: [arguments, nestedFunction]
| through: []
| upper type: function
,-[files/index.cjs:6:3]
5 | function topLevelFunction() {
6 | ,-> function innerFunction() {
7 | | function nestedFunction() {
8 | | 'use strict';
9 | | }
10 | `-> }
11 | return Object;
`----

x scope-plugin(scope): isGlobalReference(innerFunction): false
,-[files/index.cjs:6:12]
5 | function topLevelFunction() {
6 | function innerFunction() {
: ^^^^^^^^^^^^^
7 | function nestedFunction() {
`----

x scope-plugin(scope): getScope(nestedFunction):
| type: function
| isStrict: true
| variables: [arguments]
| through: []
| upper type: function
,-[files/index.cjs:7:5]
6 | function innerFunction() {
7 | ,-> function nestedFunction() {
8 | | 'use strict';
9 | `-> }
10 | }
`----

x scope-plugin(scope): isGlobalReference(nestedFunction): false
,-[files/index.cjs:7:14]
6 | function innerFunction() {
7 | function nestedFunction() {
: ^^^^^^^^^^^^^^
8 | 'use strict';
`----

x scope-plugin(scope): isGlobalReference(Object): true
,-[files/index.cjs:11:10]
10 | }
11 | return Object;
: ^^^^^^
12 | }
`----

x scope-plugin(scope): isGlobalReference(module): false
,-[files/index.cjs:14:1]
13 |
14 | module.exports = topLevelFunction();
: ^^^^^^
`----

x scope-plugin(scope): isGlobalReference(exports): false
,-[files/index.cjs:14:8]
13 |
14 | module.exports = topLevelFunction();
: ^^^^^^^
`----

x scope-plugin(scope): isGlobalReference(topLevelFunction): false
,-[files/index.cjs:14:18]
13 |
14 | module.exports = topLevelFunction();
: ^^^^^^^^^^^^^^^^
`----

x scope-plugin(scope): getDeclaredVariables(): topLevelConstant, secondTopLevelConstant
,-[files/index.js:1:1]
1 | ,-> const topLevelConstant = 1,
Expand Down Expand Up @@ -143,8 +291,8 @@
: ^^^^^^^^^^^^^^^^
`----

Found 0 warnings and 17 errors.
Finished in Xms on 1 file using X threads.
Found 0 warnings and 33 errors.
Finished in Xms on 2 files using X threads.
```

# stderr
Expand Down
Loading