-
Notifications
You must be signed in to change notification settings - Fork 18
/
.eslintrc.js
109 lines (108 loc) · 3.33 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
/** Разрешенные импорты (с публичными API) */
const ALLOWED_PATH_GROUPS = ["shared", "shared/**", "pages", "features", "models"].map(
(pattern) => ({
pattern,
group: "internal",
position: "after",
}),
);
/** Для запрета приватных путей */
const DENIED_PATH_GROUPS = [
// Private imports are prohibited, use public imports instead
"app/**",
"pages/**",
"features/**",
"shared/*/**",
"models.gen",
// Prefer absolute imports instead of relatives (for root modules)
"../**/app",
"../**/pages",
"../**/features",
"../**/shared",
"../**/models",
];
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", "@graphql-eslint", "unicorn"],
extends: [
"react-app",
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"plugin:react/recommended",
"prettier",
"prettier/react",
],
rules: {
// imports
"import/first": 2,
"import/no-unresolved": 0,
"import/order": [
2,
{
pathGroups: ALLOWED_PATH_GROUPS,
// TODO: Добавить сортировку `import "./index.scss";` (располагать внизу)
// TODO: Добавить сортировку `import *** from "react"` (располагать вверху)
pathGroupsExcludedImportTypes: ["builtin"],
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
},
],
// TODO: specify message: ("Please use allowed public API (not private imports!)")
"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": 0,
// equals
"eqeqeq": 1,
"no-eq-null": 2,
// function
"max-params": [1, 2],
"max-lines-per-function": [1, 48],
"arrow-parens": [2, "always"],
// 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:graphql
"@graphql-eslint/no-anonymous-operations": 2,
},
overrides: [
{
files: ["*.gql"],
parser: "@graphql-eslint/eslint-plugin",
plugins: ["@graphql-eslint"],
rules: {
"prettier/prettier": 0,
"max-len": 0,
},
},
],
};