-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
112 lines (106 loc) · 3.33 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
const prettierConfig = require('./.prettierrc.js');
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
jsx: true,
useJSXTextNode: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
// Disabling eslint-plugin-next for now as we are seeing errors with it
// TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
// 'plugin:@next/next/recommended',
'eslint-config-prettier',
],
plugins: ['@typescript-eslint', 'react-hooks', 'eslint-plugin-prettier'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ordered-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/display-name': 'off',
// import rules
'import/prefer-default-export': 'off',
'import/no-named-as-default-member': 'off',
'import/order': [
'error',
{
// Imports are grouped as follows:
groups: [
// 1: built-in node modules (fs, path)
'builtin',
// 2: dependencies in node_modules
'external',
// 3: internal aliases. See pathGroups below.
'internal',
// 4. relative imports
'parent',
// 5. relative imports in the same directory
'sibling',
],
pathGroups: [
{
// @/components imports are classed as 'internal'
pattern: '@/components/**',
group: 'internal',
},
{
// @/hooks imports come after internal
pattern: '@/hooks/**',
group: 'internal',
position: 'after',
},
{
// @/context imports come after internal
pattern: '@/context/**',
group: 'internal',
position: 'after',
},
{
// @/utils imports come after internal
pattern: '@/utils/**',
group: 'internal',
position: 'after',
},
{
// @/styles imports come after internal
pattern: '@/styles/**',
group: 'internal',
position: 'after',
},
],
// Required for pathGroups to work.
pathGroupsExcludedImportTypes: ['builtin'],
// Add an empty line between import groups.
'newlines-between': 'always',
},
],
// prettier rules
'prettier/prettier': ['error', prettierConfig],
},
settings: {
react: {
version: '18.2.0',
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
project: './',
},
},
},
};