Skip to content

Commit

Permalink
feat(typescript): enable rules requiring type info (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous authored May 7, 2020
1 parent 4ce0b61 commit ae57e07
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
58 changes: 26 additions & 32 deletions rules/plugins/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,50 @@ module.exports = {
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier/@typescript-eslint",
],

rules: {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/class-literal-property-style": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"default-param-last": "off",
"@typescript-eslint/default-param-last": "error", // eslint-disable-line sort-keys
"@typescript-eslint/dot-notation": "off",
"dot-notation": "off",
"@typescript-eslint/dot-notation": "error", // eslint-disable-line sort-keys
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
"@typescript-eslint/explicit-module-boundary-types": "warn",
"@typescript-eslint/init-declarations": "off",
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-base-to-string": "error",
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": "error", // eslint-disable-line sort-keys
"@typescript-eslint/no-dynamic-delete": "warn",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-for-in-array": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-invalid-this": "off",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-type-alias": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unnecessary-qualifier": "off",
"@typescript-eslint/no-unnecessary-type-arguments": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-qualifier": "warn",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-return": "error",
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "error", // eslint-disable-line sort-keys
"@typescript-eslint/no-unused-vars-experimental": "off",
Expand All @@ -56,25 +54,21 @@ module.exports = {
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-includes": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/prefer-readonly": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/prefer-reduce-type-parameter": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/prefer-readonly-parameter-types": "warn",
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
"@typescript-eslint/prefer-ts-expect-error": "off",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/require-array-sort-compare": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/return-await": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/switch-exhaustiveness-check": "off",
"@typescript-eslint/promise-function-async": "warn",
"@typescript-eslint/require-array-sort-compare": "warn",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/restrict-template-expressions": "warn",
"no-return-await": "off",
"@typescript-eslint/return-await": "error", // eslint-disable-line sort-keys
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/switch-exhaustiveness-check": "warn",
"@typescript-eslint/typedef": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/unified-signatures": "error",
},
};
15 changes: 13 additions & 2 deletions test/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ test("End-to-End", (t) => {
.filter((file) => file !== pkg.main)
.forEach((file) => {
const configName = `ybiquitous/${path.basename(file, ".js")}`;
writeESLintConfig({ extends: configName });
writeLintTargetFile("process.stdout.write(1);");
if (configName.endsWith("/typescript")) {
fs.writeFileSync("tsconfig.json", "{}");
writeESLintConfig({
extends: configName,
parserOptions: {
tsconfigRootDir: cwd,
project: ["./tsconfig.json"],
},
});
} else {
writeESLintConfig({ extends: configName });
}
writeLintTargetFile("[1, 2].indexOf(1);");
$(eslint, ".");
t.pass(`${configName} configuration`);
});
Expand Down

0 comments on commit ae57e07

Please sign in to comment.