eslint-plugin-ember-template-lint 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/lib/rules/hbs-worker.js +2 -2
- package/lib/rules/lint.js +1 -3
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# eslint-plugin-hbs-template
|
2
2
|
|
3
|
-
Provide linting (via [ember-template-lint](https://github.com/ember-template-lint/ember-template-lint)) for hbs templates files, template string literals and gts,gjs
|
3
|
+
Provide linting (via [ember-template-lint](https://github.com/ember-template-lint/ember-template-lint)) for hbs templates files, template string literals and gts,gjs (also enables eslint to run its other rules in gts/gjs)
|
4
4
|
* no extra config file needed
|
5
5
|
|
6
6
|
* no need to run extra tool for linting
|
package/lib/rules/hbs-worker.js
CHANGED
@@ -19,7 +19,7 @@ async function _applyFixes(options, results, columnOffset) {
|
|
19
19
|
|
20
20
|
let template = currentSource;
|
21
21
|
if (columnOffset) {
|
22
|
-
template = spaces + template.
|
22
|
+
template = spaces + template.replace(/\n([^\n])/g, '\n' + spaces + '$1');
|
23
23
|
}
|
24
24
|
const origDoc = new Document(template);
|
25
25
|
fixableIssues.forEach((r) => {
|
@@ -63,7 +63,7 @@ async function _applyFixes(options, results, columnOffset) {
|
|
63
63
|
}
|
64
64
|
const diffs = generateDifferences(template, code);
|
65
65
|
diffs.forEach((d) => {
|
66
|
-
d.range = [d.offset, d.offset + (d.deleteText?.length || 0)];
|
66
|
+
d.range = [d.offset - columnOffset, d.offset + (d.deleteText?.length || 0) - columnOffset];
|
67
67
|
});
|
68
68
|
fixableIssues.filter(r => r.rule === ruleName).forEach((r) => {
|
69
69
|
const range = r.range;
|
package/lib/rules/lint.js
CHANGED
@@ -27,8 +27,6 @@ function runTemplateLint(node, context) {
|
|
27
27
|
lintMessages.forEach((m) => {
|
28
28
|
if (m.fix) {
|
29
29
|
m.fix.forEach((fix) => {
|
30
|
-
const d = fix;
|
31
|
-
fix.range = [d.offset, d.offset + (d.deleteText?.length || 0)];
|
32
30
|
const start = originalDocument.offsetToPosition(fix.range[0]);
|
33
31
|
const end = originalDocument.offsetToPosition(fix.range[1]);
|
34
32
|
fix.range = [
|
@@ -41,7 +39,7 @@ function runTemplateLint(node, context) {
|
|
41
39
|
character: end.character
|
42
40
|
})
|
43
41
|
];
|
44
|
-
fix.range = fix.range.map(x => offset + x
|
42
|
+
fix.range = fix.range.map(x => offset + x);
|
45
43
|
});
|
46
44
|
}
|
47
45
|
m.range = [
|