eslint-plugin-prefer-let 4.0.0 → 4.0.1

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,10 @@
1
1
  # eslint-plugin-prefer-let
2
2
 
3
+ ## \[4.0.1]
4
+
5
+ - [`ee2ef1b`](https://github.com/thefrontside/javascript/commit/ee2ef1be18087421c2870eb2845b3235e1e10d58) allow var in TypeScript ambient declarations
6
+ - [`02b89a4`](https://github.com/thefrontside/javascript/commit/02b89a41ecc9711cea3ef6131f9a2bde842ec4fe) Support the `using` declaration from explicit resource management
7
+
3
8
  ## \[4.0.0]
4
9
 
5
10
  - [`e597fa9`](https://github.com/thefrontside/javascript/commit/e597fa93ce94f81d08d259895003a489ccc0021e) Support ESLint v9
@@ -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.0.1",
4
4
  "description": "Rule to prefer using `let` to bind names to values",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,6 +20,7 @@
20
20
  "requireindex": "~1.2.0"
21
21
  },
22
22
  "devDependencies": {
23
+ "@typescript-eslint/parser": "^8.0.0",
23
24
  "eslint": "^9.3.0",
24
25
  "globals": "^15.3.0",
25
26
  "mocha": "^9.1.3"