Skip to content

Commit fc95878

Browse files
committed
feature: @putout/plugin-minify: convert-const-to-var -> convert-const-to-let
1 parent 059d019 commit fc95878

32 files changed

+82
-70
lines changed

packages/plugin-merge-destructuring-properties/test/fixture/minify-fix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const {defineProperty: a} = Object;
1+
const {defineProperty: a, keys: b} = Object;
22
let c = null;
3-
var d = 1073741823, {keys: b} = Object;
3+
let d = 1073741823;
44

55
function A(...e) {
66
if (n)

packages/plugin-minify/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ npm i @putout/plugin-putout -D
1616
-[apply-template-literal](#apply-template-literal);
1717
-[apply-ternary](#apply-ternary);
1818
-[convert-array-from-to-spread](#convert-array-from-to-spread);
19-
-[convert-const-to-var](#convert-const-to-var);
19+
-[convert-const-to-let](#convert-const-to-let);
2020
-[convert-if-to-logical](#convert-if-to-logical);
2121
-[convert-return-to-sequence-expression](#convert-return-to-sequence-expression);
2222
-[convert-strict-equal-to-equal](#convert-strict-equal-to-equal);
@@ -149,7 +149,7 @@ b && (console.log('hello'), console.log('world'));
149149
a ? (console.log(1), console.log(2)) : (console.log(3), console.log(4));
150150
```
151151

152-
## convert-const-to-var
152+
## convert-const-to-let
153153

154154
### ❌ Example of incorrect code
155155

@@ -160,7 +160,7 @@ const a = 5;
160160
### ✅ Example of correct code
161161

162162
```js
163-
var a = 5;
163+
let a = 5;
164164
```
165165

166166
## convert-return-to-sequence-expression

packages/plugin-minify/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {defineConfig} from 'eslint/config';
55
export const match = {
66
'README.md{js}': {
77
'no-var': 'off',
8+
'prefer-const': 'off',
89
},
910
};
1011
export default defineConfig([safeAlign, matchToFlat(match)]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let a = 5;

packages/plugin-minify/lib/convert-const-to-var/fixture/convert-const-to-var.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/convert-const-to-let.js

File renamed without changes.

packages/plugin-minify/lib/convert-const-to-var/fixture/for.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/for.js

File renamed without changes.

packages/plugin-minify/lib/convert-const-to-var/fixture/mutation-fix.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/mutation-fix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async function a(A) {
55

66
type == 'email' && (c = c.split('@')[1]);
77

8-
var d = await checkDomain(c);
8+
let d = await checkDomain(c);
99

1010
e.innerHTML = `Result: ${d.data}`;
1111
}

packages/plugin-minify/lib/convert-const-to-var/fixture/mutation.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/mutation.js

File renamed without changes.

packages/plugin-minify/lib/convert-const-to-var/fixture/not-identifier.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/not-identifier.js

File renamed without changes.

packages/plugin-minify/lib/convert-const-to-var/fixture/overlap-fix.js renamed to packages/plugin-minify/lib/convert-const-to-let/fixture/overlap-fix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function mergeProps() {
2-
var n = a();
2+
let n = a();
33

44
if (n) {
55
n();

0 commit comments

Comments
 (0)