eslint-plugin-prefer-let 4.0.0 → 4.1.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # eslint-plugin-prefer-let
2
2
 
3
+ ## \[4.1.0]
4
+
5
+ - [`6a5ba09`](https://github.com/thefrontside/javascript/commit/6a5ba096b531357d4c9ddd41fe158623cbebf601) Support ESLint v10
6
+
7
+ ## \[4.0.1]
8
+
9
+ - [`ee2ef1b`](https://github.com/thefrontside/javascript/commit/ee2ef1be18087421c2870eb2845b3235e1e10d58) allow var in TypeScript ambient declarations
10
+ - [`02b89a4`](https://github.com/thefrontside/javascript/commit/02b89a41ecc9711cea3ef6131f9a2bde842ec4fe) Support the `using` declaration from explicit resource management
11
+
3
12
  ## \[4.0.0]
4
13
 
5
14
  - [`e597fa9`](https://github.com/thefrontside/javascript/commit/e597fa93ce94f81d08d259895003a489ccc0021e) Support ESLint v9
@@ -22,7 +22,7 @@ module.exports = {
22
22
  },
23
23
 
24
24
  create: function(context) {
25
- let sourceCode = context.getSourceCode();
25
+ let sourceCode = context.sourceCode ?? context.getSourceCode();
26
26
 
27
27
  //----------------------------------------------------------------------
28
28
  // Helpers
@@ -51,6 +51,17 @@ module.exports = {
51
51
  return isGlobalScope(node) || isModuleScope(node) || isProgramScope(node);
52
52
  }
53
53
 
54
+ function isInAmbientContext(node) {
55
+ let current = node.parent;
56
+ while (current) {
57
+ if (current.type === 'TSModuleDeclaration' && current.declare === true) {
58
+ return true;
59
+ }
60
+ current = current.parent;
61
+ }
62
+ return false;
63
+ }
64
+
54
65
  //----------------------------------------------------------------------
55
66
  // Public
56
67
  //----------------------------------------------------------------------
@@ -58,11 +69,14 @@ module.exports = {
58
69
  return {
59
70
  VariableDeclaration(node) {
60
71
  if (node.kind === 'var') {
72
+ if (isInAmbientContext(node)) {
73
+ return;
74
+ }
61
75
  context.report({
62
76
  message: 'prefer `let` over `var` to declare value bindings',
63
77
  node
64
78
  });
65
- } else if (node.kind !== 'let' && !isTopLevelScope(node)) {
79
+ } else if (node.kind === 'const' && !isTopLevelScope(node)) {
66
80
  let constToken = sourceCode.getFirstToken(node);
67
81
 
68
82
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-prefer-let",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Rule to prefer using `let` to bind names to values",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,8 @@
20
20
  "requireindex": "~1.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "eslint": "^9.3.0",
23
+ "@typescript-eslint/parser": "^8.0.0",
24
+ "eslint": "^10.0.0",
24
25
  "globals": "^15.3.0",
25
26
  "mocha": "^9.1.3"
26
27
  },