eslint-plugin-prefer-let 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/lib/rules/prefer-let.js +10 -3
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ long-standing conventions set forth by both formal symbolic logic and
|
|
|
8
8
|
the practice of functional programming.
|
|
9
9
|
|
|
10
10
|
Usage of the `const` keyword to bind an _intermediate_ value of a
|
|
11
|
-
computation places emphasis on the compiler and
|
|
11
|
+
computation places emphasis on the compiler and its role in
|
|
12
12
|
ensuring that a _reference_ never changes. By contrast using `let` in
|
|
13
13
|
the same situation reads, in plain English, the programmer's intent to
|
|
14
14
|
declare a name value binding.
|
package/lib/rules/prefer-let.js
CHANGED
|
@@ -28,16 +28,23 @@ module.exports = {
|
|
|
28
28
|
// Helpers
|
|
29
29
|
//----------------------------------------------------------------------
|
|
30
30
|
|
|
31
|
+
function getScope(node) {
|
|
32
|
+
let sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
33
|
+
return sourceCode.getScope
|
|
34
|
+
? sourceCode.getScope(node)
|
|
35
|
+
: context.getScope();
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
function isGlobalScope(node) {
|
|
32
|
-
return
|
|
39
|
+
return getScope(node).type === 'global';
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
function isModuleScope(node) {
|
|
36
|
-
return
|
|
43
|
+
return getScope(node).type === 'module';
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
function isProgramScope(node) {
|
|
40
|
-
return
|
|
47
|
+
return getScope(node).block.type === 'Program';
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
function isTopLevelScope(node) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prefer-let",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Rule to prefer using `let` to bind names to values",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/thefrontside/javascript.git",
|
|
8
|
+
"directory": "packages/eslint-plugin-prefer-let"
|
|
9
|
+
},
|
|
5
10
|
"keywords": [
|
|
6
11
|
"eslint",
|
|
7
12
|
"eslintplugin",
|
|
@@ -15,12 +20,12 @@
|
|
|
15
20
|
"requireindex": "~1.2.0"
|
|
16
21
|
},
|
|
17
22
|
"devDependencies": {
|
|
18
|
-
"eslint": "^
|
|
23
|
+
"eslint": "^9.3.0",
|
|
24
|
+
"globals": "^15.3.0",
|
|
19
25
|
"mocha": "^9.1.3"
|
|
20
26
|
},
|
|
21
27
|
"engines": {
|
|
22
28
|
"node": ">=0.10.0"
|
|
23
29
|
},
|
|
24
|
-
"license": "ISC"
|
|
25
|
-
"repository": "thefrontside/javascript"
|
|
30
|
+
"license": "ISC"
|
|
26
31
|
}
|