From 2d4bc5146729a4f4306b64d0adea4b85d8040175 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 23 May 2024 13:34:30 -0600 Subject: [PATCH] feat: enable type checked linting --- .eslintrc.json | 71 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4151575356c85..325b33e74b190 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,14 +43,29 @@ } }, { "files": ["**/__tests__/**"], "env": { "jest": true } }, + { + "files": ["packages/next/**/*.d.ts"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "sourceType": "module", + "warnOnUnsupportedTypeScriptVersion": false + }, + "rules": { + "no-unused-vars": "warn", + "no-dupe-class-members": "warn", + "no-undef": "warn" + } + }, { "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/stylistic" + "plugin:@typescript-eslint/recommended-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked" ], "files": ["**/*.ts", "**/*.tsx"], + "excludedFiles": ["packages/next/**/*.d.ts"], "parser": "@typescript-eslint/parser", "parserOptions": { + "project": true, "sourceType": "module", "warnOnUnsupportedTypeScriptVersion": false }, @@ -99,11 +114,45 @@ "ignoreRestSiblings": true } ], - "no-use-before-define": "off", "no-useless-constructor": "off", - "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-useless-constructor": "error", - "@typescript-eslint/prefer-literal-enum-member": "error" + "no-use-before-define": "off", + "@typescript-eslint/no-use-before-define": "warn", + "@typescript-eslint/prefer-literal-enum-member": "error", + + "@typescript-eslint/consistent-type-imports": [ + "error", + { + "disallowTypeAnnotations": false + } + ], + "@typescript-eslint/no-import-type-side-effects": "error", + + // + "@typescript-eslint/no-unsafe-assignment": "warn", + "@typescript-eslint/no-unnecessary-type-assertion": "warn", + "@typescript-eslint/prefer-nullish-coalescing": "warn", + "@typescript-eslint/no-unsafe-call": "warn", + "@typescript-eslint/no-unsafe-member-access": "warn", + "@typescript-eslint/prefer-string-starts-ends-with": "warn", + "@typescript-eslint/no-floating-promises": "warn", + "@typescript-eslint/non-nullable-type-assertion-style": "warn", + "@typescript-eslint/no-unsafe-return": "warn", + "@typescript-eslint/prefer-optional-chain": "warn", + "@typescript-eslint/no-redundant-type-constituents": "warn", + "@typescript-eslint/require-await": "warn", + "@typescript-eslint/no-unsafe-argument": "warn", + "@typescript-eslint/dot-notation": "warn", + "@typescript-eslint/no-unsafe-enum-comparison": "warn", + "@typescript-eslint/restrict-template-expressions": "warn", + "@typescript-eslint/unbound-method": "warn", + "@typescript-eslint/no-implied-eval": "warn", + "@typescript-eslint/await-thenable": "warn", + "@typescript-eslint/no-base-to-string": "warn", + "@typescript-eslint/restrict-plus-operands": "warn", + "@typescript-eslint/no-misused-promises": "warn", + "@typescript-eslint/no-duplicate-type-constituents": "warn", + "@typescript-eslint/no-for-in-array": "warn" } }, { @@ -196,18 +245,6 @@ ], "eslint-plugin/require-meta-docs-url": "error" } - }, - { - "files": ["packages/**/*.tsx", "packages/**/*.ts"], - "rules": { - "@typescript-eslint/consistent-type-imports": [ - "error", - { - "disallowTypeAnnotations": false - } - ], - "@typescript-eslint/no-import-type-side-effects": "error" - } } ], "rules": {