forked from flapjs/webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
116 lines (114 loc) · 3.06 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
/* eslint-env node */
const path = require('path');
module.exports = {
'env': {
'browser': true,
'es2020': true
},
'extends': [
'eslint:recommended',
'plugin:react/recommended',
'plugin:import/react',
'plugin:import/recommended',
],
'settings': {
'react': {
'version': 'detect'
},
/** For import aliases (eslint-plugin-import-resolver-alias) */
'import/resolver': {
alias: {
map: [
/** Add any aliases that need to be resolved by eslint here. Refer to webpack and jest config as well. */
// NOTE: This does not resolve for stylelint.
['@flapjs', path.resolve(__dirname, 'src')]
]
}
},
},
'parser': 'babel-eslint',
'parserOptions': {
'ecmaFeatures': {
'jsx': true
},
'ecmaVersion': 11,
'sourceType': 'module'
},
'plugins': [
'react',
'import',
'react-hooks',
],
'rules': {
'indent': [
'error',
4,
{ 'SwitchCase': 1 }
],
// We turn this off, since git already converts all linebreaks to unix style.
'linebreak-style': [
'off',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
],
/** Our custom-defined rules... */
// Allman brace style (braces on new lines) is more readable.
'brace-style': [
'error',
'allman',
{ 'allowSingleLine': true }
],
// We want an empty line at the end. Just convention.
'eol-last': [
'error',
'always'
],
/*
* This disables removing unused parameters from functions.
* The reason is because knowing what parameters are expected
* in a function can be a useful self-documenting feature.
*/
'no-unused-vars': [
'error',
{
'vars': 'all',
'args': 'none'
}
],
// Enforces all imports to have file extensions.
'import/extensions': ['error', 'ignorePackages'],
// This makes sure that dynamic imports are properly configured for webpack.
'import/dynamic-import-chunkname': 'error',
// Only allow JSX usage in these file types.
'react/jsx-filename-extension': [
'error',
{
'extensions': ['jsx', 'spec.js', 'stories.js']
}
],
/** React Hooks */
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn'
},
'overrides': [
{
'files': [ '*.spec.js' ],
'env': {
'jest': true
}
},
{
'files': ['*.stories.js'],
'env': {
'node': true
}
}
]
};