@nitra/eslint-config 3.4.8 → 3.6.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 CHANGED
@@ -79,7 +79,7 @@ export default [
79
79
 
80
80
  ## Що входить у конфіг
81
81
 
82
- - Базові правила JS (recommended), JSDoc, Import, Unicorn
82
+ - Базові правила JS (recommended), JSDoc, **eslint-plugin-import-x** (префікс `import-x/`), Unicorn
83
83
  - YAML і Markdown
84
84
  - Для **Node**: eslint-plugin-n
85
85
  - Для **Vue**: eslint-plugin-vue з правилами атрибутів та порядку
@@ -17,6 +17,9 @@ let onDiskConfig
17
17
  let onDiskConfigLoaded = false
18
18
  const RELEVANT_KEYWORDS = ['gql', 'graphql', 'GraphQL']
19
19
 
20
+ /** Регулярний вираз на рівні модуля для e18e/prefer-static-regex. */
21
+ const VUE_OR_SVELTE_FILE_RE = /\.(vue|svelte)$/
22
+
20
23
  /**
21
24
  * Шлях для graphql-config: для віртуальних блоків Vue — фізичний .vue, інакше той самий filePath.
22
25
  * @param {string} filePath шлях файлу, який обробляє processor
@@ -86,7 +89,7 @@ ${error.message}`
86
89
  for (const [i, block] of blocks.entries()) {
87
90
  const { lineOffset, offset } = block
88
91
  for (const message of messages[i] || []) {
89
- const isVueOrSvelte = /\.(vue|svelte)$/.test(filePath)
92
+ const isVueOrSvelte = VUE_OR_SVELTE_FILE_RE.test(filePath)
90
93
  if (isVueOrSvelte) {
91
94
  delete message.endLine
92
95
  delete message.endColumn
package/index.js CHANGED
@@ -1,15 +1,17 @@
1
+ import e18ePlugin from '@e18e/eslint-plugin'
1
2
  import { fixupPluginRules } from '@eslint/compat'
2
3
  import js from '@eslint/js'
3
4
  import graphqlEslintPlugin from '@graphql-eslint/eslint-plugin'
4
5
  import { graphqlCodefileProcessor, graphqlParserWithConfigAnchor } from './graphql-eslint-anchor.js'
5
6
  import microsoftSdl from '@microsoft/eslint-plugin-sdl'
6
- import { flatConfigs as importPlugin } from 'eslint-plugin-import'
7
+ import { flatConfigs as importXFlatConfigs } from 'eslint-plugin-import-x'
7
8
  import jsdocPlugin from 'eslint-plugin-jsdoc'
8
9
  import { configs as jsoncConfigs } from 'eslint-plugin-jsonc'
9
10
  import markdownPlugin from 'eslint-plugin-markdown'
10
11
  import nodePlugin from 'eslint-plugin-n'
11
12
  import oxlint from 'eslint-plugin-oxlint'
12
13
  import securityPlugin from 'eslint-plugin-security'
14
+ import sonarjsPlugin from 'eslint-plugin-sonarjs'
13
15
  import unicornPlugin from 'eslint-plugin-unicorn'
14
16
  import vuePlugin from 'eslint-plugin-vue'
15
17
  import { configs as ymlConfigs } from 'eslint-plugin-yml'
@@ -20,6 +22,10 @@ import globals from 'globals'
20
22
  /** Glob-патерни файлів для eslint-plugin-unicorn (JS-подібні джерела; без сирих YAML/Markdown). */
21
23
  const UNICORN_FILES = ['**/*.{js,mjs,cjs,vue}']
22
24
 
25
+ /** Пресет recommended `@e18e/eslint-plugin` (flat). */
26
+ // @ts-expect-error типізація плагіна не гарантує `configs.recommended`; у runtime поле є.
27
+ const e18eRecommendedFlat = /** @type {import('eslint').Linter.FlatConfig} */ (e18ePlugin.configs.recommended)
28
+
23
29
  /** Віртуальні документи з gql/graphql у .js/.vue (processor); ESLint обробляє їх як окремі `*.graphql` файли. */
24
30
  const GRAPHQL_EXTRACTED_DOCUMENT_FILES = ['**/*.graphql']
25
31
 
@@ -75,11 +81,11 @@ function flatConfigsWithFiles(configs, files) {
75
81
  return configs.map(config => ({ ...config, files }))
76
82
  }
77
83
 
78
- // Перевизначаємо версію EcmaScript на останню
79
- const importPluginEcmaLatest = {
80
- ...importPlugin.recommended,
84
+ // Перевизначаємо версію EcmaScript на останню (eslint-plugin-import-x — fork import з flat recommended)
85
+ const importXPluginEcmaLatest = {
86
+ ...importXFlatConfigs.recommended,
81
87
  languageOptions: {
82
- ...importPlugin.recommended?.languageOptions,
88
+ ...importXFlatConfigs.recommended?.languageOptions,
83
89
  ecmaVersion: 'latest'
84
90
  }
85
91
  }
@@ -95,14 +101,14 @@ const all = [
95
101
  ...jsoncConfigs['flat/recommended-with-jsonc'],
96
102
  // Загальні правила для всіх MD файлів проекту
97
103
  ...markdownPlugin.configs.recommended,
98
- // Плагін eslint-plugin-import
99
- importPluginEcmaLatest,
104
+ // Плагін eslint-plugin-import-x (правила з префіксом import-x/)
105
+ importXPluginEcmaLatest,
100
106
  {
101
107
  rules: {
102
- 'import/no-unresolved': 'off', // не працює з monorepo та #alias
103
- 'import/newline-after-import': ['error', { count: 1 }],
104
- // 'import/order': ['error', { warnOnUnassignedImports: true }],
105
- 'import/no-useless-path-segments': ['error', { noUselessIndex: false }]
108
+ 'import-x/no-unresolved': 'off', // не працює з monorepo та #alias
109
+ 'import-x/newline-after-import': ['error', { count: 1 }],
110
+ // 'import-x/order': ['error', { warnOnUnassignedImports: true }],
111
+ 'import-x/no-useless-path-segments': ['error', { noUselessIndex: false }]
106
112
  }
107
113
  },
108
114
  // Загальні правила для всіх js файлів проекту
@@ -164,6 +170,13 @@ const all = [
164
170
  'security/detect-unsafe-regex': 'off'
165
171
  }
166
172
  },
173
+ // eslint-plugin-sonarjs — recommended (bugs, complexity, duplicates; лише JS-подібні файли)
174
+ { ...sonarjsPlugin.configs.recommended, files: UNICORN_FILES },
175
+ // @e18e/eslint-plugin — recommended (modernization + module replacements + performance)
176
+ {
177
+ files: UNICORN_FILES,
178
+ ...e18eRecommendedFlat
179
+ },
167
180
  // @microsoft/eslint-plugin-sdl — common SDL (без TypeScript/React/Angular; узгоджено з UNICORN_FILES)
168
181
  ...flatConfigsWithFiles(microsoftSdl.configs.common, UNICORN_FILES)
169
182
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/eslint-config",
3
- "version": "3.4.8",
3
+ "version": "3.6.0",
4
4
  "description": "An ESLint shareable config for projects using Vue and Node",
5
5
  "keywords": [
6
6
  "eslint",
@@ -22,6 +22,7 @@
22
22
  "types": "./index.d.ts",
23
23
  "exports": "./index.js",
24
24
  "dependencies": {
25
+ "@e18e/eslint-plugin": "^0.3.0",
25
26
  "@eslint/compat": "^2.0.5",
26
27
  "@eslint/js": "^10.0.1",
27
28
  "@graphql-eslint/eslint-plugin": "^4.4.0",
@@ -30,13 +31,14 @@
30
31
  "@microsoft/eslint-plugin-sdl": "^1.1.0",
31
32
  "eslint": "^10.2.0",
32
33
  "eslint-merge-processors": "^2.0.0",
33
- "eslint-plugin-import": "^2.32.0",
34
+ "eslint-plugin-import-x": "^4.16.2",
34
35
  "eslint-plugin-jsdoc": "^62.9.0",
35
36
  "eslint-plugin-jsonc": "^3.1.2",
36
37
  "eslint-plugin-markdown": "^5.1.0",
37
38
  "eslint-plugin-n": "^17.24.0",
38
39
  "eslint-plugin-oxlint": "^1.59.0",
39
40
  "eslint-plugin-security": "^4.0.0",
41
+ "eslint-plugin-sonarjs": "^4.0.2",
40
42
  "eslint-plugin-unicorn": "^64.0.0",
41
43
  "eslint-plugin-vue": "^10.8.0",
42
44
  "eslint-plugin-yml": "^3.3.1",