-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
173 lines (172 loc) · 5.94 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
module.exports = {
root: true,
extends: [
'plugin:react/jsx-runtime',
'plugin:prettier/recommended',
'plugin:react-hooks/recommended',
'@z1digitalstudio/eslint-config-imports',
'plugin:storybook/recommended',
],
parserOptions: {
ecmaVersion: 2021,
},
ignorePatterns: [
'!.*.js',
'!.storybook',
'package.json',
'graphql.config.json',
'*apollo-helpers.ts',
],
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:prettier/recommended',
'@z1digitalstudio/eslint-config-imports',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'react-hooks'],
settings: {
react: {
version: 'detect',
},
},
// Rules that apply only to typescript files should go here
rules: {
// Disabled because Typescript takes care of that already.
'@typescript-eslint/no-unused-vars': 'warn',
// This rule is enabled by eslint-config-airbnb and disabled by
// eslint-plugin-prettier:
// https://github.com/prettier/eslint-plugin-prettier/issues/65
// This is a rare issue and we feel like this rule improves the
// consistency of the code so we keep it on.
'arrow-body-style': 'warn',
// Typescript takes care of that already
'import/no-unresolved': 'off',
// The "a" element does require the "href" attribute, but it's next's
// Link job to pass it using "passHref".
'jsx-a11y/anchor-is-valid': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
// Allow hoisting
'@typescript-eslint/no-use-before-define': [2, { functions: false }],
'no-param-reassign': [
'error',
{
// Allow overwriting props from the immerjs draft
ignorePropertyModificationsFor: ['next'],
props: true,
},
],
'no-underscore-dangle': [
'warn',
{
allow: ['__typename'],
},
],
// "void" is useful to purposefully ignore the result of promises
'no-void': 'off',
// "TO-DO" comments (with a hyphen so the IDE doesn't pick it up) are
// usually left to indicate that something shouldn't be committed. In
// the event that we actually want to commit a warning comment, we
// should add a card to the issue tracker instead.
'no-warning-comments': 'warn',
// Contrary to what we'd expect, eslint-config-airbnb doesn't enable
// this rule, so we enable it manually.
'react/jsx-key': [
'warn',
{
// This is disabled by default to prevent a breaking change. We are
// not affected by that so we enable it.
// https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/jsx-key.md#checkfragmentshorthand-default-false
checkFragmentShorthand: true,
},
],
// Disabled because we use TypeScript, so we don't care about PropTypes
'react/prop-types': 'off',
// Disabled because as of React 17 this is not necessary
'react/react-in-jsx-scope': 'off',
// Disabled because there's scalable way of providing exceptions for
// this rule. In principle, I agree with it: we shouldn't spread props
// into our component. But in practice, it gets in the way of libraries
// like react-hook-form or react-dropzone. Enforcing that our custom
// components don't accept spread props should therefore be done at the
// pull request review layer.
'react/jsx-props-no-spreading': 'off',
// Restrict some import formats
'@typescript-eslint/no-restricted-imports': [
'error',
{
patterns: [
'../..',
'!../styles',
'!../types',
'!../connect',
'!../constants',
'!../utils',
'!../logic',
],
},
],
// Always prefer named exports, except in storybook and pages files
'import/no-default-export': 'error',
},
overrides: [
{
// Files which requires a default export: pages, storybook, and others
files: [
'**/*.stories.*',
'**/stories.*',
'src/storybook/**/*.*',
'src/pages/**/*.tsx',
'additional.d.ts',
'src/graphql/instrospection.ts',
],
rules: {
'import/no-anonymous-default-export': 'off',
'import/no-default-export': 'off',
'import/named': 'off',
},
},
// Always enforce exported functions to be typed, except in specific
// cases where we want the return type to be inferred.
{
files: [
'src/components/**/logic.ts',
'src/containers/**/connect.ts',
'src/containers/**/logic.ts',
'src/graphql/hooks/**/*.ts',
'src/model/**/*.ts',
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
],
},
{
files: ['.storybook/*.js'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
ecmaFeatures: { jsx: true },
},
},
],
// Only rules that apply to both javascript and typescript files should go
// here. Typescript rules should go in the overrides section.
rules: {
'arrow-body-style': 'warn',
'no-console': 'warn',
'no-debugger': 'warn',
'prettier/prettier': 'warn',
'react/jsx-uses-react': 'error',
},
};