-
-
Notifications
You must be signed in to change notification settings - Fork 224
fix!: remove nodejsScope option
#699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Note: uses of this property will be removed from ESLint in eslint/eslint#20145. |
| it("creates a function scope following the global scope immediately and creates module scope", () => { | ||
| const ast = espree("import {x as v} from 'mod';"); | ||
|
|
||
| const scopeManager = analyze(ast, { ecmaVersion: 6, nodejsScope: true, sourceType: "module" }); | ||
|
|
||
| expect(scopeManager.scopes).to.have.length(3); | ||
| expect(scopeManager.isGlobalReturn()).to.be.true; | ||
|
|
||
| let scope = scopeManager.scopes[0]; | ||
|
|
||
| expect(scope.type).to.be.equal("global"); | ||
| expect(scope.block.type).to.be.equal("Program"); | ||
| expect(scope.isStrict).to.be.false; | ||
| expect(scope.variables).to.have.length(0); | ||
|
|
||
| scope = scopeManager.scopes[1]; | ||
| expect(scope.type).to.be.equal("function"); | ||
| expect(scope.block.type).to.be.equal("Program"); | ||
| expect(scope.isStrict).to.be.false; | ||
| expect(scope.variables).to.have.length(1); | ||
| expect(scope.variables[0].name).to.be.equal("arguments"); | ||
|
|
||
| scope = scopeManager.scopes[2]; | ||
| expect(scope.type).to.be.equal("module"); | ||
| expect(scope.variables).to.have.length(1); | ||
| expect(scope.variables[0].name).to.be.equal("v"); | ||
| expect(scope.variables[0].defs[0].type).to.be.equal("ImportBinding"); | ||
| expect(scope.references).to.have.length(0); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was inherited from escope. I'm not sure why nodejsScope: true, sourceType: "module" combination was supported at all, and even less why it was supported by nesting scopes as: Global > Function > Module. For this combination, I think Global > Module > Function would make more sense for practical purposes as it could represent code that is going to be wrapped in a function that is in an ES module.
Prerequisites checklist
What is the purpose of this pull request?
Removes
nodejsScopeoption fromeslint-scope.What changes did you make? (Give an overview)
Removed the option and updated
analyze()to throw an error if it's passed.Related Issues
Fixes #697
Is there anything you'd like reviewers to focus on?