Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3db8a02

Browse files
committed
try fixer
1 parent 07c28b5 commit 3db8a02

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/eslint-rules/no-production-logging.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ module.exports = function(context) {
2727
['warning', 'warningWithoutStack'].includes(name);
2828

2929
return {
30+
meta: {
31+
fixable: 'code',
32+
},
3033
CallExpression: node => {
3134
if (!isLoggerNode(node.callee.name)) {
3235
return;
@@ -38,6 +41,12 @@ module.exports = function(context) {
3841
data: {
3942
identifier: node.callee.name,
4043
},
44+
fix: function(fixer) {
45+
return [
46+
fixer.insertTextBefore(node.parent, 'if (__DEV__) {'),
47+
fixer.insertTextAfter(node.parent, '}'),
48+
];
49+
},
4150
});
4251
}
4352
},

0 commit comments

Comments
 (0)