|
| 1 | +/** @type {import("eslint").ESLint.ConfigData} */ |
| 2 | +const config = { |
| 3 | + root: true, |
| 4 | + parser: "@typescript-eslint/parser", |
| 5 | + parserOptions: { |
| 6 | + sourceType: "module", |
| 7 | + tsconfigRootDir: __dirname, |
| 8 | + project: [ |
| 9 | + "./tsconfig.eslint.json", |
| 10 | + "./packages/*/tsconfig.json", |
| 11 | + "./packages/@proto-graphql/*/tsconfig.json", |
| 12 | + "./packages/@proto-nexus/*/tsconfig.json", |
| 13 | + "./e2e/tsconfig.eslint.json", |
| 14 | + "./e2e/tests/*/tsconfig.json", |
| 15 | + ], |
| 16 | + }, |
| 17 | + ignorePatterns: [ |
| 18 | + "packages/@testapis/**", |
| 19 | + "**/__generated__/**", |
| 20 | + "**/coverage/**", |
| 21 | + "**/lib/**", |
| 22 | + "**/module/**", |
| 23 | + "**/tmp/**", |
| 24 | + ], |
| 25 | + env: { |
| 26 | + node: true, |
| 27 | + }, |
| 28 | + extends: [ |
| 29 | + "eslint:recommended", |
| 30 | + "plugin:@typescript-eslint/recommended", |
| 31 | + "prettier", |
| 32 | + // 'plugin:import/recommended', // use only `import/order` |
| 33 | + // 'plugin:import/typescript', // Not necessary for `import/order` use only |
| 34 | + ], |
| 35 | + plugins: ["@typescript-eslint", "import", "unused-imports"], |
| 36 | + rules: { |
| 37 | + // eslint: recommended rules |
| 38 | + "no-undef": "off", |
| 39 | + |
| 40 | + // eslint: additional rules |
| 41 | + "prefer-const": "error", |
| 42 | + eqeqeq: ["error", "smart"], |
| 43 | + "no-console": "error", |
| 44 | + "no-restricted-syntax": [ |
| 45 | + "error", |
| 46 | + { |
| 47 | + selector: "TSEnumDeclaration", |
| 48 | + message: |
| 49 | + "Don't use TypeScript enums. Use object literal with `as const` instead. See https://typescriptbook.jp/reference/values-types-variables/enum/enum-problems-and-alternatives-to-enums", |
| 50 | + }, |
| 51 | + ], |
| 52 | + |
| 53 | + // typescript-eslint: recommended rules |
| 54 | + "@typescript-eslint/no-unused-vars": [ |
| 55 | + "warn", |
| 56 | + { |
| 57 | + varsIgnorePattern: "^_", |
| 58 | + argsIgnorePattern: "^_", |
| 59 | + ignoreRestSiblings: true, |
| 60 | + }, |
| 61 | + ], |
| 62 | + // TODO: Change to "error" when all warnings are resolved |
| 63 | + "@typescript-eslint/no-explicit-any": "off", |
| 64 | + |
| 65 | + // typescript-eslint: additional rules |
| 66 | + "@typescript-eslint/explicit-member-accessibility": [ |
| 67 | + "error", |
| 68 | + { |
| 69 | + overrides: { |
| 70 | + constructors: "no-public", |
| 71 | + parameterProperties: "no-public", |
| 72 | + accessors: "no-public", |
| 73 | + }, |
| 74 | + }, |
| 75 | + ], |
| 76 | + "@typescript-eslint/no-redeclare": "error", |
| 77 | + |
| 78 | + // import |
| 79 | + "import/order": [ |
| 80 | + "error", |
| 81 | + { |
| 82 | + groups: [ |
| 83 | + "builtin", |
| 84 | + "external", |
| 85 | + ["internal", "parent", "sibling", "index"], |
| 86 | + "object", |
| 87 | + "type", |
| 88 | + ], |
| 89 | + "newlines-between": "always", |
| 90 | + alphabetize: { |
| 91 | + order: "asc", |
| 92 | + }, |
| 93 | + }, |
| 94 | + ], |
| 95 | + |
| 96 | + // unused-imports |
| 97 | + "unused-imports/no-unused-imports": "error", |
| 98 | + }, |
| 99 | + reportUnusedDisableDirectives: true, |
| 100 | + overrides: [ |
| 101 | + { |
| 102 | + files: ["{test,__test__}/**", "**/*.{spec,test}.{,m,c}{j,t}s{,x}"], |
| 103 | + plugins: ["jest"], |
| 104 | + env: { |
| 105 | + jest: true, |
| 106 | + "jest/globals": true, |
| 107 | + }, |
| 108 | + extends: ["plugin:jest/recommended"], |
| 109 | + }, |
| 110 | + ], |
| 111 | +}; |
| 112 | + |
| 113 | +module.exports = config; |
0 commit comments