]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/rules/one-var.js
import 8.4.0 source
[pve-eslint.git] / eslint / lib / rules / one-var.js
index e3df8320f8b13002ba88582a332f5ed2c64f258f..1818c02e6e14156a5c42460fe7488299406e9277 100644 (file)
@@ -28,13 +28,13 @@ function isInStatementList(node) {
 // Rule Definition
 //------------------------------------------------------------------------------
 
+/** @type {import('../shared/types').Rule} */
 module.exports = {
     meta: {
         type: "suggestion",
 
         docs: {
             description: "enforce variables to be declared either together or separately in functions",
-            category: "Stylistic Issues",
             recommended: false,
             url: "https://eslint.org/docs/rules/one-var"
         },
@@ -209,7 +209,7 @@ module.exports = {
 
         /**
          * Determines the current scope (function or block)
-         * @param  {string} statementType node.kind, one of: "var", "let", or "const"
+         * @param {string} statementType node.kind, one of: "var", "let", or "const"
          * @returns {Object} The scope associated with statementType
          */
         function getCurrentScope(statementType) {
@@ -542,6 +542,8 @@ module.exports = {
             FunctionDeclaration: startFunction,
             FunctionExpression: startFunction,
             ArrowFunctionExpression: startFunction,
+            StaticBlock: startFunction, // StaticBlock creates a new scope for `var` variables
+
             BlockStatement: startBlock,
             ForStatement: startBlock,
             ForInStatement: startBlock,
@@ -553,10 +555,12 @@ module.exports = {
             "ForInStatement:exit": endBlock,
             "SwitchStatement:exit": endBlock,
             "BlockStatement:exit": endBlock,
+
             "Program:exit": endFunction,
             "FunctionDeclaration:exit": endFunction,
             "FunctionExpression:exit": endFunction,
-            "ArrowFunctionExpression:exit": endFunction
+            "ArrowFunctionExpression:exit": endFunction,
+            "StaticBlock:exit": endFunction
         };
 
     }