-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eslintrc.js
119 lines (115 loc) · 3.88 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
'use strict'
const typescriptPlugin = require('@typescript-eslint/eslint-plugin')
const prettierConfig = require('eslint-config-prettier')
const jestPlugin = require('eslint-plugin-jest')
const jestDomPlugin = require('eslint-plugin-jest-dom')
const testingLibraryPlugin = require('eslint-plugin-testing-library')
module.exports = {
plugins: [
'formatjs',
'import',
'jsx-a11y',
'prettier',
'promise',
'react',
'react-hooks',
'unicorn',
],
env: { browser: true, node: true },
globals: { __IS_DEV__: false },
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:jsx-a11y/recommended',
'plugin:promise/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
],
ignorePatterns: ['!**/.*', '.git'],
rules: {
'no-console': ['error', { allow: ['error', 'info', 'warn'] }],
'no-param-reassign': ['error', { props: true }],
'formatjs/enforce-default-message': 'error',
'formatjs/enforce-description': 'error',
'formatjs/enforce-placeholders': 'error',
'formatjs/enforce-plural-rules': ['error', { other: true }],
'formatjs/no-multiple-whitespaces': 'error',
'import/order': [
'error',
{
groups: [
['builtin', 'external'],
['internal', 'parent', 'sibling', 'index', 'unknown'],
],
'newlines-between': 'always',
},
],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prevent-abbreviations': 'off',
'prettier/prettier': 'error',
},
overrides: [
{
files: ['*.ts?(x)'],
parser: typescriptPlugin.configs.base.parser,
parserOptions: {
...typescriptPlugin.configs.base.parserOptions,
project: 'tsconfig.json',
},
plugins: typescriptPlugin.configs.base.plugins,
rules: {
...typescriptPlugin.configs.recommended.rules,
...typescriptPlugin.configs['eslint-recommended'].overrides[0].rules,
...typescriptPlugin.configs['recommended-requiring-type-checking']
.rules,
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'import/named': 'off',
// TODO: Enable the following rules
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
...prettierConfig.rules,
},
},
{
files: [
'config/jest/**/*.?(js|ts)',
'src/**/__mocks__/**/*.ts',
'src/**/?(*.)test.ts?(x)',
],
globals: jestPlugin.environments.globals.globals,
plugins: [
...jestPlugin.configs.recommended.plugins,
...jestDomPlugin.configs.recommended.plugins,
...testingLibraryPlugin.configs.react.plugins,
],
rules: {
...jestPlugin.configs.recommended.rules,
...jestDomPlugin.configs.recommended.rules,
...testingLibraryPlugin.configs.react.rules,
},
},
],
settings: {
'import/extensions': ['.d.ts', '.js', '.ts', '.tsx'],
'import/parsers': { '@typescript-eslint/parser': ['.d.ts', '.ts', '.tsx'] },
'import/resolver': {
typescript: { alwaysTryTypes: true, directory: 'tsconfig.json' },
},
react: { version: 'latest' },
},
}