-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path.eslintrc.js
107 lines (106 loc) · 3.09 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
/** Разрешенные импорты (с публичными API) */
const ALLOWED_PATH_GROUPS = [
"pages/**",
"widgets/**",
"features/**",
"entities/**",
"shared/**",
].map((pattern) => ({
pattern,
group: "internal",
position: "after",
}));
/** Для запрета приватных путей */
const DENIED_PATH_GROUPS = [
// Private imports are prohibited, use public imports instead
"app/**",
"pages/*/**",
"widgets/*/**",
"features/*/**",
"entities/*/**",
"shared/*/*/**",
// Prefer absolute imports instead of relatives (for root modules)
"../**/app",
"../**/pages",
"../**/widgets",
"../**/features",
"../**/entities",
"../**/shared",
];
// TODO: Заэкстендить позднее
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
ecmaFeatures: {
jsx: true,
modules: true,
},
sourceType: "module",
},
env: {
browser: true,
es6: true,
},
plugins: ["react", "@typescript-eslint", "unicorn"],
extends: [
"react-app",
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"plugin:react/recommended",
"prettier",
],
rules: {
// imports
"import/first": 2,
"import/no-unresolved": 0,
// TODO: eslint-plugin-boundaries
"import/order": [
2,
{
pathGroups: ALLOWED_PATH_GROUPS,
pathGroupsExcludedImportTypes: ["builtin"],
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
},
],
"no-restricted-imports": [2, { patterns: DENIED_PATH_GROUPS }],
// variables
"prefer-const": 2,
"no-var": 2,
// base
"camelcase": [1, { ignoreDestructuring: true, ignoreImports: true, properties: "never" }],
"no-else-return": 2,
"max-len": [1, { code: 120 }],
"dot-notation": 2,
"eol-last": 2,
// alert, console
"no-alert": 2,
"no-console": 2,
// equals
"eqeqeq": 1,
"no-eq-null": 2,
// function
"max-params": [1, 2],
"max-lines-per-function": [1, 48],
"arrow-parens": [2, "always"],
// "arrow-body-style": [1, "as-needed"],
// plugin:unicorn
"unicorn/no-for-loop": 2,
"unicorn/no-abusive-eslint-disable": 2,
"unicorn/no-array-instanceof": 2,
"unicorn/no-zero-fractions": 2,
"unicorn/prefer-includes": 2,
"unicorn/prefer-text-content": 2,
"unicorn/import-index": 2,
"unicorn/throw-new-error": 2,
// plugin: react
"react/jsx-uses-react": 0,
"react/react-in-jsx-scope": 0,
"react/prop-types": 0,
"no-restricted-globals": 1,
},
overrides: [],
};