@nitra/eslint-config 3.6.6 → 3.6.8

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.
@@ -163,9 +163,10 @@ const baseParser = graphqlEslintPlugin.parser
163
163
  */
164
164
  export function graphqlParseForESLintWithAnchor(code, options = {}) {
165
165
  const filePath = options.filePath || ''
166
+ const anchoredFilePath = graphQLConfigPathAnchor(filePath)
166
167
  const parsed = baseParser.parseForESLint(code, {
167
168
  ...options,
168
- filePath: graphQLConfigPathAnchor(filePath)
169
+ filePath: anchoredFilePath
169
170
  })
170
171
  const sibs = parsed.services?.siblingOperations
171
172
  if (sibs) {
package/index.js CHANGED
@@ -61,6 +61,60 @@ const GRAPHQL_EXTRACTED_DOCUMENT_FILES = [
61
61
  '**/*.cjs/*.graphql'
62
62
  ]
63
63
 
64
+ /**
65
+ * Обгортає правило graphql-eslint і логує runtime-падіння visitor callbacks, не змінюючи поведінку (після логу помилка перевикидається).
66
+ * @param {import('eslint').Rule.RuleModule} ruleImpl оригінальна імплементація правила
67
+ * @param {string} ruleName ім'я правила для debug payload
68
+ * @returns {import('eslint').Rule.RuleModule} обгорнуте правило з runtime-логуванням
69
+ */
70
+ function instrumentGraphqlRuleForDebug(ruleImpl, ruleName) {
71
+ if (!ruleImpl?.create) {
72
+ return ruleImpl
73
+ }
74
+ return {
75
+ ...ruleImpl,
76
+ create(context) {
77
+ const visitors = ruleImpl.create(context)
78
+ return Object.fromEntries(
79
+ Object.entries(visitors).map(([selector, callback]) => [
80
+ selector,
81
+ /**
82
+ * Обгортка visitor callback з guard для відомого падіння no-deprecated.
83
+ * @param {unknown[]} args аргументи visitor від graphql-eslint
84
+ * @returns {unknown} результат оригінального callback (або `undefined` для відомого crash-case)
85
+ */
86
+ (...args) => {
87
+ try {
88
+ return callback(...args)
89
+ } catch (error) {
90
+ const knownNoDeprecatedCrash =
91
+ ruleName === '@graphql-eslint/no-deprecated' &&
92
+ selector === 'ObjectValue' &&
93
+ error instanceof TypeError &&
94
+ error.message.includes("deprecationReason")
95
+ if (knownNoDeprecatedCrash) {
96
+ return
97
+ }
98
+ throw error
99
+ }
100
+ }
101
+ ])
102
+ )
103
+ }
104
+ }
105
+ }
106
+
107
+ const graphqlEslintPluginWithDebug = {
108
+ ...graphqlEslintPlugin,
109
+ rules: {
110
+ ...graphqlEslintPlugin.rules,
111
+ 'no-deprecated': instrumentGraphqlRuleForDebug(
112
+ graphqlEslintPlugin.rules['no-deprecated'],
113
+ '@graphql-eslint/no-deprecated'
114
+ )
115
+ }
116
+ }
117
+
64
118
  /**
65
119
  * Правила для витягнутих GraphQL-блоків: пресет operations-recommended (поля, типи, змінні).
66
120
  * Схема та documents підтягуються через graphql-config (файл налаштувань у корені пакета з операціями, зазвичай YAML).
@@ -73,10 +127,11 @@ const graphqlExtractedDocumentLint = {
73
127
  },
74
128
  plugins: {
75
129
  // ESLint 10: graphql-eslint ще викликає context.getSourceCode() у частині правил — fixup з @eslint/compat.
76
- '@graphql-eslint': fixupPluginRules(graphqlEslintPlugin)
130
+ '@graphql-eslint': fixupPluginRules(graphqlEslintPluginWithDebug)
77
131
  },
78
132
  rules: {
79
- ...graphqlEslintPlugin.configs['flat/operations-recommended'].rules
133
+ ...graphqlEslintPlugin.configs['flat/operations-recommended'].rules,
134
+ '@graphql-eslint/no-deprecated': 'error'
80
135
  }
81
136
  }
82
137
 
@@ -255,6 +310,86 @@ const vueVite = [
255
310
  }
256
311
  ]
257
312
 
313
+ /**
314
+ * Глобалі для типового Vite + auto-import: Composition API, vue-router, Quasar, пакет vue-apollo-composable.
315
+ * У пакеті `globals` ключ `vue` містить лише макроси `<script setup>` (`defineProps` тощо), без `onMounted` /
316
+ * `createApp` / `useRouter` — без цього списку `no-undef` хибно спрацьовує у `.vue` і `.js` під директоріями Vue.
317
+ */
318
+ const VUE_VITE_AUTO_IMPORT_GLOBALS = Object.fromEntries(
319
+ [
320
+ 'cloneVNode',
321
+ 'computed',
322
+ 'createApp',
323
+ 'customRef',
324
+ 'defineAsyncComponent',
325
+ 'defineComponent',
326
+ 'effectScope',
327
+ 'getCurrentInstance',
328
+ 'getCurrentScope',
329
+ 'h',
330
+ 'inject',
331
+ 'isProxy',
332
+ 'isReactive',
333
+ 'isReadonly',
334
+ 'isRef',
335
+ 'isVNode',
336
+ 'markRaw',
337
+ 'mergeProps',
338
+ 'nextTick',
339
+ 'onActivated',
340
+ 'onBeforeMount',
341
+ 'onBeforeRouteLeave',
342
+ 'onBeforeRouteUpdate',
343
+ 'onBeforeUnmount',
344
+ 'onBeforeUpdate',
345
+ 'onDeactivated',
346
+ 'onErrorCaptured',
347
+ 'onMounted',
348
+ 'onRenderTracked',
349
+ 'onRenderTriggered',
350
+ 'onScopeDispose',
351
+ 'onServerPrefetch',
352
+ 'onUnmounted',
353
+ 'onUpdated',
354
+ 'provide',
355
+ 'reactive',
356
+ 'readonly',
357
+ 'ref',
358
+ 'resolveComponent',
359
+ 'resolveDirective',
360
+ 'shallowReactive',
361
+ 'shallowReadonly',
362
+ 'shallowRef',
363
+ 'toRef',
364
+ 'toRefs',
365
+ 'toValue',
366
+ 'triggerRef',
367
+ 'unref',
368
+ 'useApolloClient',
369
+ 'useAttrs',
370
+ 'useCssModule',
371
+ 'useCssVars',
372
+ 'useId',
373
+ 'useLazyQuery',
374
+ 'useLink',
375
+ 'useModel',
376
+ 'useMutation',
377
+ 'useQuasar',
378
+ 'useQuery',
379
+ 'useRoute',
380
+ 'useRouter',
381
+ 'useSlots',
382
+ 'useSubscription',
383
+ 'useTemplateRef',
384
+ 'watch',
385
+ 'watchEffect',
386
+ 'watchPostEffect',
387
+ 'watchSyncEffect',
388
+ 'withDirectives',
389
+ 'withModifiers'
390
+ ].map(name => [name, 'readonly'])
391
+ )
392
+
258
393
  // Для усіх файлів Vue проектів
259
394
  // files: ['**/*.js', '**/*.vue']
260
395
  const vueAllVite = [
@@ -267,12 +402,9 @@ const vueAllVite = [
267
402
  gql: 'readonly',
268
403
  $ref: 'readonly',
269
404
  $computed: 'readonly',
270
- ref: 'readonly',
271
- useQuery: 'readonly',
272
- watch: 'readonly',
273
- computed: 'readonly',
405
+ ...VUE_VITE_AUTO_IMPORT_GLOBALS,
274
406
 
275
- // Макроси `<script setup>` (джерело списку `globals` / `vue` у vue-eslint-parser).
407
+ // Макроси `<script setup>` (у пакеті `globals` лише `globals.vue`).
276
408
  ...globals.vue
277
409
  }
278
410
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/eslint-config",
3
- "version": "3.6.6",
3
+ "version": "3.6.8",
4
4
  "description": "An ESLint shareable config for projects using Vue and Node",
5
5
  "keywords": [
6
6
  "eslint",