Skip to content

Commit 041ae72

Browse files
committed
fix: Ensuring we pass node and/or line, column, endLine, endColumn to log
1 parent 6c4cc03 commit 041ae72

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/rules/prettier.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ module.exports = class Prettier extends Rule {
9090

9191
this.log({
9292
message,
93+
// As of [email protected], passing line and column whose values match the
94+
// reference node's line and column isn't required (it uses the node's line/column).
95+
// In order to support older versions (> 3.8.0), we're keeping these properties here.
9396
line: node.loc && node.loc.start.line,
9497
column: node.loc && node.loc.start.column,
98+
node,
9599
source,
96100
});
97101

@@ -131,7 +135,15 @@ module.exports = class Prettier extends Rule {
131135
break;
132136
}
133137

134-
this.log({ message, line, column, source, isFixable: true });
138+
this.log({
139+
message,
140+
line,
141+
column,
142+
endLine: line,
143+
endColumn: column,
144+
source,
145+
isFixable: true,
146+
});
135147
});
136148
}
137149
},

test/unit/rules/lint-prettier-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ test
3434
message: "Delete `⏎`",
3535
line: 1,
3636
column: 34,
37+
endLine: 1,
38+
endColumn: 34,
3739
source: "{{#my-component}}{{/my-component}}\n",
3840
isFixable: true,
3941
},
@@ -50,6 +52,8 @@ test
5052
message: 'Replace `⏎·data-bar="lol"⏎·····` with ` data-bar="lol"`',
5153
line: 1,
5254
column: 13,
55+
endLine: 1,
56+
endColumn: 13,
5357
source: `<div data-foo
5458
data-bar="lol"
5559
some-other-thing={{haha-morethaneightychars}}>
@@ -65,6 +69,8 @@ test
6569
message: "Delete `⏎`",
6670
line: 1,
6771
column: 4,
72+
endLine: 1,
73+
endColumn: 4,
6874
source: "test\n",
6975
isFixable: true,
7076
},
@@ -85,6 +91,8 @@ test
8591
message: "Insert `··`",
8692
line: 2,
8793
column: 1,
94+
endLine: 2,
95+
endColumn: 1,
8896
source: "{{#my-component}}\n\ntest\n\n{{/my-component}}",
8997
isFixable: true,
9098
},
@@ -103,6 +111,8 @@ test
103111
message: "Delete `·`",
104112
line: 2,
105113
column: 6,
114+
endLine: 2,
115+
endColumn: 6,
106116
source:
107117
'{{#my-component class="class1 class2"}}\n test \n\n{{/my-component}}',
108118
isFixable: true,

0 commit comments

Comments
 (0)