-
Notifications
You must be signed in to change notification settings - Fork 20
/
eslint.config.mjs
126 lines (123 loc) · 3.71 KB
/
eslint.config.mjs
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
// Encountered any problem? Read https://jc-verse.github.io/js-style-guide
// for more information.
// @ts-check
import jcRules from 'eslint-config-jc';
import cssModulesPlugin from 'eslint-plugin-css-modules';
import tseslint from 'typescript-eslint';
export default tseslint.config(
...jcRules({
typescriptTypeCheck: true,
node: ['api/**/*'],
react: ['frontend/**/*'],
}),
{
ignores: [
'frontend/src/generated/',
'frontend/src/queries/graphql-queries.ts',
'frontend/build',
'patches/',
'api/src/**/*.queries.ts',
'api/src/graphql-types.ts',
'**/graphql-codegen.ts',
],
},
{
plugins: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
'css-modules': cssModulesPlugin,
},
languageOptions: {
parserOptions: {
project: true,
},
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
// Too many false positives
checksVoidReturn: false,
},
],
'css-modules/no-unused-class': 'error',
'css-modules/no-undef-class': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'./tools/**/*',
'./frontend/vite.config.ts',
'./eslint.config.mjs',
],
},
],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'sibling', 'parent', 'index'],
'newlines-between': 'ignore',
pathGroups: [
// Used extensively and are critical to our infra
{
pattern: '{react,react-dom/*,react-router-dom,express}',
group: 'external',
position: 'before',
},
// Important utilities but not as important
{
pattern:
'{clsx,react-icons,react-icons/**,react-bootstrap,react-bootstrap/**,@sentry/*}',
group: 'external',
position: 'before',
},
{
pattern: './**/*.css',
group: 'index',
position: 'after',
},
],
pathGroupsExcludedImportTypes: [],
// Treat pathGroups as distinct groups, so they won't be sorted with
// other modules (we don't enforce blank lines for this reason)
distinctGroup: true,
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'react/jsx-child-element-spacing': 'off',
'react/jsx-no-bind': 'off',
'react/jsx-uses-react': 'off',
'react/no-array-index-key': 'off',
// TODO: we should eventually get rid of `in` operator
'no-restricted-syntax': 'off',
},
},
{
files: ['frontend/**/*'],
rules: {
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message:
'Lodash is too heavy to be allowed in frontend. Write your own utility, or import a standalone package like lodash.debounce instead.',
},
],
patterns: [
{
group: ['luxon', 'moment'],
message:
"Do you really need a Date library? Consider hand-rolling your own utilities. Look around for examples. We don't need anything complex because we will only possibly deal with three time zones: Yale, UTC, and user device. Maybe be on the lookout for https://tc39.es/proposal-temporal/docs/",
},
],
},
],
},
},
);