Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-prefer-let

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-prefer-let - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

16

lib/rules/prefer-let.js

@@ -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',

2

package.json
{
"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 @@ ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc