Skip to content

Commit 61f77c6

Browse files
author
Josh Goldberg
authored
Added, corrected end-to-end tests for TypeScript config paths (#134)
Tests were failing previously for not having the right `cwd` set in the executing command. Changed that in `runTests.ts` and voila!, they're all running correctly now! Hooray.
1 parent 48e42f8 commit 61f77c6

File tree

18 files changed

+371
-53
lines changed

18 files changed

+371
-53
lines changed

test/createTests.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ export type TestSettings = {
2323

2424
jest.setTimeout(10000);
2525

26-
const act = async (testArgs: string[]) => {
27-
try {
28-
return await exec(`ts-node bin/tslint-to-eslint-config ${testArgs.join(" ")}`);
29-
} catch (error) {
30-
return error;
31-
}
32-
};
26+
const binFile = path.join(__dirname, "../bin/tslint-to-eslint-config");
3327

3428
export const createTests = (
3529
cwd: string,
@@ -40,6 +34,16 @@ export const createTests = (
4034
const cwdPath = (fileName: string) => path.join(cwd, fileName);
4135
const readTestFile = async (fileName: string) => (await readFile(cwdPath(fileName))).toString();
4236

37+
const act = async (testArgs: string[]) => {
38+
try {
39+
return await exec(`ts-node ${binFile} ${testArgs.join(" ")}`, {
40+
cwd,
41+
});
42+
} catch (error) {
43+
return error;
44+
}
45+
};
46+
4347
describe(testName, () => {
4448
test("configuration output", async () => {
4549
// Arrange
Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,74 @@
11
module.exports = {
2-
env: {
3-
es6: true,
4-
node: true,
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
56
},
6-
parser: "@typescript-eslint/parser",
7-
parserOptions: {
8-
project: "tsconfig.json",
9-
sourceType: "module",
10-
},
11-
plugins: ["@typescript-eslint", "@typescript-eslint/tslint"],
12-
rules: {
7+
"extends": [],
8+
"rules": {
139
"@typescript-eslint/array-type": "error",
1410
"@typescript-eslint/interface-name-prefix": "error",
11+
"@typescript-eslint/member-ordering": "off",
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"@typescript-eslint/no-param-reassign": "off",
14+
"@typescript-eslint/no-parameter-properties": "off",
15+
"@typescript-eslint/no-use-before-declare": "off",
16+
"@typescript-eslint/promise-function-async": "off",
17+
"@typescript-eslint/unbound-method": "off",
18+
"arrow-body-style": "off",
19+
"default-case": "off",
20+
"linebreak-style": "off",
21+
"no-bitwise": "off",
22+
"no-empty": "off",
23+
"no-empty-functions": "off",
1524
"no-magic-numbers": "off",
1625
"prefer-template": "off",
1726
"@typescript-eslint/tslint/config": [
1827
"error",
1928
{
20-
rules: {
21-
"no-implicit-dependencies": [true, "dev"],
29+
"rules": {
30+
"no-implicit-dependencies": [
31+
true,
32+
"dev"
33+
],
2234
"strict-boolean-expressions": [
2335
true,
2436
"allow-boolean-or-undefined",
25-
"allow-number",
26-
],
27-
},
28-
},
29-
],
37+
"allow-number"
38+
]
39+
}
40+
}
41+
]
42+
},
43+
"globals": {},
44+
"parser": "@typescript-eslint/parser",
45+
"parserOptions": {
46+
"project": "tsconfig.json",
47+
"sourceType": "module"
3048
},
49+
"plugins": [
50+
"@typescript-eslint",
51+
"@typescript-eslint/tslint"
52+
],
53+
"settings": {
54+
"import/resolver": {
55+
"node": {
56+
"extensions": [
57+
".mjs",
58+
".js",
59+
".json"
60+
]
61+
}
62+
},
63+
"import/extensions": [
64+
".js",
65+
".mjs",
66+
".jsx"
67+
],
68+
"import/core-modules": [],
69+
"import/ignore": [
70+
"node_modules",
71+
"\\.(coffee|scss|css|less|hbs|svg|json)$"
72+
]
73+
}
3174
};
Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,74 @@
11
module.exports = {
2-
env: {
3-
es6: true,
4-
node: true,
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
56
},
6-
parser: "@typescript-eslint/parser",
7-
parserOptions: {
8-
project: "tsconfig.json",
9-
sourceType: "module",
10-
},
11-
plugins: ["@typescript-eslint", "@typescript-eslint/tslint"],
12-
rules: {
7+
"extends": [],
8+
"rules": {
139
"@typescript-eslint/array-type": "error",
1410
"@typescript-eslint/interface-name-prefix": "error",
11+
"@typescript-eslint/member-ordering": "off",
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"@typescript-eslint/no-param-reassign": "off",
14+
"@typescript-eslint/no-parameter-properties": "off",
15+
"@typescript-eslint/no-use-before-declare": "off",
16+
"@typescript-eslint/promise-function-async": "off",
17+
"@typescript-eslint/unbound-method": "off",
18+
"arrow-body-style": "off",
19+
"default-case": "off",
20+
"linebreak-style": "off",
21+
"no-bitwise": "off",
22+
"no-empty": "off",
23+
"no-empty-functions": "off",
1524
"no-magic-numbers": "off",
1625
"prefer-template": "off",
1726
"@typescript-eslint/tslint/config": [
1827
"error",
1928
{
20-
rules: {
21-
"no-implicit-dependencies": [true, "dev"],
29+
"rules": {
30+
"no-implicit-dependencies": [
31+
true,
32+
"dev"
33+
],
2234
"strict-boolean-expressions": [
2335
true,
2436
"allow-boolean-or-undefined",
25-
"allow-number",
26-
],
27-
},
28-
},
29-
],
37+
"allow-number"
38+
]
39+
}
40+
}
41+
]
42+
},
43+
"globals": {},
44+
"parser": "@typescript-eslint/parser",
45+
"parserOptions": {
46+
"project": "tsconfig.json",
47+
"sourceType": "module"
3048
},
49+
"plugins": [
50+
"@typescript-eslint",
51+
"@typescript-eslint/tslint"
52+
],
53+
"settings": {
54+
"import/resolver": {
55+
"node": {
56+
"extensions": [
57+
".mjs",
58+
".js",
59+
".json"
60+
]
61+
}
62+
},
63+
"import/extensions": [
64+
".js",
65+
".mjs",
66+
".jsx"
67+
],
68+
"import/core-modules": [],
69+
"import/ignore": [
70+
"node_modules",
71+
"\\.(coffee|scss|css|less|hbs|svg|json)$"
72+
]
73+
}
3174
};
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
❌ Could not start tslint-to-eslint: ❌
2-
Command failed: tslint --print-config "./tslint.json"
3-
Could not find configuration path. Try passing a --config to your tslint.json.
4-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
✨ 17 rules replaced with their ESLint equivalents. ✨
2+
️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀
3+
✅ All is well! ✅
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"project": "tsconfig.json",
10+
"sourceType": "module"
11+
},
12+
"plugins": [
13+
"@typescript-eslint",
14+
"@typescript-eslint/tslint"
15+
],
16+
"rules": {
17+
"@typescript-eslint/array-type": "error",
18+
"@typescript-eslint/interface-name-prefix": "error",
19+
"@typescript-eslint/member-ordering": "off",
20+
"@typescript-eslint/no-explicit-any": "off",
21+
"@typescript-eslint/no-param-reassign": "off",
22+
"@typescript-eslint/no-parameter-properties": "off",
23+
"@typescript-eslint/no-use-before-declare": "off",
24+
"@typescript-eslint/promise-function-async": "off",
25+
"@typescript-eslint/unbound-method": "off",
26+
"arrow-body-style": "off",
27+
"default-case": "off",
28+
"linebreak-style": "off",
29+
"no-bitwise": "off",
30+
"no-empty": "off",
31+
"no-empty-functions": "off",
32+
"no-magic-numbers": "off",
33+
"prefer-template": "off",
34+
"@typescript-eslint/tslint/config": [
35+
"error",
36+
{
37+
"rules": {
38+
"no-implicit-dependencies": [
39+
true,
40+
"dev"
41+
],
42+
"strict-boolean-expressions": [
43+
true,
44+
"allow-boolean-or-undefined",
45+
"allow-number"
46+
]
47+
}
48+
}
49+
]
50+
}
51+
};
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
❌ Could not start tslint-to-eslint: ❌
2-
Command failed: tslint --print-config "./tslint.json"
3-
Could not find configuration path. Try passing a --config to your tslint.json.
4-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
✨ 17 rules replaced with their ESLint equivalents. ✨
2+
️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀
3+
✅ All is well! ✅
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"node": true
5+
},
6+
"parser": "@typescript-eslint/parser",
7+
"parserOptions": {
8+
"project": "tsconfig.json",
9+
"sourceType": "module"
10+
},
11+
"plugins": [
12+
"@typescript-eslint",
13+
"@typescript-eslint/tslint"
14+
],
15+
"rules": {
16+
"@typescript-eslint/array-type": "error",
17+
"@typescript-eslint/interface-name-prefix": "error",
18+
"@typescript-eslint/member-ordering": "off",
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/no-param-reassign": "off",
21+
"@typescript-eslint/no-parameter-properties": "off",
22+
"@typescript-eslint/no-use-before-declare": "off",
23+
"@typescript-eslint/promise-function-async": "off",
24+
"@typescript-eslint/unbound-method": "off",
25+
"arrow-body-style": "off",
26+
"default-case": "off",
27+
"linebreak-style": "off",
28+
"no-bitwise": "off",
29+
"no-empty": "off",
30+
"no-empty-functions": "off",
31+
"no-magic-numbers": "off",
32+
"prefer-template": "off",
33+
"@typescript-eslint/tslint/config": [
34+
"error",
35+
{
36+
"rules": {
37+
"no-implicit-dependencies": [
38+
true,
39+
"dev"
40+
],
41+
"strict-boolean-expressions": [
42+
true,
43+
"allow-boolean-or-undefined",
44+
"allow-number"
45+
]
46+
}
47+
}
48+
]
49+
}
50+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
node: true,
5+
},
6+
parser: "@typescript-eslint/parser",
7+
parserOptions: {
8+
project: "tsconfig.json",
9+
sourceType: "module",
10+
},
11+
plugins: ["@typescript-eslint", "@typescript-eslint/tslint"],
12+
rules: {
13+
"@typescript-eslint/array-type": "error",
14+
"@typescript-eslint/interface-name-prefix": "error",
15+
"no-magic-numbers": "off",
16+
"prefer-template": "off",
17+
"@typescript-eslint/tslint/config": [
18+
"error",
19+
{
20+
rules: {
21+
"no-implicit-dependencies": [true, "dev"],
22+
"strict-boolean-expressions": [
23+
true,
24+
"allow-boolean-or-undefined",
25+
"allow-number",
26+
],
27+
},
28+
},
29+
],
30+
},
31+
};

test/tests/custom typescript path/stderr.txt

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
✨ 17 rules replaced with their ESLint equivalents. ✨
2+
️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀
3+
✅ All is well! ✅
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createTests } from "../../createTests";
2+
3+
createTests(__dirname, {
4+
extraArgs: ["--typescript", "./tsconfig.custom.json"],
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["dom"]
4+
}
5+
}

0 commit comments

Comments
 (0)