From ccd930309957896f5d22ed59d40a67803ee77868 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Fri, 22 Nov 2024 03:32:13 +0700 Subject: [PATCH] Fix report lint issues not on first char of file for `.vue` and support ESLint fixes and suggestions (#2735) * move * rename * more * more * more * more * more * more * more * moree * moree * moree * moree * more * more * more * [skip ci] * more * fix icons * update docs to use Nextra 4 * [skip ci] * fix lint [skip ci] * more [skip ci] * more * upd * pnpm dedupe * yoyo * aa * aa * build pass * more * aa * aa * [skip ci] * Update examples/vue-code-file/test.vue [skip ci] Co-authored-by: Brendan Mulholland * polish * add changeset --------- Co-authored-by: Brendan Mulholland --- .changeset/fast-fishes-shake.md | 5 ++ examples/vue-code-file/eslint.config.js | 22 +++-- examples/vue-code-file/package.json | 5 +- examples/vue-code-file/test.vue | 6 +- .../__tests__/__snapshots__/examples.spec.md | 80 ++++++++++++++++++- packages/plugin/__tests__/examples.spec.ts | 2 +- packages/plugin/src/graphql-config.ts | 14 +++- packages/plugin/src/parser.ts | 8 +- packages/plugin/src/processor.ts | 5 ++ pnpm-lock.yaml | 75 +++++++++++++++-- 10 files changed, 195 insertions(+), 27 deletions(-) create mode 100644 .changeset/fast-fishes-shake.md diff --git a/.changeset/fast-fishes-shake.md b/.changeset/fast-fishes-shake.md new file mode 100644 index 00000000000..b867f15b5ad --- /dev/null +++ b/.changeset/fast-fishes-shake.md @@ -0,0 +1,5 @@ +--- +'@graphql-eslint/eslint-plugin': patch +--- + +fix reporting lint issues not on first char of file for `.vue` and support ESLint fixes and suggestions for them. Use [new official example](https://github.com/dimaMachina/graphql-eslint/blob/master/examples/vue-code-file/eslint.config.js) diff --git a/examples/vue-code-file/eslint.config.js b/examples/vue-code-file/eslint.config.js index d4c93c8b4bc..39bd26547b5 100644 --- a/examples/vue-code-file/eslint.config.js +++ b/examples/vue-code-file/eslint.config.js @@ -1,18 +1,30 @@ -import vueParser from 'vue-eslint-parser'; +import { mergeProcessors } from 'eslint-merge-processors'; +import pluginVue from 'eslint-plugin-vue'; +import processorVueBlocks from 'eslint-processor-vue-blocks'; import js from '@eslint/js'; import graphqlPlugin from '@graphql-eslint/eslint-plugin'; export default [ { - files: ['**/*.js', '**/*.vue'], + files: ['**/*.js'], processor: graphqlPlugin.processor, rules: js.configs.recommended.rules, }, + ...pluginVue.configs['flat/recommended'], { files: ['**/*.vue'], - languageOptions: { - parser: vueParser, - }, + // `eslint-plugin-vue` will set a default processor for `.vue` files + // we use `eslint-merge-processors` to extend it + processor: mergeProcessors([ + pluginVue.processors.vue, + processorVueBlocks({ + blocks: { + script: true, + scriptSetup: true, + customBlocks: true, + }, + }), + ]), }, { files: ['**/*.graphql'], diff --git a/examples/vue-code-file/package.json b/examples/vue-code-file/package.json index 6a1efbe91ff..4bb097d8f8e 100644 --- a/examples/vue-code-file/package.json +++ b/examples/vue-code-file/package.json @@ -12,8 +12,9 @@ }, "devDependencies": { "@graphql-eslint/eslint-plugin": "workspace:*", - "@vue/compiler-sfc": "3.5.13", "eslint": "9.14.0", - "vue-eslint-parser": "9.4.3" + "eslint-merge-processors": "^0.1.0", + "eslint-plugin-vue": "^9.31.0", + "eslint-processor-vue-blocks": "^0.1.2" } } diff --git a/examples/vue-code-file/test.vue b/examples/vue-code-file/test.vue index d666f4e5cc7..60194b815e5 100644 --- a/examples/vue-code-file/test.vue +++ b/examples/vue-code-file/test.vue @@ -1,9 +1,9 @@