|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + browser: false, |
| 4 | + es2020: true, |
| 5 | + jest: true, |
| 6 | + node: true, |
| 7 | + }, |
| 8 | + ignorePatterns: ['coverage', 'lib'], |
| 9 | + extends: [ |
| 10 | + 'plugin:@typescript-eslint/recommended', |
| 11 | + 'plugin:prettier/recommended', |
| 12 | + ], |
| 13 | + parser: '@typescript-eslint/parser', |
| 14 | + plugins: ['@typescript-eslint', 'prettier'], |
| 15 | + settings: { |
| 16 | + 'import/resolver': { |
| 17 | + node: {}, |
| 18 | + typescript: { |
| 19 | + project: './tsconfig.json', |
| 20 | + alwaysTryTypes: true, |
| 21 | + }, |
| 22 | + }, |
| 23 | + }, |
| 24 | + rules: { |
| 25 | + '@typescript-eslint/explicit-function-return-type': [ |
| 26 | + 'error', |
| 27 | + { allowExpressions: true }, |
| 28 | + ], // Enforce return type definitions for functions |
| 29 | + '@typescript-eslint/explicit-member-accessibility': 'error', // Enforce explicit accessibility modifiers on class properties and methods (public, private, protected) |
| 30 | + '@typescript-eslint/member-ordering': [ |
| 31 | + // Standardize the order of class members |
| 32 | + 'error', |
| 33 | + { |
| 34 | + default: { |
| 35 | + memberTypes: [ |
| 36 | + 'signature', |
| 37 | + 'public-field', |
| 38 | + 'protected-field', |
| 39 | + 'private-field', |
| 40 | + 'constructor', |
| 41 | + 'public-method', |
| 42 | + 'protected-method', |
| 43 | + 'private-method', |
| 44 | + ], |
| 45 | + order: 'alphabetically', |
| 46 | + }, |
| 47 | + }, |
| 48 | + ], |
| 49 | + '@typescript-eslint/no-explicit-any': 'error', // Disallow usage of the any type |
| 50 | + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], // Disallow unused variables, except for variables starting with an underscore |
| 51 | + '@typescript-eslint/no-use-before-define': ['off'], // Check if this rule is needed |
| 52 | + 'no-unused-vars': 'off', // Disable eslint core rule, since it's replaced by @typescript-eslint/no-unused-vars |
| 53 | + // Rules from eslint core https://eslint.org/docs/latest/rules/ |
| 54 | + 'array-bracket-spacing': ['error', 'never'], // Disallow spaces inside of array brackets |
| 55 | + 'computed-property-spacing': ['error', 'never'], // Disallow spaces inside of computed properties |
| 56 | + 'func-style': ['warn', 'expression'], // Enforce function expressions instead of function declarations |
| 57 | + 'keyword-spacing': 'error', // Enforce spaces after keywords and before parenthesis, e.g. if (condition) instead of if(condition) |
| 58 | + 'padding-line-between-statements': [ |
| 59 | + // Require an empty line before return statements |
| 60 | + 'error', |
| 61 | + { blankLine: 'always', prev: '*', next: 'return' }, |
| 62 | + ], |
| 63 | + 'no-console': 0, // Allow console.log statements |
| 64 | + 'no-multi-spaces': ['error', { ignoreEOLComments: false }], // Disallow multiple spaces except for comments |
| 65 | + 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], // Enforce no empty line at the beginning & end of files and max 1 empty line between consecutive statements |
| 66 | + 'no-throw-literal': 'error', // Disallow throwing literals as exceptions, e.g. throw 'error' instead of throw new Error('error') |
| 67 | + 'object-curly-spacing': ['error', 'always'], // Enforce spaces inside of curly braces in objects |
| 68 | + 'prefer-arrow-callback': 'error', // Enforce arrow functions instead of anonymous functions for callbacks |
| 69 | + quotes: ['error', 'single', { allowTemplateLiterals: true }], // Enforce single quotes except for template strings |
| 70 | + semi: ['error', 'always'], // Require semicolons instead of ASI (automatic semicolon insertion) at the end of statements |
| 71 | + }, |
| 72 | +}; |
0 commit comments