Skip to content

Reduced size of end-to-end test tslint.json rulesets #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ End-to-end tests that execute the `bin/tslint-to-eslint` command and validate ou
Each directory there contains:

- `test.ts`: Test file that runs `createTests(__dirname);` to set up tests in that directory
- `.eslintrc.json`: `.gitignore`d output from the most recent test run
- `expected.json`: Expected output ESLint configuration
- `.eslintrc.js`: `.gitignore`d output from the most recent test run
- `expected.txt`: Expected output ESLint configuration
- `stderr.txt`: Expected output written to the process `stderr`
- `stdout.txt`: Expected output written to the process `stdout`
- `tslint.json`: Original TSLint configuration file to convert
Expand Down
2 changes: 1 addition & 1 deletion test/createTestArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const readdir = promisify(fs.readdir);

export const createTestArgs = async (cwd: string, extraArgs: string[]) => {
const items = new Set(await readdir(cwd));
const flags = ["--config", path.join(cwd, ".eslintrc.json")];
const flags = ["--config", path.join(cwd, ".eslintrc.js")];

if (items.has("tslint.json")) {
flags.push("--tslint", path.join(cwd, "tslint.json"));
Expand Down
4 changes: 2 additions & 2 deletions test/createTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const binFile = path.join(__dirname, "../bin/tslint-to-eslint-config");

export const createTests = (
cwd: string,
{ eslint = "./.eslintrc.json", extraArgs = [] }: TestSettings = {},
{ eslint = "./.eslintrc.js", extraArgs = [] }: TestSettings = {},
) => {
const testName = path.basename(cwd);
const accept = "acceptTestChanges" in globalThis;
Expand All @@ -52,7 +52,7 @@ export const createTests = (
// Act
await act(testArgs);

await assertFileContents(cwdPath("expected.json"), await readTestFile(eslint), accept);
await assertFileContents(cwdPath("expected.txt"), await readTestFile(eslint), accept);
});

test("stderr", async () => {
Expand Down
22 changes: 22 additions & 0 deletions test/tests/custom eslint path/.eslintrc.custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [],
"rules": {
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-floating-promises": "error",
"previously-existing-rule": "warn",
},
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
]
};
84 changes: 0 additions & 84 deletions test/tests/custom eslint path/eslintrc.js

This file was deleted.

84 changes: 0 additions & 84 deletions test/tests/custom eslint path/expected.json

This file was deleted.

22 changes: 22 additions & 0 deletions test/tests/custom eslint path/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [],
"rules": {
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-floating-promises": "error",
"previously-existing-rule": "warn",
},
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
]
};
5 changes: 1 addition & 4 deletions test/tests/custom eslint path/stdout.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
✨ 19 rules replaced with their ESLint equivalents. ✨
️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀
⚡ 1 package is required for new ESLint rules. ⚡
unicorn
✨ 2 rules replaced with their ESLint equivalents. ✨
✅ All is well! ✅
4 changes: 2 additions & 2 deletions test/tests/custom eslint path/test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createTests } from "../../createTests";

const eslint = "./eslintrc.js";
const eslint = "./.eslintrc.custom.js";

createTests(__dirname, {
eslint,
extraArgs: ["--eslint", eslint],
extraArgs: ["--config", eslint, "--eslint", eslint],
});
2 changes: 0 additions & 2 deletions test/tests/custom eslint path/tslint-to-eslint-config.log
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
no-implicit-dependencies does not yet have an ESLint equivalent.
strict-boolean-expressions does not yet have an ESLint equivalent.
30 changes: 1 addition & 29 deletions test/tests/custom eslint path/tslint.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
{
"rules": {
"array-type": [true, "array"],
"arrow-return-shorthand": false,
"completed-docs": false,
"comment-format": false,
"file-name-casing": false,
"linebreak-style": false,
"interface-name": [true, "never-prefix"],
"member-ordering": false,
"newline-before-return": false,
"no-any": false,
"no-bitwise": false,
"no-empty": false,
"no-magic-numbers": false,
"no-import-side-effect": false,
"no-implicit-dependencies": [true, "dev"],
"no-null-keyword": false,
"no-parameter-reassignment": false,
"no-parameter-properties": false,
"no-submodule-imports": false,
"no-unbound-method": false,
"no-unused-variable": false,
"no-use-before-declare": false,
"prefer-conditional-expression": false,
"prefer-method-signature": false,
"prefer-switch": false,
"prefer-template": false,
"promise-function-async": false,
"strict-boolean-expressions": [true, "allow-boolean-or-undefined", "allow-number"],
"switch-default": false,
"switch-final-break": false,
"no-floating-promises": true,
"typedef": false
}
}
21 changes: 21 additions & 0 deletions test/tests/custom package path/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [],
"rules": {
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-floating-promises": "error"
},
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
]
};
31 changes: 0 additions & 31 deletions test/tests/custom package path/.eslintrc.json

This file was deleted.

Loading