@nitra/eslint-config 3.6.2 → 3.6.3

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 (2) hide show
  1. package/index.js +47 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,8 +2,8 @@ import e18ePlugin from '@e18e/eslint-plugin'
2
2
  import { fixupPluginRules } from '@eslint/compat'
3
3
  import js from '@eslint/js'
4
4
  import graphqlEslintPlugin from '@graphql-eslint/eslint-plugin'
5
- import { graphqlCodefileProcessor, graphqlParserWithConfigAnchor } from './graphql-eslint-anchor.js'
6
5
  import microsoftSdl from '@microsoft/eslint-plugin-sdl'
6
+ import { mergeProcessors } from 'eslint-merge-processors'
7
7
  import { flatConfigs as importXFlatConfigs } from 'eslint-plugin-import-x'
8
8
  import jsdocPlugin from 'eslint-plugin-jsdoc'
9
9
  import { configs as jsoncConfigs } from 'eslint-plugin-jsonc'
@@ -14,15 +14,34 @@ import securityPlugin from 'eslint-plugin-security'
14
14
  import sonarjsPlugin from 'eslint-plugin-sonarjs'
15
15
  import unicornPlugin from 'eslint-plugin-unicorn'
16
16
  import vuePlugin from 'eslint-plugin-vue'
17
- import vueEslintParser from 'vue-eslint-parser'
18
17
  import { configs as ymlConfigs } from 'eslint-plugin-yml'
19
- import { mergeProcessors } from 'eslint-merge-processors'
20
18
  import processorVueBlocks from 'eslint-processor-vue-blocks'
21
19
  import globals from 'globals'
20
+ import vueEslintParser from 'vue-eslint-parser'
21
+ import { graphqlCodefileProcessor, graphqlParserWithConfigAnchor } from './graphql-eslint-anchor.js'
22
22
 
23
23
  /** Glob-патерни файлів для eslint-plugin-unicorn (JS-подібні джерела; без сирих YAML/Markdown). */
24
24
  const UNICORN_FILES = ['**/*.{js,mjs,cjs,vue}']
25
25
 
26
+ /** Узгоджені опції `no-unused-vars` для `.js` і Vue SFC (`eslint-plugin-oxlint` не вимикає це правило для `.vue`, тож oxlint CLI його там не покриває). */
27
+ const NO_UNUSED_VARS_RULE = ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
28
+
29
+ /**
30
+ * Частина ядра `eslint:recommended`, яку не вимикає `eslint-plugin-oxlint` flat/recommended (oxlint не заявляє заміну
31
+ * цих правил у ESLint) і яка не ввімкнена в oxlint за кореневим `.oxlintrc.json` — для `<script>` у `.vue` їх
32
+ * лишаємо на ESLint після oxlint. Решту з recommended для SFC покриває oxlint CLI з вашого `.oxlintrc.json`.
33
+ */
34
+ const VUE_SCRIPT_ESLINT_RECOMMENDED_GAP_RULES = {
35
+ 'getter-return': 'error',
36
+ 'no-dupe-args': 'error',
37
+ 'no-octal': 'error',
38
+ 'no-undef': 'error',
39
+ 'no-unreachable': 'error',
40
+ 'no-useless-assignment': 'error',
41
+ 'preserve-caught-error': 'error',
42
+ 'no-unused-vars': NO_UNUSED_VARS_RULE
43
+ }
44
+
26
45
  /** Пресет recommended `@e18e/eslint-plugin` (flat). */
27
46
  // @ts-expect-error типізація плагіна не гарантує `configs.recommended`; у runtime поле є.
28
47
  const e18eRecommendedFlat = /** @type {import('eslint').Linter.FlatConfig} */ (e18ePlugin.configs.recommended)
@@ -122,7 +141,7 @@ const all = [
122
141
  },
123
142
  rules: {
124
143
  ...js.configs.recommended.rules,
125
- 'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
144
+ 'no-unused-vars': NO_UNUSED_VARS_RULE
126
145
  }
127
146
  },
128
147
  // Unicorn правила (лише JS-подібні файли — узгоджено з блоком рекомендованих правил ESLint)
@@ -238,14 +257,9 @@ const vueAllVite = [
238
257
  useQuery: 'readonly',
239
258
  watch: 'readonly',
240
259
  computed: 'readonly',
241
- // Макроси `<script setup>` і vue-macros (`defineOptions` тощо).
242
- defineProps: 'readonly',
243
- defineEmits: 'readonly',
244
- defineExpose: 'readonly',
245
- withDefaults: 'readonly',
246
- defineSlots: 'readonly',
247
- defineModel: 'readonly',
248
- defineOptions: 'readonly'
260
+
261
+ // Макроси `<script setup>` (джерело списку — `globals` / `vue` у vue-eslint-parser).
262
+ ...globals.vue
249
263
  }
250
264
  }
251
265
  }
@@ -332,6 +346,26 @@ function pushGraphqlVueMergedProcessorLast(result, dirs) {
332
346
  })
333
347
  }
334
348
 
349
+ /**
350
+ * Після oxlint додає для `.vue` правила з `eslint:recommended`, які не делегує `eslint-plugin-oxlint` і які
351
+ * не ввімкнені в oxlint за `.oxlintrc.json` (див. `VUE_SCRIPT_ESLINT_RECOMMENDED_GAP_RULES`).
352
+ * @param {import('eslint').Linter.FlatConfig[]} result масив конфігів
353
+ * @param {string[]} dirs кореневі директорії Vue-пакетів (ті самі аргументи dirs, що й у pushVueConfigs)
354
+ */
355
+ function pushVueScriptEslintRecommendedGapsAfterOxlint(result, dirs) {
356
+ if (!dirs?.length) {
357
+ return
358
+ }
359
+ result.push({
360
+ name: 'nitra/vue-script-eslint-recommended-oxlint-gaps',
361
+ files: dirs.map(name => `${name}/**/*.vue`),
362
+ // Правила з `eslint:recommended` + `no-unused-vars` з опціями; тип `RuleConfig` у ESLint 10 вимагає кортеж, тож подвійне приведення.
363
+ rules: /** @type {import('eslint').Linter.RulesRecord} */ (
364
+ /** @type {unknown} */ (VUE_SCRIPT_ESLINT_RECOMMENDED_GAP_RULES)
365
+ )
366
+ })
367
+ }
368
+
335
369
  /**
336
370
  * Додає до result конфіги для Vue-проєктів (vite, .vue, .js).
337
371
  * @param {import('eslint').Linter.FlatConfig[]} result масив конфігів
@@ -410,6 +444,7 @@ export function getConfig(params = { node: [], vue: [], vue2: [] }) {
410
444
 
411
445
  if (graphqlVueDirsLast.length) {
412
446
  pushGraphqlVueMergedProcessorLast(result, graphqlVueDirsLast)
447
+ pushVueScriptEslintRecommendedGapsAfterOxlint(result, graphqlVueDirsLast)
413
448
  }
414
449
 
415
450
  return result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/eslint-config",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "description": "An ESLint shareable config for projects using Vue and Node",
5
5
  "keywords": [
6
6
  "eslint",