diff --git a/docs/Testing.md b/docs/Testing.md index b75bd5fa6..2afdb86b2 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -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 diff --git a/test/createTestArgs.ts b/test/createTestArgs.ts index 84efb2306..7bb872156 100644 --- a/test/createTestArgs.ts +++ b/test/createTestArgs.ts @@ -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")); diff --git a/test/createTests.ts b/test/createTests.ts index 8fa598c31..114b358d1 100644 --- a/test/createTests.ts +++ b/test/createTests.ts @@ -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; @@ -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 () => { diff --git a/test/tests/custom eslint path/.eslintrc.custom.js b/test/tests/custom eslint path/.eslintrc.custom.js new file mode 100644 index 000000000..6e37da782 --- /dev/null +++ b/test/tests/custom eslint path/.eslintrc.custom.js @@ -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" + ] +}; diff --git a/test/tests/custom eslint path/eslintrc.js b/test/tests/custom eslint path/eslintrc.js deleted file mode 100644 index 67cd63656..000000000 --- a/test/tests/custom eslint path/eslintrc.js +++ /dev/null @@ -1,84 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-template": "off", - "unicorn/filename-case": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - }, - "globals": {}, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "settings": { - "import/resolver": { - "node": { - "extensions": [ - ".mjs", - ".js", - ".json" - ] - } - }, - "import/extensions": [ - ".js", - ".mjs", - ".jsx" - ], - "import/core-modules": [], - "import/ignore": [ - "node_modules", - "\\.(coffee|scss|css|less|hbs|svg|json)$" - ] - } -}; diff --git a/test/tests/custom eslint path/expected.json b/test/tests/custom eslint path/expected.json deleted file mode 100644 index 67cd63656..000000000 --- a/test/tests/custom eslint path/expected.json +++ /dev/null @@ -1,84 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-template": "off", - "unicorn/filename-case": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - }, - "globals": {}, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "settings": { - "import/resolver": { - "node": { - "extensions": [ - ".mjs", - ".js", - ".json" - ] - } - }, - "import/extensions": [ - ".js", - ".mjs", - ".jsx" - ], - "import/core-modules": [], - "import/ignore": [ - "node_modules", - "\\.(coffee|scss|css|less|hbs|svg|json)$" - ] - } -}; diff --git a/test/tests/custom eslint path/expected.txt b/test/tests/custom eslint path/expected.txt new file mode 100644 index 000000000..6e37da782 --- /dev/null +++ b/test/tests/custom eslint path/expected.txt @@ -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" + ] +}; diff --git a/test/tests/custom eslint path/stdout.txt b/test/tests/custom eslint path/stdout.txt index 5b5f91fc5..e472c978c 100644 --- a/test/tests/custom eslint path/stdout.txt +++ b/test/tests/custom eslint path/stdout.txt @@ -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! ✅ diff --git a/test/tests/custom eslint path/test.ts b/test/tests/custom eslint path/test.ts index 31c11e9b1..104d223e5 100644 --- a/test/tests/custom eslint path/test.ts +++ b/test/tests/custom eslint path/test.ts @@ -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], }); \ No newline at end of file diff --git a/test/tests/custom eslint path/tslint-to-eslint-config.log b/test/tests/custom eslint path/tslint-to-eslint-config.log index f76acb2ca..e69de29bb 100644 --- a/test/tests/custom eslint path/tslint-to-eslint-config.log +++ b/test/tests/custom eslint path/tslint-to-eslint-config.log @@ -1,2 +0,0 @@ -no-implicit-dependencies does not yet have an ESLint equivalent. -strict-boolean-expressions does not yet have an ESLint equivalent. diff --git a/test/tests/custom eslint path/tslint.json b/test/tests/custom eslint path/tslint.json index 4a2aa47f4..6cc0aa010 100644 --- a/test/tests/custom eslint path/tslint.json +++ b/test/tests/custom eslint path/tslint.json @@ -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 } } diff --git a/test/tests/custom package path/.eslintrc.js b/test/tests/custom package path/.eslintrc.js new file mode 100644 index 000000000..b6b6646c4 --- /dev/null +++ b/test/tests/custom package path/.eslintrc.js @@ -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" + ] +}; diff --git a/test/tests/custom package path/.eslintrc.json b/test/tests/custom package path/.eslintrc.json deleted file mode 100644 index 06585f8f1..000000000 --- a/test/tests/custom package path/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - env: { - es6: true, - node: true, - }, - parser: "@typescript-eslint/parser", - parserOptions: { - project: "tsconfig.json", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "@typescript-eslint/tslint"], - rules: { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - rules: { - "no-implicit-dependencies": [true, "dev"], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number", - ], - }, - }, - ], - }, -}; diff --git a/test/tests/custom package path/eslintrc.js b/test/tests/custom package path/eslintrc.js deleted file mode 100644 index 04c4b5f7e..000000000 --- a/test/tests/custom package path/eslintrc.js +++ /dev/null @@ -1,61 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-template": "off", - "unicorn/filename-case": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -}; diff --git a/test/tests/custom package path/expected.json b/test/tests/custom package path/expected.json deleted file mode 100644 index 06585f8f1..000000000 --- a/test/tests/custom package path/expected.json +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - env: { - es6: true, - node: true, - }, - parser: "@typescript-eslint/parser", - parserOptions: { - project: "tsconfig.json", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "@typescript-eslint/tslint"], - rules: { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - rules: { - "no-implicit-dependencies": [true, "dev"], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number", - ], - }, - }, - ], - }, -}; diff --git a/test/tests/custom package path/expected.txt b/test/tests/custom package path/expected.txt new file mode 100644 index 000000000..b6b6646c4 --- /dev/null +++ b/test/tests/custom package path/expected.txt @@ -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" + ] +}; diff --git a/test/tests/custom package path/stdout.txt b/test/tests/custom package path/stdout.txt index 5b5f91fc5..e472c978c 100644 --- a/test/tests/custom package path/stdout.txt +++ b/test/tests/custom package path/stdout.txt @@ -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! ✅ diff --git a/test/tests/custom package path/tslint-to-eslint-config.log b/test/tests/custom package path/tslint-to-eslint-config.log index f76acb2ca..e69de29bb 100644 --- a/test/tests/custom package path/tslint-to-eslint-config.log +++ b/test/tests/custom package path/tslint-to-eslint-config.log @@ -1,2 +0,0 @@ -no-implicit-dependencies does not yet have an ESLint equivalent. -strict-boolean-expressions does not yet have an ESLint equivalent. diff --git a/test/tests/custom package path/tslint.json b/test/tests/custom package path/tslint.json index 4a2aa47f4..6cc0aa010 100644 --- a/test/tests/custom package path/tslint.json +++ b/test/tests/custom package path/tslint.json @@ -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 } } diff --git a/test/tests/custom typescript path/.eslintrc.js b/test/tests/custom typescript path/.eslintrc.js new file mode 100644 index 000000000..2370864a3 --- /dev/null +++ b/test/tests/custom typescript path/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + "env": { + "browser": 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" + ], +}; diff --git a/test/tests/custom typescript path/.eslintrc.json b/test/tests/custom typescript path/.eslintrc.json deleted file mode 100644 index 3dc1ec1c1..000000000 --- a/test/tests/custom typescript path/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - env: { - browser: true, - node: true, - }, - parser: "@typescript-eslint/parser", - parserOptions: { - project: "tsconfig.json", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "@typescript-eslint/tslint"], - rules: { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - rules: { - "no-implicit-dependencies": [true, "dev"], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number", - ], - }, - }, - ], - }, -}; diff --git a/test/tests/custom typescript path/eslintrc.js b/test/tests/custom typescript path/eslintrc.js deleted file mode 100644 index 1727af53d..000000000 --- a/test/tests/custom typescript path/eslintrc.js +++ /dev/null @@ -1,60 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-template": "off", - "unicorn/filename-case": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -}; diff --git a/test/tests/custom typescript path/expected.json b/test/tests/custom typescript path/expected.json deleted file mode 100644 index 3dc1ec1c1..000000000 --- a/test/tests/custom typescript path/expected.json +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - env: { - browser: true, - node: true, - }, - parser: "@typescript-eslint/parser", - parserOptions: { - project: "tsconfig.json", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "@typescript-eslint/tslint"], - rules: { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - rules: { - "no-implicit-dependencies": [true, "dev"], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number", - ], - }, - }, - ], - }, -}; diff --git a/test/tests/custom typescript path/expected.txt b/test/tests/custom typescript path/expected.txt new file mode 100644 index 000000000..ab8873da6 --- /dev/null +++ b/test/tests/custom typescript path/expected.txt @@ -0,0 +1,20 @@ +module.exports = { + "env": { + "browser": 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" + ] +}; diff --git a/test/tests/custom typescript path/stdout.txt b/test/tests/custom typescript path/stdout.txt index 5b5f91fc5..e472c978c 100644 --- a/test/tests/custom typescript path/stdout.txt +++ b/test/tests/custom typescript path/stdout.txt @@ -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! ✅ diff --git a/test/tests/custom typescript path/tslint-to-eslint-config.log b/test/tests/custom typescript path/tslint-to-eslint-config.log index f76acb2ca..e69de29bb 100644 --- a/test/tests/custom typescript path/tslint-to-eslint-config.log +++ b/test/tests/custom typescript path/tslint-to-eslint-config.log @@ -1,2 +0,0 @@ -no-implicit-dependencies does not yet have an ESLint equivalent. -strict-boolean-expressions does not yet have an ESLint equivalent. diff --git a/test/tests/custom typescript path/tslint.json b/test/tests/custom typescript path/tslint.json index 4a2aa47f4..6cc0aa010 100644 --- a/test/tests/custom typescript path/tslint.json +++ b/test/tests/custom typescript path/tslint.json @@ -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 } } diff --git a/test/tests/missing tslint.json/.eslintrc.js b/test/tests/missing tslint.json/.eslintrc.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/test/tests/missing tslint.json/.eslintrc.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/tests/missing tslint.json/.eslintrc.json b/test/tests/missing tslint.json/.eslintrc.json deleted file mode 100644 index 79186a52c..000000000 --- a/test/tests/missing tslint.json/.eslintrc.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "env": { - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/test/tests/missing tslint.json/expected.json b/test/tests/missing tslint.json/expected.json deleted file mode 100644 index 79186a52c..000000000 --- a/test/tests/missing tslint.json/expected.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "env": { - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/test/tests/missing tslint.json/expected.txt b/test/tests/missing tslint.json/expected.txt new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/test/tests/missing tslint.json/expected.txt @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/tests/rule notices/.eslintrc.js b/test/tests/rule notices/.eslintrc.js new file mode 100644 index 000000000..19c2be0ed --- /dev/null +++ b/test/tests/rule notices/.eslintrc.js @@ -0,0 +1,22 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "max-classes-per-file": [ + "error", + "exclude-class-expressions" + ], + "no-caller": "error" + } +}; diff --git a/test/tests/rule notices/expected.txt b/test/tests/rule notices/expected.txt new file mode 100644 index 000000000..19c2be0ed --- /dev/null +++ b/test/tests/rule notices/expected.txt @@ -0,0 +1,22 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "max-classes-per-file": [ + "error", + "exclude-class-expressions" + ], + "no-caller": "error" + } +}; diff --git a/test/tests/rule notices/stderr.txt b/test/tests/rule notices/stderr.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/tests/rule notices/stdout.txt b/test/tests/rule notices/stdout.txt new file mode 100644 index 000000000..9772882e0 --- /dev/null +++ b/test/tests/rule notices/stdout.txt @@ -0,0 +1,5 @@ +✨ 2 rules replaced with their ESLint equivalents. ✨ +📢 1 ESLint rule behaves differently from their TSLint counterparts: 📢 +* max-classes-per-file: + - Class expressions will no longer be ignored. +✅ All is well! ✅ diff --git a/test/tests/rule notices/test.ts b/test/tests/rule notices/test.ts new file mode 100644 index 000000000..1749a97ae --- /dev/null +++ b/test/tests/rule notices/test.ts @@ -0,0 +1,3 @@ +import { createTests } from "../../createTests"; + +createTests(__dirname); \ No newline at end of file diff --git a/test/tests/rule notices/tslint-to-eslint-config.log b/test/tests/rule notices/tslint-to-eslint-config.log new file mode 100644 index 000000000..e69de29bb diff --git a/test/tests/rule notices/tslint.json b/test/tests/rule notices/tslint.json new file mode 100644 index 000000000..945857242 --- /dev/null +++ b/test/tests/rule notices/tslint.json @@ -0,0 +1,6 @@ +{ + "rules": { + "max-classes-per-file": [true, "exclude-class-expressions"], + "no-arg": true + } +} diff --git a/test/tests/standalone tslint.json/.eslintrc.js b/test/tests/standalone tslint.json/.eslintrc.js new file mode 100644 index 000000000..b6b6646c4 --- /dev/null +++ b/test/tests/standalone tslint.json/.eslintrc.js @@ -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" + ] +}; diff --git a/test/tests/standalone tslint.json/.eslintrc.json b/test/tests/standalone tslint.json/.eslintrc.json deleted file mode 100644 index 79186a52c..000000000 --- a/test/tests/standalone tslint.json/.eslintrc.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "env": { - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/test/tests/standalone tslint.json/eslintrc.js b/test/tests/standalone tslint.json/eslintrc.js deleted file mode 100644 index d0a220fc6..000000000 --- a/test/tests/standalone tslint.json/eslintrc.js +++ /dev/null @@ -1,62 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "import/no-default-export": "error", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-template": "off", - "unicorn/filename-case": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -}; diff --git a/test/tests/standalone tslint.json/expected.json b/test/tests/standalone tslint.json/expected.json deleted file mode 100644 index 79186a52c..000000000 --- a/test/tests/standalone tslint.json/expected.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "env": { - "es6": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint", - "@typescript-eslint/tslint" - ], - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/interface-name-prefix": "error", - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-param-reassign": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/promise-function-async": "off", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "off", - "default-case": "off", - "linebreak-style": "off", - "no-bitwise": "off", - "no-empty": "off", - "no-magic-numbers": "off", - "prefer-template": "off", - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "no-implicit-dependencies": [ - true, - "dev" - ], - "strict-boolean-expressions": [ - true, - "allow-boolean-or-undefined", - "allow-number" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/test/tests/standalone tslint.json/expected.txt b/test/tests/standalone tslint.json/expected.txt new file mode 100644 index 000000000..b6b6646c4 --- /dev/null +++ b/test/tests/standalone tslint.json/expected.txt @@ -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" + ] +}; diff --git a/test/tests/standalone tslint.json/stdout.txt b/test/tests/standalone tslint.json/stdout.txt index 8e8acdb02..e472c978c 100644 --- a/test/tests/standalone tslint.json/stdout.txt +++ b/test/tests/standalone tslint.json/stdout.txt @@ -1,6 +1,2 @@ -✨ 20 rules replaced with their ESLint equivalents. ✨ -️👀 2 rules do not yet have ESLint equivalents; defaulting to eslint-plugin-tslint. 👀 -⚡ 2 packages are required for new ESLint rules. ⚡ - unicorn - import +✨ 2 rules replaced with their ESLint equivalents. ✨ ✅ All is well! ✅ diff --git a/test/tests/standalone tslint.json/tslint-to-eslint-config.log b/test/tests/standalone tslint.json/tslint-to-eslint-config.log index f76acb2ca..e69de29bb 100644 --- a/test/tests/standalone tslint.json/tslint-to-eslint-config.log +++ b/test/tests/standalone tslint.json/tslint-to-eslint-config.log @@ -1,2 +0,0 @@ -no-implicit-dependencies does not yet have an ESLint equivalent. -strict-boolean-expressions does not yet have an ESLint equivalent. diff --git a/test/tests/standalone tslint.json/tslint.json b/test/tests/standalone tslint.json/tslint.json index 948d7c3fa..6cc0aa010 100644 --- a/test/tests/standalone tslint.json/tslint.json +++ b/test/tests/standalone tslint.json/tslint.json @@ -1,36 +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-default-export": true, - "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 } } diff --git a/test/tests/unknown rule/.eslintrc.js b/test/tests/unknown rule/.eslintrc.js new file mode 100644 index 000000000..3b1477b49 --- /dev/null +++ b/test/tests/unknown rule/.eslintrc.js @@ -0,0 +1,26 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint", + "@typescript-eslint/tslint" + ], + "rules": { + "@typescript-eslint/tslint/config": [ + "error", + { + "rules": { + "this-definitely-does-not-exist": true + } + } + ] + } +}; diff --git a/test/tests/unknown rule/expected.txt b/test/tests/unknown rule/expected.txt new file mode 100644 index 000000000..3b1477b49 --- /dev/null +++ b/test/tests/unknown rule/expected.txt @@ -0,0 +1,26 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint", + "@typescript-eslint/tslint" + ], + "rules": { + "@typescript-eslint/tslint/config": [ + "error", + { + "rules": { + "this-definitely-does-not-exist": true + } + } + ] + } +}; diff --git a/test/tests/unknown rule/stderr.txt b/test/tests/unknown rule/stderr.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/tests/unknown rule/stdout.txt b/test/tests/unknown rule/stdout.txt new file mode 100644 index 000000000..0827cf75e --- /dev/null +++ b/test/tests/unknown rule/stdout.txt @@ -0,0 +1,2 @@ +️👀 1 rule does not yet have an ESLint equivalent; defaulting to eslint-plugin-tslint. 👀 +✅ All is well! ✅ diff --git a/test/tests/unknown rule/test.ts b/test/tests/unknown rule/test.ts new file mode 100644 index 000000000..1749a97ae --- /dev/null +++ b/test/tests/unknown rule/test.ts @@ -0,0 +1,3 @@ +import { createTests } from "../../createTests"; + +createTests(__dirname); \ No newline at end of file diff --git a/test/tests/unknown rule/tslint-to-eslint-config.log b/test/tests/unknown rule/tslint-to-eslint-config.log new file mode 100644 index 000000000..c7eff6b6b --- /dev/null +++ b/test/tests/unknown rule/tslint-to-eslint-config.log @@ -0,0 +1 @@ +this-definitely-does-not-exist does not yet have an ESLint equivalent. diff --git a/test/tests/unknown rule/tslint.json b/test/tests/unknown rule/tslint.json new file mode 100644 index 000000000..e88c90f1a --- /dev/null +++ b/test/tests/unknown rule/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "this-definitely-does-not-exist": true + } +}