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
3
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 1.0.1 to 1.0.2-37a5fdd

9

lib/rules/prefer-let.js

@@ -25,3 +25,3 @@ /**

create: function(context) {
// variables should be defined here
let sourceCode = context.getSourceCode();

@@ -60,5 +60,10 @@ //----------------------------------------------------------------------

} else if (node.kind !== 'let' && !isTopLevelScope(node)) {
let constToken = sourceCode.getFirstToken(node);
context.report({
message: '`const` declaration outside top-level scope',
node
node,
fix: function(fixer) {
return fixer.replaceText(constToken, 'let');
}
});

@@ -65,0 +70,0 @@ }

{
"name": "eslint-plugin-prefer-let",
"version": "1.0.1",
"version": "1.0.2-37a5fdd",
"description": "Rule to prefer using `let` to bind names to values",

@@ -10,4 +10,2 @@ "keywords": [

],
"author": "Charles Lowell",
"homepage": "https://github.com/cowboyd/eslint-plugin-prefer-let",
"main": "lib/index.js",

@@ -21,3 +19,3 @@ "scripts": {

"devDependencies": {
"eslint": "^3.5.0",
"eslint": "^4.18.2",
"mocha": "^2.4.5"

@@ -24,0 +22,0 @@ },

# eslint-plugin-prefer-let
[![Build Status](https://travis-ci.org/cowboyd/eslint-plugin-prefer-let.svg?branch=master)](https://travis-ci.org/cowboyd/eslint-plugin-prefer-let)
An eslint plugin to encourage semantic of usage of `let` and `const`.

@@ -86,1 +84,14 @@

```
### Possible Conflicts
This plugin may conflict with other plugins or configs that set `eslint prefer-const`. You can configure the rules to avoid this:
```json
{
"rules": {
"prefer-let/prefer-let": 2,
"prefer-const": "off"
}
}
```

@@ -54,2 +54,3 @@ /**

code: "function y() { const x = 'y'; return x; }",
output: "function y() { let x = 'y'; return x; }",
errors: [{

@@ -62,2 +63,3 @@ message: "`const` declaration outside top-level scope",

code: "function y() { const {x, y} = {x: 'x', y: 'y'}}",
output: "function y() { let {x, y} = {x: 'x', y: 'y'}}",
errors: [{

@@ -97,2 +99,3 @@ message: "`const` declaration outside top-level scope",

code: "function y() { const x = 'y'; return x; }",
output: "function y() { let x = 'y'; return x; }",
errors: [{

@@ -99,0 +102,0 @@ message: "`const` declaration outside top-level scope",

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