// 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"
},
/**
* 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) {
FunctionDeclaration: startFunction,
FunctionExpression: startFunction,
ArrowFunctionExpression: startFunction,
+ StaticBlock: startFunction, // StaticBlock creates a new scope for `var` variables
+
BlockStatement: startBlock,
ForStatement: startBlock,
ForInStatement: startBlock,
"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
};
}