Skip to content
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

docs: Add Vue usage instructions #2598

Merged
merged 49 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0261839
add new docs
dimaMachina Aug 11, 2024
a35c18b
more
dimaMachina Aug 11, 2024
9b44466
more
dimaMachina Aug 11, 2024
97e2435
add
dimaMachina Aug 11, 2024
b344cb5
more
dimaMachina Aug 11, 2024
01cedbe
more
dimaMachina Aug 11, 2024
91a608f
more
dimaMachina Aug 11, 2024
5a5ccf4
more
dimaMachina Aug 11, 2024
0aeb05b
more
dimaMachina Aug 11, 2024
c9aa432
fix generate docs prettier, incorrectly formatted _meta.ts
dimaMachina Aug 16, 2024
e59b5d8
add baseUrl
dimaMachina Aug 16, 2024
24b0a85
Merge branch 'master' into new-docs
dimaMachina Aug 16, 2024
c2921f9
update eslint patch
dimaMachina Aug 16, 2024
84dc3a0
Merge branch 'master' into new-docs
dimaMachina Aug 16, 2024
ed6f00a
fix snapshots
dimaMachina Aug 16, 2024
9ee2db8
fix lint
dimaMachina Aug 16, 2024
30d8858
move
dimaMachina Aug 16, 2024
df1febd
more
dimaMachina Aug 17, 2024
03d10cd
more
dimaMachina Aug 17, 2024
6f33b00
more
dimaMachina Aug 17, 2024
84a348f
more
dimaMachina Aug 17, 2024
e38826f
more
dimaMachina Aug 17, 2024
6073694
prettier
dimaMachina Aug 17, 2024
1b585fe
more
dimaMachina Aug 17, 2024
63cfd35
more
dimaMachina Aug 17, 2024
5d62d4e
more
dimaMachina Aug 17, 2024
f1b3929
prettier
dimaMachina Aug 17, 2024
e93e0a1
more
dimaMachina Aug 17, 2024
5286a44
prettier
dimaMachina Aug 17, 2024
a4fb171
more
dimaMachina Aug 17, 2024
d45155c
more
dimaMachina Aug 17, 2024
9a15829
more
dimaMachina Aug 17, 2024
a8e264f
prettier
dimaMachina Aug 17, 2024
e080b15
fix for generate-configs
dimaMachina Aug 17, 2024
23724b5
test legacy configs examples
dimaMachina Aug 17, 2024
ba4141e
more
dimaMachina Aug 17, 2024
895a6de
more
dimaMachina Aug 17, 2024
f8932c4
prettier
dimaMachina Aug 17, 2024
2fde1ef
more
dimaMachina Aug 17, 2024
02fd67e
more
dimaMachina Aug 17, 2024
e86509a
more
dimaMachina Aug 17, 2024
73b20ec
run tests for examples with legacy configs
dimaMachina Aug 17, 2024
54e08ad
lint
dimaMachina Aug 17, 2024
df1385a
Add Vue usage instructions
bmulholland Oct 3, 2024
da9d077
Merge branch 'master' into 2598
dimaMachina Nov 13, 2024
2d21bfd
prettier
dimaMachina Nov 13, 2024
49a2e3e
1. graphql plugin can now we specified with
dimaMachina Nov 13, 2024
142bf2e
improve
dimaMachina Nov 13, 2024
b5e3ad5
fix indent
dimaMachina Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .changeset/chilled-rivers-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@graphql-eslint/eslint-plugin': major
---

1. graphql plugin can now we be specified as

```js
plugins: { '@graphql-eslint': graphqlPlugin }
```

1. Config rules should now be accessed through the `rules` property

```diff
rules: {
- ...graphqlESLint.configs['flat/operations-recommended']
+ ...graphqlESLint.configs['flat/operations-recommended'].rules
```

1. processor can now be specified with accessing `processor` property

```js
processor: graphqlPlugin.processor
```

1. The plugin can now be imported using a default import

```js
import graphqlPlugin from '@graphql-eslint/eslint-plugin'
```
6 changes: 4 additions & 2 deletions .changeset/healthy-moose-kneel.md
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.
2 changes: 1 addition & 1 deletion packages/plugin/src/meta.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = process.env.VERSION
export const version = process.env.VERSION;
4 changes: 2 additions & 2 deletions website/src/pages/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ If you are using [`graphql-config`](https://the-guild.dev/graphql/config), you a
Alternatively, you can define `parserOptions.schema` in the `*.graphql` override in your ESLint
config.

The parser allows you to specify a `.json` file / `.graphql` files(s) / url / raw string to locate your
schema (We are using `graphql-tools` to do that). Just add `parserOptions.schema` to your
The parser allows you to specify a `.json` file / `.graphql` files(s) / url / raw string to locate
your schema (We are using `graphql-tools` to do that). Just add `parserOptions.schema` to your
configuration file:

```diff filename=".eslintrc.json"
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project integrates GraphQL and ESLint, for a better developer experience.
<source src="/demo.mp4" type="video/mp4" />
</video>

<p className="mt-3 text-center italic text-sm">Demo GraphQL-ESLint in VSCode</p>
<p className="mt-3 text-center text-sm italic">Demo GraphQL-ESLint in VSCode</p>

## Features

Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/parser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ title: How Does a Parser Work?
The `graphql-eslint` parser is works in the following way:

1. Loads all relevant GraphQL code using ESLint core (either from `.graphql` files, or using
[ESLint `processor`](https://eslint.org/docs/latest/extend/plugins#processors-in-plugins)
to find in code-files).
[ESLint `processor`](https://eslint.org/docs/latest/extend/plugins#processors-in-plugins) to find
in code-files).
1. Is uses `graphql-js` (and `graphql-tools`) to parse the found string into a `DocumentNode`.
1. Extracts all comments (marked as `# ...`) from the parsed AST, and provides to ESLint as
directives hints.
Expand Down
68 changes: 68 additions & 0 deletions website/src/pages/docs/usage/vue.mdx
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: graphqlPlugin.processor
// 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': graphqlPlugin },
rules: {
...graphqlESLint.configs['flat/operations-recommended'].rules
// Can also override the recommended rules here, e.g.:
// "@graphql-eslint/naming-convention": ["off"],
}
}
]
```