@nitra/eslint-config 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +150 -78
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,91 +7,163 @@ import securityPlugin from 'eslint-plugin-security'
|
|
|
7
7
|
import pluginVue from 'eslint-plugin-vue'
|
|
8
8
|
import globals from 'globals'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const all = [
|
|
11
|
+
{
|
|
12
|
+
// До дефолтних "**/node_modules/", ".git/" додаємо
|
|
13
|
+
ignores: ['.yarn/**', '**/dist/**']
|
|
14
|
+
},
|
|
15
|
+
// Загальні правила для всіх js файлів проекту
|
|
16
|
+
{
|
|
17
|
+
files: ['**/*.js'],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 13,
|
|
20
|
+
sourceType: 'module'
|
|
15
21
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
languageOptions: {
|
|
20
|
-
globals: {
|
|
21
|
-
process: 'readonly',
|
|
22
|
-
__dirname: 'readonly'
|
|
23
|
-
}
|
|
24
|
-
}
|
|
22
|
+
plugins: {
|
|
23
|
+
prettier: configPrettier,
|
|
24
|
+
standard: configStandard
|
|
25
25
|
},
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
rules: {
|
|
27
|
+
...js.configs.recommended.rules,
|
|
28
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
// Тільки для node js проектів
|
|
33
|
+
const node = [
|
|
34
|
+
nodePlugin.configs['flat/recommended-module'],
|
|
35
|
+
securityPlugin.configs.recommended,
|
|
36
|
+
{ plugins: { '@microsoft/eslint-plugin-sdl': sdlPlugin } },
|
|
37
|
+
{
|
|
38
|
+
rules: {
|
|
39
|
+
'security/detect-non-literal-fs-filename': 'off',
|
|
40
|
+
'security/detect-object-injection': 'off'
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
// Тільки для Vue проектів
|
|
46
|
+
// files: ['**/vite.config.js']
|
|
47
|
+
const vueVite = [
|
|
48
|
+
{
|
|
49
|
+
languageOptions: {
|
|
50
|
+
globals: {
|
|
51
|
+
process: 'readonly',
|
|
52
|
+
__dirname: 'readonly'
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
// Для усіх файлів Vue проектів
|
|
59
|
+
// files: ['**/*.js', '**/*.vue']
|
|
60
|
+
const vueAllVite = [
|
|
61
|
+
{
|
|
62
|
+
languageOptions: {
|
|
63
|
+
globals: {
|
|
64
|
+
...globals.browser,
|
|
65
|
+
createLogger: 'readonly',
|
|
66
|
+
gql: 'readonly',
|
|
67
|
+
$ref: 'readonly',
|
|
68
|
+
ref: 'readonly',
|
|
69
|
+
useQuery: 'readonly',
|
|
70
|
+
watch: 'readonly',
|
|
71
|
+
computed: 'readonly'
|
|
66
72
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
// Для Vue файлів Vue проектів
|
|
78
|
+
// files: ['**/*.vue']
|
|
79
|
+
const vue = [
|
|
80
|
+
...pluginVue.configs['flat/recommended'],
|
|
81
|
+
{
|
|
82
|
+
rules: {
|
|
83
|
+
'vue/no-v-html': 'off',
|
|
84
|
+
'vue/html-indent': 'off',
|
|
85
|
+
'vue/max-attributes-per-line': 'off',
|
|
86
|
+
'vue/html-closing-bracket-newline': 'off',
|
|
87
|
+
'vue/singleline-html-element-content-newline': 'off',
|
|
88
|
+
'vue/multi-word-component-names': 'off',
|
|
89
|
+
'vue/html-self-closing': [
|
|
90
|
+
'error',
|
|
91
|
+
{
|
|
92
|
+
html: {
|
|
93
|
+
void: 'always' // під преттієр https://github.com/prettier/prettier/issues/5641
|
|
81
94
|
}
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
// Нітра порядок сортування
|
|
98
|
+
'vue/attributes-order': [
|
|
99
|
+
'error',
|
|
100
|
+
{
|
|
101
|
+
order: [
|
|
102
|
+
'DEFINITION',
|
|
103
|
+
'LIST_RENDERING',
|
|
104
|
+
'CONDITIONALS',
|
|
105
|
+
'RENDER_MODIFIERS',
|
|
106
|
+
'GLOBAL',
|
|
107
|
+
['UNIQUE', 'SLOT'],
|
|
108
|
+
'TWO_WAY_BINDING',
|
|
109
|
+
'OTHER_DIRECTIVES',
|
|
110
|
+
'EVENTS',
|
|
111
|
+
'OTHER_ATTR',
|
|
112
|
+
'CONTENT'
|
|
113
|
+
],
|
|
114
|
+
alphabetical: false
|
|
115
|
+
}
|
|
116
|
+
]
|
|
84
117
|
}
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
}
|
|
119
|
+
]
|
|
87
120
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// }))
|
|
121
|
+
/**
|
|
122
|
+
* Eslint правила
|
|
123
|
+
*
|
|
124
|
+
* @param {{node?: Array, vue?: Array}} params список директорій до яких примінити Eslint правили
|
|
125
|
+
*/
|
|
126
|
+
export function getConfig(params = { node: [], vue: [] }) {
|
|
127
|
+
const result = all
|
|
96
128
|
|
|
97
|
-
//
|
|
129
|
+
// якщо присутні nodejs проекти в monorepo
|
|
130
|
+
if (params.node) {
|
|
131
|
+
const files = params.node.map(name => `${name}/**/*.js`)
|
|
132
|
+
const nodeConfig = node.map(configObject => ({
|
|
133
|
+
files,
|
|
134
|
+
...configObject
|
|
135
|
+
}))
|
|
136
|
+
result.push(...nodeConfig)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// якщо присутні nodejs проекти в monorepo
|
|
140
|
+
if (params.vue) {
|
|
141
|
+
// по певним файлам правили
|
|
142
|
+
const filesVite = params.vue.map(name => `${name}/**/vite.config.js`)
|
|
143
|
+
const vueViteConfig = vueVite.map(configObject => ({
|
|
144
|
+
files: filesVite,
|
|
145
|
+
...configObject
|
|
146
|
+
}))
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
result.push(...vueViteConfig)
|
|
149
|
+
|
|
150
|
+
// Для Vue файлів правила
|
|
151
|
+
const files = params.vue.map(name => `${name}/**/*.vue`)
|
|
152
|
+
const vueConfig = [...vueAllVite, ...vue].map(configObject => ({
|
|
153
|
+
files,
|
|
154
|
+
...configObject
|
|
155
|
+
}))
|
|
156
|
+
result.push(...vueConfig)
|
|
157
|
+
|
|
158
|
+
// Для js файлів всередині Vue проектів правила
|
|
159
|
+
const filesJS = params.vue.map(name => `${name}/**/*.js`)
|
|
160
|
+
const vueJSConfig = vueAllVite.map(configObject => ({
|
|
161
|
+
files: filesJS,
|
|
162
|
+
...configObject
|
|
163
|
+
}))
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
result.push(...vueJSConfig)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return result
|
|
169
|
+
}
|