This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
155 lines (144 loc) · 5.07 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const HTTP_CODES = [200, 201, 204, 301, 302, 400, 401, 404, 422, 500];
const HTML_HEADER_LEVELS = [1, 2, 3, 4, 5, 6];
const COMMON_MATH_VALUES = [24, 60, 100];
const COMMON_INDEX_VALUES = [-1, 0, 1];
const ALLOWED_NUMBERS = Array.from(
new Set(
COMMON_INDEX_VALUES.concat(
HTTP_CODES,
HTML_HEADER_LEVELS,
COMMON_MATH_VALUES,
),
),
);
// eslint-disable-next-line fp/no-mutation
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
'plugin:import/recommended',
],
plugins: ['jest', 'fp', 'prettier'],
rules: {
// Core rules replaced by Typescript rules
'no-use-before-define': 'off',
'consistent-return': 'off', // TypeScript takes care of checking return
'import/no-unresolved': 'off', // Doesn't work properly with TypeScript
'no-extra-parens': 'off',
// Additional Fishbrain rules
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-ignore': 'off',
// This rule required so many exceptions that it was getting difficult to maintain. So
// just name things sensibly :)
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
// Noop functions are a common pattern we use during testing, so we don't want to enable it.
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/triple-slash-reference': [
'error',
{ types: 'prefer-import' },
],
'@typescript-eslint/prefer-readonly': 'error',
// Warns if a type assertion does not change the type of an expression
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
// Enforce includes method over indexOf method
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-includes.md
'@typescript-eslint/prefer-includes': 'error',
// Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking substrings
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
curly: ['error', 'all'],
'fp/no-delete': 'error',
'fp/no-let': 'error',
'fp/no-loops': 'error',
'fp/no-mutating-assign': 'error',
'fp/no-mutation': [
'error',
{
allowThis: true,
},
],
'import/named': 'off', // Redundant when used with Typescript.
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.test.tsx',
'**/*.test.ts',
'**/testing.tsx',
'**/*.stories.tsx',
'**/*.stories.ts',
'**/setupTests.ts',
'**/webpack.config.{js,ts}', // webpack config
'**/webpack.config.*.{js,ts}', // webpack config
],
},
],
'import/order': [
'error',
{
'newlines-between': 'always-and-inside-groups',
groups: [
['builtin', 'external'],
['internal', 'sibling', 'parent', 'index'],
],
},
],
'import/prefer-default-export': 'off',
// Allow typescript imports, airbnb has disallowed it
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'max-lines': ['error', { max: 300, skipComments: true }],
// Disallow Magic Numbers
// https://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': [
'error',
{ ignoreArrayIndexes: true, ignore: ALLOWED_NUMBERS },
],
// disallow the use of console
// https://eslint.org/docs/rules/no-console
'no-console': 'off',
'prettier/prettier': 'error',
// Disallow assignments that can lead to race conditions due to usage of await or yield
// https://eslint.org/docs/rules/require-atomic-updates
'require-atomic-updates': 'error',
// no export from test file
// https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-export.md
'jest/no-export': 'error',
},
parserOptions: {
project: './tsconfig.json',
ecmaFeatures: {
jsx: true,
},
},
env: {
es6: true,
jest: true,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
};