@putout/plugin-convert-const-to-let
Advanced tools
Comparing version
@@ -14,6 +14,10 @@ 'use strict'; | ||
for (const binding of values(path.scope.bindings)) { | ||
if (binding.constant) | ||
const {parentPath, node} = binding.path; | ||
const {init} = node; | ||
if (init && binding.constant) | ||
continue; | ||
const {parentPath} = binding.path; | ||
if (isLoop(parentPath) && binding.constant) | ||
continue; | ||
@@ -23,5 +27,4 @@ if (!parentPath.node) | ||
if (binding.path.isVariableDeclarator() && parentPath.node.kind === 'const') { | ||
if (binding.path.isVariableDeclarator() && parentPath.node.kind === 'const') | ||
push(binding.path.parentPath); | ||
} | ||
} | ||
@@ -31,1 +34,7 @@ }, | ||
const isLoop = ({parentPath}) => { | ||
if (parentPath.isForOfStatement()) | ||
return true; | ||
return parentPath.isForInStatement(); | ||
}; |
{ | ||
"name": "@putout/plugin-convert-const-to-let", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"type": "commonjs", | ||
@@ -39,15 +39,15 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
"@putout/plugin-split-variable-declarations": "*", | ||
"@putout/test": "^5.0.0", | ||
"c8": "^7.5.0", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-n": "^15.2.4", | ||
"eslint-plugin-putout": "^16.0.0", | ||
"madrun": "^9.0.0" | ||
"@putout/test": "^10.0.0", | ||
"c8": "^10.0.0", | ||
"eslint": "^9.0.0", | ||
"eslint-plugin-n": "^17.0.0", | ||
"eslint-plugin-putout": "^22.0.0", | ||
"madrun": "^10.0.0" | ||
}, | ||
"peerDependencies": { | ||
"putout": ">=26" | ||
"putout": ">=35" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=16" | ||
"node": ">=18" | ||
}, | ||
@@ -54,0 +54,0 @@ "publishConfig": { |
@@ -33,2 +33,3 @@ # @putout/plugin-convert-const-to-let [![NPM version][NPMIMGURL]][NPMURL] | ||
const a = 5; | ||
a = 3; | ||
@@ -41,2 +42,3 @@ ``` | ||
let a = 5; | ||
a = 3; | ||
@@ -43,0 +45,0 @@ ``` |
4501
6.53%27
35%48
4.35%