blob: db775ea8be4d6f47802c8a8626d4648f78553876 [file] [log] [blame]
Hector Dearman4dc1cdc2022-05-19 09:05:21 +01001module.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',
Steve Golton13a79de2024-01-10 13:23:20 +000014 'project': './tsconfig.json',
Hector Dearman4dc1cdc2022-05-19 09:05:21 +010015 },
16 'plugins': [
17 '@typescript-eslint',
18 ],
19 'rules': {
Hector Dearman1518b6d2022-06-05 11:58:54 +010020 // We don't want to enforce jsdoc everywhere:
Hector Dearman4dc1cdc2022-05-19 09:05:21 +010021 'require-jsdoc': 'off',
Hector Dearman1518b6d2022-06-05 11:58:54 +010022
Steve Goltond9c32312024-01-25 11:58:39 +000023 // Relax jsdoc requirements
24 'valid-jsdoc': ['error', {
25 'requireParamType': false,
26 'requireReturnType': false,
27 'requireReturn': false,
28 }],
29
Steve Golton2953fa12024-03-18 14:17:15 +000030 // 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",
Hector Dearman1518b6d2022-06-05 11:58:54 +010039
Steve Golton7a4efa52024-01-25 09:18:45 +000040 // clang-format --js used to format EOL comments after (e.g.) an if like:
Hector Dearman1518b6d2022-06-05 11:58:54 +010041 // 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':
Steve Golton9ae75582023-01-26 18:48:16 +000052 ['error', {'argsIgnorePattern': '^_.*', 'varsIgnorePattern': '^_.*'}],
Hector Dearman1518b6d2022-06-05 11:58:54 +010053
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'],
Hector Dearmanc29629f2022-06-05 12:59:39 +010059
Tuchila Octavianc80e7962022-08-25 18:06:14 +010060 // 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
Hector Dearmanc29629f2022-06-05 12:59:39 +010067 // 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.
Hector Dearman44048192022-06-06 09:44:05 +010071 'new-cap': ['error', {'capIsNew': false, 'properties': false}],
Hector Dearman8a0ec982023-10-30 17:32:49 +000072
73 // Don't allow new introduction of any it is most always a mistake.
74 '@typescript-eslint/no-explicit-any': 'error',
Steve Golton13a79de2024-01-10 13:23:20 +000075
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 ],
Hector Dearman4dc1cdc2022-05-19 09:05:21 +010089 },
90};