-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross-platform-rules.js
126 lines (115 loc) · 3.25 KB
/
cross-platform-rules.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
const { rules: eslintPluginImportRules } = require('eslint-plugin-import');
// eslint-disable-next-line node/no-missing-require
const {
configs: eslintPluginTypescriptConfigs,
} = require('@typescript-eslint/eslint-plugin');
// this will enable all rules
const importRulesAllOn = Object.fromEntries(
Object.keys(eslintPluginImportRules).map((ruleName) => [
`import/${ruleName}`,
'error',
]),
);
const importRules = {
...importRulesAllOn,
// now we have to disable some of them
'import/named': 'off',
'import/default': 'off',
'import/prefer-default-export': 'off',
'import/no-internal-modules': 'off',
'import/no-relative-parent-imports': 'off',
'import/no-relative-packages': 'off',
'import/no-named-export': 'off',
'import/no-import-module-exports': 'off',
'import/group-exports': 'off',
'import/exports-last': 'off',
'import/dynamic-import-chunkname': 'off',
'import/max-dependencies': [
'error',
{
max: 15,
ignoreTypeImports: true,
},
],
// disable
'import/order': 'off',
'sort-imports': 'off',
// enable this rules for all import sorting problems
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
};
const crossPlatformTSRules = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': [
'warn',
{
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
},
],
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
'@typescript-eslint/no-type-alias': ['error', { allowAliases: 'in-unions' }],
// we dont need that - TS will cover this
'node/no-unsupported-features/es-syntax': 'off',
...eslintPluginTypescriptConfigs['disable-type-checked'].rules,
};
const crossPlatformJSRules = {
'arrow-body-style': 'off',
'one-var': ['error', 'never'],
'id-length': 'off',
'no-void': ['error', { allowAsStatement: true }],
'no-undefined': 'off',
'no-ternary': 'off',
'vars-on-top': 'off',
'no-implicit-coercion': 'off',
'require-unicode-regexp': 'off',
'sort-keys': 'off',
'no-negated-condition': 'off',
'no-undef-init': 'off',
// enable warnings for some rules
'no-magic-numbers': 'warn',
'prefer-named-capture-group': 'warn',
// max statements, imports, lines per function, length, params
'max-statements': ['error', 15],
'max-lines-per-function': ['error', 200],
'import/max-dependencies': [
'error',
{
max: 15,
ignoreTypeImports: false,
},
],
'max-params': ['error', 5],
// comments
'capitalized-comments': 'off',
'no-warning-comments': 'off',
'multiline-comment-style': ['error', 'separate-lines'],
// unicorn
'unicorn/filename-case': [
'error',
{
cases: {
kebabCase: true,
pascalCase: true,
},
},
],
'unicorn/no-null': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/no-useless-undefined': 'off',
'func-names': 'off',
...importRules,
};
const crossPlatformJSTSRules = {
...crossPlatformJSRules,
...crossPlatformTSRules,
};
module.exports = {
crossPlatformTSRules,
crossPlatformJSRules,
crossPlatformJSTSRules,
};