Skip to content

Commit d039092

Browse files
committed
more
1 parent 405604a commit d039092

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

website/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const RootLayout: FC<{
3636
layoutProps={{
3737
banner: (
3838
<Banner dismissible={false}>
39-
🚧 This is WIP documentation for v4 of the plugin. For v3 click{' '}
39+
This is documentation for v4 of the plugin. For v3 click{' '}
4040
<Anchor href="https://074c6ee9.graphql-eslint.pages.dev/docs">here</Anchor>.
4141
</Banner>
4242
),

website/content/docs/custom-rules.mdx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type. But if you wish to use JavaScript - that's fine :)
3333

3434
Here's an example for a simple rule that reports on anonymous GraphQL operations:
3535

36-
```ts filename="your-rule-name.ts"
36+
```ts filename="my-rule.ts"
3737
import { GraphQLESLintRule } from '@graphql-eslint/eslint-plugin'
3838

3939
const rule: GraphQLESLintRule = {
@@ -82,7 +82,7 @@ objects.
8282

8383
Here's an example for using original `graphql-js` validate method to validate `OperationDefinition`:
8484

85-
```ts filename="your-rule-name.ts"
85+
```ts filename="my-rule.ts"
8686
import { validate } from 'graphql'
8787
import { requireGraphQLSchemaFromContext } from '@graphql-eslint/eslint-plugin'
8888

@@ -131,12 +131,12 @@ call `requireGraphQLSchemaFromContext` - it will validate that the schema is loa
131131
`typeInfo` is provided on every node, based on the type of that node, for example, to access the
132132
`GraphQLOutputType` while you are visiting a `SelectionSet` node, you can do:
133133

134-
```ts filename="your-rule-name.ts"
134+
```ts filename="my-rule.ts"
135135
import { requireGraphQLSchemaFromContext } from '@graphql-eslint/eslint-plugin'
136136

137137
export const rule = {
138138
create(context) {
139-
requireGraphQLSchemaFromContext('your-rule-name', context)
139+
requireGraphQLSchemaFromContext('my-rule', context)
140140

141141
return {
142142
SelectionSet(node) {
@@ -163,13 +163,28 @@ of ESLint.
163163
The wrapped `GraphQLRuleTester` provides built-in configured parser, and a schema loader, if you
164164
need to test your rule with a loaded schema.
165165

166-
```ts filename="your-rule-name.spec.ts"
167-
import { GraphQLRuleTester } from '@graphql-eslint/eslint-plugin'
166+
```ts filename="my-rule.test.ts"
167+
import { parser } from '@graphql-eslint/eslint-plugin'
168+
import { RuleTester } from 'eslint';
168169
import { rule } from './my-rule'
169170

170-
const ruleTester = new GraphQLRuleTester()
171-
172-
ruleTester.runGraphQLTests('your-rule-name', rule, {
171+
const ruleTester = new RuleTester({
172+
languageOptions: {
173+
parser,
174+
parserOptions: {
175+
graphQLConfig: {
176+
schema: /* GraphQL */ `
177+
# Optionally, your schema, your rule could have access to it
178+
`,
179+
documents: /* GraphQL */ `
180+
# Optionally, your operations, your rule could have access to them
181+
`,
182+
},
183+
},
184+
},
185+
});
186+
187+
ruleTester.run('my-rule', rule, {
173188
valid: [
174189
{
175190
code: 'query something { foo }'

0 commit comments

Comments
 (0)