eslint-plugin-ember-template-lint 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rules/hbs-worker.js +38 -1
- package/lib/rules/lint.js +1 -1
- package/package.json +1 -1
package/lib/rules/hbs-worker.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const { runAsWorker } = require('synckit');
|
2
|
-
const { generateDifferences } = require('prettier-linter-helpers');
|
2
|
+
const { generateDifferences, showInvisibles } = require('prettier-linter-helpers');
|
3
3
|
const Document = require('../utils/document');
|
4
4
|
|
5
5
|
async function _applyFixes(options, results, columnOffset) {
|
@@ -65,6 +65,43 @@ async function _applyFixes(options, results, columnOffset) {
|
|
65
65
|
diffs.forEach((d) => {
|
66
66
|
d.range = [d.offset - columnOffset, d.offset + (d.deleteText?.length || 0) - columnOffset];
|
67
67
|
});
|
68
|
+
if (ruleName === 'prettier') {
|
69
|
+
const { INSERT, DELETE, REPLACE } = generateDifferences;
|
70
|
+
let message;
|
71
|
+
results.length = 0;
|
72
|
+
diffs.forEach((d) => {
|
73
|
+
switch (d.operation) {
|
74
|
+
case INSERT:
|
75
|
+
message = `Insert \`${showInvisibles(
|
76
|
+
d.insertText
|
77
|
+
)}\``;
|
78
|
+
break;
|
79
|
+
case DELETE:
|
80
|
+
message = `Delete \`${showInvisibles(
|
81
|
+
d.deleteText
|
82
|
+
)}\``;
|
83
|
+
break;
|
84
|
+
case REPLACE:
|
85
|
+
message = `Replace \`${showInvisibles(
|
86
|
+
d.deleteText
|
87
|
+
)}\` with \`${showInvisibles(d.insertText)}\``;
|
88
|
+
break;
|
89
|
+
}
|
90
|
+
const { line, character: column } = origDoc.offsetToPosition(d.offset-columnOffset);
|
91
|
+
const { line: endLine, character: endColumn } = origDoc.offsetToPosition(d.offset + (d.deleteText?.length || 0)-columnOffset);
|
92
|
+
results.push({
|
93
|
+
isFixable: true,
|
94
|
+
rule: ruleName,
|
95
|
+
message,
|
96
|
+
line: line + 1,
|
97
|
+
column,
|
98
|
+
endLine: endLine + 1,
|
99
|
+
endColumn,
|
100
|
+
fix: [d]
|
101
|
+
});
|
102
|
+
});
|
103
|
+
return;
|
104
|
+
}
|
68
105
|
fixableIssues.filter(r => r.rule === ruleName).forEach((r) => {
|
69
106
|
const range = r.range;
|
70
107
|
r.fix = diffs.filter(d => diffContained(d, range) || diffIntersect(d, range));
|
package/lib/rules/lint.js
CHANGED