1module.exports = { 2 'env': { 3 'browser': true, 4 'es2021': true, 5 'node': true, 6 }, 7 'extends': [ 8 'google', 9 ], 10 'parser': '@typescript-eslint/parser', 11 'parserOptions': { 12 'ecmaVersion': 'latest', 13 'sourceType': 'module', 14 'project': './tsconfig.json', 15 }, 16 'plugins': [ 17 '@typescript-eslint', 18 ], 19 'rules': { 20 // We don't want to enforce jsdoc everywhere: 21 'require-jsdoc': 'off', 22 23 // Relax jsdoc requirements 24 'valid-jsdoc': ['error', { 25 'requireParamType': false, 26 'requireReturnType': false, 27 'requireReturn': false, 28 }], 29 30 // Formatting handled by prettier 31 'indent': 'off', 32 'max-len': 'off', 33 'operator-linebreak': 'off', 34 'quotes': 'off', 35 'brace-style': 'off', 36 'space-before-function-paren': 'off', 37 'generator-star-spacing': 'off', 38 'semi-spacing': 'off', 39 40 // clang-format --js used to format EOL comments after (e.g.) an if like: 41 // if (foo) { // insightful comment 42 // with two spaces between the slash and the brace. Turn 43 // ignoreEOLComments on to allow that. We still want 44 // no-multi-spaces turned on in general as it fixes issues like: 45 // if (a === b) 46 'no-multi-spaces': ['error', {ignoreEOLComments: true}], 47 48 // Default no-unused-vars doesn't understand TypeScript enums. See: 49 // https://github.com/typescript-eslint/typescript-eslint/issues/2621 50 'no-unused-vars': 'off', 51 '@typescript-eslint/no-unused-vars': 52 ['error', {'argsIgnorePattern': '^_.*', 'varsIgnorePattern': '^_.*'}], 53 54 // new Array() is banned (use [] instead) but new Array<Foo>() is 55 // allowed since it can be clearer to put the type by the 56 // construtor. 57 'no-array-constructor': 'off', 58 '@typescript-eslint/no-array-constructor': ['error'], 59 60 // Rest parameters are not equivalent to 'arguments'. 61 // Rest parameters are arrays: https://developer.mozilla.org/en-US/docs/Web/ 62 // JavaScript/Reference/Functions/rest_parameters 63 // 'arguments' are objects: https://developer.mozilla.org/en-US/docs/Web/ 64 // JavaScript/Reference/Functions/arguments 65 'prefer-rest-params': 'off', 66 67 // We have a lot normal functions which are capitalised. 68 // TODO(hjd): Switch these to be lowercase and remove capIsNew. 69 // There are also some properties like: foo.factory these should 70 // stay. 71 'new-cap': ['error', {'capIsNew': false, 'properties': false}], 72 73 // Don't allow new introduction of any it is most always a mistake. 74 '@typescript-eslint/no-explicit-any': 'error', 75 76 // Prohibit numbers and strings from being used in boolean expressions. 77 '@typescript-eslint/strict-boolean-expressions': [ 78 'error', 79 { 80 // Eventually we probably want to enable all of these, for now this 81 // tackles numbers and keeps the error count manageable. 82 allowAny: true, 83 allowNullableBoolean: true, 84 allowNullableString: true, 85 allowNumber: true, 86 allowString: true, 87 }, 88 ], 89 }, 90}; 91