/
frontend-typescript.js
68 lines (67 loc) · 2.34 KB
/
frontend-typescript.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
const commonExtends = require('./common/extends.json');
const commonPlugins = require('./common/plugins');
const tsParser = require('./common/ts-parser');
const {
allowRequireInConfigs,
noExplicitsInTests,
noCastWithJestMock,
} = require('./common/overrides');
const consistentTypeImports = require('./rules/consistent-type-imports.json');
const frontendConfig = require('./frontend');
const typescriptRules = require('./rules/typescript');
const youDontNeedLodashRules = require('./rules/you-dont-need-lodash.json');
module.exports = {
extends: ['./frontend.js', ...commonExtends, 'plugin:you-dont-need-lodash-underscore/compatible'],
plugins: [...commonPlugins, ...frontendConfig.plugins, 'testing-library'],
...tsParser,
rules: {
...frontendConfig.rules,
// Often test name starts with component name which are always capitalized
'jest/lowercase-name': 'off',
'react/prop-types': 'off',
'react/display-name': 'warn',
'testing-library/await-async-query': 'error',
'testing-library/no-await-sync-query': 'error',
'testing-library/no-wait-for-empty-callback': 'error',
// It's enabled in overrides
'testing-library/no-debugging-utils': 'off',
'testing-library/consistent-data-testid': [
2,
{
testIdPattern: '^(([a-z])+(-)*)+$',
},
],
...consistentTypeImports,
// it fail to compile TS on react static class properties (displayName | defaultProps | etc..)
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/consistent-type-assertions': 'warn',
// Don`t need for typescript files
'@typescript-eslint/no-empty-function': 'off',
...typescriptRules,
'@typescript-eslint/no-unused-vars': ['error', {ignoreRestSiblings: true}],
...youDontNeedLodashRules,
},
overrides: [
allowRequireInConfigs,
noExplicitsInTests,
noCastWithJestMock,
{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
extends: ['plugin:testing-library/react'],
},
{
files: ['*.test.{ts,tsx,js}', 'mocks.ts', 'mock.js'],
rules: {
camelcase: 'off',
'sonarjs/no-duplicate-string': 'off',
'testing-library/no-debugging-utils': 'error',
},
},
{
files: ['*.styled.{ts,tsx}'],
rules: {
'sonarjs/no-nested-template-literals': 'off',
},
},
],
};