eslint-plugin-prefer-let
Advanced tools
Comparing version 0.0.0 to 0.1.0
@@ -31,4 +31,14 @@ /** | ||
// any helper functions should go here or else delete this section | ||
function isGlobalScope(node) { | ||
return context.getScope().type === 'global'; | ||
} | ||
function isModuleScope(node) { | ||
return context.getScope().type === 'module'; | ||
} | ||
function isTopLevelScope(node) { | ||
return isGlobalScope(node) || isModuleScope(node); | ||
} | ||
//---------------------------------------------------------------------- | ||
@@ -40,2 +50,3 @@ // Public | ||
VariableDeclaration(node) { | ||
var scopeType = context.getScope().type; | ||
if (node.kind === 'var') { | ||
@@ -46,3 +57,4 @@ context.report({ | ||
}); | ||
} else if (node.kind !== 'let' && context.getScope().type !== 'global') { | ||
} else if (node.kind !== 'let' && !isTopLevelScope(node)) { | ||
console.log(context.getScope().type); | ||
context.report({ | ||
@@ -49,0 +61,0 @@ message: '`const` declaration outside top-level scope', |
{ | ||
"name": "eslint-plugin-prefer-let", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "Rule to prefer using `let` to bind names to values", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -17,3 +17,4 @@ /** | ||
parserOptions: { | ||
ecmaVersion: 6 | ||
ecmaVersion: 6, | ||
sourceType: "module" | ||
} | ||
@@ -36,2 +37,5 @@ }); | ||
code: "const { foo, bar } = {};" | ||
}, | ||
{ | ||
code: `export const AlsoObject = Object;` | ||
} | ||
@@ -38,0 +42,0 @@ ], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7517
140