Skip to content

Commit 684af92

Browse files
authored
Fixes issue where todos were deleted from a different engine (#86)
1 parent fbd267d commit 684af92

File tree

7 files changed

+138
-66
lines changed

7 files changed

+138
-66
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"errorCount": 1,
3+
"results": [
4+
{
5+
"messages": [
6+
{
7+
"rule": "require-input-label",
8+
"severity": 2,
9+
"moduleId": "{{path}}/app/templates/components/add-ssh-key.hbs",
10+
"message": "Input elements require a valid associated label.",
11+
"line": 3,
12+
"column": 4,
13+
"source": ""
14+
}
15+
],
16+
"errorCount": 1,
17+
"filePath": "{{path}}/app/templates/components/add-ssh-key.hbs",
18+
"source": ""
19+
}
20+
]
21+
}

__tests__/__utils__/get-fixture.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { join, resolve } from 'path';
2+
import { ESLint } from 'eslint';
3+
import { readFileSync, readJsonSync } from 'fs-extra';
4+
import { TemplateLintResult } from '@ember-template-lint/todo-utils';
5+
6+
const cache: Map<string, string> = new Map();
7+
8+
export function getStringFixture(fileName: string): string {
9+
if (cache.has(fileName)) {
10+
return cache.get(fileName) || '';
11+
}
12+
13+
const contents = readFileSync(
14+
require.resolve(join('../__fixtures__/', fileName)),
15+
{
16+
encoding: 'utf8',
17+
}
18+
);
19+
20+
cache.set(fileName, contents);
21+
22+
return contents;
23+
}
24+
25+
export function getObjectFixture<
26+
T extends ESLint.LintResult | TemplateLintResult
27+
>(fileName: string, tmp: string): T[] {
28+
const fixture = readJsonSync(
29+
resolve(join('./__tests__/__fixtures__/', fileName))
30+
);
31+
32+
return updatePaths(
33+
tmp,
34+
fixture.hasOwnProperty('results') ? fixture.results : fixture
35+
);
36+
}
37+
38+
function updatePaths<T extends { filePath: string }>(
39+
path: string,
40+
data: T[]
41+
): T[] {
42+
data.forEach((d) => (d.filePath = d.filePath.replace('{{path}}', path)));
43+
44+
return data;
45+
}

__tests__/__utils__/read-file-cached.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)