Skip to content

Commit 973e696

Browse files
committed
feature: @putout/plugin-nodejs: convert-promisify-to-fs-promises-lowercase
1 parent a30e404 commit 973e696

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.putout.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
}
3333
},
3434
"rules": {
35-
"putout/apply-lowercase-to-node-builders": "off",
36-
"putout/declare": "off",
35+
"putout/apply-lowercase-to-node-builders": "on",
3736
"remove-useless-spread/object": ["off", {
3837
"exclude": "module.exports.rules = __"
3938
}],

packages/plugin-nodejs/lib/convert-promisify-to-fs-promises/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import {
2-
types as t,
3-
operator,
4-
} from 'putout';
1+
import {types, operator} from 'putout';
2+
3+
const {
4+
objectProperty,
5+
identifier,
6+
objectPattern,
7+
} = types;
58

69
const {replaceWith, remove} = operator;
710

@@ -17,9 +20,9 @@ export const fix = ({path, promisified}) => {
1720
const [declarator] = path.node.declarations;
1821
const {name} = declarator.id;
1922

20-
props.push(t.ObjectProperty(
21-
t.Identifier(name),
22-
t.Identifier(name),
23+
props.push(objectProperty(
24+
identifier(name),
25+
identifier(name),
2326
NOT_COMPUTED,
2427
SHORTHAND,
2528
));
@@ -30,7 +33,7 @@ export const fix = ({path, promisified}) => {
3033

3134
init.arguments[0].value = 'fs/promises';
3235

33-
replaceWith(path.get('id'), t.ObjectPattern(props));
36+
replaceWith(path.get('id'), objectPattern(props));
3437
};
3538

3639
export const find = (ast, {push, traverse}) => {

0 commit comments

Comments
 (0)