-
Couldn't load subscription status.
- Fork 109
add an example with custom graphql rules #2787
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 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d2f1164
aa
dimaMachina 394d8ed
aa
dimaMachina af5784d
aa
dimaMachina 0bd1e54
aa
dimaMachina aa3822f
aa
dimaMachina 993468b
Update examples/custom-rules/package.json
dimaMachina b5ddea2
aa
dimaMachina 433b6e5
polish
dimaMachina d46f8ed
fix test
dimaMachina b932ddf
tiny fix
dimaMachina 6267678
aa
dimaMachina d33e771
aa
dimaMachina 995feb3
aa
dimaMachina 98f4644
Update .changeset/strong-otters-mate.md
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@graphql-eslint/eslint-plugin': patch | ||
| --- | ||
|
|
||
| add an example with custom graphql rules | ||
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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import graphqlPlugin from '@graphql-eslint/eslint-plugin'; | ||
| import { rule } from './my-rule.js'; | ||
|
|
||
| export default [ | ||
| { | ||
| files: ['**/*.graphql'], | ||
| languageOptions: { | ||
| parser: graphqlPlugin.parser, | ||
| }, | ||
| plugins: { | ||
| '@internal': { | ||
| rules: { | ||
| 'my-rule': rule, | ||
| }, | ||
| }, | ||
| }, | ||
| rules: { | ||
| '@internal/my-rule': 'error', | ||
| }, | ||
| }, | ||
| ]; |
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export const rule = { | ||
| create(context) { | ||
| return { | ||
| OperationDefinition(node) { | ||
| if (!node.name?.value) { | ||
| context.report({ | ||
| node, | ||
| message: 'Oops, name is required!', | ||
| }); | ||
| } | ||
| }, | ||
| }; | ||
| }, | ||
| }; |
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "name": "@graphql-eslint/example-custom-rules", | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "repository": "https://github.com/dimaMachina/graphql-eslint", | ||
| "author": "Dimitri POSTOLOV <[email protected]>", | ||
| "private": true, | ||
| "scripts": { | ||
| "lint": "eslint --cache ." | ||
| }, | ||
| "dependencies": { | ||
| "graphql": "16.9.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@graphql-eslint/eslint-plugin": "4.1.0", | ||
dimaMachina marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "eslint": "9.15.0" | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| query { | ||
| foo | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| sidebarTitle: Custom GraphQL Rules | ||
| --- | ||
|
|
||
| # Usage with custom GraphQL rules | ||
|
|
||
| <ESLintConfigs gitFolder="custom-rules" additionalFiles={{ 'Custom GraphQL Rule': 'my-rule.js' }} /> | ||
|
|
||
| > [!TIP] | ||
| > | ||
| > Check out the [custom rules](/docs/custom-rules) guide to learn how to create your own rules. |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.