|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + rules: { |
| 4 | + 'prefer-template': 2 |
| 5 | + }, |
| 6 | + |
| 7 | + parser: '@typescript-eslint/parser', // Make ESLint compatible with TypeScript |
| 8 | + parserOptions: { |
| 9 | + // Enable linting rules with type information from our tsconfig |
| 10 | + tsconfigRootDir: __dirname, |
| 11 | + project: ['./tsconfig.eslint.json'], |
| 12 | + |
| 13 | + sourceType: 'module', // Allow the use of imports / ES modules |
| 14 | + |
| 15 | + ecmaFeatures: { |
| 16 | + impliedStrict: true, // Enable global strict mode |
| 17 | + }, |
| 18 | + }, |
| 19 | + |
| 20 | + // Specify global variables that are predefined |
| 21 | + env: { |
| 22 | + browser: true, // Enable browser global variables |
| 23 | + node: true, // Enable node global variables & Node.js scoping |
| 24 | + es2020: true, // Add all ECMAScript 2020 globals and automatically set the ecmaVersion parser option to ES2020 |
| 25 | + jest: true, // Add Jest testing global variables |
| 26 | + }, |
| 27 | + |
| 28 | + plugins: [ |
| 29 | + '@typescript-eslint', // Add some TypeScript specific rules, and disable rules covered by the typechecker |
| 30 | + 'import', // Add rules that help validate proper imports |
| 31 | + 'jest', // Add rules for writing better Jest tests |
| 32 | + 'prettier', // Allows running prettier as an ESLint rule, and reporting differences as individual linting issues |
| 33 | + ], |
| 34 | + |
| 35 | + extends: [ |
| 36 | + // ESLint recommended rules |
| 37 | + 'eslint:recommended', |
| 38 | + |
| 39 | + // Add TypeScript-specific rules, and disable rules covered by typechecker |
| 40 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 41 | + 'plugin:@typescript-eslint/recommended', |
| 42 | + |
| 43 | + // Add rules for import/export syntax |
| 44 | + 'plugin:import/errors', |
| 45 | + 'plugin:import/warnings', |
| 46 | + 'plugin:import/typescript', |
| 47 | + |
| 48 | + // Add rules for Jest-specific syntax |
| 49 | + 'plugin:jest/recommended', |
| 50 | + |
| 51 | + // Add rules that specifically require type information using our tsconfig |
| 52 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 53 | + |
| 54 | + // Enable Prettier for ESLint --fix, and disable rules that conflict with Prettier |
| 55 | + 'prettier/@typescript-eslint', |
| 56 | + 'plugin:prettier/recommended', |
| 57 | + ], |
| 58 | + |
| 59 | + // rules: { |
| 60 | + // // This rule is about explicitly using `return undefined` when a function returns any non-undefined object. |
| 61 | + // // However, since we're using TypeScript, it will yell at us if a function is not allowed to return `undefined` in its signature, so we don't need this rule. |
| 62 | + // "consistent-return": "off", |
| 63 | + // }, |
| 64 | + |
| 65 | + overrides: [ |
| 66 | + // Overrides for all test files |
| 67 | + { |
| 68 | + files: '__tests__/**/*.ts', |
| 69 | + rules: { |
| 70 | + // For our just test files, the pattern has been to have unnamed functions |
| 71 | + 'func-names': 'off', |
| 72 | + // Using non-null assertions (obj!.property) cancels the benefits of the strict null-checking mode, but these are test files, so we don't care. |
| 73 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 74 | + // For some test files, we shadow testing constants with function parameter names |
| 75 | + 'no-shadow': 'off', |
| 76 | + // Some of our test files declare helper classes with errors |
| 77 | + 'max-classes-per-file': 'off', |
| 78 | + }, |
| 79 | + }, |
| 80 | + { |
| 81 | + files: '**/*.ts', |
| 82 | + rules: { |
| 83 | + // Allow unused variables in our files when explicitly prepended with `_`. |
| 84 | + '@typescript-eslint/no-unused-vars': [ |
| 85 | + 'error', |
| 86 | + { argsIgnorePattern: '^_' }, |
| 87 | + ], |
| 88 | + |
| 89 | + // Allow us to import computed values for GRPC package definitions |
| 90 | + 'import/namespace': [2, { allowComputed: true }], |
| 91 | + |
| 92 | + // These rules are deprecated, but we have an old config that enables it |
| 93 | + '@typescript-eslint/camelcase': 'off', |
| 94 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 95 | + }, |
| 96 | + }, |
| 97 | + ], |
| 98 | +} |
0 commit comments