@nitra/eslint-config 3.2.3 → 3.4.0
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/README.md +3 -3
- package/index.js +59 -19
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
bun add @nitra/eslint-config -D
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
_Це лише спільна конфігурація.
|
|
16
|
+
_Це лише спільна конфігурація. ESLint та плагіни потрібно встановлювати окремо або вони підтягнуться як залежності (форматування коду — окремо, наприклад oxfmt)._
|
|
17
17
|
|
|
18
18
|
## Використання
|
|
19
19
|
|
|
@@ -79,8 +79,8 @@ export default [
|
|
|
79
79
|
|
|
80
80
|
## Що входить у конфіг
|
|
81
81
|
|
|
82
|
-
- Базові правила JS (recommended),
|
|
82
|
+
- Базові правила JS (recommended), JSDoc, Import, Unicorn
|
|
83
83
|
- YAML і Markdown
|
|
84
|
-
- Для **Node**: eslint-plugin-n
|
|
84
|
+
- Для **Node**: eslint-plugin-n
|
|
85
85
|
- Для **Vue**: eslint-plugin-vue з правилами атрибутів та порядку
|
|
86
86
|
- Oxlint (recommended)
|
package/index.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
+
import microsoftSdl from '@microsoft/eslint-plugin-sdl'
|
|
1
2
|
import js from '@eslint/js'
|
|
2
|
-
import configPrettier from 'eslint-config-prettier'
|
|
3
3
|
import { flatConfigs as importPlugin } from 'eslint-plugin-import'
|
|
4
4
|
import jsdocPlugin from 'eslint-plugin-jsdoc'
|
|
5
5
|
import markdownPlugin from 'eslint-plugin-markdown'
|
|
6
6
|
import nodePlugin from 'eslint-plugin-n'
|
|
7
7
|
import oxlint from 'eslint-plugin-oxlint'
|
|
8
|
+
import securityPlugin from 'eslint-plugin-security'
|
|
8
9
|
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
9
10
|
import vuePlugin from 'eslint-plugin-vue'
|
|
11
|
+
import { configs as jsoncConfigs } from 'eslint-plugin-jsonc'
|
|
10
12
|
import { configs as ymlConfigs } from 'eslint-plugin-yml'
|
|
11
13
|
import globals from 'globals'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
/** Glob-патерни файлів для eslint-plugin-unicorn (JS-подібні джерела; без сирих YAML/Markdown). */
|
|
16
|
+
const UNICORN_FILES = ['**/*.{js,mjs,cjs,vue}']
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Обмежує масив flat-конфігів ESLint заданими `files` (копія кожного елемента).
|
|
20
|
+
* @param {import('eslint').Linter.FlatConfig[]} configs вхідні конфіги
|
|
21
|
+
* @param {string[]} files glob-патерни файлів
|
|
22
|
+
* @returns {import('eslint').Linter.FlatConfig[]} новий масив flat-конфігів з полем `files`
|
|
23
|
+
*/
|
|
24
|
+
function flatConfigsWithFiles(configs, files) {
|
|
25
|
+
return configs.map(config => ({ ...config, files }))
|
|
26
|
+
}
|
|
14
27
|
|
|
15
28
|
// Перевизначаємо версію EcmaScript на останню
|
|
16
29
|
const importPluginEcmaLatest = {
|
|
@@ -27,7 +40,9 @@ const all = [
|
|
|
27
40
|
ignores: ['.yarn/**', '**/dist/**']
|
|
28
41
|
},
|
|
29
42
|
// Загальні правила для всіх Yaml файлів проекту
|
|
30
|
-
...ymlConfigs['flat/
|
|
43
|
+
...ymlConfigs['flat/recommended'],
|
|
44
|
+
// JSON / JSONC / JSON5 (рекомендований пресет як у документації плагіна)
|
|
45
|
+
...jsoncConfigs['flat/recommended-with-jsonc'],
|
|
31
46
|
// Загальні правила для всіх MD файлів проекту
|
|
32
47
|
...markdownPlugin.configs.recommended,
|
|
33
48
|
// Плагін eslint-plugin-import
|
|
@@ -42,7 +57,6 @@ const all = [
|
|
|
42
57
|
},
|
|
43
58
|
// Загальні правила для всіх js файлів проекту
|
|
44
59
|
jsdocPlugin.configs['flat/recommended'],
|
|
45
|
-
configPrettier,
|
|
46
60
|
{
|
|
47
61
|
files: ['**/*.js'],
|
|
48
62
|
languageOptions: {
|
|
@@ -54,9 +68,12 @@ const all = [
|
|
|
54
68
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
|
|
55
69
|
}
|
|
56
70
|
},
|
|
57
|
-
// Unicorn правила
|
|
58
|
-
unicornPlugin.configs.recommended
|
|
71
|
+
// Unicorn правила (лише JS-подібні файли — узгоджено з блоком рекомендованих правил ESLint)
|
|
72
|
+
...(Array.isArray(unicornPlugin.configs.recommended)
|
|
73
|
+
? unicornPlugin.configs.recommended.map(config => ({ ...config, files: UNICORN_FILES }))
|
|
74
|
+
: [{ ...unicornPlugin.configs.recommended, files: UNICORN_FILES }]),
|
|
59
75
|
{
|
|
76
|
+
files: UNICORN_FILES,
|
|
60
77
|
rules: {
|
|
61
78
|
'unicorn/filename-case': 'off',
|
|
62
79
|
'unicorn/no-null': 'off',
|
|
@@ -74,22 +91,42 @@ const all = [
|
|
|
74
91
|
'unicorn/numeric-separators-style': [
|
|
75
92
|
'error',
|
|
76
93
|
{ onlyIfContainsSeparator: true, binary: { onlyIfContainsSeparator: false } }
|
|
94
|
+
],
|
|
95
|
+
// unicorn за замовчуванням default для path — вимикаємо, лишаємо лише named (join, resolve тощо)
|
|
96
|
+
'unicorn/import-style': [
|
|
97
|
+
'error',
|
|
98
|
+
{
|
|
99
|
+
styles: {
|
|
100
|
+
path: { default: false, namespace: false, named: true },
|
|
101
|
+
'node:path': { default: false, namespace: false, named: true }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
77
104
|
]
|
|
78
105
|
}
|
|
79
|
-
}
|
|
106
|
+
},
|
|
107
|
+
// eslint-plugin-security (лише JS-подібні файли — як unicorn)
|
|
108
|
+
{ ...securityPlugin.configs.recommended, files: UNICORN_FILES },
|
|
109
|
+
{
|
|
110
|
+
files: UNICORN_FILES,
|
|
111
|
+
rules: {
|
|
112
|
+
'security/detect-non-literal-fs-filename': 'off',
|
|
113
|
+
'security/detect-object-injection': 'off',
|
|
114
|
+
'security/detect-unsafe-regex': 'off'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// @microsoft/eslint-plugin-sdl — common SDL (без TypeScript/React/Angular; узгоджено з UNICORN_FILES)
|
|
118
|
+
...flatConfigsWithFiles(microsoftSdl.configs.common, UNICORN_FILES)
|
|
80
119
|
]
|
|
81
120
|
// Тільки для node js проектів
|
|
121
|
+
/* Друга частина SDL node: лише правила microsoft-sdl; перший блок upstream дублює реєстрацію eslint-plugin-n. */
|
|
122
|
+
const microsoftSdlNodeConfigsWithoutN = microsoftSdl.configs.node.slice(1)
|
|
123
|
+
|
|
82
124
|
const node = [
|
|
83
125
|
nodePlugin.configs['flat/recommended-module'],
|
|
84
|
-
// securityPlugin.configs.recommended,
|
|
85
|
-
// { plugins: { '@microsoft/eslint-plugin-sdl': sdlPlugin } },
|
|
86
126
|
{
|
|
87
127
|
rules: {
|
|
88
128
|
'n/no-missing-import': 'off', // покривається oxlint https://github.com/oxc-project/oxc/issues/481#issuecomment-3135766557
|
|
89
|
-
'
|
|
90
|
-
'security/detect-object-injection': 'off'
|
|
91
|
-
// eslint-plugin-security@3.0.1 використовує context.getSourceCode() — прибрано в ESLint 9+
|
|
92
|
-
// 'security/detect-unsafe-regex': 'off'
|
|
129
|
+
'n/no-deprecated-api': 'error' // як перший блок `configs.node` у @microsoft/eslint-plugin-sdl
|
|
93
130
|
},
|
|
94
131
|
languageOptions: {
|
|
95
132
|
globals: {
|
|
@@ -146,7 +183,7 @@ const vue = [
|
|
|
146
183
|
'error',
|
|
147
184
|
{
|
|
148
185
|
html: {
|
|
149
|
-
void: 'always' //
|
|
186
|
+
void: 'always' // узгоджено з oxfmt / стабільним форматуванням void-елементів
|
|
150
187
|
}
|
|
151
188
|
}
|
|
152
189
|
],
|
|
@@ -184,9 +221,9 @@ const vue2 = [
|
|
|
184
221
|
|
|
185
222
|
/**
|
|
186
223
|
* Додає до result конфіги для Vue-проєктів (vite, .vue, .js).
|
|
187
|
-
* @param {
|
|
224
|
+
* @param {import('eslint').Linter.FlatConfig[]} result масив конфігів
|
|
188
225
|
* @param {string[]} dirs директорії Vue-проєктів
|
|
189
|
-
* @param {{ includeVite?: boolean, extraVueConfigs?:
|
|
226
|
+
* @param {{ includeVite?: boolean, extraVueConfigs?: import('eslint').Linter.FlatConfig[] }} [options] опції: includeVite, extraVueConfigs
|
|
190
227
|
*/
|
|
191
228
|
function pushVueConfigs(result, dirs, options = {}) {
|
|
192
229
|
const { includeVite = false, extraVueConfigs = [] } = options
|
|
@@ -206,7 +243,7 @@ function pushVueConfigs(result, dirs, options = {}) {
|
|
|
206
243
|
|
|
207
244
|
/**
|
|
208
245
|
* ESLint flat config для проєктів на Vue та Node.
|
|
209
|
-
* @param {
|
|
246
|
+
* @param {object} [params] — список директорій для застосування правил
|
|
210
247
|
* @param {string[]} [params.node] — шляхи до Node.js коду
|
|
211
248
|
* @param {string[]} [params.vue] — шляхи до Vue 3
|
|
212
249
|
* @param {string[]} [params.vue2] — шляхи до Vue 2
|
|
@@ -218,7 +255,10 @@ export function getConfig(params = { node: [], vue: [], vue2: [] }) {
|
|
|
218
255
|
|
|
219
256
|
if (params.node?.length) {
|
|
220
257
|
const files = params.node.map(name => `${name}/**/*.js`)
|
|
221
|
-
result.push(
|
|
258
|
+
result.push(
|
|
259
|
+
...node.map(configObject => ({ files, ...configObject })),
|
|
260
|
+
...flatConfigsWithFiles(microsoftSdlNodeConfigsWithoutN, files)
|
|
261
|
+
)
|
|
222
262
|
}
|
|
223
263
|
|
|
224
264
|
if (params.vue?.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitra/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "An ESLint shareable config for projects using Vue and Node",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -22,18 +22,20 @@
|
|
|
22
22
|
"exports": "./index.js",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@eslint/js": "^10.0.1",
|
|
25
|
-
"eslint": "^
|
|
26
|
-
"eslint
|
|
25
|
+
"@microsoft/eslint-plugin-sdl": "^1.1.0",
|
|
26
|
+
"eslint": "^10.2.0",
|
|
27
27
|
"eslint-plugin-import": "^2.32.0",
|
|
28
|
-
"eslint-plugin-jsdoc": "^62.
|
|
28
|
+
"eslint-plugin-jsdoc": "^62.9.0",
|
|
29
|
+
"eslint-plugin-jsonc": "^3.1.2",
|
|
29
30
|
"eslint-plugin-markdown": "^5.1.0",
|
|
30
|
-
"eslint-plugin-n": "^17.
|
|
31
|
-
"eslint-plugin-oxlint": "^1.
|
|
32
|
-
"eslint-plugin-
|
|
33
|
-
"eslint-plugin-
|
|
34
|
-
"eslint-plugin-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
31
|
+
"eslint-plugin-n": "^17.24.0",
|
|
32
|
+
"eslint-plugin-oxlint": "^1.58.0",
|
|
33
|
+
"eslint-plugin-security": "^4.0.0",
|
|
34
|
+
"eslint-plugin-unicorn": "^64.0.0",
|
|
35
|
+
"eslint-plugin-vue": "^10.8.0",
|
|
36
|
+
"eslint-plugin-yml": "^3.3.1",
|
|
37
|
+
"globals": "^17.4.0",
|
|
38
|
+
"vue-eslint-parser": "^10.4.0"
|
|
37
39
|
},
|
|
38
40
|
"engines": {
|
|
39
41
|
"node": ">=20.19.0"
|