eslint-plugin-prefer-let
Advanced tools
Comparing version 1.0.1 to 1.0.2-37a5fdd
@@ -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", |
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
8364
170
97
6
2
2