Skip to content

Commit 81b0381

Browse files
committed
fix: @putout/plugin-apply-arrow: no loc
1 parent 48dd374 commit 81b0381

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ function isToLong(__b, maxSize) {
5959
if (isBlockStatement(__b.body))
6060
return false;
6161

62-
if (__b.loc)
62+
if (__b.loc) {
6363
linesCount = __b.loc.end.line - __b.loc.start.line;
64-
65-
columnsCount = __b.loc.end.column - __b.loc.start.column;
64+
columnsCount = __b.loc.end.column - __b.loc.start.column;
65+
}
6666

6767
if (!__b.loc || linesCount) {
6868
const code = print(__b);

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const {createTest} = require('@putout/test');
44
const {operator} = require('putout');
55

66
const plugin = require('..');
7-
const {getTemplateValues} = operator;
7+
const {
8+
compare,
9+
getTemplateValues,
10+
} = operator;
811

912
const test = createTest(__dirname, {
1013
plugins: [
@@ -54,10 +57,15 @@ test('putout: apply-arrow: no report: no-loc', (t) => {
5457
noLoc: {
5558
report: () => '',
5659
fix: (path) => {
57-
const {__b} = getTemplateValues(path, FN);
60+
const {__b} = getTemplateValues(path.get('body.0.declaration'), FN);
61+
5862
delete __b.loc;
5963
},
60-
include: () => [FN],
64+
include: () => ['Program'],
65+
filter: (path) => {
66+
const fnPath = path.get('body.0.declaration');
67+
return compare(fnPath, FN);
68+
},
6169
},
6270
});
6371
t.end();
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export function equal(a, b) {
2-
return a.type === b.type && a.value === b.value;
3-
}
1+
export const equal = (a, b) => a.type === b.type;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export function equal(a, b) {
2-
return a.type === b.type && a.value === b.value;
2+
return a.type === b.type;
33
}
44

0 commit comments

Comments
 (0)