-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
175 lines (174 loc) · 5.16 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['airbnb-base', 'plugin:solid/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['html', 'prettier', 'solid', '@typescript-eslint'],
settings: {
'import/extensions': [
'.js',
'.jsx',
'.ts',
'.tsx',
'.grahpql',
'.md',
'.mdx',
'.html',
],
'import/resolver': {
node: {
extensions: [
'.js',
'.jsx',
'.ts',
'.tsx',
'.graphql',
'.md',
'.mdx',
'.html',
],
},
},
},
rules: {
// note you must disable the base rule as it can report incorrect errors
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
// this disables the base rule for no unused vars and then tells the config below to use the TS version as it can report incorrect errors
'no-unused-vars': 'off',
// allows us to use the TS version on no unused a variables
'@typescript-eslint/no-unused-vars': [
'warn',
{
ignoreRestSiblings: true,
argsIgnorePattern: 'res|next|^err',
},
],
// allow files to be imported without the extension being included
'import/extensions': ['error', 'never'],
// checks for circal dependencies to a depth of 1
'import/no-cycle': [2, { maxDepth: 1 }],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.test.js',
'**/*.spec.js',
'jest.config.js',
'*.config.*',
'**/*.config.*',
],
},
],
// allows you to add a anchor that isn't a valid link
'jsx-a11y/href-no-hash': 'off',
// warns if a debugger is left in the code
'no-debugger': 'warn',
// warns if you use an alert
'no-alert': 'warn',
// allows you to await within a loop. There are some valid scenarios for this
'no-await-in-loop': 'off',
// doesnt allow you to assign variables in a return statement unless in parentheses
'no-return-assign': ['error', 'except-parens'],
// errors if the following statements are used
'no-restricted-syntax': [
'error',
'ForInStatement',
'LabeledStatement',
'WithStatement',
],
// ensures variables should be const if they're never reassigned
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
// ensures curly braces are used when they're need
'arrow-body-style': ['error', 'as-needed'],
// ensure no expressions defined are unused and allows template literals to be used
'no-unused-expressions': [
'error',
{
allowTaggedTemplates: true,
},
],
// ensure you dont directly manipulate an argument, you must reassign it first. Allows you to mutate props of args
'no-param-reassign': [
'error',
{
props: false,
},
],
// warn if console logs are left in
'no-console': 'warn',
// allows a named export even when its the only export in a file
'import/prefer-default-export': 'off',
// allows you to assign anonymous functions to named variables
'func-names': 'off',
// ensures you dont have a space before func parens
'space-before-function-paren': 'off',
// allows dangling commas
'comma-dangle': 'off',
// doesn't enforce a max line length
'max-len': 'off',
// alows underscore dangle. example; const _foo = `bar`;
'no-underscore-dangle': 'off',
// allows you to have returns that don't return a value
'consistent-return': 'off',
// allows you to omit the second argument to parseInt a.k.a the radix
radix: 'off',
// doesn't allow shadow variables to be declared
'no-shadow': [
'error',
{
hoist: 'all',
allow: ['resolve', 'reject', 'done', 'next', 'err', 'error'],
},
],
'dot-notation': ['error', { allowKeywords: true }],
// enforces single quotes
quotes: [
`error`,
'single',
{
// allows the use of non single quotes if it would have otherwise been escaped
avoidEscape: true,
// allows backticks for template litterals
allowTemplateLiterals: true,
},
],
'react/jsx-filename-extension': 'off',
'prettier/prettier': [
'error',
{
trailingComma: 'es5',
singleQuote: true,
printWidth: 80,
// below line only for windows users facing CLRF and eslint/prettier error
// non windows users feel free to delete it
endOfLine: 'auto',
},
],
},
overrides: [
// eslint recommends you turn off 'no-undef' for TS projects as it complains about global type references
// link: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
{
files: ['*.ts', '*.tsx'],
rules: {
'no-undef': 'off',
},
},
],
};