[go: nahoru, domu]

blob: d8ac543b3b6cbd74fe29200a6df16b5672834cba [file] [log] [blame]
Tim van der Lipped6c33c42020-03-10 16:57:221const path = require('path');
2const rulesDirPlugin = require('eslint-plugin-rulesdir')
3rulesDirPlugin.RULES_DIR = path.join(__dirname, 'scripts', 'eslint_rules', 'lib');
4
Blink Reformat4c46d092018-04-07 15:32:375module.exports = {
Tim van der Lippe1d6e57a2019-09-30 11:55:346 'root': true,
Blink Reformat4c46d092018-04-07 15:32:377
Tim van der Lippe1d6e57a2019-09-30 11:55:348 'env': {'browser': true, 'es6': true},
Blink Reformat4c46d092018-04-07 15:32:379
Tim van der Lippe399a9562020-01-16 10:53:2810 'parser': '@typescript-eslint/parser',
11
12 'plugins': [
13 '@typescript-eslint',
Jack Franklin8b9aa2f2020-02-12 16:35:1514 'mocha',
Tim van der Lipped6c33c42020-03-10 16:57:2215 'rulesdir',
Tim van der Lippe298b8cc2020-04-03 11:55:1016 'import',
Tim van der Lippe399a9562020-01-16 10:53:2817 ],
18
Tim van der Lippe1d6e57a2019-09-30 11:55:3419 'parserOptions': {'ecmaVersion': 9, 'sourceType': 'module'},
Blink Reformat4c46d092018-04-07 15:32:3720
Tim van der Lippe1d6e57a2019-09-30 11:55:3421 /**
Blink Reformat4c46d092018-04-07 15:32:3722 * ESLint rules
23 *
24 * All available rules: http://eslint.org/docs/rules/
25 *
26 * Rules take the following form:
Tim van der Lippe159b8902020-09-21 10:55:0727 * 'rule-name', [severity, { opts }]
Blink Reformat4c46d092018-04-07 15:32:3728 * Severity: 2 == error, 1 == warning, 0 == off.
29 */
Tim van der Lippe1d6e57a2019-09-30 11:55:3430 'rules': {
31 /**
Blink Reformat4c46d092018-04-07 15:32:3732 * Enforced rules
33 */
34
35
Tim van der Lippe1d6e57a2019-09-30 11:55:3436 // syntax preferences
Mathias Bynens23ee1aa2020-03-02 12:06:3837 'quotes': [2, 'single', {'avoidEscape': true, 'allowTemplateLiterals': false}],
Tim van der Lippe1d6e57a2019-09-30 11:55:3438 'semi': 2,
39 'no-extra-semi': 2,
40 'comma-style': [2, 'last'],
41 'wrap-iife': [2, 'inside'],
42 'spaced-comment': [2, 'always', {'markers': ['*']}],
43 'eqeqeq': [2],
44 'accessor-pairs': [2, {'getWithoutSet': false, 'setWithoutGet': false}],
45 'curly': 2,
46 'new-parens': 2,
47 'func-call-spacing': 2,
48 'arrow-parens': [2, 'as-needed'],
Tim van der Lippe20b29c22019-11-04 14:36:1549 'eol-last': 2,
Blink Reformat4c46d092018-04-07 15:32:3750
Tim van der Lippe1d6e57a2019-09-30 11:55:3451 // anti-patterns
Tim van der Lippe1d6e57a2019-09-30 11:55:3452 'no-caller': 2,
Mathias Bynens88e8f152020-03-25 14:33:1253 'no-case-declarations': 2,
Mathias Bynensf06e8c02020-02-28 13:58:2854 'no-cond-assign': 2,
55 'no-console': [2, {'allow': ['assert', 'context', 'error', 'timeStamp', 'time', 'timeEnd', 'warn']}],
56 'no-debugger': 2,
57 'no-dupe-keys': 2,
58 'no-duplicate-case': 2,
59 'no-else-return': [2, {'allowElseIf': false}],
60 'no-empty-character-class': 2,
Mathias Bynens15213d02020-05-14 11:55:1161 'no-global-assign': 2,
Tim van der Lippe1d6e57a2019-09-30 11:55:3462 'no-implied-eval': 2,
63 'no-labels': 2,
Mathias Bynensf06e8c02020-02-28 13:58:2864 'no-multi-str': 2,
Tim van der Lippe1d6e57a2019-09-30 11:55:3465 'no-new-object': 2,
66 'no-octal-escape': 2,
67 'no-self-compare': 2,
68 'no-shadow-restricted-names': 2,
Tim van der Lippe1d6e57a2019-09-30 11:55:3469 'no-unreachable': 2,
70 'no-unsafe-negation': 2,
Mathias Bynensf06e8c02020-02-28 13:58:2871 'no-unused-vars': [2, {'args': 'none', 'vars': 'local'}],
72 'no-var': 2,
73 'no-with': 2,
74 'prefer-const': 2,
Tim van der Lippe1d6e57a2019-09-30 11:55:3475 'radix': 2,
76 'valid-typeof': 2,
Patrick Brossete65aaac2020-06-22 08:04:4077 'no-return-assign': [2, 'always'],
Blink Reformat4c46d092018-04-07 15:32:3778
Tim van der Lippe1d6e57a2019-09-30 11:55:3479 // es2015 features
80 'require-yield': 2,
81 'template-curly-spacing': [2, 'never'],
Blink Reformat4c46d092018-04-07 15:32:3782
Tim van der Lippe1d6e57a2019-09-30 11:55:3483 // spacing details
84 'space-infix-ops': 2,
85 'space-in-parens': [2, 'never'],
86 'space-before-function-paren': [2, {'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always'}],
87 'no-whitespace-before-property': 2,
88 'keyword-spacing': [
89 2, {
90 'overrides': {
91 'if': {'after': true},
92 'else': {'after': true},
93 'for': {'after': true},
94 'while': {'after': true},
95 'do': {'after': true},
96 'switch': {'after': true},
97 'return': {'after': true}
98 }
99 }
100 ],
101 'arrow-spacing': [2, {'after': true, 'before': true}],
Blink Reformat4c46d092018-04-07 15:32:37102
Tim van der Lippe1d6e57a2019-09-30 11:55:34103 // file whitespace
104 'no-multiple-empty-lines': [2, {'max': 2}],
105 'no-mixed-spaces-and-tabs': 2,
106 'no-trailing-spaces': 2,
107 'linebreak-style': [2, 'unix'],
Blink Reformat4c46d092018-04-07 15:32:37108
Tim van der Lippe1d6e57a2019-09-30 11:55:34109 /**
Blink Reformat4c46d092018-04-07 15:32:37110 * Disabled, aspirational rules
111 */
112
Tim van der Lippe1d6e57a2019-09-30 11:55:34113 'indent': [0, 2, {'SwitchCase': 1, 'CallExpression': {'arguments': 2}, 'MemberExpression': 2}],
Blink Reformat4c46d092018-04-07 15:32:37114
Tim van der Lippe1d6e57a2019-09-30 11:55:34115 // brace-style is disabled, as eslint cannot enforce 1tbs as default, but allman for functions
116 'brace-style': [0, 'allman', {'allowSingleLine': true}],
Blink Reformat4c46d092018-04-07 15:32:37117
Tim van der Lippe1d6e57a2019-09-30 11:55:34118 // key-spacing is disabled, as some objects use value-aligned spacing, some not.
119 'key-spacing': [0, {'beforeColon': false, 'afterColon': true, 'align': 'value'}],
120 // quote-props is diabled, as property quoting styles are too varied to enforce.
121 'quote-props': [0, 'as-needed'],
Blink Reformat4c46d092018-04-07 15:32:37122
Tim van der Lippe1d6e57a2019-09-30 11:55:34123 // no-implicit-globals will prevent accidental globals
Tim van der Lippe399a9562020-01-16 10:53:28124 'no-implicit-globals': [0],
125
Jack Franklin264237a2020-07-15 09:02:26126 // forbids interfaces starting with an I prefix.
Paul Lewis839037f2020-07-21 12:25:19127 '@typescript-eslint/naming-convention':
128 [2, {'selector': 'interface', 'format': ['PascalCase'], 'custom': {'regex': '^I[A-Z]', 'match': false}}],
Tim van der Lippe399a9562020-01-16 10:53:28129 '@typescript-eslint/explicit-member-accessibility': [0],
Paul Lewis839037f2020-07-21 12:25:19130 '@typescript-eslint/no-explicit-any': 2,
Jack Franklin8b9aa2f2020-02-12 16:35:15131
132 // errors on it('test') with no body
133 'mocha/no-pending-tests': 2,
134 // errors on {describe, it}.only
135 'mocha/no-exclusive-tests': 2,
Tim van der Lipped6c33c42020-03-10 16:57:22136
Tim van der Lippe298b8cc2020-04-03 11:55:10137 // Closure does not properly typecheck default exports
138 'import/no-default-export': 2,
139
Tim van der Lipped6c33c42020-03-10 16:57:22140 // DevTools specific rules
141 'rulesdir/es_modules_import': 2,
Tim van der Lippe4a8441c2020-03-12 15:45:18142 'rulesdir/check_license_header': 2,
Tim van der Lippe80c10282020-04-22 12:03:04143 'rulesdir/check_test_definitions': 2,
Jack Franklin28447fd2020-04-23 12:09:35144 'rulesdir/avoid_assert_equal': 2,
Peter Marshallf8f4ea42020-08-14 12:31:05145 'rulesdir/no_repeated_tests': 2,
Tim van der Lippe399a9562020-01-16 10:53:28146 },
147 'overrides': [{
148 'files': ['*.ts'],
149 'rules': {
Jack Franklin173a1ae2020-06-12 13:45:40150 '@typescript-eslint/explicit-member-accessibility': [2, {'accessibility': 'no-public'}],
Tim van der Lippe399a9562020-01-16 10:53:28151 'comma-dangle': [2, 'always-multiline'],
Jack Franklin95310322020-03-20 14:34:04152 // run just the TypeScript unused-vars rule, else we get duplicate errors
153 'no-unused-vars': 0,
Tim van der Lippe159b8902020-09-21 10:55:07154 '@typescript-eslint/no-unused-vars': [2, {'argsIgnorePattern': '^_'}],
Jack Franklinb5920ca2020-11-13 10:19:20155 'rulesdir/kebab_case_events': 2,
Tim van der Lippe399a9562020-01-16 10:53:28156 }
157 }]
Blink Reformat4c46d092018-04-07 15:32:37158};