-
Notifications
You must be signed in to change notification settings - Fork 108
docs: Add Vue usage instructions #2598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 46 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
0261839
add new docs
dimaMachina a35c18b
more
dimaMachina 9b44466
more
dimaMachina 97e2435
add
dimaMachina b344cb5
more
dimaMachina 01cedbe
more
dimaMachina 91a608f
more
dimaMachina 5a5ccf4
more
dimaMachina 0aeb05b
more
dimaMachina c9aa432
fix generate docs prettier, incorrectly formatted _meta.ts
dimaMachina e59b5d8
add baseUrl
dimaMachina 24b0a85
Merge branch 'master' into new-docs
dimaMachina c2921f9
update eslint patch
dimaMachina 84dc3a0
Merge branch 'master' into new-docs
dimaMachina ed6f00a
fix snapshots
dimaMachina 9ee2db8
fix lint
dimaMachina 30d8858
move
dimaMachina df1febd
more
dimaMachina 03d10cd
more
dimaMachina 6f33b00
more
dimaMachina 84a348f
more
dimaMachina e38826f
more
dimaMachina 6073694
prettier
dimaMachina 1b585fe
more
dimaMachina 63cfd35
more
dimaMachina 5d62d4e
more
dimaMachina f1b3929
prettier
dimaMachina e93e0a1
more
dimaMachina 5286a44
prettier
dimaMachina a4fb171
more
dimaMachina d45155c
more
dimaMachina 9a15829
more
dimaMachina a8e264f
prettier
dimaMachina e080b15
fix for generate-configs
dimaMachina 23724b5
test legacy configs examples
dimaMachina ba4141e
more
dimaMachina 895a6de
more
dimaMachina f8932c4
prettier
dimaMachina 2fde1ef
more
dimaMachina 02fd67e
more
dimaMachina e86509a
more
dimaMachina 73b20ec
run tests for examples with legacy configs
dimaMachina 54e08ad
lint
dimaMachina df1385a
Add Vue usage instructions
bmulholland da9d077
Merge branch 'master' into 2598
dimaMachina 2d21bfd
prettier
dimaMachina 49a2e3e
1. graphql plugin can now we specified with
dimaMachina 142bf2e
improve
dimaMachina b5e3ad5
fix indent
dimaMachina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| --- | ||
| "@graphql-eslint/eslint-plugin": patch | ||
| '@graphql-eslint/eslint-plugin': patch | ||
| --- | ||
|
|
||
| The import attribute syntax (with { type: "json" }) is still experimental so warnings showed up when using the library as it was being used to import the package.json file to extract the package version | ||
| The import attribute syntax (with { type: "json" }) is still experimental so warnings showed up when | ||
| using the library as it was being used to import the package.json file to extract the package | ||
| version | ||
|
|
||
| As an alternative, the current version will be injected on build time through tsup configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| export const version = process.env.VERSION | ||
| export const version = process.env.VERSION; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,69 @@ | ||
| # Usage with `.vue` files | ||
|
|
||
| `graphql-eslint` can lint GraphQL documents inside Vue Single-File Components (.vue files). It does | ||
| this in two steps: (1) extract the GraphQL documents from the Vue (or js/ts) file, and (2) lint the | ||
| extracted GraphQL documents. | ||
|
|
||
| If you don't embed GraphQL documents in your Vue files, you can skip this page. | ||
|
|
||
| <Callout type="warning"> | ||
| Due to [a limitation in | ||
| graphql-tag-pluck](https://github.com/dimaMachina/graphql-eslint/issues/2103), lint violations | ||
| will show up at the top of the Vue document, on the first character, not inline. | ||
| </Callout> | ||
|
|
||
| ## Configuration | ||
|
|
||
| Add the following configuration to your `eslint.config.js` file to setup `@graphql-eslint` plugin. | ||
| The intermediate graphql files always have the .graphql extension. Make sure the second block | ||
| matches those files, even if you use another extension for your project's GraphQL (e.g. .gql). | ||
|
|
||
| <Callout type="warning"> | ||
| Make sure the first section, which extracts GrahpQL from Vue files, comes **before** any other Vue | ||
| rules. Otherwise, eslint may incorrectly rewrite all error messages to say only "clear." | ||
| </Callout> | ||
|
|
||
| ```js filename="eslint.config.js" | ||
| import graphqlPlugin from '@graphql-eslint/eslint-plugin' | ||
|
|
||
| export default [ | ||
| { | ||
| // NOTE: Order matters! This has to happen FIRST, before any block that | ||
| // includes the Vue parser (including e.g. recommended Vue ESLint rules). | ||
| // It also has to be before the .graphql block, below | ||
| // | ||
| // Extract GraphQL from files for linting -- this creates .graphql files | ||
| // that are then linted below | ||
| // | ||
| // graphql-eslint scans all files (using the processor lsited) and outputs | ||
| // an intermediate file with the extracted GraphQL. That intermediate file | ||
| // is then linted, generating the errors we see. The intermediate file has | ||
| // a fixed .graphql extension, so you need to include that extension below | ||
| // or these files won't be linted. | ||
| files: ['**/*.js', '**/*.ts', '**/*.vue'], | ||
| processor: graphql.processors.graphql | ||
| // NOTE: While you CAN put rules here to affect JS/TS/Vue files, those | ||
| // rules won't affect GraphQL. To modify rules that effect GrahpQL inside | ||
| // these files, add those to the block for .graphql files, below. | ||
| }, | ||
| // ...other config | ||
| { | ||
| // Lint all GraphQL files, including the intermediate ones above. If you | ||
| // want to tune the rules that appear in your files, even Vue/JS/TS files, | ||
| // put those rule changes HERE | ||
| files: ['**/*.graphql'], // Add .gql extension if you use that | ||
| languageOptions: { | ||
| parser: graphqlPlugin.parser | ||
| }, | ||
|
|
||
| // Any rule overrides for GraphQL go HERE. For example, to enable | ||
| // recommended operations rules | ||
| plugins: { '@graphql-eslint': { rules: graphqlESLint.rules } }, | ||
| rules: { | ||
| ...graphqlESLint.configs['flat/operations-recommended'] | ||
| // Can also override the recommended rules here, e.g.: | ||
| // "@graphql-eslint/naming-convention": ["off"], | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.