Skip to content

Commit 36b8c05

Browse files
committed
feature: @putout/plugin-apply-arrow: exclude LogicalExpression
1 parent 61b328c commit 36b8c05

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

packages/plugin-apply-arrow/lib/apply-arrow.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
'use strict';
22

33
const {print, types} = require('putout');
4-
const {isFunction, isProgram} = types;
4+
const {
5+
isFunction,
6+
isProgram,
7+
isLogicalExpression,
8+
} = types;
9+
510
const isTopScope = (a) => isFunction(a) || isProgram(a);
611

712
module.exports.report = () => `Use 'Arrow Function' instead of 'Function Declaration`;
@@ -11,6 +16,9 @@ module.exports.match = () => ({
1116
if (isToLong(__b))
1217
return false;
1318

19+
if (isLogicalExpression(__b))
20+
return false;
21+
1422
const [first] = path.node.body.body;
1523
const {leadingComments} = first;
1624

packages/plugin-apply-arrow/test/apply-arrow.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ test('putout: apply-arrow: no report: comment', (t) => {
4242
t.end();
4343
});
4444

45+
test('putout: apply-arrow: no report: logical', (t) => {
46+
t.noReport('logical');
47+
t.end();
48+
});
49+
4550
test('putout: apply-arrow: no report: no-loc', (t) => {
4651
const FN = 'function __a(__args) {return __b}';
4752

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function isNewLine(code) {
2+
return code === 10
3+
|| code === 13
4+
|| code === 0x2028
5+
|| code === 0x2029;
6+
}

0 commit comments

Comments
 (0)