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