Skip to content

Commit

Permalink
run tests on node 22 (#2483)
Browse files Browse the repository at this point in the history
* run tests on node 22

* add description in rules

* more

* more

* fix tests

* fix markdown link

* fix

* a

* aa
  • Loading branch information
dimaMachina authored Aug 9, 2024
1 parent ac4679c commit d52585a
Show file tree
Hide file tree
Showing 69 changed files with 330 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-ants-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

fix compatibility with Node.js v22
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
graphql_version: [15, 16]
graphql_version: [16]

steps:
- name: Checkout Master
Expand All @@ -39,13 +39,13 @@ jobs:
run: pnpm build

test:
name: Node.js v${{matrix.node_version}} / GraphQL v${{matrix.graphql_version}} / ESLint v8
name: Node.js v${{matrix.node_version}} / GraphQL v${{matrix.graphql_version}} / ESLint v9
timeout-minutes: 60
runs-on: ubuntu-latest
needs: [typecheck]
strategy:
matrix:
node_version: [18, 20.7]
node_version: [18, 20, 22]
graphql_version: [16]

steps:
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/__tests__/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getESLintOutput(cwd: string): ESLint.LintResult[] {
'',
)
.replace(
/\(node:\d{4}\) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js./,
/\(node:\d{4,5}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
'',
)
.replace('(Use `node --trace-warnings ...` to show where the warning was created)', '')
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin/src/meta.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import packageJson from '../package.json' assert { type: 'json' };
import packageJson from '../package.json' with { type: 'json' };

export const { name, version } = packageJson;
export const { version } = packageJson;
9 changes: 8 additions & 1 deletion scripts/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ function printMarkdownTable(columns: (Column | string)[], dataSource: string[][]
].join('\n');
}

const MARKDOWN_LINK_RE = /\[(.*?)]\(.*\)/;

async function generateDocs(): Promise<void> {
const prettierConfig = await prettier.resolveConfig('./docs/README.md');

const result = Object.entries(rules).map(async ([ruleName, rule]) => {
const blocks: string[] = [`# \`${ruleName}\``];
const blocks: string[] = [
'---',
`description: ${JSON.stringify(rule.meta.docs!.description!.replace(/\n.*/g, '').replace(MARKDOWN_LINK_RE, '$1'))}`,
'---',
`# \`${ruleName}\``,
];
const { deprecated, docs, schema, fixable, hasSuggestions } = rule.meta;

if (deprecated) {
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/alphabetize.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'Enforce arrange in alphabetical order for type fields, enum values, input object fields,
operation selections and more.'
---

# `alphabetize`

🔧 The `--fix` option on the
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/description-style.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Require all comments to follow the same style (either block or inline).'
---

# `description-style`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/executable-definitions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid for execution if all definitions are either operation or
fragment definitions.'
---

# `executable-definitions`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/fields-on-correct-type.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid if all fields selected are defined by the parent type, or are an
allowed meta field such as `__typename`.'
---

# `fields-on-correct-type`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
7 changes: 7 additions & 0 deletions website/src/pages/rules/fragments-on-composite-type.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---
description:
'Fragments use a type condition to determine if they apply, since fragments can only be spread
into a composite type (object, interface, or union), the type condition must also be a composite
type.'
---

# `fragments-on-composite-type`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/input-name.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'Require mutation argument to be always called "input" and input type to be called Mutation name +
"Input".'
---

# `input-name`

💡 This rule provides
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/known-argument-names.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'A GraphQL field is only valid if all supplied arguments are defined by that field.'
---

# `known-argument-names`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/known-directives.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid if all `@directive`s are known by the schema and legally
positioned.'
---

# `known-directives`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/known-fragment-names.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined
in the same document.'
---

# `known-fragment-names`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/known-type-names.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid if referenced types (specifically variable definitions and
fragment conditions) are defined by the type schema.'
---

# `known-type-names`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/lone-anonymous-operation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document that contains an anonymous operation (the `query` short-hand) is only valid if
it contains only that one operation definition.'
---

# `lone-anonymous-operation`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
5 changes: 5 additions & 0 deletions website/src/pages/rules/lone-executable-definition.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
description:
'Require queries, mutations, subscriptions or fragments to be located in separate files.'
---

# `lone-executable-definition`

- Category: `Operations`
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/lone-schema-definition.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'A GraphQL document is only valid if it contains only one schema definition.'
---

# `lone-schema-definition`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/match-document-filename.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'This rule allows you to enforce that the file name should match the operation name.'
---

# `match-document-filename`

- Category: `Operations`
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/naming-convention.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Require names to follow specified conventions.'
---

# `naming-convention`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/no-anonymous-operations.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'Require name for your GraphQL operations. This is useful since most GraphQL client libraries are
using the operation name for caching purposes.'
---

# `no-anonymous-operations`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-deprecated.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Enforce that deprecated fields or enum values are not in use by operations.'
---

# `no-deprecated`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/no-duplicate-fields.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'Checks for duplicate fields in selection set, variables in operation definition, or in arguments
set of a field.'
---

# `no-duplicate-fields`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-fragment-cycles.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'A GraphQL fragment is only valid when it does not have cycles in fragments usage.'
---

# `no-fragment-cycles`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-hashtag-description.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.'
---

# `no-hashtag-description`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-one-place-fragments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Disallow fragments that are used only in one place.'
---

# `no-one-place-fragments`

- Category: `Operations`
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-root-type.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Disallow using root types `mutation` and/or `subscription`.'
---

# `no-root-type`

💡 This rule provides
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-scalar-result-type-on-mutation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Avoid scalar result type on mutation type to make sure to return a valid state.'
---

# `no-scalar-result-type-on-mutation`

💡 This rule provides
Expand Down
5 changes: 5 additions & 0 deletions website/src/pages/rules/no-typename-prefix.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
description:
'Enforces users to avoid using the type name in a field name while defining your schema.'
---

# `no-typename-prefix`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/no-undefined-variables.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL operation is only valid if all variables encountered, both directly and via fragment
spreads, are defined by that operation.'
---

# `no-undefined-variables`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-unreachable-types.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Requires all types to be reachable at some level by root level fields.'
---

# `no-unreachable-types`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/no-unused-fields.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Requires all fields to be used at some level by siblings operations.'
---

# `no-unused-fields`

💡 This rule provides
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/no-unused-fragments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL document is only valid if all fragment definitions are spread within operations, or
spread within other fragments spread within operations.'
---

# `no-unused-fragments`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/no-unused-variables.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A GraphQL operation is only valid if all variables defined by an operation are used, either
directly or within a spread fragment.'
---

# `no-unused-variables`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/one-field-subscriptions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'A GraphQL subscription is valid only if it contains a single root field.'
---

# `one-field-subscriptions`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/overlapping-fields-can-be-merged.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A selection set is only valid if all fields (including spreading any fragments) either correspond
to distinct response names or can be merged without ambiguity.'
---

# `overlapping-fields-can-be-merged`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
7 changes: 7 additions & 0 deletions website/src/pages/rules/possible-fragment-spread.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---
description:
'A fragment spread is only valid if the type condition could ever possibly be true: if there is a
non-empty intersection of the possible parent types, and possible types which pass the type
condition.'
---

# `possible-fragment-spread`

✅ The `"extends": "plugin:@graphql-eslint/operations-recommended"` property in a configuration file
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/possible-type-extension.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'A type extension is only valid if the type is defined and has the same kind.'
---

# `possible-type-extension`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file
Expand Down
6 changes: 6 additions & 0 deletions website/src/pages/rules/provided-required-arguments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
description:
'A field or directive is only valid if all required (non-null without a default value) field
arguments have been provided.'
---

# `provided-required-arguments`

✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` and
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/relay-arguments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Set of rules to follow Relay specification for Arguments.'
---

# `relay-arguments`

- Category: `Schema`
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/relay-connection-types.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Set of rules to follow Relay specification for Connection types.'
---

# `relay-connection-types`

- Category: `Schema`
Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/rules/relay-edge-types.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: 'Set of rules to follow Relay specification for Edge types.'
---

# `relay-edge-types`

- Category: `Schema`
Expand Down
Loading

0 comments on commit d52585a

Please sign in to comment.