Skip to content

Commit 90146fe

Browse files
committed
feature: @putout/plugin-apply-arrow: exclude long lines
1 parent ead3686 commit 90146fe

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
module.exports.report = () => `Use 'Arrow Function' instead of 'Function Declaration`;
44

55
module.exports.match = () => ({
6-
'function __a(__args) {return __b}': ({__a}, path) => {
6+
'function __a(__args) {return __b}': ({__a, __b}, path) => {
7+
const columnsCount = __b.loc.end.column - __b.loc.start.column;
8+
const linesCount = __b.loc.end.line - __b.loc.start.line;
9+
10+
if (columnsCount > 30 && !linesCount)
11+
return false;
12+
713
const {name} = __a;
814
const binding = path.parentPath.scope.bindings[name];
915

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ test('putout: apply-arrow: transform', (t) => {
1818
t.transform('apply-arrow');
1919
t.end();
2020
});
21+
22+
test('putout: apply-arrow: no report: long', (t) => {
23+
t.noReport('long');
24+
t.end();
25+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function equal(a, b) {
2+
return a.type === b.type && a.value === b.value;
3+
}
4+

0 commit comments

Comments
 (0)