-
Notifications
You must be signed in to change notification settings - Fork 81
/
.eslintrc.js
132 lines (131 loc) · 3.85 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
const path = require('path');
const rulesDirPlugin = require('eslint-plugin-rulesdir');
rulesDirPlugin.RULES_DIR = path.resolve(
__dirname,
'./scripts/eslint-rules/custom',
);
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:you-dont-need-lodash-underscore/compatible',
],
plugins: ['import', 'react-hooks', 'jest-dom', 'testing-library', 'rulesdir'],
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
},
env: {
jest: true,
browser: true,
node: true,
},
settings: {
'import/extensions': ['.js', '.ts', '.tsx'],
react: {
version: 'detect',
},
},
rules: {
'no-console': 'warn',
'react/prop-types': 'off',
'react/prefer-stateless-function': ['off', { ignorePureComponents: true }],
'react/jsx-filename-extension': ['off', { extensions: ['.js', '.tsx'] }],
'react/forbid-prop-types': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/sort-comp': 'off',
'react/jsx-wrap-multilines': 'off',
'function-paren-newline': 'off',
'react/button-has-type': 'error',
'react/jsx-no-target-blank': 'error',
'react/jsx-no-bind': ['error', { allowArrowFunctions: true }],
'react/no-access-state-in-setstate': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/no-children-prop': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-empty-function': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'import/named': 'error',
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': 'error',
'react/jsx-handler-names': 'error',
'rulesdir/emotion-in-function': 'error',
},
overrides: [
// allow specific rules in example files so there are no eslint-disable comments in code playgrounds
{
files: ['**/examples/**/*'],
rules: {
'jsx-a11y/no-autofocus': 'off',
},
},
{
files: ['**/*.stories.*'],
rules: {
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'import/no-default-export': 'off',
'react/jsx-handler-names': 'off',
},
},
{
files: ['**/*.js', '**/*.jsx'],
env: {
node: true,
browser: true,
},
},
{
files: [
'**/forma-36-react-components/tools/**/*',
'**/packages/components/**/*',
'**/packages/**/examples/**',
],
rules: {
'import/no-default-export': 'off',
},
},
{
// Overides estraneous-dependencies for places where it's expected.
// e.g. Example files, test files, and codemod fixtures
files: [
'**/*.stories.*',
'**/*.test.*',
'**/examples/**',
'**/packages/**/__testfixtures__/**',
],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
// Example files and codemods are allowed to log to console
files: ['**/examples/**', '**/packages/forma-36-codemod/**/*'],
rules: {
'no-console': 'off',
},
},
],
};