-
Notifications
You must be signed in to change notification settings - Fork 21
/
.eslintrc.js
124 lines (119 loc) · 4.35 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
module.exports = {
extends: ['airbnb-typescript-prettier', 'plugin:storybook/recommended'],
settings: {
'import/resolver': {
typescript: {
project: [
'tsconfig.json',
'packages/*/tsconfig.json',
],
},
},
react: {
version: require('react').version,
},
},
rules: {
'simple-import-sort/imports': 'warn',
quotes: [2, 'single', { avoidEscape: true }],
'prettier/prettier': 'error',
// TODO: ticket all of these to be enabled or explain why they are disabled
// Destructuring props is not required because it clutters the function type signature.
// Props can be destructured in a separate line.
'react/destructuring-assignment': 'off',
// Use TypeScript instead of PropTypes for new code.
'react/forbid-prop-types': 'off',
// Allow writing components as arrow functions.
'react/function-component-definition': 'off',
'react/prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
'react/react-in-jsx-scope': 'off',
'react/require-default-props': 'off',
'react/sort-comp': 'off',
'react/static-property-placement': 'off',
'import/named': 'off',
'import/no-cycle': 'off',
// With eslint-import-resolver-typescript, ESLint sees 'date-fns' and 'date-fns/fp' as
// duplicates and combines them into one import from 'date-fns'.
'import/no-duplicates': 'off',
// Allow tests' and build dependencies to be listed in devDependencies or dependencies.
'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/*.test.{js,ts,tsx}', '**/vite.config.*', '**/jest.config.*'] }],
'import/no-named-as-default': 'off',
// Named exports are more convenient for mocking.
'import/prefer-default-export': 'off',
// TS directive comments will be necessary during transition from JS to TS.
'@typescript-eslint/ban-ts-comment': 'off',
// TODO: Replace these types with alternatives recommended by this rule.
'@typescript-eslint/ban-types': ['error', { types: { Function: false, Object: false, '{}': false } }],
// No-ops are often used in tests and sometimes as default values for callback props.
'@typescript-eslint/no-empty-function': 'off',
// `any` is useful for incremental type improvements during the transition from JS to TS.
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'class-methods-use-this': 'off',
'consistent-return': 'off',
'default-param-last': 'off',
'func-names': 'off',
// Formatting is handled by Prettier.
'max-len': 'off',
'no-await-in-loop': 'off',
'no-case-declarations': 'off',
// Allow some console methods.
'no-console': ['warn', { allow: ['assert', 'error'] }],
// Allow `while (true) {...}`
'no-constant-condition': ['error', {checkLoops: false}],
'no-empty': ['error', { allowEmptyCatch: true }],
'no-continue': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-promise-executor-return': 'off',
'no-restricted-syntax': 'off',
'no-return-await': 'off',
'no-unused-expressions': 'off',
'no-void': 'off',
'prefer-destructuring': 'off',
'prefer-promise-reject-errors': 'off',
'prefer-regex-literals': 'off',
radix: 'off',
//
'@typescript-eslint/no-unused-vars': [
'warn',
{
vars: 'all',
args: 'all',
argsIgnorePattern: '_|^_|^props',
destructuredArrayIgnorePattern: '_|^_',
ignoreRestSiblings: true,
},
],
},
overrides: [
{
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.test.js', 'src/setupTests.ts'],
env: {
jest: true,
},
},
{
files: 'src/**/*.{js,ts,tsx}',
rules: {
// 'no-console': ['warn', { allow: ['assert', 'error'] }],//TODO: should be enabled
},
},
{
files: ['integration-tests/**'],
rules: {
// Integration tests use CommonJS instead of ESM.
'@typescript-eslint/no-var-requires': 'off',
// TODO: Add dependencies to package.json.
'import/no-extraneous-dependencies': 'off',
// Integration tests frequently log.
'no-console': 'off',
}
},
],
plugins: ['lodash-fp', 'simple-import-sort'],
'ignorePatterns': ['!.storybook'],
};