From 7be0d5205810f8d13e2daada48adf94909957892 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 14:47:41 +0200 Subject: [PATCH 01/39] more --- package.json | 4 +- packages/plugin/src/testkit.ts | 18 +- .../plugin/tests/description-style.spec.ts | 6 +- pnpm-lock.yaml | 186 +++++++++--------- 4 files changed, 108 insertions(+), 106 deletions(-) diff --git a/package.json b/package.json index ceeabd2bba5..30f6ee64f5b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "chalk": "4.1.2", "dedent": "1.2.0", "enquirer": "2.4.0", - "eslint": "8.44.0", + "eslint": "8.45.0", "eslint-plugin-eslint-plugin": "5.0.7", "eslint-plugin-tailwindcss": "3.13.0", "husky": "8.0.3", @@ -54,7 +54,7 @@ }, "pnpm": { "patchedDependencies": { - "eslint@8.44.0": "patches/eslint@8.31.0.patch", + "eslint@8.45.0": "patches/eslint@8.31.0.patch", "eslint-plugin-eslint-plugin@5.0.7": "patches/eslint-plugin-eslint-plugin@5.0.6.patch", "json-schema-to-markdown@1.1.1": "patches/json-schema-to-markdown@1.1.1.patch", "@vitest/runner@0.30.1": "patches/@vitest__runner@0.28.4.patch" diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index e20460dc8a1..2f799adf858 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -2,9 +2,11 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester } from 'eslint'; +import { FlatRuleTester } from 'eslint/use-at-your-own-risk'; import { ASTKindToNode } from 'graphql'; import { GraphQLESTreeNode } from './estree-converter/index.js'; import { GraphQLESLintRule, ParserOptions } from './types.js'; +import { parseForESLint } from './parser.js' export type GraphQLESLintRuleListener = Record< string, @@ -41,15 +43,17 @@ type RuleTesterConfig = { parserOptions: Omit; }; -export class GraphQLRuleTester extends RuleTester { +export class GraphQLRuleTester extends FlatRuleTester { config: RuleTesterConfig; constructor(parserOptions: Omit = {}) { const config = { - parser: require.resolve('@graphql-eslint/eslint-plugin'), - parserOptions: { - ...parserOptions, - skipGraphQLConfig: true, + languageOptions: { + parser: { parseForESLint }, + parserOptions: { + ...parserOptions, + skipGraphQLConfig: true, + }, }, }; super(config); @@ -60,7 +64,7 @@ export class GraphQLRuleTester extends RuleTester { return readFileSync(resolve(__dirname, `../tests/mocks/${path}`), 'utf-8'); } - runGraphQLTests( + run( ruleId: string, rule: GraphQLESLintRule, tests: { @@ -157,6 +161,8 @@ export class GraphQLRuleTester extends RuleTester { } } +export const ruleTester = new GraphQLRuleTester(); + function removeTrailingBlankLines(text: string): string { return text.replace(/^\s*\n/, '').trimEnd(); } diff --git a/packages/plugin/tests/description-style.spec.ts b/packages/plugin/tests/description-style.spec.ts index 409f59d8c67..84734eb88c0 100644 --- a/packages/plugin/tests/description-style.spec.ts +++ b/packages/plugin/tests/description-style.spec.ts @@ -1,8 +1,6 @@ -import { GraphQLRuleTester } from '../src'; +import { ruleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/description-style'; -const ruleTester = new GraphQLRuleTester(); - const INLINE_SDL = /* GraphQL */ ` " Test " type CreateOneUserPayload { @@ -31,7 +29,7 @@ export const BLOCK_SDL = /* GraphQL */ ` } `; -ruleTester.runGraphQLTests('description-style', rule, { +ruleTester.run('description-style', rule, { valid: [ BLOCK_SDL, { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61b6fb11c37..25f60040b82 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ patchedDependencies: eslint-plugin-eslint-plugin@5.0.7: hash: cdhdgvmsbh3fbusrlxsl6de2he path: patches/eslint-plugin-eslint-plugin@5.0.6.patch - eslint@8.44.0: + eslint@8.45.0: hash: v7lv2hbnxmm2b22qo3sob3rjvq path: patches/eslint@8.31.0.patch json-schema-to-markdown@1.1.1: @@ -36,7 +36,7 @@ importers: version: 9.2.1(graphql@16.7.1) '@theguild/eslint-config': specifier: 0.11.0 - version: 0.11.0(eslint@8.44.0)(typescript@5.1.6) + version: 0.11.0(eslint@8.45.0)(typescript@5.1.6) '@theguild/prettier-config': specifier: 1.2.0 version: 1.2.0(prettier@2.8.8) @@ -59,11 +59,11 @@ importers: specifier: 2.4.0 version: 2.4.0 eslint: - specifier: 8.44.0 - version: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + specifier: 8.45.0 + version: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-plugin-eslint-plugin: specifier: 5.0.7 - version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.44.0) + version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.45.0) eslint-plugin-tailwindcss: specifier: 3.13.0 version: 3.13.0(tailwindcss@3.3.3) @@ -1519,13 +1519,13 @@ packages: eslint-visitor-keys: 3.4.1 dev: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.44.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.45.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-visitor-keys: 3.4.1 dev: true @@ -2914,28 +2914,28 @@ packages: - webpack dev: false - /@theguild/eslint-config@0.11.0(eslint@8.44.0)(typescript@5.1.6): + /@theguild/eslint-config@0.11.0(eslint@8.45.0)(typescript@5.1.6): resolution: {integrity: sha512-dxKcEb0uKZvkKBp9KwcKe/npuHZw789vrQPUJGJksz9ghjvAQOc9Kx4PMJTTrVWOzg/1lzFB9s070V9yviYkHg==} peerDependencies: eslint: ^8.24.0 dependencies: '@rushstack/eslint-patch': 1.3.2 - '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.44.0)(typescript@5.1.6) - '@typescript-eslint/parser': 5.62.0(eslint@8.44.0)(typescript@5.1.6) - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-config-prettier: 8.8.0(eslint@8.44.0) - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.44.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0) - eslint-plugin-jsonc: 2.9.0(eslint@8.44.0) - eslint-plugin-jsx-a11y: 6.7.1(eslint@8.44.0) - eslint-plugin-mdx: 2.1.0(eslint@8.44.0) - eslint-plugin-n: 16.0.1(eslint@8.44.0) - eslint-plugin-promise: 6.1.1(eslint@8.44.0) - eslint-plugin-react: 7.33.0(eslint@8.44.0) - eslint-plugin-react-hooks: 4.6.0(eslint@8.44.0) - eslint-plugin-sonarjs: 0.19.0(eslint@8.44.0) - eslint-plugin-unicorn: 47.0.0(eslint@8.44.0) - eslint-plugin-yml: 1.8.0(eslint@8.44.0) + '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint-config-prettier: 8.8.0(eslint@8.45.0) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint-plugin-jsonc: 2.9.0(eslint@8.45.0) + eslint-plugin-jsx-a11y: 6.7.1(eslint@8.45.0) + eslint-plugin-mdx: 2.1.0(eslint@8.45.0) + eslint-plugin-n: 16.0.1(eslint@8.45.0) + eslint-plugin-promise: 6.1.1(eslint@8.45.0) + eslint-plugin-react: 7.33.0(eslint@8.45.0) + eslint-plugin-react-hooks: 4.6.0(eslint@8.45.0) + eslint-plugin-sonarjs: 0.19.0(eslint@8.45.0) + eslint-plugin-unicorn: 47.0.0(eslint@8.45.0) + eslint-plugin-yml: 1.8.0(eslint@8.45.0) transitivePeerDependencies: - eslint-import-resolver-node - eslint-import-resolver-webpack @@ -3181,7 +3181,7 @@ packages: '@types/node': 18.17.1 dev: false - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.44.0)(typescript@5.1.6): + /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.45.0)(typescript@5.1.6): resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3193,12 +3193,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.6.0 - '@typescript-eslint/parser': 5.62.0(eslint@8.44.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.44.0)(typescript@5.1.6) - '@typescript-eslint/utils': 5.62.0(eslint@8.44.0)(typescript@5.1.6) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -3209,7 +3209,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.62.0(eslint@8.44.0)(typescript@5.1.6): + /@typescript-eslint/parser@5.62.0(eslint@8.45.0)(typescript@5.1.6): resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3223,7 +3223,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) debug: 4.3.4 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) typescript: 5.1.6 transitivePeerDependencies: - supports-color @@ -3237,7 +3237,7 @@ packages: '@typescript-eslint/visitor-keys': 5.62.0 dev: true - /@typescript-eslint/type-utils@5.62.0(eslint@8.44.0)(typescript@5.1.6): + /@typescript-eslint/type-utils@5.62.0(eslint@8.45.0)(typescript@5.1.6): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3248,9 +3248,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - '@typescript-eslint/utils': 5.62.0(eslint@8.44.0)(typescript@5.1.6) + '@typescript-eslint/utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) tsutils: 3.21.0(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: @@ -3283,19 +3283,19 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.44.0)(typescript@5.1.6): + /@typescript-eslint/utils@5.62.0(eslint@8.45.0)(typescript@5.1.6): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.0 '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -5721,13 +5721,13 @@ packages: eslint: 8.38.0 dev: true - /eslint-config-prettier@8.8.0(eslint@8.44.0): + /eslint-config-prettier@8.8.0(eslint@8.45.0): resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) dev: true /eslint-import-resolver-node@0.3.7: @@ -5740,7 +5740,7 @@ packages: - supports-color dev: true - /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.44.0): + /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0): resolution: {integrity: sha512-TdJqPHs2lW5J9Zpe17DZNQuDnox4xo2o+0tE7Pggain9Rbc19ik8kFtXdxZ250FVx2kF4vlt2RSf4qlUpG7bhw==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -5749,9 +5749,9 @@ packages: dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) get-tsconfig: 4.6.2 globby: 13.2.2 is-core-module: 2.12.1 @@ -5764,7 +5764,7 @@ packages: - supports-color dev: true - /eslint-mdx@2.1.0(eslint@8.44.0): + /eslint-mdx@2.1.0(eslint@8.45.0): resolution: {integrity: sha512-dVLHDcpCFJRXZhxEQx8nKc68KT1qm+9JOeMD+j1/WW2h+oco1j7Qq+CLrX2kP64LI3fF9TUtj7a0AvncHUME6w==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} peerDependencies: @@ -5772,7 +5772,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) espree: 9.6.1 estree-util-visit: 1.2.1 remark-mdx: 2.3.0 @@ -5789,7 +5789,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -5810,39 +5810,39 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.44.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) debug: 3.2.7 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-import-resolver-node: 0.3.7 - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.44.0) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0) transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-es-x@7.2.0(eslint@8.44.0): + /eslint-plugin-es-x@7.2.0(eslint@8.45.0): resolution: {integrity: sha512-9dvv5CcvNjSJPqnS5uZkqb3xmbeqRLnvXKK7iI5+oK/yTusyc46zbBZKENGsOfojm/mKfszyZb+wNqNPAPeGXA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) '@eslint-community/regexpp': 4.6.0 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) dev: true - /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.44.0): + /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.45.0): resolution: {integrity: sha512-hcz4Bze1ECwv3Q/Bi/ZMZZNiuvI2YclNuxjnczkblQ0skrlPhdO83rSM7felf5n+7ZJOZi4GS8y8gNiRtvI0hA==} engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-utils: 3.0.0(eslint@8.44.0) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint-utils: 3.0.0(eslint@8.45.0) estraverse: 5.3.0 dev: true patched: true - /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0): + /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} engines: {node: '>=4'} peerDependencies: @@ -5852,15 +5852,15 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.44.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.44.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) has: 1.0.3 is-core-module: 2.12.1 is-glob: 4.0.3 @@ -5875,19 +5875,19 @@ packages: - supports-color dev: true - /eslint-plugin-jsonc@2.9.0(eslint@8.44.0): + /eslint-plugin-jsonc@2.9.0(eslint@8.45.0): resolution: {integrity: sha512-RK+LeONVukbLwT2+t7/OY54NJRccTXh/QbnXzPuTLpFMVZhPuq1C9E07+qWenGx7rrQl0kAalAWl7EmB+RjpGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) jsonc-eslint-parser: 2.3.0 natural-compare: 1.4.0 dev: true - /eslint-plugin-jsx-a11y@6.7.1(eslint@8.44.0): + /eslint-plugin-jsx-a11y@6.7.1(eslint@8.45.0): resolution: {integrity: sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==} engines: {node: '>=4.0'} peerDependencies: @@ -5902,7 +5902,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) has: 1.0.3 jsx-ast-utils: 3.3.4 language-tags: 1.0.5 @@ -5912,27 +5912,27 @@ packages: semver: 6.3.1 dev: true - /eslint-plugin-markdown@3.0.0(eslint@8.44.0): + /eslint-plugin-markdown@3.0.0(eslint@8.45.0): resolution: {integrity: sha512-hRs5RUJGbeHDLfS7ELanT0e29Ocyssf/7kBM+p7KluY5AwngGkDf8Oyu4658/NZSGTTq05FZeWbkxXtbVyHPwg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-mdx@2.1.0(eslint@8.44.0): + /eslint-plugin-mdx@2.1.0(eslint@8.45.0): resolution: {integrity: sha512-Q8P1JXv+OrD+xhWT95ZyV30MMdnqJ1voKtXfxWrJJ2XihJRI15gPmXbIWY9t8CjA8C//isfzNOmnVY9e3GTL0g==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8.0.0' dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-mdx: 2.1.0(eslint@8.44.0) - eslint-plugin-markdown: 3.0.0(eslint@8.44.0) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint-mdx: 2.1.0(eslint@8.45.0) + eslint-plugin-markdown: 3.0.0(eslint@8.45.0) remark-mdx: 2.3.0 remark-parse: 10.0.2 remark-stringify: 10.0.3 @@ -5943,16 +5943,16 @@ packages: - supports-color dev: true - /eslint-plugin-n@16.0.1(eslint@8.44.0): + /eslint-plugin-n@16.0.1(eslint@8.45.0): resolution: {integrity: sha512-CDmHegJN0OF3L5cz5tATH84RPQm9kG+Yx39wIqIwPR2C0uhBGMWfbbOtetR83PQjjidA5aXMu+LEFw1jaSwvTA==} engines: {node: '>=16.0.0'} peerDependencies: eslint: '>=7.0.0' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) builtins: 5.0.1 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-plugin-es-x: 7.2.0(eslint@8.44.0) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint-plugin-es-x: 7.2.0(eslint@8.45.0) ignore: 5.2.4 is-core-module: 2.12.1 minimatch: 3.1.2 @@ -5977,25 +5977,25 @@ packages: prettier-linter-helpers: 1.0.0 dev: true - /eslint-plugin-promise@6.1.1(eslint@8.44.0): + /eslint-plugin-promise@6.1.1(eslint@8.45.0): resolution: {integrity: sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) dev: true - /eslint-plugin-react-hooks@4.6.0(eslint@8.44.0): + /eslint-plugin-react-hooks@4.6.0(eslint@8.45.0): resolution: {integrity: sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==} engines: {node: '>=10'} peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) dev: true - /eslint-plugin-react@7.33.0(eslint@8.44.0): + /eslint-plugin-react@7.33.0(eslint@8.45.0): resolution: {integrity: sha512-qewL/8P34WkY8jAqdQxsiL82pDUeT7nhs8IsuXgfgnsEloKCT4miAV9N9kGtx7/KM9NH/NCGUE7Edt9iGxLXFw==} engines: {node: '>=4'} peerDependencies: @@ -6005,7 +6005,7 @@ packages: array.prototype.flatmap: 1.3.1 array.prototype.tosorted: 1.1.1 doctrine: 2.1.0 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) estraverse: 5.3.0 jsx-ast-utils: 3.3.4 minimatch: 3.1.2 @@ -6019,13 +6019,13 @@ packages: string.prototype.matchall: 4.0.8 dev: true - /eslint-plugin-sonarjs@0.19.0(eslint@8.44.0): + /eslint-plugin-sonarjs@0.19.0(eslint@8.45.0): resolution: {integrity: sha512-6+s5oNk5TFtVlbRxqZN7FIGmjdPCYQKaTzFPmqieCmsU1kBYDzndTeQav0xtQNwZJWu5awWfTGe8Srq9xFOGnw==} engines: {node: '>=14'} peerDependencies: eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) dev: true /eslint-plugin-tailwindcss@3.13.0(tailwindcss@3.3.3): @@ -6039,17 +6039,17 @@ packages: tailwindcss: 3.3.3 dev: true - /eslint-plugin-unicorn@47.0.0(eslint@8.44.0): + /eslint-plugin-unicorn@47.0.0(eslint@8.45.0): resolution: {integrity: sha512-ivB3bKk7fDIeWOUmmMm9o3Ax9zbMz1Bsza/R2qm46ufw4T6VBFBaJIR1uN3pCKSmSXm8/9Nri8V+iUut1NhQGA==} engines: {node: '>=16'} peerDependencies: eslint: '>=8.38.0' dependencies: '@babel/helper-validator-identifier': 7.22.5 - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) ci-info: 3.8.0 clean-regexp: 1.0.0 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 @@ -6064,14 +6064,14 @@ packages: strip-indent: 3.0.0 dev: true - /eslint-plugin-yml@1.8.0(eslint@8.44.0): + /eslint-plugin-yml@1.8.0(eslint@8.45.0): resolution: {integrity: sha512-fgBiJvXD0P2IN7SARDJ2J7mx8t0bLdG6Zcig4ufOqW5hOvSiFxeUyc2g5I1uIm8AExbo26NNYCcTGZT0MXTsyg==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -6103,13 +6103,13 @@ packages: estraverse: 5.3.0 dev: true - /eslint-utils@3.0.0(eslint@8.44.0): + /eslint-utils@3.0.0(eslint@8.45.0): resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) eslint-visitor-keys: 2.1.0 dev: true @@ -6172,12 +6172,12 @@ packages: - supports-color dev: true - /eslint@8.44.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq): - resolution: {integrity: sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A==} + /eslint@8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq): + resolution: {integrity: sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.44.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) '@eslint-community/regexpp': 4.6.0 '@eslint/eslintrc': 2.1.0 '@eslint/js': 8.44.0 @@ -6202,7 +6202,6 @@ packages: globals: 13.20.0 graphemer: 1.4.0 ignore: 5.2.4 - import-fresh: 3.3.0 imurmurhash: 0.1.4 is-glob: 4.0.3 is-path-inside: 3.0.3 @@ -6214,7 +6213,6 @@ packages: natural-compare: 1.4.0 optionator: 0.9.3 strip-ansi: 6.0.1 - strip-json-comments: 3.1.1 text-table: 0.2.0 transitivePeerDependencies: - supports-color From 69bce08ad94e36781fd2a2f5735870e0e89c8252 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 14:50:33 +0200 Subject: [PATCH 02/39] more --- packages/plugin/tests/examples.spec.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/plugin/tests/examples.spec.ts b/packages/plugin/tests/examples.spec.ts index edb0329fa79..2feeef05d57 100644 --- a/packages/plugin/tests/examples.spec.ts +++ b/packages/plugin/tests/examples.spec.ts @@ -1,8 +1,7 @@ import { spawnSync } from 'node:child_process'; import { join, relative } from 'node:path'; import { ESLint } from 'eslint'; - -const ROOT_CWD = process.cwd(); +import { CWD } from '../src/utils'; function countErrors(results: ESLint.LintResult[]): number { return results.reduce((acc, curr: ESLint.LintResult & { fatalErrorCount: number }) => { @@ -28,7 +27,7 @@ function getESLintOutput(cwd: string): ESLint.LintResult[] { function testSnapshot(results: ESLint.LintResult[]): void { const normalizedResults = results .map(result => ({ - filePath: relative(ROOT_CWD, result.filePath), + filePath: relative(CWD, result.filePath), messages: result.messages, })) .filter(result => result.messages.length > 0); @@ -38,63 +37,63 @@ function testSnapshot(results: ESLint.LintResult[]): void { describe('Examples', () => { it('should work on `.graphql` files', () => { - const cwd = join(ROOT_CWD, 'examples/basic'); + const cwd = join(CWD, 'examples/basic'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(6); testSnapshot(results); }); it('should work on `.js` files', () => { - const cwd = join(ROOT_CWD, 'examples/code-file'); + const cwd = join(CWD, 'examples/code-file'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(4); testSnapshot(results); }); it('should work with `graphql-config`', () => { - const cwd = join(ROOT_CWD, 'examples/graphql-config'); + const cwd = join(CWD, 'examples/graphql-config'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(2); testSnapshot(results); }); it('should work with `graphql-config` on `.js` files', () => { - const cwd = join(ROOT_CWD, 'examples/graphql-config-code-file'); + const cwd = join(CWD, 'examples/graphql-config-code-file'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(3); testSnapshot(results); }); it('should work with `eslint-plugin-prettier`', () => { - const cwd = join(ROOT_CWD, 'examples/prettier'); + const cwd = join(CWD, 'examples/prettier'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(23); testSnapshot(results); }); it('should work in monorepo', () => { - const cwd = join(ROOT_CWD, 'examples/monorepo'); + const cwd = join(CWD, 'examples/monorepo'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(7); testSnapshot(results); }); it('should work in svelte', () => { - const cwd = join(ROOT_CWD, 'examples/svelte-code-file'); + const cwd = join(CWD, 'examples/svelte-code-file'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(2); testSnapshot(results); }); it('should work in vue', () => { - const cwd = join(ROOT_CWD, 'examples/vue-code-file'); + const cwd = join(CWD, 'examples/vue-code-file'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(2); testSnapshot(results); }); it('should work in multiple projects', () => { - const cwd = join(ROOT_CWD, 'examples/multiple-projects-graphql-config'); + const cwd = join(CWD, 'examples/multiple-projects-graphql-config'); const results = getESLintOutput(cwd); expect(countErrors(results)).toBe(4); testSnapshot(results); From 4dda484fcf1c8c138985bb7b4a88d13301ca89de Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 14:52:06 +0200 Subject: [PATCH 03/39] more --- .../plugin/tests/executable-definitions.spec.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/plugin/tests/executable-definitions.spec.ts b/packages/plugin/tests/executable-definitions.spec.ts index ad9fa197142..d0fd7cb65ea 100644 --- a/packages/plugin/tests/executable-definitions.spec.ts +++ b/packages/plugin/tests/executable-definitions.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { ruleTester } from '../src/testkit'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const TEST_SCHEMA = /* GraphQL */ ` @@ -17,14 +18,14 @@ const TEST_SCHEMA = /* GraphQL */ ` `; const WITH_SCHEMA = { - parserOptions: { - schema: TEST_SCHEMA, - } as ParserOptions, + languageOptions: { + parserOptions: { + schema: TEST_SCHEMA, + } as ParserOptions, + } }; -const ruleTester = new GraphQLRuleTester(); - -ruleTester.runGraphQLTests( +ruleTester.run( 'executable-definitions', GRAPHQL_JS_VALIDATIONS['executable-definitions'], { From dc5a6b7156bda497e2c6668de04e7037d8908279 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 19:30:47 +0200 Subject: [PATCH 04/39] more --- packages/plugin/tests/alphabetize.spec.ts | 6 +++--- packages/plugin/tests/known-directives.spec.ts | 7 ++++--- packages/plugin/tests/lone-schema-definition.spec.ts | 6 +++--- packages/plugin/tests/match-document-filename.spec.ts | 6 +++--- packages/plugin/tests/naming-convention.spec.ts | 6 +++--- packages/plugin/tests/no-anonymous-operations.spec.ts | 6 +++--- .../no-case-insensitive-enum-values-duplicates.spec.ts | 6 +++--- packages/plugin/tests/no-deprecated.spec.ts | 7 ++++--- packages/plugin/tests/no-duplicate-fields.spec.ts | 6 +++--- packages/plugin/tests/no-hashtag-description.spec.ts | 6 +++--- packages/plugin/tests/no-one-place-fragments.spec.ts | 6 +++--- packages/plugin/tests/no-root-type.spec.ts | 7 ++++--- .../plugin/tests/no-scalar-result-type-on-mutation.spec.ts | 7 ++++--- packages/plugin/tests/no-typename-prefix.spec.ts | 6 +++--- packages/plugin/tests/no-undefined-variables.spec.ts | 6 +++--- packages/plugin/tests/no-unreachable-types.spec.ts | 7 ++++--- packages/plugin/tests/no-unused-fields.spec.ts | 6 +++--- packages/plugin/tests/no-unused-fragments.spec.ts | 7 ++++--- packages/plugin/tests/no-unused-variables.spec.ts | 7 ++++--- packages/plugin/tests/possible-type-extension.spec.ts | 7 ++++--- packages/plugin/tests/relay-arguments.spec.ts | 7 ++++--- packages/plugin/tests/relay-connection-types.spec.ts | 6 +++--- packages/plugin/tests/relay-edge-types.spec.ts | 7 ++++--- packages/plugin/tests/relay-page-info.spec.ts | 7 ++++--- packages/plugin/tests/require-deprecation-date.spec.ts | 6 +++--- packages/plugin/tests/require-deprecation-reason.spec.ts | 6 +++--- packages/plugin/tests/require-description.spec.ts | 7 ++++--- .../require-field-of-type-query-in-mutation-result.spec.ts | 7 ++++--- 28 files changed, 97 insertions(+), 84 deletions(-) diff --git a/packages/plugin/tests/alphabetize.spec.ts b/packages/plugin/tests/alphabetize.spec.ts index c3f623b7e4e..d07189b3f1e 100644 --- a/packages/plugin/tests/alphabetize.spec.ts +++ b/packages/plugin/tests/alphabetize.spec.ts @@ -1,7 +1,7 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/alphabetize'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); const GROUP_ORDER_TEST = /* GraphQL */ ` type User { @@ -18,7 +18,7 @@ const GROUP_ORDER_TEST = /* GraphQL */ ` } `; -ruleTester.runGraphQLTests('alphabetize', rule, { +ruleTester.run('alphabetize', rule, { valid: [ { options: [{ fields: ['ObjectTypeDefinition'] }], diff --git a/packages/plugin/tests/known-directives.spec.ts b/packages/plugin/tests/known-directives.spec.ts index d8e1056a370..13cab5b8c6e 100644 --- a/packages/plugin/tests/known-directives.spec.ts +++ b/packages/plugin/tests/known-directives.spec.ts @@ -1,6 +1,7 @@ -import { GraphQLRuleTester, rules } from '../src'; +import { rules } from '../src'; +import { RuleTester } from '../src/testkit'; -const ruleTester = new GraphQLRuleTester({ +const ruleTester = new RuleTester({ schema: /* GraphQL */ ` type User { id: ID! @@ -12,7 +13,7 @@ const ruleTester = new GraphQLRuleTester({ `, }); -ruleTester.runGraphQLTests<[{ ignoreClientDirectives: string[] }]>( +ruleTester.run<[{ ignoreClientDirectives: string[] }]>( 'known-directives', rules['known-directives'], { diff --git a/packages/plugin/tests/lone-schema-definition.spec.ts b/packages/plugin/tests/lone-schema-definition.spec.ts index 43f658be668..7040037180a 100644 --- a/packages/plugin/tests/lone-schema-definition.spec.ts +++ b/packages/plugin/tests/lone-schema-definition.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests( +ruleTester.run( 'lone-schema-definition', GRAPHQL_JS_VALIDATIONS['lone-schema-definition'], { diff --git a/packages/plugin/tests/match-document-filename.spec.ts b/packages/plugin/tests/match-document-filename.spec.ts index 94dacb85a02..e036427fb8a 100644 --- a/packages/plugin/tests/match-document-filename.spec.ts +++ b/packages/plugin/tests/match-document-filename.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/match-document-filename'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('match-document-filename', rule, { +ruleTester.run('match-document-filename', rule, { valid: [ { filename: 'src/me.gql', diff --git a/packages/plugin/tests/naming-convention.spec.ts b/packages/plugin/tests/naming-convention.spec.ts index 8502edc712b..152ecc678df 100644 --- a/packages/plugin/tests/naming-convention.spec.ts +++ b/packages/plugin/tests/naming-convention.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/naming-convention'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('naming-convention', rule, { +ruleTester.run('naming-convention', rule, { valid: [ { code: /* GraphQL */ ` diff --git a/packages/plugin/tests/no-anonymous-operations.spec.ts b/packages/plugin/tests/no-anonymous-operations.spec.ts index d7ddecfca8f..d9e05b0004d 100644 --- a/packages/plugin/tests/no-anonymous-operations.spec.ts +++ b/packages/plugin/tests/no-anonymous-operations.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-anonymous-operations'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-anonymous-operations', rule, { +ruleTester.run('no-anonymous-operations', rule, { valid: ['query myQuery { a }', 'mutation doSomething { a }', 'subscription myData { a }'], invalid: [ { code: 'query { a }', errors: 1 }, diff --git a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts index 31ad7a96ecf..c74695557da 100644 --- a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts +++ b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-case-insensitive-enum-values-duplicates'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-case-insensitive-enum-values-duplicates', rule, { +ruleTester.run('no-case-insensitive-enum-values-duplicates', rule, { valid: [], invalid: [ { diff --git a/packages/plugin/tests/no-deprecated.spec.ts b/packages/plugin/tests/no-deprecated.spec.ts index 672f3ace547..eab63355e16 100644 --- a/packages/plugin/tests/no-deprecated.spec.ts +++ b/packages/plugin/tests/no-deprecated.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-deprecated'; const TEST_SCHEMA = /* GraphQL */ ` @@ -25,9 +26,9 @@ const WITH_SCHEMA = { documents: [], } as ParserOptions, }; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-deprecated', rule, { +ruleTester.run('no-deprecated', rule, { valid: [ { ...WITH_SCHEMA, code: 'query { newField }' }, { ...WITH_SCHEMA, code: 'mutation { something(t: NEW) }' }, diff --git a/packages/plugin/tests/no-duplicate-fields.spec.ts b/packages/plugin/tests/no-duplicate-fields.spec.ts index 9f67c5da2dd..7e978c3e61b 100644 --- a/packages/plugin/tests/no-duplicate-fields.spec.ts +++ b/packages/plugin/tests/no-duplicate-fields.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-duplicate-fields'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-duplicate-fields', rule, { +ruleTester.run('no-duplicate-fields', rule, { valid: [], invalid: [ { diff --git a/packages/plugin/tests/no-hashtag-description.spec.ts b/packages/plugin/tests/no-hashtag-description.spec.ts index a740f485084..bc7e138a634 100644 --- a/packages/plugin/tests/no-hashtag-description.spec.ts +++ b/packages/plugin/tests/no-hashtag-description.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RULE_ID } from '../src/rules/no-hashtag-description'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-hashtag-description', rule, { +ruleTester.run('no-hashtag-description', rule, { valid: [ /* GraphQL */ ` " Good " diff --git a/packages/plugin/tests/no-one-place-fragments.spec.ts b/packages/plugin/tests/no-one-place-fragments.spec.ts index 29ebacd9278..3efda10f175 100644 --- a/packages/plugin/tests/no-one-place-fragments.spec.ts +++ b/packages/plugin/tests/no-one-place-fragments.spec.ts @@ -1,10 +1,10 @@ import { join } from 'node:path'; -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-one-place-fragments'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-one-place-fragments', rule, { +ruleTester.run('no-one-place-fragments', rule, { valid: [ { name: 'ok when spread 2 times', diff --git a/packages/plugin/tests/no-root-type.spec.ts b/packages/plugin/tests/no-root-type.spec.ts index 1c833de7933..acbfedfb018 100644 --- a/packages/plugin/tests/no-root-type.spec.ts +++ b/packages/plugin/tests/no-root-type.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/no-root-type'; const useSchema = ( @@ -11,9 +12,9 @@ const useSchema = ( }, }); -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-root-type', rule, { +ruleTester.run('no-root-type', rule, { valid: [ { ...useSchema('type Query'), diff --git a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts index bda124ed6b3..0b34d24bcf9 100644 --- a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts +++ b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-scalar-result-type-on-mutation'; const useSchema = ( @@ -16,9 +17,9 @@ const useSchema = ( }, }); -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-scalar-result-type-on-mutation', rule, { +ruleTester.run('no-scalar-result-type-on-mutation', rule, { valid: [ useSchema(/* GraphQL */ ` type Query { diff --git a/packages/plugin/tests/no-typename-prefix.spec.ts b/packages/plugin/tests/no-typename-prefix.spec.ts index e4a248f25c4..9442676425b 100644 --- a/packages/plugin/tests/no-typename-prefix.spec.ts +++ b/packages/plugin/tests/no-typename-prefix.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-typename-prefix'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-typename-prefix', rule, { +ruleTester.run('no-typename-prefix', rule, { valid: [ /* GraphQL */ ` type User { diff --git a/packages/plugin/tests/no-undefined-variables.spec.ts b/packages/plugin/tests/no-undefined-variables.spec.ts index 0ee9f4c4433..9a2be5e8112 100644 --- a/packages/plugin/tests/no-undefined-variables.spec.ts +++ b/packages/plugin/tests/no-undefined-variables.spec.ts @@ -1,9 +1,9 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, rules } from '../src'; +import { RuleTester, rules } from '../src'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-undefined-variables', rules['no-undefined-variables'], { +ruleTester.run('no-undefined-variables', rules['no-undefined-variables'], { valid: [], invalid: [ { diff --git a/packages/plugin/tests/no-unreachable-types.spec.ts b/packages/plugin/tests/no-unreachable-types.spec.ts index f9581c7d71f..aaa32bb7ad7 100644 --- a/packages/plugin/tests/no-unreachable-types.spec.ts +++ b/packages/plugin/tests/no-unreachable-types.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-unreachable-types'; const useSchema = ( @@ -10,9 +11,9 @@ const useSchema = ( }; }; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-unreachable-types', rule, { +ruleTester.run('no-unreachable-types', rule, { valid: [ useSchema(/* GraphQL */ ` scalar A diff --git a/packages/plugin/tests/no-unused-fields.spec.ts b/packages/plugin/tests/no-unused-fields.spec.ts index fa0fab6b032..b9f55f0fc3f 100644 --- a/packages/plugin/tests/no-unused-fields.spec.ts +++ b/packages/plugin/tests/no-unused-fields.spec.ts @@ -1,4 +1,4 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/no-unused-fields'; const SCHEMA = /* GraphQL */ ` @@ -38,9 +38,9 @@ const SCHEMA = /* GraphQL */ ` } `; -const ruleTester = new GraphQLRuleTester({ schema: SCHEMA }); +const ruleTester = new RuleTester({ schema: SCHEMA }); -ruleTester.runGraphQLTests('no-unused-fields', rule, { +ruleTester.run('no-unused-fields', rule, { valid: [ { code: SCHEMA, diff --git a/packages/plugin/tests/no-unused-fragments.spec.ts b/packages/plugin/tests/no-unused-fragments.spec.ts index 447b5794b6a..07889a15ad6 100644 --- a/packages/plugin/tests/no-unused-fragments.spec.ts +++ b/packages/plugin/tests/no-unused-fragments.spec.ts @@ -1,9 +1,10 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, rules } from '../src'; +import { rules } from '../src'; +import { RuleTester } from '../src/testkit'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-unused-fragments', rules['no-unused-fragments'], { +ruleTester.run('no-unused-fragments', rules['no-unused-fragments'], { valid: [ { name: 'should find file with operation definition that import current fragment', diff --git a/packages/plugin/tests/no-unused-variables.spec.ts b/packages/plugin/tests/no-unused-variables.spec.ts index e4733e67b62..c16b8099e4d 100644 --- a/packages/plugin/tests/no-unused-variables.spec.ts +++ b/packages/plugin/tests/no-unused-variables.spec.ts @@ -1,9 +1,10 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, rules } from '../src'; +import { RuleTester } from '../src/testkit'; +import { rules } from '../src'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-unused-variables', rules['no-unused-variables'], { +ruleTester.run('no-unused-variables', rules['no-unused-variables'], { valid: [ { filename: join(__dirname, 'mocks/no-unused-variables.gql'), diff --git a/packages/plugin/tests/possible-type-extension.spec.ts b/packages/plugin/tests/possible-type-extension.spec.ts index f2026d83665..de378f66add 100644 --- a/packages/plugin/tests/possible-type-extension.spec.ts +++ b/packages/plugin/tests/possible-type-extension.spec.ts @@ -1,7 +1,8 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, ParserOptions, rules } from '../src'; +import { ParserOptions, rules } from '../src'; +import { RuleTester } from '../src/testkit'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); const useUserSchema = ( code: string, @@ -22,7 +23,7 @@ const useUserSchema = ( }; }; -ruleTester.runGraphQLTests('possible-type-extension', rules['possible-type-extension'], { +ruleTester.run('possible-type-extension', rules['possible-type-extension'], { valid: [ useUserSchema(/* GraphQL */ ` extend type User { diff --git a/packages/plugin/tests/relay-arguments.spec.ts b/packages/plugin/tests/relay-arguments.spec.ts index cd4ccb46667..34a5340976b 100644 --- a/packages/plugin/tests/relay-arguments.spec.ts +++ b/packages/plugin/tests/relay-arguments.spec.ts @@ -1,7 +1,8 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/relay-arguments'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function useSchema(code: string): { code: string; parserOptions: Pick } { return { @@ -16,7 +17,7 @@ function useSchema(code: string): { code: string; parserOptions: Pick('relay-arguments', rule, { +ruleTester.run('relay-arguments', rule, { valid: [ useSchema(/* GraphQL */ ` type User { diff --git a/packages/plugin/tests/relay-connection-types.spec.ts b/packages/plugin/tests/relay-connection-types.spec.ts index d1c74119ae9..55dde44bad0 100644 --- a/packages/plugin/tests/relay-connection-types.spec.ts +++ b/packages/plugin/tests/relay-connection-types.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/relay-connection-types'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('relay-connection-types', rule, { +ruleTester.run('relay-connection-types', rule, { valid: [ { name: 'follow Relay spec', diff --git a/packages/plugin/tests/relay-edge-types.spec.ts b/packages/plugin/tests/relay-edge-types.spec.ts index a6f9f203a3b..a1271158a08 100644 --- a/packages/plugin/tests/relay-edge-types.spec.ts +++ b/packages/plugin/tests/relay-edge-types.spec.ts @@ -1,7 +1,8 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/relay-edge-types'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function useSchema(code: string): { code: string; parserOptions: Pick } { return { @@ -12,7 +13,7 @@ function useSchema(code: string): { code: string; parserOptions: Pick('relay-edge-types', rule, { +ruleTester.run('relay-edge-types', rule, { valid: [ { name: 'when cursor returns string', diff --git a/packages/plugin/tests/relay-page-info.spec.ts b/packages/plugin/tests/relay-page-info.spec.ts index 07ddd00456d..4ec15cb339d 100644 --- a/packages/plugin/tests/relay-page-info.spec.ts +++ b/packages/plugin/tests/relay-page-info.spec.ts @@ -1,7 +1,8 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/relay-page-info'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function useSchema(code: string): { code: string; parserOptions: Pick } { return { @@ -12,7 +13,7 @@ function useSchema(code: string): { code: string; parserOptions: Pick('require-deprecation-date', rule, { +ruleTester.run('require-deprecation-date', rule, { valid: [ 'type User { firstName: String }', `scalar Old @deprecated(deletionDate: "${tomorrow}")`, diff --git a/packages/plugin/tests/require-deprecation-reason.spec.ts b/packages/plugin/tests/require-deprecation-reason.spec.ts index 84f8dfbff58..5a532ead191 100644 --- a/packages/plugin/tests/require-deprecation-reason.spec.ts +++ b/packages/plugin/tests/require-deprecation-reason.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/require-deprecation-reason'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('require-deprecation-reason', rule, { +ruleTester.run('require-deprecation-reason', rule, { valid: [ /* GraphQL */ ` query getUser { diff --git a/packages/plugin/tests/require-description.spec.ts b/packages/plugin/tests/require-description.spec.ts index 076cfe819e0..bc4ec2eed0a 100644 --- a/packages/plugin/tests/require-description.spec.ts +++ b/packages/plugin/tests/require-description.spec.ts @@ -1,10 +1,11 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions, RULE_ID } from '../src/rules/require-description'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); const OPERATION = { OperationDefinition: true }; -ruleTester.runGraphQLTests('require-description', rule, { +ruleTester.run('require-description', rule, { valid: [ { code: /* GraphQL */ ` diff --git a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts index b74bda23239..f3f0990550b 100644 --- a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts +++ b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/require-field-of-type-query-in-mutation-result'; const useSchema = ( @@ -16,9 +17,9 @@ const useSchema = ( }, }); -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('require-field-of-type-query-in-mutation-result', rule, { +ruleTester.run('require-field-of-type-query-in-mutation-result', rule, { valid: [ useSchema(/* GraphQL */ ` type Query { From c7c118e7db7dd099e58ce097eadc9e43b41abd51 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 19:36:17 +0200 Subject: [PATCH 05/39] more --- packages/plugin/tests/eslint-directives.spec.ts | 8 ++++---- packages/plugin/tests/fields-on-correct-type.spec.ts | 7 ++++--- packages/plugin/tests/input-name.spec.ts | 6 +++--- packages/plugin/tests/known-fragment-names.spec.ts | 7 ++++--- packages/plugin/tests/lone-executable-definition.spec.ts | 6 +++--- packages/plugin/tests/require-id-when-available.spec.ts | 7 ++++--- packages/plugin/tests/require-import-fragment.spec.ts | 7 ++++--- .../tests/require-nullable-fields-with-oneof.spec.ts | 6 +++--- .../plugin/tests/require-nullable-result-in-root.spec.ts | 7 ++++--- .../plugin/tests/require-type-pattern-with-oneof.spec.ts | 6 +++--- packages/plugin/tests/selection-set-depth.spec.ts | 7 ++++--- packages/plugin/tests/strict-id-in-types.spec.ts | 7 ++++--- packages/plugin/tests/unique-fragment-name.spec.ts | 7 ++++--- packages/plugin/tests/unique-operation-name.spec.ts | 7 ++++--- packages/plugin/tests/unique-type-names.spec.ts | 7 ++++--- 15 files changed, 56 insertions(+), 46 deletions(-) diff --git a/packages/plugin/tests/eslint-directives.spec.ts b/packages/plugin/tests/eslint-directives.spec.ts index fcb6a411013..0a57830e9a3 100644 --- a/packages/plugin/tests/eslint-directives.spec.ts +++ b/packages/plugin/tests/eslint-directives.spec.ts @@ -1,11 +1,11 @@ import { join } from 'node:path'; -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule as noAnonymousOperations } from '../src/rules/no-anonymous-operations'; import { rule as noTypenamePrefix } from '../src/rules/no-typename-prefix'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('no-typename-prefix', noTypenamePrefix, { +ruleTester.run('no-typename-prefix', noTypenamePrefix, { valid: [ { name: 'should work with descriptions #942', @@ -20,7 +20,7 @@ ruleTester.runGraphQLTests('no-typename-prefix', noTypenamePrefix, { invalid: [], }); -ruleTester.runGraphQLTests('test-directives', noAnonymousOperations, { +ruleTester.run('test-directives', noAnonymousOperations, { valid: [ /* GraphQL */ ` # eslint-disable-next-line diff --git a/packages/plugin/tests/fields-on-correct-type.spec.ts b/packages/plugin/tests/fields-on-correct-type.spec.ts index e38562b793c..6f13350602e 100644 --- a/packages/plugin/tests/fields-on-correct-type.spec.ts +++ b/packages/plugin/tests/fields-on-correct-type.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions, rules } from '../src'; +import { ParserOptions, rules } from '../src'; +import { RuleTester } from '../src/testkit'; const parserOptions: Pick = { schema: /* GraphQL */ ` @@ -12,9 +13,9 @@ const parserOptions: Pick = { } `, }; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('fields-on-correct-type', rules['fields-on-correct-type'], { +ruleTester.run('fields-on-correct-type', rules['fields-on-correct-type'], { valid: [], invalid: [ { diff --git a/packages/plugin/tests/input-name.spec.ts b/packages/plugin/tests/input-name.spec.ts index 7bd2285b46a..976f6ac669d 100644 --- a/packages/plugin/tests/input-name.spec.ts +++ b/packages/plugin/tests/input-name.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/input-name'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('input-name', rule, { +ruleTester.run('input-name', rule, { valid: [ { code: 'type Mutation { SetMessage(input: SetMessageInput): String }', diff --git a/packages/plugin/tests/known-fragment-names.spec.ts b/packages/plugin/tests/known-fragment-names.spec.ts index 3b0804fedbd..f1f353f7fe5 100644 --- a/packages/plugin/tests/known-fragment-names.spec.ts +++ b/packages/plugin/tests/known-fragment-names.spec.ts @@ -1,9 +1,10 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, rules } from '../src'; +import { rules } from '../src'; +import { RuleTester } from '../src/testkit'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('known-fragment-names', rules['known-fragment-names'], { +ruleTester.run('known-fragment-names', rules['known-fragment-names'], { valid: [ { filename: join(__dirname, 'mocks/user.graphql'), diff --git a/packages/plugin/tests/lone-executable-definition.spec.ts b/packages/plugin/tests/lone-executable-definition.spec.ts index c925c616aff..99eb3e8ac0a 100644 --- a/packages/plugin/tests/lone-executable-definition.spec.ts +++ b/packages/plugin/tests/lone-executable-definition.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/lone-executable-definition'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('lone-executable-definition', rule, { +ruleTester.run('lone-executable-definition', rule, { valid: [ { name: 'should allow single short-hand query', diff --git a/packages/plugin/tests/require-id-when-available.spec.ts b/packages/plugin/tests/require-id-when-available.spec.ts index 8099b914c0f..354b40dc165 100644 --- a/packages/plugin/tests/require-id-when-available.spec.ts +++ b/packages/plugin/tests/require-id-when-available.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/require-id-when-available'; const TEST_SCHEMA = /* GraphQL */ ` @@ -66,7 +67,7 @@ const WITH_SCHEMA = { } as ParserOptions, }; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); const MESSAGE_ID = { messageId: 'require-id-when-available' }; const DOCUMENT_WITH_UNION = /* GraphQL */ ` @@ -79,7 +80,7 @@ const DOCUMENT_WITH_UNION = /* GraphQL */ ` } `; -ruleTester.runGraphQLTests('require-id-when-available', rule, { +ruleTester.run('require-id-when-available', rule, { valid: [ { name: 'should completely ignore FragmentDefinition', diff --git a/packages/plugin/tests/require-import-fragment.spec.ts b/packages/plugin/tests/require-import-fragment.spec.ts index 4a09f908372..9881b030165 100644 --- a/packages/plugin/tests/require-import-fragment.spec.ts +++ b/packages/plugin/tests/require-import-fragment.spec.ts @@ -1,10 +1,11 @@ import { join } from 'node:path'; -import { GraphQLInvalidTestCase, GraphQLRuleTester } from '../src'; +import { GraphQLInvalidTestCase } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/require-import-fragment'; import { Linter } from 'eslint'; import ParserOptions = Linter.ParserOptions; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function withMocks({ name, @@ -38,7 +39,7 @@ function withMocks({ }; } -ruleTester.runGraphQLTests('require-import-fragment', rule, { +ruleTester.run('require-import-fragment', rule, { valid: [ withMocks({ name: 'should not report with named import', diff --git a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts index fbc77d33774..df82c8749c7 100644 --- a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts +++ b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts @@ -1,9 +1,9 @@ -import { GraphQLRuleTester } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/require-nullable-fields-with-oneof'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('require-nullable-fields-with-oneof', rule, { +ruleTester.run('require-nullable-fields-with-oneof', rule, { valid: [ /* GraphQL */ ` input Input @oneOf { diff --git a/packages/plugin/tests/require-nullable-result-in-root.spec.ts b/packages/plugin/tests/require-nullable-result-in-root.spec.ts index cdd0d55aff6..db0023f9b69 100644 --- a/packages/plugin/tests/require-nullable-result-in-root.spec.ts +++ b/packages/plugin/tests/require-nullable-result-in-root.spec.ts @@ -1,7 +1,8 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/require-nullable-result-in-root'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function useSchema(code: string): { code: string; parserOptions: Omit } { return { @@ -10,7 +11,7 @@ function useSchema(code: string): { code: string; parserOptions: Omit('selection-set-depth', rule, { +ruleTester.run('selection-set-depth', rule, { valid: [ { options: [{ maxDepth: 2 }], diff --git a/packages/plugin/tests/strict-id-in-types.spec.ts b/packages/plugin/tests/strict-id-in-types.spec.ts index afbf212a1ef..f347e5293e4 100644 --- a/packages/plugin/tests/strict-id-in-types.spec.ts +++ b/packages/plugin/tests/strict-id-in-types.spec.ts @@ -1,7 +1,8 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/strict-id-in-types'; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); function useSchema(code: string): { code: string; parserOptions: Pick } { return { @@ -12,7 +13,7 @@ function useSchema(code: string): { code: string; parserOptions: Pick('strict-id-in-types', rule, { +ruleTester.run('strict-id-in-types', rule, { valid: [ useSchema('type A { id: ID! }'), { diff --git a/packages/plugin/tests/unique-fragment-name.spec.ts b/packages/plugin/tests/unique-fragment-name.spec.ts index dd4a036ca81..4097a8cbf37 100644 --- a/packages/plugin/tests/unique-fragment-name.spec.ts +++ b/packages/plugin/tests/unique-fragment-name.spec.ts @@ -1,5 +1,6 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/unique-fragment-name'; const TEST_FRAGMENT = /* GraphQL */ ` @@ -16,9 +17,9 @@ const SIBLING_FRAGMENTS = ( }, }); -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('unique-fragment-name', rule, { +ruleTester.run('unique-fragment-name', rule, { valid: [ { ...SIBLING_FRAGMENTS(TEST_FRAGMENT), diff --git a/packages/plugin/tests/unique-operation-name.spec.ts b/packages/plugin/tests/unique-operation-name.spec.ts index 58008d4b34c..8880fb438b3 100644 --- a/packages/plugin/tests/unique-operation-name.spec.ts +++ b/packages/plugin/tests/unique-operation-name.spec.ts @@ -1,5 +1,6 @@ import { join } from 'node:path'; -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { rule } from '../src/rules/unique-operation-name'; const TEST_OPERATION = 'query test { foo }'; @@ -12,9 +13,9 @@ const SIBLING_OPERATIONS = ( }, }); -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('unique-operation-name', rule, { +ruleTester.run('unique-operation-name', rule, { valid: [ { ...SIBLING_OPERATIONS(TEST_OPERATION), diff --git a/packages/plugin/tests/unique-type-names.spec.ts b/packages/plugin/tests/unique-type-names.spec.ts index a82b4667afc..c5914fbf85d 100644 --- a/packages/plugin/tests/unique-type-names.spec.ts +++ b/packages/plugin/tests/unique-type-names.spec.ts @@ -1,4 +1,5 @@ -import { GraphQLRuleTester, ParserOptions } from '../src'; +import { ParserOptions } from '../src'; +import { RuleTester } from '../src/testkit'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const TEST_SCHEMA = /* GraphQL */ ` @@ -15,9 +16,9 @@ const WITH_SCHEMA = { } as ParserOptions, }; -const ruleTester = new GraphQLRuleTester(); +const ruleTester = new RuleTester(); -ruleTester.runGraphQLTests('unique-type-names', GRAPHQL_JS_VALIDATIONS['unique-type-names'], { +ruleTester.run('unique-type-names', GRAPHQL_JS_VALIDATIONS['unique-type-names'], { valid: [ { ...WITH_SCHEMA, code: TEST_SCHEMA }, { From ac072bf606bb36a98f5393c716d773b3d9f20e93 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Thu, 27 Jul 2023 21:35:39 +0200 Subject: [PATCH 06/39] more --- packages/plugin/src/testkit.ts | 58 +++++-------------- .../plugin/tests/description-style.spec.ts | 4 +- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index 2f799adf858..e01223582cc 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -1,12 +1,12 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { codeFrameColumns } from '@babel/code-frame'; -import { AST, Linter, Rule, RuleTester } from 'eslint'; +import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; import { FlatRuleTester } from 'eslint/use-at-your-own-risk'; import { ASTKindToNode } from 'graphql'; import { GraphQLESTreeNode } from './estree-converter/index.js'; import { GraphQLESLintRule, ParserOptions } from './types.js'; -import { parseForESLint } from './parser.js' +import { parseForESLint } from './parser.js'; export type GraphQLESLintRuleListener = Record< string, @@ -16,7 +16,7 @@ export type GraphQLESLintRuleListener = Re }; export type GraphQLValidTestCase = Omit< - RuleTester.ValidTestCase, + ESLintRuleTester.ValidTestCase, 'options' | 'parserOptions' > & { options?: Options; @@ -24,7 +24,7 @@ export type GraphQLValidTestCase = Omit< }; export type GraphQLInvalidTestCase = GraphQLValidTestCase & { - errors: (RuleTester.TestCaseError | string)[] | number; + errors: (ESLintRuleTester.TestCaseError | string)[] | number; output?: string | null; }; @@ -43,11 +43,11 @@ type RuleTesterConfig = { parserOptions: Omit; }; -export class GraphQLRuleTester extends FlatRuleTester { - config: RuleTesterConfig; +export class RuleTester extends FlatRuleTester { + static parserName = '@graphql-eslint/eslint-plugin'; constructor(parserOptions: Omit = {}) { - const config = { + super({ languageOptions: { parser: { parseForESLint }, parserOptions: { @@ -55,9 +55,7 @@ export class GraphQLRuleTester extends FlatRuleTester { skipGraphQLConfig: true, }, }, - }; - super(config); - this.config = config; + }); } fromMockFile(path: string): string { @@ -73,6 +71,8 @@ export class GraphQLRuleTester extends FlatRuleTester { }, ): void { super.run(ruleId, rule as any, tests); + const config = this.testerConfig[1] as RuleTesterConfig; + const linter = new Linter(); linter.defineRule(ruleId, rule as any); @@ -80,25 +80,6 @@ export class GraphQLRuleTester extends FlatRuleTester { t => typeof t !== 'string' && t.only, ); - // for (const [index, testCase] of tests.valid.entries()) { - // const { name, code, filename, only }: RuleTester.ValidTestCase = - // typeof testCase === 'string' ? { code: testCase } : testCase; - // - // if (hasOnlyTest && !only) { - // continue; - // } - // - // const verifyConfig = getVerifyConfig(ruleId, this.config, testCase); - // defineParser(linter, verifyConfig.parser); - // - // const messages = linter.verify(code, verifyConfig, { filename }); - // const codeFrame = printCode(code, { line: 0, column: 0 }); - // - // it(name || `Valid #${index + 1}\n${codeFrame}`, () => { - // expect(messages).toEqual([]); - // }); - // } - for (const [idx, testCase] of tests.invalid.entries()) { const { only, filename, options, name } = testCase; if (hasOnlyTest && !only) { @@ -106,8 +87,9 @@ export class GraphQLRuleTester extends FlatRuleTester { } const code = removeTrailingBlankLines(testCase.code); - const verifyConfig = getVerifyConfig(ruleId, this.config, testCase); - defineParser(linter, verifyConfig.parser); + const verifyConfig = getVerifyConfig(ruleId, config, testCase); + defineParser(linter, config.languageOptions.parser); + verifyConfig.parser = RuleTester.parserName; const messages = linter.verify(code, verifyConfig, filename); if (messages.length === 0) { @@ -161,8 +143,6 @@ export class GraphQLRuleTester extends FlatRuleTester { } } -export const ruleTester = new GraphQLRuleTester(); - function removeTrailingBlankLines(text: string): string { return text.replace(/^\s*\n/, '').trimEnd(); } @@ -182,15 +162,10 @@ function getVerifyConfig( testerConfig: RuleTesterConfig, testCase: GraphQLInvalidTestCase, ): Omit & { parser: string } { - const { parser = testerConfig.parser, parserOptions, options } = testCase; + const { options } = testCase; return { ...testerConfig, - parser, - parserOptions: { - ...testerConfig.parserOptions, - ...parserOptions, - }, rules: { [ruleId]: Array.isArray(options) ? ['error', ...options] : 'error', }, @@ -199,7 +174,7 @@ function getVerifyConfig( const parsers = new WeakMap(); -function defineParser(linter: Linter, parser: string): void { +function defineParser(linter: Linter, parser: Linter.ParserModule): void { if (!parser) { return; } @@ -210,8 +185,7 @@ function defineParser(linter: Linter, parser: string): void { const defined = parsers.get(linter); if (!defined.has(parser)) { defined.add(parser); - // eslint-disable-next-line @typescript-eslint/no-var-requires - linter.defineParser(parser, require(parser)); + linter.defineParser(RuleTester.parserName, parser); } } diff --git a/packages/plugin/tests/description-style.spec.ts b/packages/plugin/tests/description-style.spec.ts index 84734eb88c0..e77ba2d6fb0 100644 --- a/packages/plugin/tests/description-style.spec.ts +++ b/packages/plugin/tests/description-style.spec.ts @@ -1,4 +1,4 @@ -import { ruleTester } from '../src/testkit'; +import { RuleTester } from '../src/testkit'; import { rule, RuleOptions } from '../src/rules/description-style'; const INLINE_SDL = /* GraphQL */ ` @@ -29,6 +29,8 @@ export const BLOCK_SDL = /* GraphQL */ ` } `; +const ruleTester = new RuleTester(); + ruleTester.run('description-style', rule, { valid: [ BLOCK_SDL, From 2c4fe0d3f542ea3cb1d7b8b4c343fe37978eedc9 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 00:39:43 +0200 Subject: [PATCH 07/39] more --- examples/basic/package.json | 2 +- examples/code-file/package.json | 2 +- .../graphql-config-code-file/package.json | 2 +- examples/graphql-config/package.json | 2 +- examples/monorepo/package.json | 2 +- .../package.json | 2 +- examples/prettier/package.json | 2 +- examples/svelte-code-file/package.json | 2 +- examples/vue-code-file/package.json | 2 +- package.json | 4 +- pnpm-lock.yaml | 355 ++++++++---------- 11 files changed, 159 insertions(+), 218 deletions(-) diff --git a/examples/basic/package.json b/examples/basic/package.json index fbe60476177..537d5dedba8 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0" + "eslint": "8.46.0" } } diff --git a/examples/code-file/package.json b/examples/code-file/package.json index 332934e1774..108e08dfa3c 100644 --- a/examples/code-file/package.json +++ b/examples/code-file/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0" + "eslint": "8.46.0" } } diff --git a/examples/graphql-config-code-file/package.json b/examples/graphql-config-code-file/package.json index c3904b8ae97..596995bd43f 100644 --- a/examples/graphql-config-code-file/package.json +++ b/examples/graphql-config-code-file/package.json @@ -15,6 +15,6 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0" + "eslint": "8.46.0" } } diff --git a/examples/graphql-config/package.json b/examples/graphql-config/package.json index 5db3203cf34..964fc7a8812 100644 --- a/examples/graphql-config/package.json +++ b/examples/graphql-config/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0" + "eslint": "8.46.0" } } diff --git a/examples/monorepo/package.json b/examples/monorepo/package.json index 470e393e397..335e6746014 100644 --- a/examples/monorepo/package.json +++ b/examples/monorepo/package.json @@ -13,6 +13,6 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0" + "eslint": "8.46.0" } } diff --git a/examples/multiple-projects-graphql-config/package.json b/examples/multiple-projects-graphql-config/package.json index 950d8883eb4..6671f9680e4 100644 --- a/examples/multiple-projects-graphql-config/package.json +++ b/examples/multiple-projects-graphql-config/package.json @@ -12,7 +12,7 @@ "devDependencies": { "@graphql-eslint/eslint-plugin": "workspace:*", "cosmiconfig-typescript-loader": "5.0.0", - "eslint": "8.38.0", + "eslint": "8.46.0", "ts-node": "10.9.1", "typescript": "5.1.6" } diff --git a/examples/prettier/package.json b/examples/prettier/package.json index c93ddd2a3fa..4c796791e04 100644 --- a/examples/prettier/package.json +++ b/examples/prettier/package.json @@ -14,7 +14,7 @@ "devDependencies": { "@eslint/js": "8.45.0", "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0", + "eslint": "8.46.0", "eslint-config-prettier": "8.8.0", "eslint-plugin-prettier": "4.2.1", "prettier": "2.8.8" diff --git a/examples/svelte-code-file/package.json b/examples/svelte-code-file/package.json index d47cc17147c..de4d85d894c 100644 --- a/examples/svelte-code-file/package.json +++ b/examples/svelte-code-file/package.json @@ -12,7 +12,7 @@ }, "devDependencies": { "@graphql-eslint/eslint-plugin": "workspace:*", - "eslint": "8.38.0", + "eslint": "8.46.0", "svelte": "4.1.1", "svelte-eslint-parser": "0.32.2", "svelte2tsx": "0.6.19" diff --git a/examples/vue-code-file/package.json b/examples/vue-code-file/package.json index a9ea36cd891..8f4986d5837 100644 --- a/examples/vue-code-file/package.json +++ b/examples/vue-code-file/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@graphql-eslint/eslint-plugin": "workspace:*", "@vue/compiler-sfc": "3.3.4", - "eslint": "8.38.0", + "eslint": "8.46.0", "vue-eslint-parser": "9.3.1" } } diff --git a/package.json b/package.json index 30f6ee64f5b..d44f8124f43 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "chalk": "4.1.2", "dedent": "1.2.0", "enquirer": "2.4.0", - "eslint": "8.45.0", + "eslint": "8.46.0", "eslint-plugin-eslint-plugin": "5.0.7", "eslint-plugin-tailwindcss": "3.13.0", "husky": "8.0.3", @@ -54,7 +54,7 @@ }, "pnpm": { "patchedDependencies": { - "eslint@8.45.0": "patches/eslint@8.31.0.patch", + "eslint@8.46.0": "patches/eslint@8.45.0.patch", "eslint-plugin-eslint-plugin@5.0.7": "patches/eslint-plugin-eslint-plugin@5.0.6.patch", "json-schema-to-markdown@1.1.1": "patches/json-schema-to-markdown@1.1.1.patch", "@vitest/runner@0.30.1": "patches/@vitest__runner@0.28.4.patch" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 25f60040b82..c5cc61754d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,9 @@ patchedDependencies: eslint-plugin-eslint-plugin@5.0.7: hash: cdhdgvmsbh3fbusrlxsl6de2he path: patches/eslint-plugin-eslint-plugin@5.0.6.patch - eslint@8.45.0: - hash: v7lv2hbnxmm2b22qo3sob3rjvq - path: patches/eslint@8.31.0.patch + eslint@8.46.0: + hash: jgld3jznern4ntgy2ju3hkhvtq + path: patches/eslint@8.45.0.patch json-schema-to-markdown@1.1.1: hash: beglqnggvhpsclgwbdw27hzvu4 path: patches/json-schema-to-markdown@1.1.1.patch @@ -36,7 +36,7 @@ importers: version: 9.2.1(graphql@16.7.1) '@theguild/eslint-config': specifier: 0.11.0 - version: 0.11.0(eslint@8.45.0)(typescript@5.1.6) + version: 0.11.0(eslint@8.46.0)(typescript@5.1.6) '@theguild/prettier-config': specifier: 1.2.0 version: 1.2.0(prettier@2.8.8) @@ -59,11 +59,11 @@ importers: specifier: 2.4.0 version: 2.4.0 eslint: - specifier: 8.45.0 - version: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-plugin-eslint-plugin: specifier: 5.0.7 - version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.45.0) + version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0) eslint-plugin-tailwindcss: specifier: 3.13.0 version: 3.13.0(tailwindcss@3.3.3) @@ -111,8 +111,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) examples/code-file: dependencies: @@ -127,8 +127,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) examples/graphql-config: dependencies: @@ -143,8 +143,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) examples/graphql-config-code-file: dependencies: @@ -162,8 +162,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) examples/monorepo: dependencies: @@ -178,8 +178,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) examples/multiple-projects-graphql-config: dependencies: @@ -194,8 +194,8 @@ importers: specifier: 5.0.0 version: 5.0.0(@types/node@18.17.1)(cosmiconfig@8.2.0)(typescript@5.1.6) eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) ts-node: specifier: 10.9.1 version: 10.9.1(@types/node@18.17.1)(typescript@5.1.6) @@ -216,14 +216,14 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-config-prettier: specifier: 8.8.0 - version: 8.8.0(eslint@8.38.0) + version: 8.8.0(eslint@8.46.0) eslint-plugin-prettier: specifier: 4.2.1 - version: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.38.0)(prettier@2.8.8) + version: 4.2.1(eslint-config-prettier@8.8.0)(eslint@8.46.0)(prettier@2.8.8) prettier: specifier: 2.8.8 version: 2.8.8 @@ -238,8 +238,8 @@ importers: specifier: workspace:* version: link:../../packages/plugin/dist eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) svelte: specifier: 4.1.1 version: 4.1.1 @@ -263,11 +263,11 @@ importers: specifier: 3.3.4 version: 3.3.4 eslint: - specifier: 8.38.0 - version: 8.38.0 + specifier: 8.46.0 + version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) vue-eslint-parser: specifier: 9.3.1 - version: 9.3.1(eslint@8.38.0) + version: 9.3.1(eslint@8.46.0) packages/plugin: dependencies: @@ -1509,24 +1509,14 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.38.0): - resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - dependencies: - eslint: 8.38.0 - eslint-visitor-keys: 3.4.1 - dev: true - - /@eslint-community/eslint-utils@4.4.0(eslint@8.45.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.46.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-visitor-keys: 3.4.1 + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-visitor-keys: 3.4.2 dev: true /@eslint-community/regexpp@4.6.0: @@ -1534,8 +1524,13 @@ packages: engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true - /@eslint/eslintrc@2.1.0: - resolution: {integrity: sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==} + /@eslint-community/regexpp@4.6.2: + resolution: {integrity: sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: true + + /@eslint/eslintrc@2.1.1: + resolution: {integrity: sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 @@ -1551,18 +1546,13 @@ packages: - supports-color dev: true - /@eslint/js@8.38.0: - resolution: {integrity: sha512-IoD2MfUnOV58ghIHCiil01PcohxjbYR/qCxsoC+xNgUwh1EY8jOOrYmu3d3a71+tJJ23uscEV4X2HJWMsPJu4g==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - - /@eslint/js@8.44.0: - resolution: {integrity: sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==} + /@eslint/js@8.45.0: + resolution: {integrity: sha512-p/4a2uaWVHCbAPLxPcv9rkhooU1FVfUUiLoZq09v1dOgtLym/Qlsyw2L3JWr9inVRt1XaLKPP5PBcDtTxRUJPg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@eslint/js@8.45.0: - resolution: {integrity: sha512-p/4a2uaWVHCbAPLxPcv9rkhooU1FVfUUiLoZq09v1dOgtLym/Qlsyw2L3JWr9inVRt1XaLKPP5PBcDtTxRUJPg==} + /@eslint/js@8.46.0: + resolution: {integrity: sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -2914,28 +2904,28 @@ packages: - webpack dev: false - /@theguild/eslint-config@0.11.0(eslint@8.45.0)(typescript@5.1.6): + /@theguild/eslint-config@0.11.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-dxKcEb0uKZvkKBp9KwcKe/npuHZw789vrQPUJGJksz9ghjvAQOc9Kx4PMJTTrVWOzg/1lzFB9s070V9yviYkHg==} peerDependencies: eslint: ^8.24.0 dependencies: '@rushstack/eslint-patch': 1.3.2 - '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.45.0)(typescript@5.1.6) - '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-config-prettier: 8.8.0(eslint@8.45.0) - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) - eslint-plugin-jsonc: 2.9.0(eslint@8.45.0) - eslint-plugin-jsx-a11y: 6.7.1(eslint@8.45.0) - eslint-plugin-mdx: 2.1.0(eslint@8.45.0) - eslint-plugin-n: 16.0.1(eslint@8.45.0) - eslint-plugin-promise: 6.1.1(eslint@8.45.0) - eslint-plugin-react: 7.33.0(eslint@8.45.0) - eslint-plugin-react-hooks: 4.6.0(eslint@8.45.0) - eslint-plugin-sonarjs: 0.19.0(eslint@8.45.0) - eslint-plugin-unicorn: 47.0.0(eslint@8.45.0) - eslint-plugin-yml: 1.8.0(eslint@8.45.0) + '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-config-prettier: 8.8.0(eslint@8.46.0) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) + eslint-plugin-jsonc: 2.9.0(eslint@8.46.0) + eslint-plugin-jsx-a11y: 6.7.1(eslint@8.46.0) + eslint-plugin-mdx: 2.1.0(eslint@8.46.0) + eslint-plugin-n: 16.0.1(eslint@8.46.0) + eslint-plugin-promise: 6.1.1(eslint@8.46.0) + eslint-plugin-react: 7.33.0(eslint@8.46.0) + eslint-plugin-react-hooks: 4.6.0(eslint@8.46.0) + eslint-plugin-sonarjs: 0.19.0(eslint@8.46.0) + eslint-plugin-unicorn: 47.0.0(eslint@8.46.0) + eslint-plugin-yml: 1.8.0(eslint@8.46.0) transitivePeerDependencies: - eslint-import-resolver-node - eslint-import-resolver-webpack @@ -3181,7 +3171,7 @@ packages: '@types/node': 18.17.1 dev: false - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.45.0)(typescript@5.1.6): + /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3193,12 +3183,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.6.0 - '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) - '@typescript-eslint/utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) + '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -3209,7 +3199,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.62.0(eslint@8.45.0)(typescript@5.1.6): + /@typescript-eslint/parser@5.62.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3223,7 +3213,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) debug: 4.3.4 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) typescript: 5.1.6 transitivePeerDependencies: - supports-color @@ -3237,7 +3227,7 @@ packages: '@typescript-eslint/visitor-keys': 5.62.0 dev: true - /@typescript-eslint/type-utils@5.62.0(eslint@8.45.0)(typescript@5.1.6): + /@typescript-eslint/type-utils@5.62.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -3248,9 +3238,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - '@typescript-eslint/utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) tsutils: 3.21.0(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: @@ -3283,19 +3273,19 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.45.0)(typescript@5.1.6): + /@typescript-eslint/utils@5.62.0(eslint@8.46.0)(typescript@5.1.6): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.0 '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -5712,22 +5702,13 @@ packages: engines: {node: '>=12'} dev: false - /eslint-config-prettier@8.8.0(eslint@8.38.0): + /eslint-config-prettier@8.8.0(eslint@8.46.0): resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.38.0 - dev: true - - /eslint-config-prettier@8.8.0(eslint@8.45.0): - resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==} - hasBin: true - peerDependencies: - eslint: '>=7.0.0' - dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) dev: true /eslint-import-resolver-node@0.3.7: @@ -5740,7 +5721,7 @@ packages: - supports-color dev: true - /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0): + /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0): resolution: {integrity: sha512-TdJqPHs2lW5J9Zpe17DZNQuDnox4xo2o+0tE7Pggain9Rbc19ik8kFtXdxZ250FVx2kF4vlt2RSf4qlUpG7bhw==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -5749,9 +5730,9 @@ packages: dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) get-tsconfig: 4.6.2 globby: 13.2.2 is-core-module: 2.12.1 @@ -5764,7 +5745,7 @@ packages: - supports-color dev: true - /eslint-mdx@2.1.0(eslint@8.45.0): + /eslint-mdx@2.1.0(eslint@8.46.0): resolution: {integrity: sha512-dVLHDcpCFJRXZhxEQx8nKc68KT1qm+9JOeMD+j1/WW2h+oco1j7Qq+CLrX2kP64LI3fF9TUtj7a0AvncHUME6w==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} peerDependencies: @@ -5772,7 +5753,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) espree: 9.6.1 estree-util-visit: 1.2.1 remark-mdx: 2.3.0 @@ -5789,7 +5770,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -5810,39 +5791,39 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 3.2.7 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-import-resolver-node: 0.3.7 - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-es-x@7.2.0(eslint@8.45.0): + /eslint-plugin-es-x@7.2.0(eslint@8.46.0): resolution: {integrity: sha512-9dvv5CcvNjSJPqnS5uZkqb3xmbeqRLnvXKK7iI5+oK/yTusyc46zbBZKENGsOfojm/mKfszyZb+wNqNPAPeGXA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) '@eslint-community/regexpp': 4.6.0 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) dev: true - /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.45.0): + /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0): resolution: {integrity: sha512-hcz4Bze1ECwv3Q/Bi/ZMZZNiuvI2YclNuxjnczkblQ0skrlPhdO83rSM7felf5n+7ZJOZi4GS8y8gNiRtvI0hA==} engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-utils: 3.0.0(eslint@8.45.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-utils: 3.0.0(eslint@8.46.0) estraverse: 5.3.0 dev: true patched: true - /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): + /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0): resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} engines: {node: '>=4'} peerDependencies: @@ -5852,15 +5833,15 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.45.0)(typescript@5.1.6) + '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) has: 1.0.3 is-core-module: 2.12.1 is-glob: 4.0.3 @@ -5875,19 +5856,19 @@ packages: - supports-color dev: true - /eslint-plugin-jsonc@2.9.0(eslint@8.45.0): + /eslint-plugin-jsonc@2.9.0(eslint@8.46.0): resolution: {integrity: sha512-RK+LeONVukbLwT2+t7/OY54NJRccTXh/QbnXzPuTLpFMVZhPuq1C9E07+qWenGx7rrQl0kAalAWl7EmB+RjpGA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) jsonc-eslint-parser: 2.3.0 natural-compare: 1.4.0 dev: true - /eslint-plugin-jsx-a11y@6.7.1(eslint@8.45.0): + /eslint-plugin-jsx-a11y@6.7.1(eslint@8.46.0): resolution: {integrity: sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==} engines: {node: '>=4.0'} peerDependencies: @@ -5902,7 +5883,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) has: 1.0.3 jsx-ast-utils: 3.3.4 language-tags: 1.0.5 @@ -5912,27 +5893,27 @@ packages: semver: 6.3.1 dev: true - /eslint-plugin-markdown@3.0.0(eslint@8.45.0): + /eslint-plugin-markdown@3.0.0(eslint@8.46.0): resolution: {integrity: sha512-hRs5RUJGbeHDLfS7ELanT0e29Ocyssf/7kBM+p7KluY5AwngGkDf8Oyu4658/NZSGTTq05FZeWbkxXtbVyHPwg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-mdx@2.1.0(eslint@8.45.0): + /eslint-plugin-mdx@2.1.0(eslint@8.46.0): resolution: {integrity: sha512-Q8P1JXv+OrD+xhWT95ZyV30MMdnqJ1voKtXfxWrJJ2XihJRI15gPmXbIWY9t8CjA8C//isfzNOmnVY9e3GTL0g==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8.0.0' dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-mdx: 2.1.0(eslint@8.45.0) - eslint-plugin-markdown: 3.0.0(eslint@8.45.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-mdx: 2.1.0(eslint@8.46.0) + eslint-plugin-markdown: 3.0.0(eslint@8.46.0) remark-mdx: 2.3.0 remark-parse: 10.0.2 remark-stringify: 10.0.3 @@ -5943,16 +5924,16 @@ packages: - supports-color dev: true - /eslint-plugin-n@16.0.1(eslint@8.45.0): + /eslint-plugin-n@16.0.1(eslint@8.46.0): resolution: {integrity: sha512-CDmHegJN0OF3L5cz5tATH84RPQm9kG+Yx39wIqIwPR2C0uhBGMWfbbOtetR83PQjjidA5aXMu+LEFw1jaSwvTA==} engines: {node: '>=16.0.0'} peerDependencies: eslint: '>=7.0.0' dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) builtins: 5.0.1 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) - eslint-plugin-es-x: 7.2.0(eslint@8.45.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-plugin-es-x: 7.2.0(eslint@8.46.0) ignore: 5.2.4 is-core-module: 2.12.1 minimatch: 3.1.2 @@ -5960,7 +5941,7 @@ packages: semver: 7.5.4 dev: true - /eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.8.0)(eslint@8.38.0)(prettier@2.8.8): + /eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.8.0)(eslint@8.46.0)(prettier@2.8.8): resolution: {integrity: sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==} engines: {node: '>=12.0.0'} peerDependencies: @@ -5971,31 +5952,31 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.38.0 - eslint-config-prettier: 8.8.0(eslint@8.38.0) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint-config-prettier: 8.8.0(eslint@8.46.0) prettier: 2.8.8 prettier-linter-helpers: 1.0.0 dev: true - /eslint-plugin-promise@6.1.1(eslint@8.45.0): + /eslint-plugin-promise@6.1.1(eslint@8.46.0): resolution: {integrity: sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) dev: true - /eslint-plugin-react-hooks@4.6.0(eslint@8.45.0): + /eslint-plugin-react-hooks@4.6.0(eslint@8.46.0): resolution: {integrity: sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==} engines: {node: '>=10'} peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) dev: true - /eslint-plugin-react@7.33.0(eslint@8.45.0): + /eslint-plugin-react@7.33.0(eslint@8.46.0): resolution: {integrity: sha512-qewL/8P34WkY8jAqdQxsiL82pDUeT7nhs8IsuXgfgnsEloKCT4miAV9N9kGtx7/KM9NH/NCGUE7Edt9iGxLXFw==} engines: {node: '>=4'} peerDependencies: @@ -6005,7 +5986,7 @@ packages: array.prototype.flatmap: 1.3.1 array.prototype.tosorted: 1.1.1 doctrine: 2.1.0 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) estraverse: 5.3.0 jsx-ast-utils: 3.3.4 minimatch: 3.1.2 @@ -6019,13 +6000,13 @@ packages: string.prototype.matchall: 4.0.8 dev: true - /eslint-plugin-sonarjs@0.19.0(eslint@8.45.0): + /eslint-plugin-sonarjs@0.19.0(eslint@8.46.0): resolution: {integrity: sha512-6+s5oNk5TFtVlbRxqZN7FIGmjdPCYQKaTzFPmqieCmsU1kBYDzndTeQav0xtQNwZJWu5awWfTGe8Srq9xFOGnw==} engines: {node: '>=14'} peerDependencies: eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) dev: true /eslint-plugin-tailwindcss@3.13.0(tailwindcss@3.3.3): @@ -6039,17 +6020,17 @@ packages: tailwindcss: 3.3.3 dev: true - /eslint-plugin-unicorn@47.0.0(eslint@8.45.0): + /eslint-plugin-unicorn@47.0.0(eslint@8.46.0): resolution: {integrity: sha512-ivB3bKk7fDIeWOUmmMm9o3Ax9zbMz1Bsza/R2qm46ufw4T6VBFBaJIR1uN3pCKSmSXm8/9Nri8V+iUut1NhQGA==} engines: {node: '>=16'} peerDependencies: eslint: '>=8.38.0' dependencies: '@babel/helper-validator-identifier': 7.22.5 - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) ci-info: 3.8.0 clean-regexp: 1.0.0 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 @@ -6064,14 +6045,14 @@ packages: strip-indent: 3.0.0 dev: true - /eslint-plugin-yml@1.8.0(eslint@8.45.0): + /eslint-plugin-yml@1.8.0(eslint@8.46.0): resolution: {integrity: sha512-fgBiJvXD0P2IN7SARDJ2J7mx8t0bLdG6Zcig4ufOqW5hOvSiFxeUyc2g5I1uIm8AExbo26NNYCcTGZT0MXTsyg==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -6103,13 +6084,21 @@ packages: estraverse: 5.3.0 dev: true - /eslint-utils@3.0.0(eslint@8.45.0): + /eslint-scope@7.2.2: + resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + dev: true + + /eslint-utils@3.0.0(eslint@8.46.0): resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq) + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-visitor-keys: 2.1.0 dev: true @@ -6123,64 +6112,20 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.38.0: - resolution: {integrity: sha512-pIdsD2jwlUGf/U38Jv97t8lq6HpaU/G9NKbYmpWpZGw3LdTNhZLbJePqxOXGB5+JEKfOPU/XLxYxFh03nr1KTg==} + /eslint-visitor-keys@3.4.2: + resolution: {integrity: sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - hasBin: true - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.38.0) - '@eslint-community/regexpp': 4.6.0 - '@eslint/eslintrc': 2.1.0 - '@eslint/js': 8.38.0 - '@humanwhocodes/config-array': 0.11.10 - '@humanwhocodes/module-importer': 1.0.1 - '@nodelib/fs.walk': 1.2.8 - ajv: 6.12.6 - chalk: 4.1.2 - cross-spawn: 7.0.3 - debug: 4.3.4 - doctrine: 3.0.0 - escape-string-regexp: 4.0.0 - eslint-scope: 7.2.1 - eslint-visitor-keys: 3.4.1 - espree: 9.6.1 - esquery: 1.5.0 - esutils: 2.0.3 - fast-deep-equal: 3.1.3 - file-entry-cache: 6.0.1 - find-up: 5.0.0 - glob-parent: 6.0.2 - globals: 13.20.0 - grapheme-splitter: 1.0.4 - ignore: 5.2.4 - import-fresh: 3.3.0 - imurmurhash: 0.1.4 - is-glob: 4.0.3 - is-path-inside: 3.0.3 - js-sdsl: 4.4.2 - js-yaml: 4.1.0 - json-stable-stringify-without-jsonify: 1.0.1 - levn: 0.4.1 - lodash.merge: 4.6.2 - minimatch: 3.1.2 - natural-compare: 1.4.0 - optionator: 0.9.3 - strip-ansi: 6.0.1 - strip-json-comments: 3.1.1 - text-table: 0.2.0 - transitivePeerDependencies: - - supports-color dev: true - /eslint@8.45.0(patch_hash=v7lv2hbnxmm2b22qo3sob3rjvq): - resolution: {integrity: sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==} + /eslint@8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq): + resolution: {integrity: sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) - '@eslint-community/regexpp': 4.6.0 - '@eslint/eslintrc': 2.1.0 - '@eslint/js': 8.44.0 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) + '@eslint-community/regexpp': 4.6.2 + '@eslint/eslintrc': 2.1.1 + '@eslint/js': 8.46.0 '@humanwhocodes/config-array': 0.11.10 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 @@ -6190,8 +6135,8 @@ packages: debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 - eslint-scope: 7.2.1 - eslint-visitor-keys: 3.4.1 + eslint-scope: 7.2.2 + eslint-visitor-keys: 3.4.2 espree: 9.6.1 esquery: 1.5.0 esutils: 2.0.3 @@ -6225,7 +6170,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint-visitor-keys: 3.4.1 + eslint-visitor-keys: 3.4.2 dev: true /esprima@4.0.1: @@ -7784,10 +7729,6 @@ packages: engines: {node: '>=10'} dev: true - /js-sdsl@4.4.2: - resolution: {integrity: sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w==} - dev: true - /js-string-escape@1.0.1: resolution: {integrity: sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==} engines: {node: '>= 0.8'} @@ -12672,14 +12613,14 @@ packages: resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} dev: false - /vue-eslint-parser@9.3.1(eslint@8.38.0): + /vue-eslint-parser@9.3.1(eslint@8.46.0): resolution: {integrity: sha512-Clr85iD2XFZ3lJ52/ppmUDG/spxQu6+MAeHXjjyI4I1NUYZ9xmenQp4N0oaHJhrA8OOxltCVxMRfANGa70vU0g==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.38.0 + eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) eslint-scope: 7.2.1 eslint-visitor-keys: 3.4.1 espree: 9.6.1 From c7ccaed158f238b8b87712a5d9559029c25251a7 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 00:47:33 +0200 Subject: [PATCH 08/39] patches --- package.json | 2 +- ...slint@8.31.0.patch => eslint@8.46.0.patch} | 34 +++++--- pnpm-lock.yaml | 80 +++++++++---------- 3 files changed, 64 insertions(+), 52 deletions(-) rename patches/{eslint@8.31.0.patch => eslint@8.46.0.patch} (51%) diff --git a/package.json b/package.json index d44f8124f43..a532e0e012f 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "pnpm": { "patchedDependencies": { - "eslint@8.46.0": "patches/eslint@8.45.0.patch", + "eslint@8.46.0": "patches/eslint@8.46.0.patch", "eslint-plugin-eslint-plugin@5.0.7": "patches/eslint-plugin-eslint-plugin@5.0.6.patch", "json-schema-to-markdown@1.1.1": "patches/json-schema-to-markdown@1.1.1.patch", "@vitest/runner@0.30.1": "patches/@vitest__runner@0.28.4.patch" diff --git a/patches/eslint@8.31.0.patch b/patches/eslint@8.46.0.patch similarity index 51% rename from patches/eslint@8.31.0.patch rename to patches/eslint@8.46.0.patch index 3ce101a2e77..934a58a571b 100644 --- a/patches/eslint@8.31.0.patch +++ b/patches/eslint@8.46.0.patch @@ -1,10 +1,10 @@ diff --git a/lib/linter/linter.js b/lib/linter/linter.js -index a29ce92..a574871 100644 +index 233cbed5b5ccdf89806df9786a0902a317dd451e..7db8fa9c1fca4183460164ca1fd8fa0a3c9e6206 100644 --- a/lib/linter/linter.js +++ b/lib/linter/linter.js -@@ -41,7 +41,8 @@ const { getRuleFromConfig } = require("../config/flat-config-helpers"); +@@ -44,7 +44,8 @@ const { getRuleFromConfig } = require("../config/flat-config-helpers"); const { FlatConfigArray } = require("../config/flat-config-array"); - + const debug = require("debug")("eslint:linter"); -const MAX_AUTOFIX_PASSES = 10; +// 🚨 10 is not enough for alphabetize test with definitions sorting @@ -12,11 +12,28 @@ index a29ce92..a574871 100644 const DEFAULT_PARSER_NAME = "espree"; const DEFAULT_ECMA_VERSION = 5; const commentParser = new ConfigCommentParser(); +diff --git a/lib/rule-tester/flat-rule-tester.js b/lib/rule-tester/flat-rule-tester.js +index f143873f7bc76737acc5ff00871e462ef058bf4b..ac6ecbbda2854bf927c6de3632588c5b6ea8a9a8 100644 +--- a/lib/rule-tester/flat-rule-tester.js ++++ b/lib/rule-tester/flat-rule-tester.js +@@ -998,11 +998,7 @@ class FlatRuleTester { + assert.strictEqual(result.output, item.output, "Output is incorrect."); + } + } else { +- assert.strictEqual( +- result.output, +- item.code, +- "The rule fixed the code. Please add 'output' property." +- ); ++ // 🚨 Don't need, as we assert autofix output with snapshots + } + + assertASTDidntChange(result.beforeAST, result.afterAST); diff --git a/lib/rule-tester/rule-tester.js b/lib/rule-tester/rule-tester.js -index 2af272b..738f80f 100644 +index e4dc126783c8232a67268c72def615829c4508b9..9b38bf58032a161dfbed70e6bb3974644297dd8f 100644 --- a/lib/rule-tester/rule-tester.js +++ b/lib/rule-tester/rule-tester.js -@@ -1005,11 +1005,12 @@ class RuleTester { +@@ -1008,11 +1008,7 @@ class RuleTester { assert.strictEqual(result.output, item.output, "Output is incorrect."); } } else { @@ -26,11 +43,6 @@ index 2af272b..738f80f 100644 - "The rule fixed the code. Please add 'output' property." - ); + // 🚨 Don't need, as we assert autofix output with snapshots -+ // assert.strictEqual( -+ // result.output, -+ // item.code, -+ // "The rule fixed the code. Please add 'output' property." -+ // ); } - + assertASTDidntChange(result.beforeAST, result.afterAST); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5cc61754d0..78893ede359 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ patchedDependencies: hash: cdhdgvmsbh3fbusrlxsl6de2he path: patches/eslint-plugin-eslint-plugin@5.0.6.patch eslint@8.46.0: - hash: jgld3jznern4ntgy2ju3hkhvtq - path: patches/eslint@8.45.0.patch + hash: deiqbyg3gmwgmixqd3hulwyry4 + path: patches/eslint@8.46.0.patch json-schema-to-markdown@1.1.1: hash: beglqnggvhpsclgwbdw27hzvu4 path: patches/json-schema-to-markdown@1.1.1.patch @@ -60,7 +60,7 @@ importers: version: 2.4.0 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-plugin-eslint-plugin: specifier: 5.0.7 version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0) @@ -112,7 +112,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) examples/code-file: dependencies: @@ -128,7 +128,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) examples/graphql-config: dependencies: @@ -144,7 +144,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) examples/graphql-config-code-file: dependencies: @@ -163,7 +163,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) examples/monorepo: dependencies: @@ -179,7 +179,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) examples/multiple-projects-graphql-config: dependencies: @@ -195,7 +195,7 @@ importers: version: 5.0.0(@types/node@18.17.1)(cosmiconfig@8.2.0)(typescript@5.1.6) eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) ts-node: specifier: 10.9.1 version: 10.9.1(@types/node@18.17.1)(typescript@5.1.6) @@ -217,7 +217,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-config-prettier: specifier: 8.8.0 version: 8.8.0(eslint@8.46.0) @@ -239,7 +239,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) svelte: specifier: 4.1.1 version: 4.1.1 @@ -264,7 +264,7 @@ importers: version: 3.3.4 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) vue-eslint-parser: specifier: 9.3.1 version: 9.3.1(eslint@8.46.0) @@ -1515,7 +1515,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-visitor-keys: 3.4.2 dev: true @@ -2912,7 +2912,7 @@ packages: '@rushstack/eslint-patch': 1.3.2 '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-config-prettier: 8.8.0(eslint@8.46.0) eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) @@ -3188,7 +3188,7 @@ packages: '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -3213,7 +3213,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) typescript: 5.1.6 transitivePeerDependencies: - supports-color @@ -3240,7 +3240,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) tsutils: 3.21.0(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: @@ -3285,7 +3285,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -5708,7 +5708,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) dev: true /eslint-import-resolver-node@0.3.7: @@ -5730,7 +5730,7 @@ packages: dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) get-tsconfig: 4.6.2 @@ -5753,7 +5753,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) espree: 9.6.1 estree-util-visit: 1.2.1 remark-mdx: 2.3.0 @@ -5793,7 +5793,7 @@ packages: dependencies: '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 3.2.7 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-import-resolver-node: 0.3.7 eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) transitivePeerDependencies: @@ -5808,7 +5808,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) '@eslint-community/regexpp': 4.6.0 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) dev: true /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0): @@ -5817,7 +5817,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-utils: 3.0.0(eslint@8.46.0) estraverse: 5.3.0 dev: true @@ -5839,7 +5839,7 @@ packages: array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-import-resolver-node: 0.3.7 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) has: 1.0.3 @@ -5863,7 +5863,7 @@ packages: eslint: '>=6.0.0' dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) jsonc-eslint-parser: 2.3.0 natural-compare: 1.4.0 dev: true @@ -5883,7 +5883,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) has: 1.0.3 jsx-ast-utils: 3.3.4 language-tags: 1.0.5 @@ -5899,7 +5899,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color @@ -5911,7 +5911,7 @@ packages: peerDependencies: eslint: '>=8.0.0' dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-mdx: 2.1.0(eslint@8.46.0) eslint-plugin-markdown: 3.0.0(eslint@8.46.0) remark-mdx: 2.3.0 @@ -5932,7 +5932,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) builtins: 5.0.1 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-plugin-es-x: 7.2.0(eslint@8.46.0) ignore: 5.2.4 is-core-module: 2.12.1 @@ -5952,7 +5952,7 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-config-prettier: 8.8.0(eslint@8.46.0) prettier: 2.8.8 prettier-linter-helpers: 1.0.0 @@ -5964,7 +5964,7 @@ packages: peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) dev: true /eslint-plugin-react-hooks@4.6.0(eslint@8.46.0): @@ -5973,7 +5973,7 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) dev: true /eslint-plugin-react@7.33.0(eslint@8.46.0): @@ -5986,7 +5986,7 @@ packages: array.prototype.flatmap: 1.3.1 array.prototype.tosorted: 1.1.1 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) estraverse: 5.3.0 jsx-ast-utils: 3.3.4 minimatch: 3.1.2 @@ -6006,7 +6006,7 @@ packages: peerDependencies: eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) dev: true /eslint-plugin-tailwindcss@3.13.0(tailwindcss@3.3.3): @@ -6030,7 +6030,7 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) ci-info: 3.8.0 clean-regexp: 1.0.0 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 @@ -6052,7 +6052,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -6098,7 +6098,7 @@ packages: peerDependencies: eslint: '>=5' dependencies: - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-visitor-keys: 2.1.0 dev: true @@ -6117,7 +6117,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq): + /eslint@8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4): resolution: {integrity: sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true @@ -12620,7 +12620,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=jgld3jznern4ntgy2ju3hkhvtq) + eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) eslint-scope: 7.2.1 eslint-visitor-keys: 3.4.1 espree: 9.6.1 From 48e1ac00276c2a38fde90bf99b748ca58d5cb5ed Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 00:50:55 +0200 Subject: [PATCH 09/39] green --- packages/plugin/src/testkit.ts | 41 ++++++------ .../tests/executable-definitions.spec.ts | 62 +++++++++---------- 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index e01223582cc..b7617f8a199 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -2,11 +2,9 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; -import { FlatRuleTester } from 'eslint/use-at-your-own-risk'; import { ASTKindToNode } from 'graphql'; import { GraphQLESTreeNode } from './estree-converter/index.js'; import { GraphQLESLintRule, ParserOptions } from './types.js'; -import { parseForESLint } from './parser.js'; export type GraphQLESLintRuleListener = Record< string, @@ -43,19 +41,19 @@ type RuleTesterConfig = { parserOptions: Omit; }; -export class RuleTester extends FlatRuleTester { - static parserName = '@graphql-eslint/eslint-plugin'; +export class RuleTester extends ESLintRuleTester { + config: RuleTesterConfig; constructor(parserOptions: Omit = {}) { - super({ - languageOptions: { - parser: { parseForESLint }, - parserOptions: { - ...parserOptions, - skipGraphQLConfig: true, - }, + const config = { + parser: require.resolve('@graphql-eslint/eslint-plugin'), + parserOptions: { + ...parserOptions, + skipGraphQLConfig: true, }, - }); + }; + super(config); + this.config = config; } fromMockFile(path: string): string { @@ -71,8 +69,6 @@ export class RuleTester extends FlatRuleTester { }, ): void { super.run(ruleId, rule as any, tests); - const config = this.testerConfig[1] as RuleTesterConfig; - const linter = new Linter(); linter.defineRule(ruleId, rule as any); @@ -87,9 +83,8 @@ export class RuleTester extends FlatRuleTester { } const code = removeTrailingBlankLines(testCase.code); - const verifyConfig = getVerifyConfig(ruleId, config, testCase); - defineParser(linter, config.languageOptions.parser); - verifyConfig.parser = RuleTester.parserName; + const verifyConfig = getVerifyConfig(ruleId, this.config, testCase); + defineParser(linter, verifyConfig.parser); const messages = linter.verify(code, verifyConfig, filename); if (messages.length === 0) { @@ -162,10 +157,15 @@ function getVerifyConfig( testerConfig: RuleTesterConfig, testCase: GraphQLInvalidTestCase, ): Omit & { parser: string } { - const { options } = testCase; + const { parser = testerConfig.parser, parserOptions, options } = testCase; return { ...testerConfig, + parser, + parserOptions: { + ...testerConfig.parserOptions, + ...parserOptions, + }, rules: { [ruleId]: Array.isArray(options) ? ['error', ...options] : 'error', }, @@ -174,7 +174,7 @@ function getVerifyConfig( const parsers = new WeakMap(); -function defineParser(linter: Linter, parser: Linter.ParserModule): void { +function defineParser(linter: Linter, parser: string): void { if (!parser) { return; } @@ -185,7 +185,8 @@ function defineParser(linter: Linter, parser: Linter.ParserModule): void { const defined = parsers.get(linter); if (!defined.has(parser)) { defined.add(parser); - linter.defineParser(RuleTester.parserName, parser); + // eslint-disable-next-line @typescript-eslint/no-var-requires + linter.defineParser(parser, require(parser)); } } diff --git a/packages/plugin/tests/executable-definitions.spec.ts b/packages/plugin/tests/executable-definitions.spec.ts index d0fd7cb65ea..dd0134933c5 100644 --- a/packages/plugin/tests/executable-definitions.spec.ts +++ b/packages/plugin/tests/executable-definitions.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { ruleTester } from '../src/testkit'; +import { RuleTester } from '../src/testkit'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const TEST_SCHEMA = /* GraphQL */ ` @@ -18,37 +18,33 @@ const TEST_SCHEMA = /* GraphQL */ ` `; const WITH_SCHEMA = { - languageOptions: { - parserOptions: { - schema: TEST_SCHEMA, - } as ParserOptions, - } + parserOptions: { + schema: TEST_SCHEMA, + } as ParserOptions, }; -ruleTester.run( - 'executable-definitions', - GRAPHQL_JS_VALIDATIONS['executable-definitions'], - { - valid: [ - { - ...WITH_SCHEMA, - code: 'query test2 { foo }', - }, - { - ...WITH_SCHEMA, - code: 'mutation test { foo }', - }, - { - ...WITH_SCHEMA, - code: 'fragment Test on T { foo }', - }, - ], - invalid: [ - { - ...WITH_SCHEMA, - code: 'type Query { t: String }', - errors: [{ message: 'The "Query" definition is not executable.' }], - }, - ], - }, -); +const ruleTester = new RuleTester(); + +ruleTester.run('executable-definitions', GRAPHQL_JS_VALIDATIONS['executable-definitions'], { + valid: [ + { + ...WITH_SCHEMA, + code: 'query test2 { foo }', + }, + { + ...WITH_SCHEMA, + code: 'mutation test { foo }', + }, + { + ...WITH_SCHEMA, + code: 'fragment Test on T { foo }', + }, + ], + invalid: [ + { + ...WITH_SCHEMA, + code: 'type Query { t: String }', + errors: [{ message: 'The "Query" definition is not executable.' }], + }, + ], +}); From a93afc4c5b6b5779a4b89610c704dc2196d311d2 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 01:07:47 +0200 Subject: [PATCH 10/39] 1 --- packages/plugin/src/testkit.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index b7617f8a199..bd8444aee94 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -68,7 +68,14 @@ export class RuleTester extends ESLintRuleTester { invalid: GraphQLInvalidTestCase[]; }, ): void { + for (const test of [...tests.valid, ...tests.invalid]) { + test.getMessages = (messages) => { + console.log(123,{messages}) + } + } + super.run(ruleId, rule as any, tests); + return const linter = new Linter(); linter.defineRule(ruleId, rule as any); From 26266837ddfb9c43155099d01fa92832eaa7d2ca Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 01:08:31 +0200 Subject: [PATCH 11/39] 1 --- packages/plugin/src/testkit.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index bd8444aee94..11f3bce61a3 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -69,26 +69,18 @@ export class RuleTester extends ESLintRuleTester { }, ): void { for (const test of [...tests.valid, ...tests.invalid]) { - test.getMessages = (messages) => { - console.log(123,{messages}) - } + test.getMessages = messages => { + console.log(123, { messages }); + }; } super.run(ruleId, rule as any, tests); - return + return; const linter = new Linter(); linter.defineRule(ruleId, rule as any); - const hasOnlyTest = [...tests.valid, ...tests.invalid].some( - t => typeof t !== 'string' && t.only, - ); - for (const [idx, testCase] of tests.invalid.entries()) { - const { only, filename, options, name } = testCase; - if (hasOnlyTest && !only) { - continue; - } - + const { filename, options, name } = testCase; const code = removeTrailingBlankLines(testCase.code); const verifyConfig = getVerifyConfig(ruleId, this.config, testCase); defineParser(linter, verifyConfig.parser); From 4dec79bb1776fed5ee2155f00966c4879940ddca Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:12:15 +0200 Subject: [PATCH 12/39] more --- packages/plugin/src/testkit.ts | 103 +++++------------- .../__snapshots__/description-style.spec.md | 4 +- .../__snapshots__/eslint-directives.spec.md | 2 +- .../executable-definitions.spec.md | 2 +- .../known-fragment-names.spec.md | 2 +- .../lone-schema-definition.spec.md | 2 +- .../tests/__snapshots__/no-deprecated.spec.md | 8 +- .../__snapshots__/no-duplicate-fields.spec.md | 8 +- .../no-hashtag-description.spec.md | 10 +- .../no-one-place-fragments.spec.md | 2 +- .../__snapshots__/no-typename-prefix.spec.md | 6 +- .../no-undefined-variables.spec.md | 2 +- .../no-unreachable-types.spec.md | 10 +- .../__snapshots__/relay-arguments.spec.md | 6 +- .../require-deprecation-date.spec.md | 10 +- .../unique-fragment-name.spec.md | 4 +- .../unique-operation-name.spec.md | 4 +- .../__snapshots__/unique-type-names.spec.md | 2 +- 18 files changed, 68 insertions(+), 119 deletions(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index 11f3bce61a3..05a5056abe2 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -36,24 +36,15 @@ function applyFix(code: string, { range, text }: Rule.Fix): string { return [code.slice(0, range[0]), text, code.slice(range[1])].join(''); } -type RuleTesterConfig = { - parser: string; - parserOptions: Omit; -}; - export class RuleTester extends ESLintRuleTester { - config: RuleTesterConfig; - constructor(parserOptions: Omit = {}) { - const config = { + super({ parser: require.resolve('@graphql-eslint/eslint-plugin'), parserOptions: { ...parserOptions, skipGraphQLConfig: true, }, - }; - super(config); - this.config = config; + }); } fromMockFile(path: string): string { @@ -68,27 +59,23 @@ export class RuleTester extends ESLintRuleTester { invalid: GraphQLInvalidTestCase[]; }, ): void { - for (const test of [...tests.valid, ...tests.invalid]) { - test.getMessages = messages => { - console.log(123, { messages }); + const getMessages = (testCase: ESLintRuleTester.InvalidTestCase) => () => { + const { options, code: rawCode, filename, parserOptions } = testCase; + + const testerConfig = { + ...this.testerConfig, + parserOptions: { + ...this.testerConfig.parserOptions, + ...parserOptions, + }, + rules: { + [ruleId]: Array.isArray(options) ? ['error', ...options] : 'error', + }, }; - } - super.run(ruleId, rule as any, tests); - return; - const linter = new Linter(); - linter.defineRule(ruleId, rule as any); - - for (const [idx, testCase] of tests.invalid.entries()) { - const { filename, options, name } = testCase; - const code = removeTrailingBlankLines(testCase.code); - const verifyConfig = getVerifyConfig(ruleId, this.config, testCase); - defineParser(linter, verifyConfig.parser); - - const messages = linter.verify(code, verifyConfig, filename); - if (messages.length === 0) { - throw new Error('Invalid case should have at least one error.'); - } + const code = removeTrailingBlankLines(rawCode); + const messages = this.linter.verify(code, testerConfig, filename); + const codeFrame = indentCode(printCode(code, { line: 0, column: 0 })); const messageForSnapshot = ['#### ⌨️ Code', codeFrame]; @@ -98,10 +85,6 @@ export class RuleTester extends ESLintRuleTester { } for (const [index, message] of messages.entries()) { - if (message.fatal) { - throw new Error(message.message); - } - const codeWithMessage = printCode(code, message, 1); messageForSnapshot.push( printWithIndex('#### ❌ Error', index, messages.length), @@ -123,17 +106,21 @@ export class RuleTester extends ESLintRuleTester { } } } - if (rule.meta.fixable) { - const { fixed, output } = linter.verifyAndFix(code, verifyConfig, filename); + const { fixed, output } = this.linter.verifyAndFix(code, testerConfig, filename); if (fixed) { messageForSnapshot.push('#### 🔧 Autofix output', indentCode(printCode(output))); } } - it(name || `Invalid #${idx + 1}`, () => { - expect(messageForSnapshot.join('\n\n')).toMatchSnapshot(); - }); + expect(messageForSnapshot.join('\n\n')).toMatchSnapshot(); + }; + + for (const [id, testCase] of tests.invalid.entries()) { + testCase.name = `Invalid #${id + 1}`; + testCase.getMessages = getMessages(testCase); } + + super.run(ruleId, rule as any, tests); } } @@ -151,44 +138,6 @@ function printWithIndex(title: string, index: number, total: number, description return title; } -function getVerifyConfig( - ruleId: string, - testerConfig: RuleTesterConfig, - testCase: GraphQLInvalidTestCase, -): Omit & { parser: string } { - const { parser = testerConfig.parser, parserOptions, options } = testCase; - - return { - ...testerConfig, - parser, - parserOptions: { - ...testerConfig.parserOptions, - ...parserOptions, - }, - rules: { - [ruleId]: Array.isArray(options) ? ['error', ...options] : 'error', - }, - }; -} - -const parsers = new WeakMap(); - -function defineParser(linter: Linter, parser: string): void { - if (!parser) { - return; - } - if (!parsers.has(linter)) { - parsers.set(linter, new Set()); - } - - const defined = parsers.get(linter); - if (!defined.has(parser)) { - defined.add(parser); - // eslint-disable-next-line @typescript-eslint/no-var-requires - linter.defineParser(parser, require(parser)); - } -} - function printCode( code: string, result: Partial = {}, diff --git a/packages/plugin/tests/__snapshots__/description-style.spec.md b/packages/plugin/tests/__snapshots__/description-style.spec.md index d46cf142c4b..6e6a88237a3 100644 --- a/packages/plugin/tests/__snapshots__/description-style.spec.md +++ b/packages/plugin/tests/__snapshots__/description-style.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`description-style > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | enum EnumUserLanguagesSkill { @@ -91,7 +91,7 @@ exports[`Invalid #1 1`] = ` 12 | } `; -exports[`Invalid #2 1`] = ` +exports[`description-style > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | " Test " diff --git a/packages/plugin/tests/__snapshots__/eslint-directives.spec.md b/packages/plugin/tests/__snapshots__/eslint-directives.spec.md index 88a2604eb82..24f6c139b9f 100644 --- a/packages/plugin/tests/__snapshots__/eslint-directives.spec.md +++ b/packages/plugin/tests/__snapshots__/eslint-directives.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`test-directives > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | # eslint-disable-next-line non-existing-rule diff --git a/packages/plugin/tests/__snapshots__/executable-definitions.spec.md b/packages/plugin/tests/__snapshots__/executable-definitions.spec.md index 12111cd18b1..8802e38bfc0 100644 --- a/packages/plugin/tests/__snapshots__/executable-definitions.spec.md +++ b/packages/plugin/tests/__snapshots__/executable-definitions.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`executable-definitions > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Query { t: String } diff --git a/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md b/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md index e0898008a60..0da7dc9b63b 100644 --- a/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md +++ b/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should not throw an error on undefined fragment 1`] = ` +exports[`known-fragment-names > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | { diff --git a/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md b/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md index 699f53b7a09..60a3d2719b9 100644 --- a/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md +++ b/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`lone-schema-definition > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Query { diff --git a/packages/plugin/tests/__snapshots__/no-deprecated.spec.md b/packages/plugin/tests/__snapshots__/no-deprecated.spec.md index 7d0bacc44bb..41564657f1a 100644 --- a/packages/plugin/tests/__snapshots__/no-deprecated.spec.md +++ b/packages/plugin/tests/__snapshots__/no-deprecated.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-deprecated > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | mutation { something(t: OLD) } @@ -15,7 +15,7 @@ exports[`Invalid #1 1`] = ` 1 | mutation { something(t: ) } `; -exports[`Invalid #2 1`] = ` +exports[`no-deprecated > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | mutation { something(t: OLD_WITH_REASON) } @@ -30,7 +30,7 @@ exports[`Invalid #2 1`] = ` 1 | mutation { something(t: ) } `; -exports[`Invalid #3 1`] = ` +exports[`no-deprecated > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | query { oldField } @@ -45,7 +45,7 @@ exports[`Invalid #3 1`] = ` 1 | query { } `; -exports[`Invalid #4 1`] = ` +exports[`no-deprecated > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | query { oldFieldWithReason } diff --git a/packages/plugin/tests/__snapshots__/no-duplicate-fields.spec.md b/packages/plugin/tests/__snapshots__/no-duplicate-fields.spec.md index 5f6300a0b32..a914063f4a8 100644 --- a/packages/plugin/tests/__snapshots__/no-duplicate-fields.spec.md +++ b/packages/plugin/tests/__snapshots__/no-duplicate-fields.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-duplicate-fields > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | query test($v: String, $t: String, $v: String) { @@ -20,7 +20,7 @@ exports[`Invalid #1 1`] = ` 3 | } `; -exports[`Invalid #2 1`] = ` +exports[`no-duplicate-fields > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | query test { @@ -45,7 +45,7 @@ exports[`Invalid #2 1`] = ` 5 | } `; -exports[`Invalid #3 1`] = ` +exports[`no-duplicate-fields > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | query test { @@ -76,7 +76,7 @@ exports[`Invalid #3 1`] = ` 8 | } `; -exports[`Invalid #4 1`] = ` +exports[`no-duplicate-fields > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | query test { diff --git a/packages/plugin/tests/__snapshots__/no-hashtag-description.spec.md b/packages/plugin/tests/__snapshots__/no-hashtag-description.spec.md index d4fb34a2274..20049bbf613 100644 --- a/packages/plugin/tests/__snapshots__/no-hashtag-description.spec.md +++ b/packages/plugin/tests/__snapshots__/no-hashtag-description.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-hashtag-description > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | # Bad @@ -30,7 +30,7 @@ exports[`Invalid #1 1`] = ` 4 | } `; -exports[`Invalid #2 1`] = ` +exports[`no-hashtag-description > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | # multiline @@ -64,7 +64,7 @@ exports[`Invalid #2 1`] = ` 5 | } `; -exports[`Invalid #3 1`] = ` +exports[`no-hashtag-description > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type Query { @@ -95,7 +95,7 @@ exports[`Invalid #3 1`] = ` 4 | } `; -exports[`Invalid #4 1`] = ` +exports[`no-hashtag-description > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | type Query { @@ -132,7 +132,7 @@ exports[`Invalid #4 1`] = ` 6 | } `; -exports[`Invalid #5 1`] = ` +exports[`no-hashtag-description > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type Query { diff --git a/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md b/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md index e8c32fabfb0..6623662e7a1 100644 --- a/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md +++ b/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should error fragment used in one place 1`] = ` +exports[`no-one-place-fragments > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | fragment UserFields on User { diff --git a/packages/plugin/tests/__snapshots__/no-typename-prefix.spec.md b/packages/plugin/tests/__snapshots__/no-typename-prefix.spec.md index 42a69885ad6..e7f250ded0d 100644 --- a/packages/plugin/tests/__snapshots__/no-typename-prefix.spec.md +++ b/packages/plugin/tests/__snapshots__/no-typename-prefix.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-typename-prefix > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type User { @@ -21,7 +21,7 @@ exports[`Invalid #1 1`] = ` 3 | } `; -exports[`Invalid #2 1`] = ` +exports[`no-typename-prefix > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type User { @@ -58,7 +58,7 @@ exports[`Invalid #2 1`] = ` 4 | } `; -exports[`Invalid #3 1`] = ` +exports[`no-typename-prefix > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | interface Node { diff --git a/packages/plugin/tests/__snapshots__/no-undefined-variables.spec.md b/packages/plugin/tests/__snapshots__/no-undefined-variables.spec.md index f9d072f5080..7469b7f4ed6 100644 --- a/packages/plugin/tests/__snapshots__/no-undefined-variables.spec.md +++ b/packages/plugin/tests/__snapshots__/no-undefined-variables.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-undefined-variables > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | query User { diff --git a/packages/plugin/tests/__snapshots__/no-unreachable-types.spec.md b/packages/plugin/tests/__snapshots__/no-unreachable-types.spec.md index e530be8116c..07b0ff5fd08 100644 --- a/packages/plugin/tests/__snapshots__/no-unreachable-types.spec.md +++ b/packages/plugin/tests/__snapshots__/no-unreachable-types.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-unreachable-types > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Query { @@ -114,7 +114,7 @@ exports[`Invalid #1 1`] = ` 18 | `; -exports[`Invalid #2 1`] = ` +exports[`no-unreachable-types > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | # ScalarTypeDefinition @@ -412,7 +412,7 @@ exports[`Invalid #2 1`] = ` 27 | `; -exports[`Invalid #3 1`] = ` +exports[`no-unreachable-types > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | interface User { @@ -462,7 +462,7 @@ exports[`Invalid #3 1`] = ` 18 | `; -exports[`Invalid #4 1`] = ` +exports[`no-unreachable-types > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | interface User { @@ -570,7 +570,7 @@ exports[`Invalid #4 1`] = ` 18 | } `; -exports[`Invalid #5 1`] = ` +exports[`no-unreachable-types > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type Query { diff --git a/packages/plugin/tests/__snapshots__/relay-arguments.spec.md b/packages/plugin/tests/__snapshots__/relay-arguments.spec.md index c122b0c2def..76dda16fb32 100644 --- a/packages/plugin/tests/__snapshots__/relay-arguments.spec.md +++ b/packages/plugin/tests/__snapshots__/relay-arguments.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`relay-arguments > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type User { @@ -49,7 +49,7 @@ exports[`Invalid #1 1`] = ` 8 | ): PostConnection `; -exports[`Invalid #2 1`] = ` +exports[`relay-arguments > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type User { @@ -71,7 +71,7 @@ exports[`Invalid #2 1`] = ` 3 | } `; -exports[`should report about 2nd required argument if 1st was provided 1`] = ` +exports[`relay-arguments > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type User { diff --git a/packages/plugin/tests/__snapshots__/require-deprecation-date.spec.md b/packages/plugin/tests/__snapshots__/require-deprecation-date.spec.md index b7923f54861..4743ba4ecda 100644 --- a/packages/plugin/tests/__snapshots__/require-deprecation-date.spec.md +++ b/packages/plugin/tests/__snapshots__/require-deprecation-date.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`require-deprecation-date > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | scalar Old @deprecated(deletionDate: "22/08/2021") @@ -15,7 +15,7 @@ exports[`Invalid #1 1`] = ` 1 | `; -exports[`Invalid #2 1`] = ` +exports[`require-deprecation-date > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | scalar Old @deprecated(untilDate: "22/08/2021") @@ -36,7 +36,7 @@ exports[`Invalid #2 1`] = ` 1 | `; -exports[`Invalid #3 1`] = ` +exports[`require-deprecation-date > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | scalar Old @deprecated(deletionDate: "bad") @@ -47,7 +47,7 @@ exports[`Invalid #3 1`] = ` | ^^^^^ Deletion date must be in format "DD/MM/YYYY" for scalar "Old" `; -exports[`Invalid #4 1`] = ` +exports[`require-deprecation-date > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | scalar Old @deprecated(deletionDate: "32/08/2021") @@ -58,7 +58,7 @@ exports[`Invalid #4 1`] = ` | ^^^^^^^^^^^^ Invalid "32/08/2021" deletion date for scalar "Old" `; -exports[`Invalid #5 1`] = ` +exports[`require-deprecation-date > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type Old { oldField: ID @deprecated } diff --git a/packages/plugin/tests/__snapshots__/unique-fragment-name.spec.md b/packages/plugin/tests/__snapshots__/unique-fragment-name.spec.md index 2b3b8fcd943..59472efeac1 100644 --- a/packages/plugin/tests/__snapshots__/unique-fragment-name.spec.md +++ b/packages/plugin/tests/__snapshots__/unique-fragment-name.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`unique-fragment-name > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | fragment HasIdFields on U { a b c } @@ -12,7 +12,7 @@ exports[`Invalid #1 1`] = ` -1866344359.graphql `; -exports[`Invalid #2 1`] = ` +exports[`unique-fragment-name > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | fragment HasIdFields on U { a b c } diff --git a/packages/plugin/tests/__snapshots__/unique-operation-name.spec.md b/packages/plugin/tests/__snapshots__/unique-operation-name.spec.md index 45151f7058b..e0c57a89aaa 100644 --- a/packages/plugin/tests/__snapshots__/unique-operation-name.spec.md +++ b/packages/plugin/tests/__snapshots__/unique-operation-name.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`unique-operation-name > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | query test { bar } @@ -12,7 +12,7 @@ exports[`Invalid #1 1`] = ` 6844040.graphql `; -exports[`Invalid #2 1`] = ` +exports[`unique-operation-name > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | query test { bar } diff --git a/packages/plugin/tests/__snapshots__/unique-type-names.spec.md b/packages/plugin/tests/__snapshots__/unique-type-names.spec.md index 3e505092477..f40374ffcd0 100644 --- a/packages/plugin/tests/__snapshots__/unique-type-names.spec.md +++ b/packages/plugin/tests/__snapshots__/unique-type-names.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`unique-type-names > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Query { From d8118e50148ba12b6f67b65565d3a4cd14d36fc1 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:13:59 +0200 Subject: [PATCH 13/39] more --- packages/plugin/src/testkit.ts | 2 +- .../__snapshots__/fields-on-correct-type.spec.md | 4 ++-- .../tests/__snapshots__/known-directives.spec.md | 2 +- .../__snapshots__/known-fragment-names.spec.md | 2 +- .../lone-executable-definition.spec.md | 6 +++--- .../__snapshots__/match-document-filename.spec.md | 14 +++++++------- .../__snapshots__/no-anonymous-operations.spec.md | 6 +++--- ...case-insensitive-enum-values-duplicates.spec.md | 4 ++-- .../__snapshots__/no-one-place-fragments.spec.md | 2 +- .../tests/__snapshots__/no-root-type.spec.md | 8 ++++---- .../no-scalar-result-type-on-mutation.spec.md | 10 +++++----- .../tests/__snapshots__/no-unused-fields.spec.md | 4 ++-- .../__snapshots__/possible-type-extension.spec.md | 2 +- .../tests/__snapshots__/relay-arguments.spec.md | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index 05a5056abe2..22f339b55b4 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -116,7 +116,7 @@ export class RuleTester extends ESLintRuleTester { }; for (const [id, testCase] of tests.invalid.entries()) { - testCase.name = `Invalid #${id + 1}`; + testCase.name ||= `Invalid #${id + 1}`; testCase.getMessages = getMessages(testCase); } diff --git a/packages/plugin/tests/__snapshots__/fields-on-correct-type.spec.md b/packages/plugin/tests/__snapshots__/fields-on-correct-type.spec.md index f69d285c9e1..3fc5c0970eb 100644 --- a/packages/plugin/tests/__snapshots__/fields-on-correct-type.spec.md +++ b/packages/plugin/tests/__snapshots__/fields-on-correct-type.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should highlight selection on multi line 1`] = ` +exports[`fields-on-correct-type > invalid > should highlight selection on multi line 1`] = ` #### ⌨️ Code 1 | { @@ -19,7 +19,7 @@ exports[`should highlight selection on multi line 1`] = ` 5 | age `; -exports[`should highlight selection on single line 1`] = ` +exports[`fields-on-correct-type > invalid > should highlight selection on single line 1`] = ` #### ⌨️ Code 1 | fragment UserFields on User { id bad age } diff --git a/packages/plugin/tests/__snapshots__/known-directives.spec.md b/packages/plugin/tests/__snapshots__/known-directives.spec.md index 897dc0e13ef..7e37884d714 100644 --- a/packages/plugin/tests/__snapshots__/known-directives.spec.md +++ b/packages/plugin/tests/__snapshots__/known-directives.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should work only with Kind.FIELD 1`] = ` +exports[`known-directives > invalid > should work only with Kind.FIELD 1`] = ` #### ⌨️ Code 1 | scalar Foo @bad diff --git a/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md b/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md index 0da7dc9b63b..b648293dd84 100644 --- a/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md +++ b/packages/plugin/tests/__snapshots__/known-fragment-names.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`known-fragment-names > invalid > Invalid #1 1`] = ` +exports[`known-fragment-names > invalid > should not throw an error on undefined fragment 1`] = ` #### ⌨️ Code 1 | { diff --git a/packages/plugin/tests/__snapshots__/lone-executable-definition.spec.md b/packages/plugin/tests/__snapshots__/lone-executable-definition.spec.md index 1de57f9fcee..2c8d71a6f95 100644 --- a/packages/plugin/tests/__snapshots__/lone-executable-definition.spec.md +++ b/packages/plugin/tests/__snapshots__/lone-executable-definition.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should allow fragments if they are ignored 1`] = ` +exports[`lone-executable-definition > invalid > should allow fragments if they are ignored 1`] = ` #### ⌨️ Code 1 | query Foo { @@ -31,7 +31,7 @@ exports[`should allow fragments if they are ignored 1`] = ` 8 | createFoo { `; -exports[`should report additional definitions 1`] = ` +exports[`lone-executable-definition > invalid > should report additional definitions 1`] = ` #### ⌨️ Code 1 | query Valid { @@ -103,7 +103,7 @@ exports[`should report additional definitions 1`] = ` 24 | id `; -exports[`should report definitions after short-hand query 1`] = ` +exports[`lone-executable-definition > invalid > should report definitions after short-hand query 1`] = ` #### ⌨️ Code 1 | { diff --git a/packages/plugin/tests/__snapshots__/match-document-filename.spec.md b/packages/plugin/tests/__snapshots__/match-document-filename.spec.md index e612dea0142..0c554ce1e46 100644 --- a/packages/plugin/tests/__snapshots__/match-document-filename.spec.md +++ b/packages/plugin/tests/__snapshots__/match-document-filename.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`match-document-filename > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | { me } @@ -17,7 +17,7 @@ exports[`Invalid #1 1`] = ` | ^ File extension ".graphql" don't match extension ".gql" `; -exports[`Invalid #2 1`] = ` +exports[`match-document-filename > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | query UserById { user { id } } @@ -36,7 +36,7 @@ exports[`Invalid #2 1`] = ` | ^ Unexpected filename "user-by-id.gql". Rename it to "UserById.gql" `; -exports[`Invalid #3 1`] = ` +exports[`match-document-filename > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | query UserById { user { id } } @@ -56,7 +56,7 @@ exports[`Invalid #3 1`] = ` | ^ Unexpected filename "userById.gql". Rename it to "UserById.query.gql" `; -exports[`Invalid #4 1`] = ` +exports[`match-document-filename > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | fragment UserFields on User { id } @@ -75,7 +75,7 @@ exports[`Invalid #4 1`] = ` | ^ Unexpected filename "user-fields.gql". Rename it to "UserFields.gql" `; -exports[`Invalid #7 1`] = ` +exports[`match-document-filename > invalid > Invalid #7 1`] = ` #### ⌨️ Code 1 | mutation addAlertChannel { @@ -97,7 +97,7 @@ exports[`Invalid #7 1`] = ` 2 | foo `; -exports[`compare only first operation name 1`] = ` +exports[`match-document-filename > invalid > compare only first operation name 1`] = ` #### ⌨️ Code 1 | query getUsers { users } mutation createPost { createPost } @@ -121,7 +121,7 @@ exports[`compare only first operation name 1`] = ` | ^ Unexpected filename "getUsersQuery.gql". Rename it to "GetUsers.query.gql" `; -exports[`compare only first operation name if fragment is present 1`] = ` +exports[`match-document-filename > invalid > compare only first operation name if fragment is present 1`] = ` #### ⌨️ Code 1 | fragment UserFields on User { diff --git a/packages/plugin/tests/__snapshots__/no-anonymous-operations.spec.md b/packages/plugin/tests/__snapshots__/no-anonymous-operations.spec.md index aec338a2840..37215e81880 100644 --- a/packages/plugin/tests/__snapshots__/no-anonymous-operations.spec.md +++ b/packages/plugin/tests/__snapshots__/no-anonymous-operations.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-anonymous-operations > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | query { a } @@ -15,7 +15,7 @@ exports[`Invalid #1 1`] = ` 1 | query a { a } `; -exports[`Invalid #2 1`] = ` +exports[`no-anonymous-operations > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | mutation { renamed: a } @@ -30,7 +30,7 @@ exports[`Invalid #2 1`] = ` 1 | mutation renamed { renamed: a } `; -exports[`Invalid #3 1`] = ` +exports[`no-anonymous-operations > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | subscription { ...someFragmentSpread } diff --git a/packages/plugin/tests/__snapshots__/no-case-insensitive-enum-values-duplicates.spec.md b/packages/plugin/tests/__snapshots__/no-case-insensitive-enum-values-duplicates.spec.md index e00d7f30621..6c24d0ed502 100644 --- a/packages/plugin/tests/__snapshots__/no-case-insensitive-enum-values-duplicates.spec.md +++ b/packages/plugin/tests/__snapshots__/no-case-insensitive-enum-values-duplicates.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-case-insensitive-enum-values-duplicates > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | enum A { TEST TesT } @@ -15,7 +15,7 @@ exports[`Invalid #1 1`] = ` 1 | enum A { TEST } `; -exports[`Invalid #2 1`] = ` +exports[`no-case-insensitive-enum-values-duplicates > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | extend enum A { TEST TesT } diff --git a/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md b/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md index 6623662e7a1..04a9beaa108 100644 --- a/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md +++ b/packages/plugin/tests/__snapshots__/no-one-place-fragments.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`no-one-place-fragments > invalid > Invalid #1 1`] = ` +exports[`no-one-place-fragments > invalid > should error fragment used in one place 1`] = ` #### ⌨️ Code 1 | fragment UserFields on User { diff --git a/packages/plugin/tests/__snapshots__/no-root-type.spec.md b/packages/plugin/tests/__snapshots__/no-root-type.spec.md index bdb0ce7b29e..3ad37ae5834 100644 --- a/packages/plugin/tests/__snapshots__/no-root-type.spec.md +++ b/packages/plugin/tests/__snapshots__/no-root-type.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`disallow mutation 1`] = ` +exports[`no-root-type > invalid > disallow mutation 1`] = ` #### ⌨️ Code 1 | type Mutation @@ -23,7 +23,7 @@ exports[`disallow mutation 1`] = ` 1 | `; -exports[`disallow subscription 1`] = ` +exports[`no-root-type > invalid > disallow subscription 1`] = ` #### ⌨️ Code 1 | type Subscription @@ -46,7 +46,7 @@ exports[`disallow subscription 1`] = ` 1 | `; -exports[`disallow when root type name is renamed 1`] = ` +exports[`no-root-type > invalid > disallow when root type name is renamed 1`] = ` #### ⌨️ Code 1 | type MyMutation @@ -69,7 +69,7 @@ exports[`disallow when root type name is renamed 1`] = ` 1 | `; -exports[`disallow with extend 1`] = ` +exports[`no-root-type > invalid > disallow with extend 1`] = ` #### ⌨️ Code 1 | extend type Mutation { foo: ID } diff --git a/packages/plugin/tests/__snapshots__/no-scalar-result-type-on-mutation.spec.md b/packages/plugin/tests/__snapshots__/no-scalar-result-type-on-mutation.spec.md index 32c7667a1a5..b86f5c84e61 100644 --- a/packages/plugin/tests/__snapshots__/no-scalar-result-type-on-mutation.spec.md +++ b/packages/plugin/tests/__snapshots__/no-scalar-result-type-on-mutation.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #2 1`] = ` +exports[`no-scalar-result-type-on-mutation > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type Mutation @@ -25,7 +25,7 @@ exports[`Invalid #2 1`] = ` 5 | } `; -exports[`Invalid #3 1`] = ` +exports[`no-scalar-result-type-on-mutation > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type RootMutation { @@ -54,7 +54,7 @@ exports[`Invalid #3 1`] = ` 7 | } `; -exports[`Invalid #4 1`] = ` +exports[`no-scalar-result-type-on-mutation > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | type RootMutation @@ -85,7 +85,7 @@ exports[`Invalid #4 1`] = ` 8 | } `; -exports[`Invalid #5 1`] = ` +exports[`no-scalar-result-type-on-mutation > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type Mutation { @@ -125,7 +125,7 @@ exports[`Invalid #5 1`] = ` 5 | } `; -exports[`should ignore arguments 1`] = ` +exports[`no-scalar-result-type-on-mutation > invalid > should ignore arguments 1`] = ` #### ⌨️ Code 1 | type Mutation { diff --git a/packages/plugin/tests/__snapshots__/no-unused-fields.spec.md b/packages/plugin/tests/__snapshots__/no-unused-fields.spec.md index 3b6bb6d7bb9..098b38eb2c5 100644 --- a/packages/plugin/tests/__snapshots__/no-unused-fields.spec.md +++ b/packages/plugin/tests/__snapshots__/no-unused-fields.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`no-unused-fields > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type User { @@ -23,7 +23,7 @@ exports[`Invalid #1 1`] = ` 4 | } `; -exports[`Invalid #2 1`] = ` +exports[`no-unused-fields > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type Query { diff --git a/packages/plugin/tests/__snapshots__/possible-type-extension.spec.md b/packages/plugin/tests/__snapshots__/possible-type-extension.spec.md index 0e8536a5594..377aaedd976 100644 --- a/packages/plugin/tests/__snapshots__/possible-type-extension.spec.md +++ b/packages/plugin/tests/__snapshots__/possible-type-extension.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`possible-type-extension > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | extend type OtherUser { diff --git a/packages/plugin/tests/__snapshots__/relay-arguments.spec.md b/packages/plugin/tests/__snapshots__/relay-arguments.spec.md index 76dda16fb32..98f6f625c11 100644 --- a/packages/plugin/tests/__snapshots__/relay-arguments.spec.md +++ b/packages/plugin/tests/__snapshots__/relay-arguments.spec.md @@ -71,7 +71,7 @@ exports[`relay-arguments > invalid > Invalid #2 1`] = ` 3 | } `; -exports[`relay-arguments > invalid > Invalid #3 1`] = ` +exports[`relay-arguments > invalid > should report about 2nd required argument if 1st was provided 1`] = ` #### ⌨️ Code 1 | type User { From a2f681aa4fe87eb6857cb391f8363c961419dc7b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:15:22 +0200 Subject: [PATCH 14/39] more --- .../relay-connection-types.spec.md | 12 +++--- .../__snapshots__/relay-page-info.spec.md | 16 ++++---- .../require-deprecation-reason.spec.md | 2 +- .../__snapshots__/require-description.spec.md | 38 +++++++++---------- ...d-of-type-query-in-mutation-result.spec.md | 8 ++-- .../require-id-when-available.spec.md | 16 ++++---- .../require-import-fragment.spec.md | 6 +-- ...require-nullable-fields-with-oneof.spec.md | 4 +- .../require-nullable-result-in-root.spec.md | 6 +-- .../require-type-pattern-with-oneof.spec.md | 4 +- .../__snapshots__/selection-set-depth.spec.md | 8 ++-- .../__snapshots__/strict-id-in-types.spec.md | 10 ++--- 12 files changed, 65 insertions(+), 65 deletions(-) diff --git a/packages/plugin/tests/__snapshots__/relay-connection-types.spec.md b/packages/plugin/tests/__snapshots__/relay-connection-types.spec.md index e85124b3c1b..5b960cd2f97 100644 --- a/packages/plugin/tests/__snapshots__/relay-connection-types.spec.md +++ b/packages/plugin/tests/__snapshots__/relay-connection-types.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`\`edges\` field should return a list type that wraps an edge type 1`] = ` +exports[`relay-connection-types > invalid > \`edges\` field should return a list type that wraps an edge type 1`] = ` #### ⌨️ Code 1 | type AConnection { @@ -27,7 +27,7 @@ exports[`\`edges\` field should return a list type that wraps an edge type 1`] = 7 | pageInfo: PageInfo! `; -exports[`\`pageInfo\` field must return a non-null \`PageInfo\` object 1`] = ` +exports[`relay-connection-types > invalid > \`pageInfo\` field must return a non-null \`PageInfo\` object 1`] = ` #### ⌨️ Code 1 | type AConnection { @@ -87,7 +87,7 @@ exports[`\`pageInfo\` field must return a non-null \`PageInfo\` object 1`] = ` 20 | } `; -exports[`should report about missing \`Connection\` suffix 1`] = ` +exports[`relay-connection-types > invalid > should report about missing \`Connection\` suffix 1`] = ` #### ⌨️ Code 1 | type User { @@ -102,7 +102,7 @@ exports[`should report about missing \`Connection\` suffix 1`] = ` 2 | edges: UserEdge `; -exports[`should report about missing \`edges\` field 1`] = ` +exports[`relay-connection-types > invalid > should report about missing \`edges\` field 1`] = ` #### ⌨️ Code 1 | type UserConnection { pageInfo: PageInfo! } @@ -113,7 +113,7 @@ exports[`should report about missing \`edges\` field 1`] = ` | ^^^^^^^^^^^^^^ Connection type must contain a field \`edges\` that return a list type. `; -exports[`should report about missing \`pageInfo\` field 1`] = ` +exports[`relay-connection-types > invalid > should report about missing \`pageInfo\` field 1`] = ` #### ⌨️ Code 1 | type UserConnection { edges: [UserEdge] } @@ -124,7 +124,7 @@ exports[`should report about missing \`pageInfo\` field 1`] = ` | ^^^^^^^^^^^^^^ Connection type must contain a field \`pageInfo\` that return a non-null \`PageInfo\` Object type. `; -exports[`should report about non connection types with \`Connection\` suffix 1`] = ` +exports[`relay-connection-types > invalid > should report about non connection types with \`Connection\` suffix 1`] = ` #### ⌨️ Code 1 | scalar DateTimeConnection diff --git a/packages/plugin/tests/__snapshots__/relay-page-info.spec.md b/packages/plugin/tests/__snapshots__/relay-page-info.spec.md index 99649777bd5..bb3d80c2320 100644 --- a/packages/plugin/tests/__snapshots__/relay-page-info.spec.md +++ b/packages/plugin/tests/__snapshots__/relay-page-info.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`relay-page-info > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | scalar PageInfo @@ -11,7 +11,7 @@ exports[`Invalid #1 1`] = ` | ^^^^^^^^ \`PageInfo\` must be an Object type. `; -exports[`when \`PageInfo\` is missing 1`] = ` +exports[`relay-page-info > invalid > when \`PageInfo\` is missing 1`] = ` #### ⌨️ Code 1 | type Query @@ -22,7 +22,7 @@ exports[`when \`PageInfo\` is missing 1`] = ` | ^ The server must provide a \`PageInfo\` object. `; -exports[`when enum 1`] = ` +exports[`relay-page-info > invalid > when enum 1`] = ` #### ⌨️ Code 1 | enum PageInfo @@ -47,7 +47,7 @@ exports[`when enum 1`] = ` 3 | hasPreviousPage `; -exports[`when extend type 1`] = ` +exports[`relay-page-info > invalid > when extend type 1`] = ` #### ⌨️ Code 1 | type PageInfo @@ -83,7 +83,7 @@ exports[`when extend type 1`] = ` 2 | extend type PageInfo { `; -exports[`when fields is missing or incorrect return type 1`] = ` +exports[`relay-page-info > invalid > when fields is missing or incorrect return type 1`] = ` #### ⌨️ Code 1 | type PageInfo { @@ -118,7 +118,7 @@ exports[`when fields is missing or incorrect return type 1`] = ` 4 | } `; -exports[`when input 1`] = ` +exports[`relay-page-info > invalid > when input 1`] = ` #### ⌨️ Code 1 | input PageInfo @@ -143,7 +143,7 @@ exports[`when input 1`] = ` 3 | hasPreviousPage: Boolean! `; -exports[`when interface 1`] = ` +exports[`relay-page-info > invalid > when interface 1`] = ` #### ⌨️ Code 1 | interface PageInfo @@ -168,7 +168,7 @@ exports[`when interface 1`] = ` 3 | hasPreviousPage: Boolean! `; -exports[`when union 1`] = ` +exports[`relay-page-info > invalid > when union 1`] = ` #### ⌨️ Code 1 | union PageInfo = UserConnection | Post diff --git a/packages/plugin/tests/__snapshots__/require-deprecation-reason.spec.md b/packages/plugin/tests/__snapshots__/require-deprecation-reason.spec.md index 6eaf90e70ff..92de704ea9b 100644 --- a/packages/plugin/tests/__snapshots__/require-deprecation-reason.spec.md +++ b/packages/plugin/tests/__snapshots__/require-deprecation-reason.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`require-deprecation-reason > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type A { diff --git a/packages/plugin/tests/__snapshots__/require-description.spec.md b/packages/plugin/tests/__snapshots__/require-description.spec.md index c55d6c1df5f..817e48a1637 100644 --- a/packages/plugin/tests/__snapshots__/require-description.spec.md +++ b/packages/plugin/tests/__snapshots__/require-description.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`require-description > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type User { id: ID } @@ -17,7 +17,7 @@ exports[`Invalid #1 1`] = ` | ^^^^ Description is required for type "User" `; -exports[`Invalid #2 1`] = ` +exports[`require-description > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | interface Node { id: ID! } @@ -34,7 +34,7 @@ exports[`Invalid #2 1`] = ` | ^^^^ Description is required for interface "Node" `; -exports[`Invalid #3 1`] = ` +exports[`require-description > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | enum Role { ADMIN } @@ -51,7 +51,7 @@ exports[`Invalid #3 1`] = ` | ^^^^ Description is required for enum "Role" `; -exports[`Invalid #4 1`] = ` +exports[`require-description > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | scalar Email @@ -68,7 +68,7 @@ exports[`Invalid #4 1`] = ` | ^^^^^ Description is required for scalar "Email" `; -exports[`Invalid #5 1`] = ` +exports[`require-description > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | input CreateUserInput { email: Email! } @@ -85,7 +85,7 @@ exports[`Invalid #5 1`] = ` | ^^^^^^^^^^^^^^^ Description is required for input "CreateUserInput" `; -exports[`Invalid #6 1`] = ` +exports[`require-description > invalid > Invalid #6 1`] = ` #### ⌨️ Code 1 | union Media = Book | Movie @@ -102,7 +102,7 @@ exports[`Invalid #6 1`] = ` | ^^^^^ Description is required for union "Media" `; -exports[`Invalid #7 1`] = ` +exports[`require-description > invalid > Invalid #7 1`] = ` #### ⌨️ Code 1 | directive @auth(requires: Role!) on FIELD_DEFINITION @@ -119,7 +119,7 @@ exports[`Invalid #7 1`] = ` | ^^^^ Description is required for directive "auth" `; -exports[`Invalid #8 1`] = ` +exports[`require-description > invalid > Invalid #8 1`] = ` #### ⌨️ Code 1 | type User { email: Email! } @@ -136,7 +136,7 @@ exports[`Invalid #8 1`] = ` | ^^^^^ Description is required for field "email" in type "User" `; -exports[`Invalid #9 1`] = ` +exports[`require-description > invalid > Invalid #9 1`] = ` #### ⌨️ Code 1 | input CreateUserInput { email: Email! } @@ -153,7 +153,7 @@ exports[`Invalid #9 1`] = ` | ^^^^^ Description is required for input value "email" in input "CreateUserInput" `; -exports[`Invalid #10 1`] = ` +exports[`require-description > invalid > Invalid #10 1`] = ` #### ⌨️ Code 1 | enum Role { ADMIN } @@ -170,7 +170,7 @@ exports[`Invalid #10 1`] = ` | ^^^^^ Description is required for enum value "ADMIN" in enum "Role" `; -exports[`Invalid #17 1`] = ` +exports[`require-description > invalid > Invalid #17 1`] = ` #### ⌨️ Code 1 | type Query { user(id: String!): User! } @@ -187,7 +187,7 @@ exports[`Invalid #17 1`] = ` | ^^^^ Description is required for field "user" in type "Query" `; -exports[`Invalid #18 1`] = ` +exports[`require-description > invalid > Invalid #18 1`] = ` #### ⌨️ Code 1 | type Mutation { createUser(id: [ID!]!): User! } @@ -204,7 +204,7 @@ exports[`Invalid #18 1`] = ` | ^^^^^^^^^^ Description is required for field "createUser" in type "Mutation" `; -exports[`Invalid #19 1`] = ` +exports[`require-description > invalid > Invalid #19 1`] = ` #### ⌨️ Code 1 | type MySubscription { @@ -228,7 +228,7 @@ exports[`Invalid #19 1`] = ` 3 | } `; -exports[`should disable description for ObjectTypeDefinition 1`] = ` +exports[`require-description > invalid > should disable description for ObjectTypeDefinition 1`] = ` #### ⌨️ Code 1 | type CreateOneUserPayload { @@ -259,7 +259,7 @@ exports[`should disable description for ObjectTypeDefinition 1`] = ` 4 | } `; -exports[`should ignore comments before fragment definition 1`] = ` +exports[`require-description > invalid > should ignore comments before fragment definition 1`] = ` #### ⌨️ Code 1 | # BAD @@ -287,7 +287,7 @@ exports[`should ignore comments before fragment definition 1`] = ` 7 | user { `; -exports[`should report because of linesBefore !== 1 1`] = ` +exports[`require-description > invalid > should report because of linesBefore !== 1 1`] = ` #### ⌨️ Code 1 | # linesBefore !== 1 @@ -310,7 +310,7 @@ exports[`should report because of linesBefore !== 1 1`] = ` 4 | foo `; -exports[`should report because skips comment that starts with \`eslint\` 1`] = ` +exports[`require-description > invalid > should report because skips comment that starts with \`eslint\` 1`] = ` #### ⌨️ Code 1 | # eslint-disable-next-line semi @@ -332,7 +332,7 @@ exports[`should report because skips comment that starts with \`eslint\` 1`] = ` 3 | foo `; -exports[`should validate mutation 1`] = ` +exports[`require-description > invalid > should validate mutation 1`] = ` #### ⌨️ Code 1 | mutation createUser { foo } @@ -349,7 +349,7 @@ exports[`should validate mutation 1`] = ` | ^^^^^^^^ Description is required for mutation "createUser" `; -exports[`should validate subscription 1`] = ` +exports[`require-description > invalid > should validate subscription 1`] = ` #### ⌨️ Code 1 | subscription commentAdded { foo } diff --git a/packages/plugin/tests/__snapshots__/require-field-of-type-query-in-mutation-result.spec.md b/packages/plugin/tests/__snapshots__/require-field-of-type-query-in-mutation-result.spec.md index 421cb6b7366..3ae90340fde 100644 --- a/packages/plugin/tests/__snapshots__/require-field-of-type-query-in-mutation-result.spec.md +++ b/packages/plugin/tests/__snapshots__/require-field-of-type-query-in-mutation-result.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #2 1`] = ` +exports[`require-field-of-type-query-in-mutation-result > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type Query @@ -18,7 +18,7 @@ exports[`Invalid #2 1`] = ` 6 | } `; -exports[`Invalid #3 1`] = ` +exports[`require-field-of-type-query-in-mutation-result > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type RootQuery @@ -39,7 +39,7 @@ exports[`Invalid #3 1`] = ` 4 | } `; -exports[`Invalid #4 1`] = ` +exports[`require-field-of-type-query-in-mutation-result > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | type RootQuery @@ -61,7 +61,7 @@ exports[`Invalid #4 1`] = ` 5 | } `; -exports[`should ignore arguments 1`] = ` +exports[`require-field-of-type-query-in-mutation-result > invalid > should ignore arguments 1`] = ` #### ⌨️ Code 1 | type Query diff --git a/packages/plugin/tests/__snapshots__/require-id-when-available.spec.md b/packages/plugin/tests/__snapshots__/require-id-when-available.spec.md index f7cd4687624..433e8631232 100644 --- a/packages/plugin/tests/__snapshots__/require-id-when-available.spec.md +++ b/packages/plugin/tests/__snapshots__/require-id-when-available.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`require-id-when-available > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | { hasId { name } } @@ -16,7 +16,7 @@ exports[`Invalid #1 1`] = ` 1 | { hasId { id name } } `; -exports[`Invalid #2 1`] = ` +exports[`require-id-when-available > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | { hasId { id } } @@ -38,7 +38,7 @@ exports[`Invalid #2 1`] = ` 1 | { hasId { name id } } `; -exports[`should not work with n nested fragments if you never get the id 1`] = ` +exports[`require-id-when-available > invalid > should not work with n nested fragments if you never get the id 1`] = ` #### ⌨️ Code 1 | query User { @@ -64,7 +64,7 @@ exports[`should not work with n nested fragments if you never get the id 1`] = ` 5 | } `; -exports[`should report an error about missing \`posts.id\` field in fragment 1`] = ` +exports[`require-id-when-available > invalid > should report an error about missing \`posts.id\` field in fragment 1`] = ` #### ⌨️ Code 1 | { user { id ...UserFields } } @@ -76,7 +76,7 @@ exports[`should report an error about missing \`posts.id\` field in fragment 1`] Include it in your selection set or add to used fragment \`UserFields\`. `; -exports[`should report an error about missing \`user.id\`, \`posts.id\`, \`author.id\` and \`authorPosts.id\` selection 1`] = ` +exports[`require-id-when-available > invalid > should report an error about missing \`user.id\`, \`posts.id\`, \`author.id\` and \`authorPosts.id\` selection 1`] = ` #### ⌨️ Code 1 | { user { ...UserFullFields } } @@ -110,7 +110,7 @@ exports[`should report an error about missing \`user.id\`, \`posts.id\`, \`autho Include it in your selection set or add to used fragments \`UserFullFields\` or \`UserFields\`. `; -exports[`should report an error with union 1`] = ` +exports[`require-id-when-available > invalid > should report an error with union 1`] = ` #### ⌨️ Code 1 | { @@ -140,7 +140,7 @@ exports[`should report an error with union 1`] = ` 7 | } `; -exports[`should report an error with union and fragment spread 1`] = ` +exports[`require-id-when-available > invalid > should report an error with union and fragment spread 1`] = ` #### ⌨️ Code 1 | { @@ -170,7 +170,7 @@ exports[`should report an error with union and fragment spread 1`] = ` 7 | } `; -exports[`support multiple id field names 1`] = ` +exports[`require-id-when-available > invalid > support multiple id field names 1`] = ` #### ⌨️ Code 1 | { hasId { name } } diff --git a/packages/plugin/tests/__snapshots__/require-import-fragment.spec.md b/packages/plugin/tests/__snapshots__/require-import-fragment.spec.md index 803e15db845..27391745144 100644 --- a/packages/plugin/tests/__snapshots__/require-import-fragment.spec.md +++ b/packages/plugin/tests/__snapshots__/require-import-fragment.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should report fragments when there are no import expressions 1`] = ` +exports[`require-import-fragment > invalid > should report fragments when there are no import expressions 1`] = ` #### ⌨️ Code 1 | { @@ -26,7 +26,7 @@ exports[`should report fragments when there are no import expressions 1`] = ` 6 | } `; -exports[`should report with default import 1`] = ` +exports[`require-import-fragment > invalid > should report with default import 1`] = ` #### ⌨️ Code 1 | #import 'bar-fragment.gql' @@ -54,7 +54,7 @@ exports[`should report with default import 1`] = ` 7 | } `; -exports[`should report with named import 1`] = ` +exports[`require-import-fragment > invalid > should report with named import 1`] = ` #### ⌨️ Code 1 | #import FooFields from "bar-fragment.gql" diff --git a/packages/plugin/tests/__snapshots__/require-nullable-fields-with-oneof.spec.md b/packages/plugin/tests/__snapshots__/require-nullable-fields-with-oneof.spec.md index ba7950d4d42..87f80b2e2d7 100644 --- a/packages/plugin/tests/__snapshots__/require-nullable-fields-with-oneof.spec.md +++ b/packages/plugin/tests/__snapshots__/require-nullable-fields-with-oneof.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should validate \`input\` 1`] = ` +exports[`require-nullable-fields-with-oneof > invalid > should validate \`input\` 1`] = ` #### ⌨️ Code 1 | input Input @oneOf { @@ -23,7 +23,7 @@ exports[`should validate \`input\` 1`] = ` 4 | } `; -exports[`should validate \`type\` 1`] = ` +exports[`require-nullable-fields-with-oneof > invalid > should validate \`type\` 1`] = ` #### ⌨️ Code 1 | type Type @oneOf { diff --git a/packages/plugin/tests/__snapshots__/require-nullable-result-in-root.spec.md b/packages/plugin/tests/__snapshots__/require-nullable-result-in-root.spec.md index bfefa575292..f0d0452db9f 100644 --- a/packages/plugin/tests/__snapshots__/require-nullable-result-in-root.spec.md +++ b/packages/plugin/tests/__snapshots__/require-nullable-result-in-root.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`require-nullable-result-in-root > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Query { @@ -27,7 +27,7 @@ exports[`Invalid #1 1`] = ` 6 | } `; -exports[`should work with default scalars 1`] = ` +exports[`require-nullable-result-in-root > invalid > should work with default scalars 1`] = ` #### ⌨️ Code 1 | type MySubscription @@ -56,7 +56,7 @@ exports[`should work with default scalars 1`] = ` 7 | } `; -exports[`should work with extend query 1`] = ` +exports[`require-nullable-result-in-root > invalid > should work with extend query 1`] = ` #### ⌨️ Code 1 | type MyMutation diff --git a/packages/plugin/tests/__snapshots__/require-type-pattern-with-oneof.spec.md b/packages/plugin/tests/__snapshots__/require-type-pattern-with-oneof.spec.md index f7bee157a34..ccdc7cd7fba 100644 --- a/packages/plugin/tests/__snapshots__/require-type-pattern-with-oneof.spec.md +++ b/packages/plugin/tests/__snapshots__/require-type-pattern-with-oneof.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`should validate \`error\` field 1`] = ` +exports[`require-type-pattern-with-oneof > invalid > should validate \`error\` field 1`] = ` #### ⌨️ Code 1 | type T @oneOf { @@ -15,7 +15,7 @@ exports[`should validate \`error\` field 1`] = ` 2 | ok: Ok `; -exports[`should validate \`ok\` field 1`] = ` +exports[`require-type-pattern-with-oneof > invalid > should validate \`ok\` field 1`] = ` #### ⌨️ Code 1 | type T @oneOf { diff --git a/packages/plugin/tests/__snapshots__/selection-set-depth.spec.md b/packages/plugin/tests/__snapshots__/selection-set-depth.spec.md index 33c9363275c..b2df89f2364 100644 --- a/packages/plugin/tests/__snapshots__/selection-set-depth.spec.md +++ b/packages/plugin/tests/__snapshots__/selection-set-depth.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`selection-set-depth > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | query deep2 { @@ -33,7 +33,7 @@ exports[`Invalid #1 1`] = ` 5 | } `; -exports[`Invalid #2 1`] = ` +exports[`selection-set-depth > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | query deep2 { @@ -66,7 +66,7 @@ exports[`Invalid #2 1`] = ` 5 | } `; -exports[`suggestions should not throw error when fragment is located in different file 1`] = ` +exports[`selection-set-depth > invalid > suggestions should not throw error when fragment is located in different file 1`] = ` #### ⌨️ Code 1 | { @@ -91,7 +91,7 @@ exports[`suggestions should not throw error when fragment is located in differen 6 | } `; -exports[`suggestions should work with inline fragments 1`] = ` +exports[`selection-set-depth > invalid > suggestions should work with inline fragments 1`] = ` #### ⌨️ Code 1 | { diff --git a/packages/plugin/tests/__snapshots__/strict-id-in-types.spec.md b/packages/plugin/tests/__snapshots__/strict-id-in-types.spec.md index 2be2ddc54fc..83f8e28d1da 100644 --- a/packages/plugin/tests/__snapshots__/strict-id-in-types.spec.md +++ b/packages/plugin/tests/__snapshots__/strict-id-in-types.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`strict-id-in-types > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type B { name: String! } @@ -13,7 +13,7 @@ exports[`Invalid #1 1`] = ` Accepted type: ID. `; -exports[`Invalid #2 1`] = ` +exports[`strict-id-in-types > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type B { id: ID! _id: String! } @@ -39,7 +39,7 @@ exports[`Invalid #2 1`] = ` Accepted types: ID or String. `; -exports[`Invalid #3 1`] = ` +exports[`strict-id-in-types > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type B { id: String! } type B1 { id: [String] } type B2 { id: [String!] } type B3 { id: [String]! } type B4 { id: [String!]! } @@ -84,7 +84,7 @@ exports[`Invalid #3 1`] = ` Accepted type: String. `; -exports[`Invalid #4 1`] = ` +exports[`strict-id-in-types > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | type B { id: ID! } type Bresult { key: String! } type BPayload { bool: Boolean! } type BPagination { num: Int! } @@ -121,7 +121,7 @@ exports[`Invalid #4 1`] = ` Accepted type: ID. `; -exports[`Invalid #5 1`] = ` +exports[`strict-id-in-types > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type B { id: ID! } type BError { message: String! } From 8dc47af76fef4714e714ea6a8ce8342599eed2a0 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:25:46 +0200 Subject: [PATCH 15/39] 1 --- packages/plugin/src/testkit.ts | 8 +- .../tests/__snapshots__/alphabetize.spec.md | 92 +++++++++++-------- .../tests/__snapshots__/input-name.spec.md | 80 +++++++++++----- .../__snapshots__/naming-convention.spec.md | 81 ++++++++++------ .../__snapshots__/relay-edge-types.spec.md | 30 +++--- packages/rule-tester/package.json | 6 ++ 6 files changed, 196 insertions(+), 101 deletions(-) create mode 100644 packages/rule-tester/package.json diff --git a/packages/plugin/src/testkit.ts b/packages/plugin/src/testkit.ts index 22f339b55b4..6baa170f962 100644 --- a/packages/plugin/src/testkit.ts +++ b/packages/plugin/src/testkit.ts @@ -51,6 +51,7 @@ export class RuleTester extends ESLintRuleTester { return readFileSync(resolve(__dirname, `../tests/mocks/${path}`), 'utf-8'); } + // @ts-expect-error run( ruleId: string, rule: GraphQLESLintRule, @@ -63,8 +64,10 @@ export class RuleTester extends ESLintRuleTester { const { options, code: rawCode, filename, parserOptions } = testCase; const testerConfig = { - ...this.testerConfig, + // @ts-expect-error + parser: this.testerConfig.parser, parserOptions: { + // @ts-expect-error ...this.testerConfig.parserOptions, ...parserOptions, }, @@ -74,6 +77,7 @@ export class RuleTester extends ESLintRuleTester { }; const code = removeTrailingBlankLines(rawCode); + // @ts-expect-error const messages = this.linter.verify(code, testerConfig, filename); const codeFrame = indentCode(printCode(code, { line: 0, column: 0 })); @@ -107,6 +111,7 @@ export class RuleTester extends ESLintRuleTester { } } if (rule.meta.fixable) { + // @ts-expect-error const { fixed, output } = this.linter.verifyAndFix(code, testerConfig, filename); if (fixed) { messageForSnapshot.push('#### 🔧 Autofix output', indentCode(printCode(output))); @@ -117,6 +122,7 @@ export class RuleTester extends ESLintRuleTester { for (const [id, testCase] of tests.invalid.entries()) { testCase.name ||= `Invalid #${id + 1}`; + // @ts-expect-error testCase.getMessages = getMessages(testCase); } diff --git a/packages/plugin/tests/__snapshots__/alphabetize.spec.md b/packages/plugin/tests/__snapshots__/alphabetize.spec.md index 3c5e5813eab..a8fb875f688 100644 --- a/packages/plugin/tests/__snapshots__/alphabetize.spec.md +++ b/packages/plugin/tests/__snapshots__/alphabetize.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`alphabetize > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type User { @@ -15,7 +15,8 @@ exports[`Invalid #1 1`] = ` { "fields": [ "ObjectTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -42,7 +43,7 @@ exports[`Invalid #1 1`] = ` 6 | } `; -exports[`Invalid #2 1`] = ` +exports[`alphabetize > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | extend type User { @@ -57,7 +58,8 @@ exports[`Invalid #2 1`] = ` { "fields": [ "ObjectTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error @@ -77,7 +79,7 @@ exports[`Invalid #2 1`] = ` 6 | } `; -exports[`Invalid #3 1`] = ` +exports[`alphabetize > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | interface Test { @@ -91,7 +93,8 @@ exports[`Invalid #3 1`] = ` { "fields": [ "InterfaceTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -117,7 +120,7 @@ exports[`Invalid #3 1`] = ` 5 | } `; -exports[`Invalid #4 1`] = ` +exports[`alphabetize > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | input UserInput { @@ -132,7 +135,8 @@ exports[`Invalid #4 1`] = ` { "fields": [ "InputObjectTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -159,7 +163,7 @@ exports[`Invalid #4 1`] = ` 6 | } `; -exports[`Invalid #5 1`] = ` +exports[`alphabetize > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | extend input UserInput { @@ -174,7 +178,8 @@ exports[`Invalid #5 1`] = ` { "fields": [ "InputObjectTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error @@ -194,7 +199,7 @@ exports[`Invalid #5 1`] = ` 6 | } `; -exports[`Invalid #6 1`] = ` +exports[`alphabetize > invalid > Invalid #6 1`] = ` #### ⌨️ Code 1 | enum Role { @@ -209,7 +214,8 @@ exports[`Invalid #6 1`] = ` { "values": [ "EnumTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -236,7 +242,7 @@ exports[`Invalid #6 1`] = ` 6 | } `; -exports[`Invalid #7 1`] = ` +exports[`alphabetize > invalid > Invalid #7 1`] = ` #### ⌨️ Code 1 | extend enum Role { @@ -251,7 +257,8 @@ exports[`Invalid #7 1`] = ` { "values": [ "EnumTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error @@ -271,7 +278,7 @@ exports[`Invalid #7 1`] = ` 6 | } `; -exports[`Invalid #8 1`] = ` +exports[`alphabetize > invalid > Invalid #8 1`] = ` #### ⌨️ Code 1 | directive @test(cc: [Cc!]!, bb: [Bb!], aa: Aa!) on FIELD_DEFINITION @@ -281,7 +288,8 @@ exports[`Invalid #8 1`] = ` { "arguments": [ "DirectiveDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -299,7 +307,7 @@ exports[`Invalid #8 1`] = ` 1 | directive @test(aa: Aa!, bb: [Bb!], cc: [Cc!]!) on FIELD_DEFINITION `; -exports[`Invalid #9 1`] = ` +exports[`alphabetize > invalid > Invalid #9 1`] = ` #### ⌨️ Code 1 | type Query { @@ -311,7 +319,8 @@ exports[`Invalid #9 1`] = ` { "arguments": [ "FieldDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -335,7 +344,7 @@ exports[`Invalid #9 1`] = ` 3 | } `; -exports[`Invalid #10 1`] = ` +exports[`alphabetize > invalid > Invalid #10 1`] = ` #### ⌨️ Code 1 | fragment TestFields on Test { @@ -349,7 +358,8 @@ exports[`Invalid #10 1`] = ` { "selections": [ "FragmentDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 @@ -375,7 +385,7 @@ exports[`Invalid #10 1`] = ` 5 | } `; -exports[`Invalid #11 1`] = ` +exports[`alphabetize > invalid > Invalid #11 1`] = ` #### ⌨️ Code 1 | query { @@ -396,7 +406,8 @@ exports[`Invalid #11 1`] = ` { "selections": [ "OperationDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/4 @@ -443,7 +454,7 @@ exports[`Invalid #11 1`] = ` 12 | } `; -exports[`Invalid #12 1`] = ` +exports[`alphabetize > invalid > Invalid #12 1`] = ` #### ⌨️ Code 1 | mutation ($cc: [Cc!]!, $bb: [Bb!], $aa: Aa!) { @@ -460,7 +471,8 @@ exports[`Invalid #12 1`] = ` ], "arguments": [ "Field" - ] + ], + "definitions": false } #### ❌ Error 1/4 @@ -498,7 +510,7 @@ exports[`Invalid #12 1`] = ` 5 | } `; -exports[`should compare with lexicographic order 1`] = ` +exports[`alphabetize > invalid > should compare with lexicographic order 1`] = ` #### ⌨️ Code 1 | enum Test { @@ -518,7 +530,8 @@ exports[`should compare with lexicographic order 1`] = ` { "values": [ "EnumTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/3 @@ -557,7 +570,7 @@ exports[`should compare with lexicographic order 1`] = ` 11 | } `; -exports[`should move comment 1`] = ` +exports[`alphabetize > invalid > should move comment 1`] = ` #### ⌨️ Code 1 | type Test { # { character @@ -580,7 +593,8 @@ exports[`should move comment 1`] = ` { "fields": [ "ObjectTypeDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/3 @@ -622,7 +636,7 @@ exports[`should move comment 1`] = ` 14 | } # } character `; -exports[`should sort by group when \`*\` at the start 1`] = ` +exports[`alphabetize > invalid > should sort by group when \`*\` at the start 1`] = ` #### ⌨️ Code 1 | type User { @@ -649,7 +663,8 @@ exports[`should sort by group when \`*\` at the start 1`] = ` "updatedAt", "id", "createdAt" - ] + ], + "definitions": false } #### ❌ Error 1/4 @@ -696,7 +711,7 @@ exports[`should sort by group when \`*\` at the start 1`] = ` 12 | } `; -exports[`should sort by group when \`*\` is at the end 1`] = ` +exports[`alphabetize > invalid > should sort by group when \`*\` is at the end 1`] = ` #### ⌨️ Code 1 | type User { @@ -723,7 +738,8 @@ exports[`should sort by group when \`*\` is at the end 1`] = ` "id", "createdAt", "*" - ] + ], + "definitions": false } #### ❌ Error 1/4 @@ -770,7 +786,7 @@ exports[`should sort by group when \`*\` is at the end 1`] = ` 12 | } `; -exports[`should sort by group when \`*\` is between 1`] = ` +exports[`alphabetize > invalid > should sort by group when \`*\` is between 1`] = ` #### ⌨️ Code 1 | type User { @@ -797,7 +813,8 @@ exports[`should sort by group when \`*\` is between 1`] = ` "*", "createdAt", "updatedAt" - ] + ], + "definitions": false } #### ❌ Error 1/4 @@ -844,7 +861,7 @@ exports[`should sort by group when \`*\` is between 1`] = ` 12 | } `; -exports[`should sort definitions 1`] = ` +exports[`alphabetize > invalid > should sort definitions 1`] = ` #### ⌨️ Code 1 | # START @@ -1039,7 +1056,7 @@ exports[`should sort definitions 1`] = ` 59 | # END `; -exports[`should sort when selection is aliased 1`] = ` +exports[`alphabetize > invalid > should sort when selection is aliased 1`] = ` #### ⌨️ Code 1 | { @@ -1055,7 +1072,8 @@ exports[`should sort when selection is aliased 1`] = ` { "selections": [ "OperationDefinition" - ] + ], + "definitions": false } #### ❌ Error 1/2 diff --git a/packages/plugin/tests/__snapshots__/input-name.spec.md b/packages/plugin/tests/__snapshots__/input-name.spec.md index 35290a274a7..308a741fb41 100644 --- a/packages/plugin/tests/__snapshots__/input-name.spec.md +++ b/packages/plugin/tests/__snapshots__/input-name.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`input-name > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type Mutation { SetMessage(message: String): String } @@ -8,7 +8,10 @@ exports[`Invalid #1 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -30,7 +33,7 @@ exports[`Invalid #1 1`] = ` 1 | type Mutation { SetMessage(message: SetMessageInput): String } `; -exports[`Invalid #2 1`] = ` +exports[`input-name > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type Mutation { SetMessage(input: String): String } @@ -38,7 +41,10 @@ exports[`Invalid #2 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error @@ -51,7 +57,7 @@ exports[`Invalid #2 1`] = ` 1 | type Mutation { SetMessage(input: SetMessageInput): String } `; -exports[`Invalid #3 1`] = ` +exports[`input-name > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | type Mutation { SetMessage(hello: SetMessageInput): String } @@ -59,7 +65,10 @@ exports[`Invalid #3 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error @@ -72,7 +81,7 @@ exports[`Invalid #3 1`] = ` 1 | type Mutation { SetMessage(input: SetMessageInput): String } `; -exports[`Invalid #4 1`] = ` +exports[`input-name > invalid > Invalid #4 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: CreateOneUserInput!): CreateOneUserPayload } @@ -80,7 +89,10 @@ exports[`Invalid #4 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -102,7 +114,7 @@ exports[`Invalid #4 1`] = ` 1 | type Mutation { userCreate(record: userCreateInput!): CreateOneUserPayload } `; -exports[`Invalid #5 1`] = ` +exports[`input-name > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: [CreateOneUserInput]!): CreateOneUserPayload } @@ -110,7 +122,10 @@ exports[`Invalid #5 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -132,7 +147,7 @@ exports[`Invalid #5 1`] = ` 1 | type Mutation { userCreate(record: [userCreateInput]!): CreateOneUserPayload } `; -exports[`Invalid #6 1`] = ` +exports[`input-name > invalid > Invalid #6 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: [CreateOneUserInput!]!): CreateOneUserPayload } @@ -140,7 +155,10 @@ exports[`Invalid #6 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -162,7 +180,7 @@ exports[`Invalid #6 1`] = ` 1 | type Mutation { userCreate(record: [userCreateInput!]!): CreateOneUserPayload } `; -exports[`Invalid #7 1`] = ` +exports[`input-name > invalid > Invalid #7 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: [CreateOneUserInput!]): CreateOneUserPayload } @@ -170,7 +188,10 @@ exports[`Invalid #7 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -192,7 +213,7 @@ exports[`Invalid #7 1`] = ` 1 | type Mutation { userCreate(record: [userCreateInput!]): CreateOneUserPayload } `; -exports[`Invalid #8 1`] = ` +exports[`input-name > invalid > Invalid #8 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: String, test: String): String } @@ -200,7 +221,10 @@ exports[`Invalid #8 1`] = ` #### ⚙️ Options { - "checkInputType": true + "checkInputType": true, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/4 @@ -240,7 +264,7 @@ exports[`Invalid #8 1`] = ` 1 | type Mutation { userCreate(record: String, test: userCreateInput): String } `; -exports[`Invalid #9 1`] = ` +exports[`input-name > invalid > Invalid #9 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(record: String, test: String): String } @@ -248,7 +272,10 @@ exports[`Invalid #9 1`] = ` #### ⚙️ Options { - "checkInputType": false + "checkInputType": false, + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error 1/2 @@ -270,7 +297,7 @@ exports[`Invalid #9 1`] = ` 1 | type Mutation { userCreate(record: String, input: String): String } `; -exports[`Invalid #10 1`] = ` +exports[`input-name > invalid > Invalid #10 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(input: String): String } @@ -279,7 +306,9 @@ exports[`Invalid #10 1`] = ` { "checkInputType": true, - "caseSensitiveInputType": false + "caseSensitiveInputType": false, + "checkQueries": false, + "checkMutations": true } #### ❌ Error @@ -292,7 +321,7 @@ exports[`Invalid #10 1`] = ` 1 | type Mutation { userCreate(input: userCreateInput): String } `; -exports[`Invalid #11 1`] = ` +exports[`input-name > invalid > Invalid #11 1`] = ` #### ⌨️ Code 1 | type Mutation { userCreate(input: UserCreateInput): String } @@ -301,7 +330,9 @@ exports[`Invalid #11 1`] = ` { "checkInputType": true, - "caseSensitiveInputType": true + "caseSensitiveInputType": true, + "checkQueries": false, + "checkMutations": true } #### ❌ Error @@ -314,7 +345,7 @@ exports[`Invalid #11 1`] = ` 1 | type Mutation { userCreate(input: userCreateInput): String } `; -exports[`Invalid #12 1`] = ` +exports[`input-name > invalid > Invalid #12 1`] = ` #### ⌨️ Code 1 | type Query { getUser(input: GetUserInput): String } @@ -324,7 +355,8 @@ exports[`Invalid #12 1`] = ` { "checkQueries": true, "checkInputType": true, - "caseSensitiveInputType": true + "caseSensitiveInputType": true, + "checkMutations": true } #### ❌ Error diff --git a/packages/plugin/tests/__snapshots__/naming-convention.spec.md b/packages/plugin/tests/__snapshots__/naming-convention.spec.md index 43a27f75d6f..f18828aaba5 100644 --- a/packages/plugin/tests/__snapshots__/naming-convention.spec.md +++ b/packages/plugin/tests/__snapshots__/naming-convention.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Invalid #1 1`] = ` +exports[`naming-convention > invalid > Invalid #1 1`] = ` #### ⌨️ Code 1 | type b { test: String } @@ -9,7 +9,9 @@ exports[`Invalid #1 1`] = ` { "types": "PascalCase", - "FieldDefinition": "PascalCase" + "FieldDefinition": "PascalCase", + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/2 @@ -31,7 +33,7 @@ exports[`Invalid #1 1`] = ` 1 | type b { Test: String } `; -exports[`Invalid #2 1`] = ` +exports[`naming-convention > invalid > Invalid #2 1`] = ` #### ⌨️ Code 1 | type __b { test__: String } @@ -62,7 +64,7 @@ exports[`Invalid #2 1`] = ` 1 | type __b { test: String } `; -exports[`Invalid #3 1`] = ` +exports[`naming-convention > invalid > Invalid #3 1`] = ` #### ⌨️ Code 1 | scalar BSONDecimal @@ -70,7 +72,9 @@ exports[`Invalid #3 1`] = ` #### ⚙️ Options { - "ScalarTypeDefinition": "snake_case" + "ScalarTypeDefinition": "snake_case", + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error @@ -83,7 +87,7 @@ exports[`Invalid #3 1`] = ` 1 | scalar bson_decimal `; -exports[`Invalid #5 1`] = ` +exports[`naming-convention > invalid > Invalid #5 1`] = ` #### ⌨️ Code 1 | enum B { test } @@ -92,7 +96,9 @@ exports[`Invalid #5 1`] = ` { "EnumTypeDefinition": "camelCase", - "EnumValueDefinition": "UPPER_CASE" + "EnumValueDefinition": "UPPER_CASE", + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/2 @@ -114,7 +120,7 @@ exports[`Invalid #5 1`] = ` 1 | enum B { TEST } `; -exports[`Invalid #6 1`] = ` +exports[`naming-convention > invalid > Invalid #6 1`] = ` #### ⌨️ Code 1 | input test { _Value: String } @@ -123,7 +129,9 @@ exports[`Invalid #6 1`] = ` { "types": "PascalCase", - "InputValueDefinition": "snake_case" + "InputValueDefinition": "snake_case", + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/3 @@ -154,7 +162,7 @@ exports[`Invalid #6 1`] = ` 1 | input test { Value: String } `; -exports[`Invalid #7 1`] = ` +exports[`naming-convention > invalid > Invalid #7 1`] = ` #### ⌨️ Code 1 | type TypeOne { aField: String } enum Z { VALUE_ONE VALUE_TWO } @@ -172,7 +180,9 @@ exports[`Invalid #7 1`] = ` "EnumValueDefinition": { "style": "camelCase", "suffix": "ENUM" - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/4 @@ -212,7 +222,7 @@ exports[`Invalid #7 1`] = ` 1 | type TypeOne { aField: String } enum Z { VALUE_ONE VALUE_TWOENUM } `; -exports[`Invalid #8 1`] = ` +exports[`naming-convention > invalid > Invalid #8 1`] = ` #### ⌨️ Code 1 | type One { aField: String } enum Z { A_ENUM_VALUE_ONE VALUE_TWO } @@ -230,7 +240,9 @@ exports[`Invalid #8 1`] = ` "EnumValueDefinition": { "style": "UPPER_CASE", "prefix": "ENUM" - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/3 @@ -261,7 +273,7 @@ exports[`Invalid #8 1`] = ` 1 | type One { aField: String } enum Z { A_ENUM_VALUE_ONE ENUMVALUE_TWO } `; -exports[`Invalid #9 1`] = ` +exports[`naming-convention > invalid > Invalid #9 1`] = ` #### ⌨️ Code 1 | type One { getFoo: String, queryBar: String } type Query { getA(id: ID!): String, queryB: String } extend type Query { getC: String } @@ -291,7 +303,9 @@ exports[`Invalid #9 1`] = ` "get", "query" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/5 @@ -340,7 +354,7 @@ exports[`Invalid #9 1`] = ` 1 | type One { getFoo: String, queryBar: String } type Query { getA(id: ID!): String, queryB: String } extend type Query { C: String } `; -exports[`Invalid #10 1`] = ` +exports[`naming-convention > invalid > Invalid #10 1`] = ` #### ⌨️ Code 1 | query Foo { foo } query getBar { bar } @@ -353,7 +367,9 @@ exports[`Invalid #10 1`] = ` "forbiddenPrefixes": [ "get" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/2 @@ -375,7 +391,7 @@ exports[`Invalid #10 1`] = ` 1 | query Foo { foo } query Bar { bar } `; -exports[`large graphql file 1`] = ` +exports[`naming-convention > invalid > large graphql file 1`] = ` #### ⌨️ Code 1 | input _idOperatorsFilterFindManyUserInput { @@ -1495,7 +1511,8 @@ exports[`large graphql file 1`] = ` "types": "PascalCase", "InputValueDefinition": "camelCase", "EnumValueDefinition": "UPPER_CASE", - "FragmentDefinition": "PascalCase" + "FragmentDefinition": "PascalCase", + "allowTrailingUnderscore": false } #### ❌ Error 1/27 @@ -1687,7 +1704,7 @@ exports[`large graphql file 1`] = ` 390 | } `; -exports[`operations-recommended config 1`] = ` +exports[`naming-convention > invalid > operations-recommended config 1`] = ` #### ⌨️ Code 1 | query TestQuery { test } @@ -1730,7 +1747,9 @@ exports[`operations-recommended config 1`] = ` "forbiddenSuffixes": [ "Fragment" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/9 @@ -1939,7 +1958,7 @@ exports[`operations-recommended config 1`] = ` 13 | fragment Test on Test { id } `; -exports[`schema-recommended config 1`] = ` +exports[`naming-convention > invalid > schema-recommended config 1`] = ` #### ⌨️ Code 1 | type Query { @@ -1991,7 +2010,9 @@ exports[`schema-recommended config 1`] = ` "forbiddenSuffixes": [ "Subscription" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/7 @@ -2170,7 +2191,7 @@ exports[`schema-recommended config 1`] = ` 15 | } `; -exports[`should error when selected type names do not match require prefixes 1`] = ` +exports[`naming-convention > invalid > should error when selected type names do not match require prefixes 1`] = ` #### ⌨️ Code 1 | scalar Secret @@ -2205,7 +2226,9 @@ exports[`should error when selected type names do not match require prefixes 1`] "requiredPrefixes": [ "hiss" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/3 @@ -2286,7 +2309,7 @@ exports[`should error when selected type names do not match require prefixes 1`] 11 | } `; -exports[`should error when selected type names do not match require suffixes 1`] = ` +exports[`naming-convention > invalid > should error when selected type names do not match require suffixes 1`] = ` #### ⌨️ Code 1 | scalar IpAddress @@ -2310,7 +2333,9 @@ exports[`should error when selected type names do not match require suffixes 1`] "requiredSuffixes": [ "IpAddress" ] - } + }, + "allowLeadingUnderscore": false, + "allowTrailingUnderscore": false } #### ❌ Error 1/2 @@ -2355,7 +2380,7 @@ exports[`should error when selected type names do not match require suffixes 1`] 6 | } `; -exports[`should ignore selections fields but check alias renaming 1`] = ` +exports[`naming-convention > invalid > should ignore selections fields but check alias renaming 1`] = ` #### ⌨️ Code 1 | { diff --git a/packages/plugin/tests/__snapshots__/relay-edge-types.spec.md b/packages/plugin/tests/__snapshots__/relay-edge-types.spec.md index ba9a0f29522..3b2b5658f4c 100644 --- a/packages/plugin/tests/__snapshots__/relay-edge-types.spec.md +++ b/packages/plugin/tests/__snapshots__/relay-edge-types.spec.md @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Edge type must be Object type 1`] = ` +exports[`relay-edge-types > invalid > Edge type must be Object type 1`] = ` #### ⌨️ Code 1 | type PageInfo @@ -31,7 +31,8 @@ exports[`Edge type must be Object type 1`] = ` { "shouldImplementNode": false, - "listTypeCanWrapOnlyEdgeType": false + "listTypeCanWrapOnlyEdgeType": false, + "withEdgeSuffix": true } #### ❌ Error 1/4 @@ -63,7 +64,7 @@ exports[`Edge type must be Object type 1`] = ` 22 | pageInfo: PageInfo! `; -exports[`list type 1`] = ` +exports[`relay-edge-types > invalid > list type 1`] = ` #### ⌨️ Code 1 | type AEdge { @@ -83,7 +84,9 @@ exports[`list type 1`] = ` #### ⚙️ Options { - "listTypeCanWrapOnlyEdgeType": true + "listTypeCanWrapOnlyEdgeType": true, + "withEdgeSuffix": true, + "shouldImplementNode": true } #### ❌ Error 1/4 @@ -115,7 +118,7 @@ exports[`list type 1`] = ` 13 | } `; -exports[`should implements Node 1`] = ` +exports[`relay-edge-types > invalid > should implements Node 1`] = ` #### ⌨️ Code 1 | type User { @@ -132,7 +135,9 @@ exports[`should implements Node 1`] = ` #### ⚙️ Options { - "shouldImplementNode": true + "shouldImplementNode": true, + "withEdgeSuffix": true, + "listTypeCanWrapOnlyEdgeType": true } #### ❌ Error @@ -143,7 +148,7 @@ exports[`should implements Node 1`] = ` 5 | node: User! `; -exports[`should report cursor when list is used 1`] = ` +exports[`relay-edge-types > invalid > should report cursor when list is used 1`] = ` #### ⌨️ Code 1 | type PageInfo @@ -160,7 +165,8 @@ exports[`should report cursor when list is used 1`] = ` { "shouldImplementNode": false, - "listTypeCanWrapOnlyEdgeType": false + "listTypeCanWrapOnlyEdgeType": false, + "withEdgeSuffix": true } #### ❌ Error 1/2 @@ -178,7 +184,7 @@ exports[`should report cursor when list is used 1`] = ` 5 | } `; -exports[`should report when fields is missing 1`] = ` +exports[`relay-edge-types > invalid > should report when fields is missing 1`] = ` #### ⌨️ Code 1 | type PageInfo @@ -203,7 +209,7 @@ exports[`should report when fields is missing 1`] = ` 3 | type AConnection { `; -exports[`should report when without Edge suffix 1`] = ` +exports[`relay-edge-types > invalid > should report when without Edge suffix 1`] = ` #### ⌨️ Code 1 | scalar Email @@ -218,7 +224,9 @@ exports[`should report when without Edge suffix 1`] = ` #### ⚙️ Options { - "withEdgeSuffix": true + "withEdgeSuffix": true, + "shouldImplementNode": true, + "listTypeCanWrapOnlyEdgeType": true } #### ❌ Error diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json new file mode 100644 index 00000000000..b99b52318df --- /dev/null +++ b/packages/rule-tester/package.json @@ -0,0 +1,6 @@ +{ + "name": "@theguild/eslint-rule-tester", + "scripts": {}, + "dependencies": {}, + "privat": true +} From e7024ad261d74b149be41fb1fb4c63b111603549 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:29:57 +0200 Subject: [PATCH 16/39] 1 --- packages/plugin/package.json | 2 -- packages/rule-tester/package.json | 14 +++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index e84ce07e29c..e24b8f3cf62 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -41,7 +41,6 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" }, "dependencies": { - "@babel/code-frame": "^7.18.6", "@graphql-tools/code-file-loader": "^7.3.6", "@graphql-tools/graphql-tag-pluck": "^7.3.6", "@graphql-tools/utils": "^9.0.0", @@ -54,7 +53,6 @@ "tslib": "^2.4.1" }, "devDependencies": { - "@types/babel__code-frame": "7.0.3", "@types/debug": "4.1.8", "@types/eslint": "8.37.0", "@types/estree": "1.0.1", diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index b99b52318df..e373853fe55 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -1,6 +1,18 @@ { "name": "@theguild/eslint-rule-tester", + "engines": { + "node": ">=18" + }, "scripts": {}, - "dependencies": {}, + "peerDependencies": { + "eslint": "^8.46.0" + }, + "dependencies": { + "@babel/code-frame": "^7.18.6" + }, + "devDependencies": { + "@types/babel__code-frame": "7.0.3", + "eslint": "^8.46.0" + }, "privat": true } From f556c3341643105c32b6d9642048a2d47915de29 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:33:56 +0200 Subject: [PATCH 17/39] move --- packages/plugin/src/index.ts | 1 - .../testkit.ts => rule-tester/src/index.ts} | 0 pnpm-lock.yaml | 100 ++++++++++-------- 3 files changed, 54 insertions(+), 47 deletions(-) rename packages/{plugin/src/testkit.ts => rule-tester/src/index.ts} (100%) diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 9c0fac88974..48f0fcea3b1 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -2,7 +2,6 @@ import { processor } from './processor.js'; export { parseForESLint } from './parser.js'; export { rules } from './rules/index.js'; -export * from './testkit.js'; export * from './types.js'; export { requireGraphQLSchemaFromContext, requireSiblingsOperations } from './utils.js'; diff --git a/packages/plugin/src/testkit.ts b/packages/rule-tester/src/index.ts similarity index 100% rename from packages/plugin/src/testkit.ts rename to packages/rule-tester/src/index.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 78893ede359..8b951bdc376 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,7 +15,7 @@ patchedDependencies: hash: cdhdgvmsbh3fbusrlxsl6de2he path: patches/eslint-plugin-eslint-plugin@5.0.6.patch eslint@8.46.0: - hash: deiqbyg3gmwgmixqd3hulwyry4 + hash: t2nfsf5qfxmsuzmwslg2btnxeq path: patches/eslint@8.46.0.patch json-schema-to-markdown@1.1.1: hash: beglqnggvhpsclgwbdw27hzvu4 @@ -60,7 +60,7 @@ importers: version: 2.4.0 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-plugin-eslint-plugin: specifier: 5.0.7 version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0) @@ -112,7 +112,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) examples/code-file: dependencies: @@ -128,7 +128,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) examples/graphql-config: dependencies: @@ -144,7 +144,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) examples/graphql-config-code-file: dependencies: @@ -163,7 +163,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) examples/monorepo: dependencies: @@ -179,7 +179,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) examples/multiple-projects-graphql-config: dependencies: @@ -195,7 +195,7 @@ importers: version: 5.0.0(@types/node@18.17.1)(cosmiconfig@8.2.0)(typescript@5.1.6) eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) ts-node: specifier: 10.9.1 version: 10.9.1(@types/node@18.17.1)(typescript@5.1.6) @@ -217,7 +217,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-config-prettier: specifier: 8.8.0 version: 8.8.0(eslint@8.46.0) @@ -239,7 +239,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) svelte: specifier: 4.1.1 version: 4.1.1 @@ -264,16 +264,13 @@ importers: version: 3.3.4 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) vue-eslint-parser: specifier: 9.3.1 version: 9.3.1(eslint@8.46.0) packages/plugin: dependencies: - '@babel/code-frame': - specifier: ^7.18.6 - version: 7.18.6 '@graphql-tools/code-file-loader': specifier: ^7.3.6 version: 7.3.6(graphql@16.7.1) @@ -305,9 +302,6 @@ importers: specifier: ^2.4.1 version: 2.4.1 devDependencies: - '@types/babel__code-frame': - specifier: 7.0.3 - version: 7.0.3 '@types/debug': specifier: 4.1.8 version: 4.1.8 @@ -334,6 +328,19 @@ importers: version: 2.9.1 publishDirectory: dist + packages/rule-tester: + dependencies: + '@babel/code-frame': + specifier: ^7.18.6 + version: 7.18.6 + devDependencies: + '@types/babel__code-frame': + specifier: 7.0.3 + version: 7.0.3 + eslint: + specifier: ^8.46.0 + version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + website: dependencies: '@graphql-eslint/eslint-plugin': @@ -696,6 +703,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/highlight': 7.22.5 + dev: false /@babel/code-frame@7.22.5: resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==} @@ -1515,7 +1523,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-visitor-keys: 3.4.2 dev: true @@ -2912,7 +2920,7 @@ packages: '@rushstack/eslint-patch': 1.3.2 '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-config-prettier: 8.8.0(eslint@8.46.0) eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) @@ -3188,7 +3196,7 @@ packages: '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -3213,7 +3221,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) typescript: 5.1.6 transitivePeerDependencies: - supports-color @@ -3240,7 +3248,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) tsutils: 3.21.0(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: @@ -3285,7 +3293,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -5708,7 +5716,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) dev: true /eslint-import-resolver-node@0.3.7: @@ -5730,7 +5738,7 @@ packages: dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) get-tsconfig: 4.6.2 @@ -5753,7 +5761,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) espree: 9.6.1 estree-util-visit: 1.2.1 remark-mdx: 2.3.0 @@ -5793,7 +5801,7 @@ packages: dependencies: '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 3.2.7 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-import-resolver-node: 0.3.7 eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) transitivePeerDependencies: @@ -5808,7 +5816,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) '@eslint-community/regexpp': 4.6.0 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) dev: true /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0): @@ -5817,7 +5825,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-utils: 3.0.0(eslint@8.46.0) estraverse: 5.3.0 dev: true @@ -5839,7 +5847,7 @@ packages: array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-import-resolver-node: 0.3.7 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) has: 1.0.3 @@ -5863,7 +5871,7 @@ packages: eslint: '>=6.0.0' dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) jsonc-eslint-parser: 2.3.0 natural-compare: 1.4.0 dev: true @@ -5883,7 +5891,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) has: 1.0.3 jsx-ast-utils: 3.3.4 language-tags: 1.0.5 @@ -5899,7 +5907,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color @@ -5911,7 +5919,7 @@ packages: peerDependencies: eslint: '>=8.0.0' dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-mdx: 2.1.0(eslint@8.46.0) eslint-plugin-markdown: 3.0.0(eslint@8.46.0) remark-mdx: 2.3.0 @@ -5932,7 +5940,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) builtins: 5.0.1 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-plugin-es-x: 7.2.0(eslint@8.46.0) ignore: 5.2.4 is-core-module: 2.12.1 @@ -5952,7 +5960,7 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-config-prettier: 8.8.0(eslint@8.46.0) prettier: 2.8.8 prettier-linter-helpers: 1.0.0 @@ -5964,7 +5972,7 @@ packages: peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) dev: true /eslint-plugin-react-hooks@4.6.0(eslint@8.46.0): @@ -5973,7 +5981,7 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) dev: true /eslint-plugin-react@7.33.0(eslint@8.46.0): @@ -5986,7 +5994,7 @@ packages: array.prototype.flatmap: 1.3.1 array.prototype.tosorted: 1.1.1 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) estraverse: 5.3.0 jsx-ast-utils: 3.3.4 minimatch: 3.1.2 @@ -6006,7 +6014,7 @@ packages: peerDependencies: eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) dev: true /eslint-plugin-tailwindcss@3.13.0(tailwindcss@3.3.3): @@ -6030,7 +6038,7 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) ci-info: 3.8.0 clean-regexp: 1.0.0 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 @@ -6052,7 +6060,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -6098,7 +6106,7 @@ packages: peerDependencies: eslint: '>=5' dependencies: - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-visitor-keys: 2.1.0 dev: true @@ -6117,7 +6125,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4): + /eslint@8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq): resolution: {integrity: sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true @@ -9600,7 +9608,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.22.5 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -12620,7 +12628,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=deiqbyg3gmwgmixqd3hulwyry4) + eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) eslint-scope: 7.2.1 eslint-visitor-keys: 3.4.1 espree: 9.6.1 From 1a4441464a3a24f557e9f0534d89f8380da45c44 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:36:54 +0200 Subject: [PATCH 18/39] more --- packages/plugin/src/rules/alphabetize.ts | 3 +-- packages/plugin/src/rules/input-name.ts | 3 +-- packages/plugin/src/rules/naming-convention.ts | 3 +-- packages/plugin/src/rules/relay-edge-types.ts | 3 +-- packages/plugin/src/types.ts | 11 +++++++++-- packages/rule-tester/src/index.ts | 9 --------- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/plugin/src/rules/alphabetize.ts b/packages/plugin/src/rules/alphabetize.ts index f8bfbe03e87..0b66071b221 100644 --- a/packages/plugin/src/rules/alphabetize.ts +++ b/packages/plugin/src/rules/alphabetize.ts @@ -21,8 +21,7 @@ import { import { FromSchema } from 'json-schema-to-ts'; import lowerCase from 'lodash.lowercase'; import { GraphQLESTreeNode } from '../estree-converter/index.js'; -import { GraphQLESLintRuleListener } from '../testkit.js'; -import { GraphQLESLintRule } from '../types.js'; +import { GraphQLESLintRule, GraphQLESLintRuleListener } from '../types.js'; import { ARRAY_DEFAULT_OPTIONS, displayNodeName, truthy } from '../utils.js'; const RULE_ID = 'alphabetize'; diff --git a/packages/plugin/src/rules/input-name.ts b/packages/plugin/src/rules/input-name.ts index 4942215c34c..40e38d2bc5f 100644 --- a/packages/plugin/src/rules/input-name.ts +++ b/packages/plugin/src/rules/input-name.ts @@ -10,8 +10,7 @@ import { } from 'graphql'; import { FromSchema } from 'json-schema-to-ts'; import { GraphQLESTreeNode } from '../estree-converter/index.js'; -import { GraphQLESLintRuleListener } from '../testkit.js'; -import { GraphQLESLintRule } from '../types.js'; +import { GraphQLESLintRule, GraphQLESLintRuleListener } from '../types.js'; const schema = { type: 'array', diff --git a/packages/plugin/src/rules/naming-convention.ts b/packages/plugin/src/rules/naming-convention.ts index 61cef6fadab..490d2f4e4f9 100644 --- a/packages/plugin/src/rules/naming-convention.ts +++ b/packages/plugin/src/rules/naming-convention.ts @@ -1,8 +1,7 @@ import { ASTKindToNode, Kind, NameNode } from 'graphql'; import { FromSchema } from 'json-schema-to-ts'; import { GraphQLESTreeNode } from '../estree-converter/index.js'; -import { GraphQLESLintRuleListener } from '../testkit.js'; -import { GraphQLESLintRule, ValueOf } from '../types.js'; +import { GraphQLESLintRule, ValueOf, GraphQLESLintRuleListener } from '../types.js'; import { ARRAY_DEFAULT_OPTIONS, convertCase, diff --git a/packages/plugin/src/rules/relay-edge-types.ts b/packages/plugin/src/rules/relay-edge-types.ts index e88f8896c18..3ae78a71077 100644 --- a/packages/plugin/src/rules/relay-edge-types.ts +++ b/packages/plugin/src/rules/relay-edge-types.ts @@ -12,8 +12,7 @@ import { } from 'graphql'; import { FromSchema } from 'json-schema-to-ts'; import { GraphQLESTreeNode } from '../estree-converter/index.js'; -import { GraphQLESLintRuleListener } from '../testkit.js'; -import { GraphQLESLintRule } from '../types.js'; +import { GraphQLESLintRule, GraphQLESLintRuleListener } from '../types.js'; import { getTypeName, requireGraphQLSchemaFromContext } from '../utils.js'; const RULE_ID = 'relay-edge-types'; diff --git a/packages/plugin/src/types.ts b/packages/plugin/src/types.ts index 2c4ea82f75e..15cdc5d33eb 100644 --- a/packages/plugin/src/types.ts +++ b/packages/plugin/src/types.ts @@ -1,11 +1,11 @@ import { GraphQLParseOptions } from '@graphql-tools/utils'; import { AST, Linter, Rule } from 'eslint'; import * as ESTree from 'estree'; -import { GraphQLSchema } from 'graphql'; +import { GraphQLSchema, ASTKindToNode } from 'graphql'; import { IExtensions, IGraphQLProject } from 'graphql-config'; import { JSONSchema } from 'json-schema-to-ts'; import { SiblingOperations } from './siblings.js'; -import { GraphQLESLintRuleListener } from './testkit.js'; +import { GraphQLESTreeNode } from './estree-converter/index.js'; export type Schema = GraphQLSchema | null; export type Pointer = string | string[]; @@ -75,6 +75,13 @@ export type RuleDocsInfo = Omit isDisabledForAllConfig?: true; }; +export type GraphQLESLintRuleListener = Record< + string, + any +> & { + [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode) => void; +}; + export type GraphQLESLintRule = { meta: Omit & { docs?: RuleDocsInfo; diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index 6baa170f962..72cbcf547f5 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -2,17 +2,8 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; -import { ASTKindToNode } from 'graphql'; -import { GraphQLESTreeNode } from './estree-converter/index.js'; import { GraphQLESLintRule, ParserOptions } from './types.js'; -export type GraphQLESLintRuleListener = Record< - string, - any -> & { - [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode) => void; -}; - export type GraphQLValidTestCase = Omit< ESLintRuleTester.ValidTestCase, 'options' | 'parserOptions' From 810c3b04dc0e9fae719b03e46d6dedb4c4c01ae0 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:54:03 +0200 Subject: [PATCH 19/39] more --- packages/rule-tester/package.json | 1 + packages/rule-tester/src/index.ts | 46 ++++++++++++++----------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index e373853fe55..a3039ca81a8 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "@types/babel__code-frame": "7.0.3", + "@types/node": "18.17.1", "eslint": "^8.46.0" }, "privat": true diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index 72cbcf547f5..aa82cd83e9e 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -1,20 +1,14 @@ -import { readFileSync } from 'fs'; -import { resolve } from 'path'; +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; -import { GraphQLESLintRule, ParserOptions } from './types.js'; -export type GraphQLValidTestCase = Omit< +type ValidTestCase> = Omit< ESLintRuleTester.ValidTestCase, 'options' | 'parserOptions' > & { options?: Options; - parserOptions?: Omit; -}; - -export type GraphQLInvalidTestCase = GraphQLValidTestCase & { - errors: (ESLintRuleTester.TestCaseError | string)[] | number; - output?: string | null; + parserOptions?: ParserOptions; }; function indentCode(code: string, indent = 4): string { @@ -27,8 +21,8 @@ function applyFix(code: string, { range, text }: Rule.Fix): string { return [code.slice(0, range[0]), text, code.slice(range[1])].join(''); } -export class RuleTester extends ESLintRuleTester { - constructor(parserOptions: Omit = {}) { +export class RuleTester extends ESLintRuleTester { + constructor(parserOptions: ParserOptions) { super({ parser: require.resolve('@graphql-eslint/eslint-plugin'), parserOptions: { @@ -43,23 +37,25 @@ export class RuleTester extends ESLintRuleTester { } // @ts-expect-error - run( + run( ruleId: string, - rule: GraphQLESLintRule, + rule: Rule.RuleModule, tests: { - valid: (GraphQLValidTestCase | string)[]; - invalid: GraphQLInvalidTestCase[]; + valid: (string | ValidTestCase)[]; + invalid: (ValidTestCase & + Pick)[]; }, ): void { + // @ts-expect-error + const { testerConfig, linter } = this; + const getMessages = (testCase: ESLintRuleTester.InvalidTestCase) => () => { const { options, code: rawCode, filename, parserOptions } = testCase; - const testerConfig = { - // @ts-expect-error - parser: this.testerConfig.parser, + const config = { + parser: testerConfig.parser, parserOptions: { - // @ts-expect-error - ...this.testerConfig.parserOptions, + ...testerConfig.parserOptions, ...parserOptions, }, rules: { @@ -68,8 +64,7 @@ export class RuleTester extends ESLintRuleTester { }; const code = removeTrailingBlankLines(rawCode); - // @ts-expect-error - const messages = this.linter.verify(code, testerConfig, filename); + const messages = linter.verify(code, config, filename); const codeFrame = indentCode(printCode(code, { line: 0, column: 0 })); const messageForSnapshot = ['#### ⌨️ Code', codeFrame]; @@ -101,9 +96,8 @@ export class RuleTester extends ESLintRuleTester { } } } - if (rule.meta.fixable) { - // @ts-expect-error - const { fixed, output } = this.linter.verifyAndFix(code, testerConfig, filename); + if (rule.meta!.fixable) { + const { fixed, output } = linter.verifyAndFix(code, config, filename); if (fixed) { messageForSnapshot.push('#### 🔧 Autofix output', indentCode(printCode(output))); } From c7a3b55325132f83e4a253b5a9dfe3eb87bd1136 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 03:56:28 +0200 Subject: [PATCH 20/39] more --- packages/rule-tester/package.json | 6 +++++- packages/rule-tester/tsconfig.json | 14 ++++++++++++++ packages/rule-tester/tsup.config.ts | 11 +++++++++++ pnpm-lock.yaml | 3 +++ turbo.json | 26 ++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 packages/rule-tester/tsconfig.json create mode 100644 packages/rule-tester/tsup.config.ts create mode 100644 turbo.json diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index a3039ca81a8..055bb74b807 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -3,7 +3,11 @@ "engines": { "node": ">=18" }, - "scripts": {}, + "scripts": { + "build": "tsup", + "dev": "tsup --watch", + "typecheck": "tsc --noEmit" + }, "peerDependencies": { "eslint": "^8.46.0" }, diff --git a/packages/rule-tester/tsconfig.json b/packages/rule-tester/tsconfig.json new file mode 100644 index 00000000000..fa30e28cf9b --- /dev/null +++ b/packages/rule-tester/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "es2019", + "module": "Node16", + "moduleResolution": "node16", + "declaration": false, + "noEmit": true, + "esModuleInterop": true, + "strict": true, + "lib": ["ESNext"], + "types": ["vitest/globals"], + "resolveJsonModule": true + } +} diff --git a/packages/rule-tester/tsup.config.ts b/packages/rule-tester/tsup.config.ts new file mode 100644 index 00000000000..666a863fac6 --- /dev/null +++ b/packages/rule-tester/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + // name: 'nextra-theme', + // entry: ['src/index.tsx'], + // format: 'esm', + // dts: true, + // external: ['react'], + // outExtension: () => ({ js: '.js' }), + // target: tsconfig.compilerOptions.target as 'es2016', +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b951bdc376..dbe5fadca08 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -337,6 +337,9 @@ importers: '@types/babel__code-frame': specifier: 7.0.3 version: 7.0.3 + '@types/node': + specifier: 18.17.1 + version: 18.17.1 eslint: specifier: ^8.46.0 version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) diff --git a/turbo.json b/turbo.json new file mode 100644 index 00000000000..8d732008744 --- /dev/null +++ b/turbo.json @@ -0,0 +1,26 @@ +{ + "pipeline": { + "build": { + "outputs": ["dist/**"], + "dependsOn": [ + // Run `build` in workspaces I depend on first + "^build" + ] + }, + "dev": { + "dependsOn": [ + // Run `dev` in workspaces I depend on first + "^dev" + ], + // Never cache anything (including logs) emitted by a `dev` task + "cache": false, + "persistent": true + }, + "typecheck": { + "dependsOn": [ + // Run `build` in workspaces I depend on first + "^build" + ] + } + } +} From 63219cd7a2fb63c5f1d0cbc2541dfa3ea10b6c90 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 04:00:59 +0200 Subject: [PATCH 21/39] more --- packages/rule-tester/package.json | 6 ++++++ packages/rule-tester/src/index.ts | 1 + packages/rule-tester/tsup.config.ts | 12 +++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index 055bb74b807..1bd68931022 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -1,8 +1,14 @@ { "name": "@theguild/eslint-rule-tester", + "type": "module", "engines": { "node": ">=18" }, + "exports": { + ".": "./dist/index.js", + "./package.json": "./package.json" + }, + "types": "./dist/index.d.ts", "scripts": { "build": "tsup", "dev": "tsup --watch", diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index aa82cd83e9e..6377d650733 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -111,6 +111,7 @@ export class RuleTester extends ESLintRuleTester { testCase.getMessages = getMessages(testCase); } + // @ts-expect-error super.run(ruleId, rule as any, tests); } } diff --git a/packages/rule-tester/tsup.config.ts b/packages/rule-tester/tsup.config.ts index 666a863fac6..ca1c92809cf 100644 --- a/packages/rule-tester/tsup.config.ts +++ b/packages/rule-tester/tsup.config.ts @@ -1,11 +1,9 @@ import { defineConfig } from 'tsup'; export default defineConfig({ - // name: 'nextra-theme', - // entry: ['src/index.tsx'], - // format: 'esm', - // dts: true, - // external: ['react'], - // outExtension: () => ({ js: '.js' }), - // target: tsconfig.compilerOptions.target as 'es2016', + name: 'eslint-rule-tester', + entry: ['src/*.ts'], + clean: true, + format: 'esm', + dts: true, }); From fef46f9c3a6addd7587a615685036a772b9b9d70 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 04:06:05 +0200 Subject: [PATCH 22/39] more --- packages/plugin/package.json | 3 ++- packages/plugin/tests/alphabetize.spec.ts | 2 +- packages/plugin/tests/description-style.spec.ts | 2 +- packages/plugin/tests/eslint-directives.spec.ts | 2 +- packages/plugin/tests/executable-definitions.spec.ts | 2 +- packages/plugin/tests/fields-on-correct-type.spec.ts | 2 +- packages/plugin/tests/input-name.spec.ts | 2 +- packages/plugin/tests/known-directives.spec.ts | 2 +- packages/plugin/tests/known-fragment-names.spec.ts | 2 +- packages/plugin/tests/lone-executable-definition.spec.ts | 2 +- packages/plugin/tests/lone-schema-definition.spec.ts | 2 +- packages/plugin/tests/match-document-filename.spec.ts | 2 +- packages/plugin/tests/naming-convention.spec.ts | 2 +- packages/plugin/tests/no-anonymous-operations.spec.ts | 2 +- .../tests/no-case-insensitive-enum-values-duplicates.spec.ts | 2 +- packages/plugin/tests/no-deprecated.spec.ts | 2 +- packages/plugin/tests/no-duplicate-fields.spec.ts | 2 +- packages/plugin/tests/no-hashtag-description.spec.ts | 2 +- packages/plugin/tests/no-one-place-fragments.spec.ts | 2 +- packages/plugin/tests/no-root-type.spec.ts | 2 +- .../plugin/tests/no-scalar-result-type-on-mutation.spec.ts | 2 +- packages/plugin/tests/no-typename-prefix.spec.ts | 2 +- packages/plugin/tests/no-unreachable-types.spec.ts | 2 +- packages/plugin/tests/no-unused-fields.spec.ts | 2 +- packages/plugin/tests/no-unused-fragments.spec.ts | 2 +- packages/plugin/tests/no-unused-variables.spec.ts | 2 +- packages/plugin/tests/possible-type-extension.spec.ts | 2 +- packages/plugin/tests/relay-arguments.spec.ts | 2 +- packages/plugin/tests/relay-connection-types.spec.ts | 2 +- packages/plugin/tests/relay-edge-types.spec.ts | 2 +- packages/plugin/tests/relay-page-info.spec.ts | 2 +- packages/plugin/tests/require-deprecation-date.spec.ts | 2 +- packages/plugin/tests/require-deprecation-reason.spec.ts | 2 +- packages/plugin/tests/require-description.spec.ts | 2 +- .../require-field-of-type-query-in-mutation-result.spec.ts | 2 +- packages/plugin/tests/require-id-when-available.spec.ts | 2 +- packages/plugin/tests/require-import-fragment.spec.ts | 2 +- .../plugin/tests/require-nullable-fields-with-oneof.spec.ts | 2 +- .../plugin/tests/require-nullable-result-in-root.spec.ts | 2 +- .../plugin/tests/require-type-pattern-with-oneof.spec.ts | 2 +- packages/plugin/tests/selection-set-depth.spec.ts | 2 +- packages/plugin/tests/strict-id-in-types.spec.ts | 2 +- packages/plugin/tests/unique-fragment-name.spec.ts | 2 +- packages/plugin/tests/unique-operation-name.spec.ts | 2 +- packages/plugin/tests/unique-type-names.spec.ts | 2 +- packages/rule-tester/package.json | 5 +++-- pnpm-lock.yaml | 3 +++ 47 files changed, 52 insertions(+), 47 deletions(-) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index e24b8f3cf62..b435e5b32c3 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -60,7 +60,8 @@ "@types/json-schema": "7.0.12", "@types/lodash.lowercase": "4.3.7", "graphql": "16.7.1", - "json-schema-to-ts": "2.9.1" + "json-schema-to-ts": "2.9.1", + "@theguild/eslint-rule-tester": "workspace:*" }, "publishConfig": { "directory": "dist", diff --git a/packages/plugin/tests/alphabetize.spec.ts b/packages/plugin/tests/alphabetize.spec.ts index d07189b3f1e..a9f52954d13 100644 --- a/packages/plugin/tests/alphabetize.spec.ts +++ b/packages/plugin/tests/alphabetize.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/alphabetize'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/description-style.spec.ts b/packages/plugin/tests/description-style.spec.ts index e77ba2d6fb0..8f8818bbf1a 100644 --- a/packages/plugin/tests/description-style.spec.ts +++ b/packages/plugin/tests/description-style.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/description-style'; const INLINE_SDL = /* GraphQL */ ` diff --git a/packages/plugin/tests/eslint-directives.spec.ts b/packages/plugin/tests/eslint-directives.spec.ts index 0a57830e9a3..4745c43308c 100644 --- a/packages/plugin/tests/eslint-directives.spec.ts +++ b/packages/plugin/tests/eslint-directives.spec.ts @@ -1,5 +1,5 @@ import { join } from 'node:path'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule as noAnonymousOperations } from '../src/rules/no-anonymous-operations'; import { rule as noTypenamePrefix } from '../src/rules/no-typename-prefix'; diff --git a/packages/plugin/tests/executable-definitions.spec.ts b/packages/plugin/tests/executable-definitions.spec.ts index dd0134933c5..da8581a6a99 100644 --- a/packages/plugin/tests/executable-definitions.spec.ts +++ b/packages/plugin/tests/executable-definitions.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const TEST_SCHEMA = /* GraphQL */ ` diff --git a/packages/plugin/tests/fields-on-correct-type.spec.ts b/packages/plugin/tests/fields-on-correct-type.spec.ts index 6f13350602e..5079f37948e 100644 --- a/packages/plugin/tests/fields-on-correct-type.spec.ts +++ b/packages/plugin/tests/fields-on-correct-type.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions, rules } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; const parserOptions: Pick = { schema: /* GraphQL */ ` diff --git a/packages/plugin/tests/input-name.spec.ts b/packages/plugin/tests/input-name.spec.ts index 976f6ac669d..c3000a43d5c 100644 --- a/packages/plugin/tests/input-name.spec.ts +++ b/packages/plugin/tests/input-name.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/input-name'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/known-directives.spec.ts b/packages/plugin/tests/known-directives.spec.ts index 13cab5b8c6e..63d18949a9b 100644 --- a/packages/plugin/tests/known-directives.spec.ts +++ b/packages/plugin/tests/known-directives.spec.ts @@ -1,5 +1,5 @@ import { rules } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; const ruleTester = new RuleTester({ schema: /* GraphQL */ ` diff --git a/packages/plugin/tests/known-fragment-names.spec.ts b/packages/plugin/tests/known-fragment-names.spec.ts index f1f353f7fe5..53fd989d1ba 100644 --- a/packages/plugin/tests/known-fragment-names.spec.ts +++ b/packages/plugin/tests/known-fragment-names.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/lone-executable-definition.spec.ts b/packages/plugin/tests/lone-executable-definition.spec.ts index 99eb3e8ac0a..31480d2faa3 100644 --- a/packages/plugin/tests/lone-executable-definition.spec.ts +++ b/packages/plugin/tests/lone-executable-definition.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/lone-executable-definition'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/lone-schema-definition.spec.ts b/packages/plugin/tests/lone-schema-definition.spec.ts index 7040037180a..598476756df 100644 --- a/packages/plugin/tests/lone-schema-definition.spec.ts +++ b/packages/plugin/tests/lone-schema-definition.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/match-document-filename.spec.ts b/packages/plugin/tests/match-document-filename.spec.ts index e036427fb8a..e95eb670623 100644 --- a/packages/plugin/tests/match-document-filename.spec.ts +++ b/packages/plugin/tests/match-document-filename.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/match-document-filename'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/naming-convention.spec.ts b/packages/plugin/tests/naming-convention.spec.ts index 152ecc678df..9ee0733e66e 100644 --- a/packages/plugin/tests/naming-convention.spec.ts +++ b/packages/plugin/tests/naming-convention.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/naming-convention'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-anonymous-operations.spec.ts b/packages/plugin/tests/no-anonymous-operations.spec.ts index d9e05b0004d..28c60acd1fd 100644 --- a/packages/plugin/tests/no-anonymous-operations.spec.ts +++ b/packages/plugin/tests/no-anonymous-operations.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-anonymous-operations'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts index c74695557da..009ff1bb78a 100644 --- a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts +++ b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-case-insensitive-enum-values-duplicates'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-deprecated.spec.ts b/packages/plugin/tests/no-deprecated.spec.ts index eab63355e16..95367c10cc4 100644 --- a/packages/plugin/tests/no-deprecated.spec.ts +++ b/packages/plugin/tests/no-deprecated.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-deprecated'; const TEST_SCHEMA = /* GraphQL */ ` diff --git a/packages/plugin/tests/no-duplicate-fields.spec.ts b/packages/plugin/tests/no-duplicate-fields.spec.ts index 7e978c3e61b..9052bb73165 100644 --- a/packages/plugin/tests/no-duplicate-fields.spec.ts +++ b/packages/plugin/tests/no-duplicate-fields.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-duplicate-fields'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-hashtag-description.spec.ts b/packages/plugin/tests/no-hashtag-description.spec.ts index bc7e138a634..b888e93bb94 100644 --- a/packages/plugin/tests/no-hashtag-description.spec.ts +++ b/packages/plugin/tests/no-hashtag-description.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RULE_ID } from '../src/rules/no-hashtag-description'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-one-place-fragments.spec.ts b/packages/plugin/tests/no-one-place-fragments.spec.ts index 3efda10f175..8921828dc7e 100644 --- a/packages/plugin/tests/no-one-place-fragments.spec.ts +++ b/packages/plugin/tests/no-one-place-fragments.spec.ts @@ -1,5 +1,5 @@ import { join } from 'node:path'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-one-place-fragments'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-root-type.spec.ts b/packages/plugin/tests/no-root-type.spec.ts index acbfedfb018..96d042d0b47 100644 --- a/packages/plugin/tests/no-root-type.spec.ts +++ b/packages/plugin/tests/no-root-type.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/no-root-type'; const useSchema = ( diff --git a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts index 0b34d24bcf9..3e718091e44 100644 --- a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts +++ b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-scalar-result-type-on-mutation'; const useSchema = ( diff --git a/packages/plugin/tests/no-typename-prefix.spec.ts b/packages/plugin/tests/no-typename-prefix.spec.ts index 9442676425b..96edd9c319e 100644 --- a/packages/plugin/tests/no-typename-prefix.spec.ts +++ b/packages/plugin/tests/no-typename-prefix.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-typename-prefix'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-unreachable-types.spec.ts b/packages/plugin/tests/no-unreachable-types.spec.ts index aaa32bb7ad7..9af33febd69 100644 --- a/packages/plugin/tests/no-unreachable-types.spec.ts +++ b/packages/plugin/tests/no-unreachable-types.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-unreachable-types'; const useSchema = ( diff --git a/packages/plugin/tests/no-unused-fields.spec.ts b/packages/plugin/tests/no-unused-fields.spec.ts index b9f55f0fc3f..b192d0a88b0 100644 --- a/packages/plugin/tests/no-unused-fields.spec.ts +++ b/packages/plugin/tests/no-unused-fields.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-unused-fields'; const SCHEMA = /* GraphQL */ ` diff --git a/packages/plugin/tests/no-unused-fragments.spec.ts b/packages/plugin/tests/no-unused-fragments.spec.ts index 07889a15ad6..0a255d75fcf 100644 --- a/packages/plugin/tests/no-unused-fragments.spec.ts +++ b/packages/plugin/tests/no-unused-fragments.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/no-unused-variables.spec.ts b/packages/plugin/tests/no-unused-variables.spec.ts index c16b8099e4d..5b18e2f593e 100644 --- a/packages/plugin/tests/no-unused-variables.spec.ts +++ b/packages/plugin/tests/no-unused-variables.spec.ts @@ -1,5 +1,5 @@ import { join } from 'node:path'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rules } from '../src'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/possible-type-extension.spec.ts b/packages/plugin/tests/possible-type-extension.spec.ts index de378f66add..f43dbbaccd8 100644 --- a/packages/plugin/tests/possible-type-extension.spec.ts +++ b/packages/plugin/tests/possible-type-extension.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { ParserOptions, rules } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/relay-arguments.spec.ts b/packages/plugin/tests/relay-arguments.spec.ts index 34a5340976b..eb1af10e3db 100644 --- a/packages/plugin/tests/relay-arguments.spec.ts +++ b/packages/plugin/tests/relay-arguments.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/relay-arguments'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/relay-connection-types.spec.ts b/packages/plugin/tests/relay-connection-types.spec.ts index 55dde44bad0..a3db2ef503c 100644 --- a/packages/plugin/tests/relay-connection-types.spec.ts +++ b/packages/plugin/tests/relay-connection-types.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/relay-connection-types'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/relay-edge-types.spec.ts b/packages/plugin/tests/relay-edge-types.spec.ts index a1271158a08..2bfd20493c9 100644 --- a/packages/plugin/tests/relay-edge-types.spec.ts +++ b/packages/plugin/tests/relay-edge-types.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/relay-edge-types'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/relay-page-info.spec.ts b/packages/plugin/tests/relay-page-info.spec.ts index 4ec15cb339d..5ea0c7ee7bb 100644 --- a/packages/plugin/tests/relay-page-info.spec.ts +++ b/packages/plugin/tests/relay-page-info.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/relay-page-info'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/require-deprecation-date.spec.ts b/packages/plugin/tests/require-deprecation-date.spec.ts index a1864d4ee73..0021ad29742 100644 --- a/packages/plugin/tests/require-deprecation-date.spec.ts +++ b/packages/plugin/tests/require-deprecation-date.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/require-deprecation-date'; const now = new Date(); diff --git a/packages/plugin/tests/require-deprecation-reason.spec.ts b/packages/plugin/tests/require-deprecation-reason.spec.ts index 5a532ead191..c4080d0ffd8 100644 --- a/packages/plugin/tests/require-deprecation-reason.spec.ts +++ b/packages/plugin/tests/require-deprecation-reason.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-deprecation-reason'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/require-description.spec.ts b/packages/plugin/tests/require-description.spec.ts index bc4ec2eed0a..e6674e251c6 100644 --- a/packages/plugin/tests/require-description.spec.ts +++ b/packages/plugin/tests/require-description.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions, RULE_ID } from '../src/rules/require-description'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts index f3f0990550b..bcaf5bf27e2 100644 --- a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts +++ b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-field-of-type-query-in-mutation-result'; const useSchema = ( diff --git a/packages/plugin/tests/require-id-when-available.spec.ts b/packages/plugin/tests/require-id-when-available.spec.ts index 354b40dc165..6d82158e948 100644 --- a/packages/plugin/tests/require-id-when-available.spec.ts +++ b/packages/plugin/tests/require-id-when-available.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/require-id-when-available'; const TEST_SCHEMA = /* GraphQL */ ` diff --git a/packages/plugin/tests/require-import-fragment.spec.ts b/packages/plugin/tests/require-import-fragment.spec.ts index 9881b030165..acb08c9848f 100644 --- a/packages/plugin/tests/require-import-fragment.spec.ts +++ b/packages/plugin/tests/require-import-fragment.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { GraphQLInvalidTestCase } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-import-fragment'; import { Linter } from 'eslint'; import ParserOptions = Linter.ParserOptions; diff --git a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts index df82c8749c7..f052850d2f7 100644 --- a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts +++ b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-nullable-fields-with-oneof'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/require-nullable-result-in-root.spec.ts b/packages/plugin/tests/require-nullable-result-in-root.spec.ts index db0023f9b69..9e6c169ad6f 100644 --- a/packages/plugin/tests/require-nullable-result-in-root.spec.ts +++ b/packages/plugin/tests/require-nullable-result-in-root.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-nullable-result-in-root'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts b/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts index cb26b04e0c7..213b84c0b22 100644 --- a/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts +++ b/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts @@ -1,4 +1,4 @@ -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-type-pattern-with-oneof'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/selection-set-depth.spec.ts b/packages/plugin/tests/selection-set-depth.spec.ts index d162f28843c..b9552db29b6 100644 --- a/packages/plugin/tests/selection-set-depth.spec.ts +++ b/packages/plugin/tests/selection-set-depth.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/selection-set-depth'; const WITH_SIBLINGS = { diff --git a/packages/plugin/tests/strict-id-in-types.spec.ts b/packages/plugin/tests/strict-id-in-types.spec.ts index f347e5293e4..04046581b32 100644 --- a/packages/plugin/tests/strict-id-in-types.spec.ts +++ b/packages/plugin/tests/strict-id-in-types.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/strict-id-in-types'; const ruleTester = new RuleTester(); diff --git a/packages/plugin/tests/unique-fragment-name.spec.ts b/packages/plugin/tests/unique-fragment-name.spec.ts index 4097a8cbf37..1d358fdbd0a 100644 --- a/packages/plugin/tests/unique-fragment-name.spec.ts +++ b/packages/plugin/tests/unique-fragment-name.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/unique-fragment-name'; const TEST_FRAGMENT = /* GraphQL */ ` diff --git a/packages/plugin/tests/unique-operation-name.spec.ts b/packages/plugin/tests/unique-operation-name.spec.ts index 8880fb438b3..df7c961c5a2 100644 --- a/packages/plugin/tests/unique-operation-name.spec.ts +++ b/packages/plugin/tests/unique-operation-name.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/unique-operation-name'; const TEST_OPERATION = 'query test { foo }'; diff --git a/packages/plugin/tests/unique-type-names.spec.ts b/packages/plugin/tests/unique-type-names.spec.ts index c5914fbf85d..2504513f6ae 100644 --- a/packages/plugin/tests/unique-type-names.spec.ts +++ b/packages/plugin/tests/unique-type-names.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '../src/testkit'; +import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const TEST_SCHEMA = /* GraphQL */ ` diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index 1bd68931022..a0418e48b4b 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -1,6 +1,8 @@ { "name": "@theguild/eslint-rule-tester", + "version": "0.0.0", "type": "module", + "private": true, "engines": { "node": ">=18" }, @@ -24,6 +26,5 @@ "@types/babel__code-frame": "7.0.3", "@types/node": "18.17.1", "eslint": "^8.46.0" - }, - "privat": true + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dbe5fadca08..5e186f96630 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -302,6 +302,9 @@ importers: specifier: ^2.4.1 version: 2.4.1 devDependencies: + '@theguild/eslint-rule-tester': + specifier: workspace:* + version: link:../rule-tester '@types/debug': specifier: 4.1.8 version: 4.1.8 From dff3241b82bf5143b7ee94f89e0bfb0e0e91504f Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 04:17:43 +0200 Subject: [PATCH 23/39] more --- packages/plugin/tsup.config.ts | 6 +----- packages/rule-tester/src/index.ts | 6 ++++-- packages/rule-tester/tsconfig.json | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/plugin/tsup.config.ts b/packages/plugin/tsup.config.ts index af23aa38bf1..834f5cb39c9 100644 --- a/packages/plugin/tsup.config.ts +++ b/packages/plugin/tsup.config.ts @@ -38,11 +38,7 @@ export default defineConfig([ 2, ).replaceAll('dist/', ''), ); - addCreateRequireBanner([ - 'estree-converter/utils.js', - 'rules/graphql-js-validation.js', - 'testkit.js', - ]); + addCreateRequireBanner(['estree-converter/utils.js', 'rules/graphql-js-validation.js']); console.log('✅ Success!'); }, }, diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index 6377d650733..f5ac037408e 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -1,8 +1,11 @@ import { readFileSync } from 'node:fs'; import { resolve } from 'node:path'; +import { createRequire } from 'node:module'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; +const require = createRequire(import.meta.url); + type ValidTestCase> = Omit< ESLintRuleTester.ValidTestCase, 'options' | 'parserOptions' @@ -64,8 +67,6 @@ export class RuleTester extends ESLintRuleTester { }; const code = removeTrailingBlankLines(rawCode); - const messages = linter.verify(code, config, filename); - const codeFrame = indentCode(printCode(code, { line: 0, column: 0 })); const messageForSnapshot = ['#### ⌨️ Code', codeFrame]; @@ -74,6 +75,7 @@ export class RuleTester extends ESLintRuleTester { messageForSnapshot.push('#### ⚙️ Options', indentCode(removeTrailingBlankLines(opts), 2)); } + const messages = linter.verify(code, config, filename); for (const [index, message] of messages.entries()) { const codeWithMessage = printCode(code, message, 1); messageForSnapshot.push( diff --git a/packages/rule-tester/tsconfig.json b/packages/rule-tester/tsconfig.json index fa30e28cf9b..035651d7863 100644 --- a/packages/rule-tester/tsconfig.json +++ b/packages/rule-tester/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "es2019", - "module": "Node16", + "target": "ES2022", + "module": "ES2022", "moduleResolution": "node16", "declaration": false, "noEmit": true, From b08b4ded6750fd5fbf07eea0b256c5194b9ddcc5 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 13:33:09 +0200 Subject: [PATCH 24/39] try --- package.json | 3 +- .../tests/no-undefined-variables.spec.ts | 3 +- packages/rule-tester/package.json | 2 +- patches/eslint@8.46.0.patch | 9 +- pnpm-lock.yaml | 147 +++++++++++++----- 5 files changed, 118 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index a532e0e012f..c8e87d12f46 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "pnpm": ">=8" }, "scripts": { - "build": "pnpm --filter @graphql-eslint/eslint-plugin build && bob check", + "build": "turbo run build --filter=!website && bob check", "ci:lint": "eslint --ignore-path .gitignore --output-file eslint_report.json --format json .", "create-rule": "tsx scripts/create-rule.ts", "generate:configs": "tsx scripts/generate-configs.ts", @@ -46,6 +46,7 @@ "rimraf": "5.0.1", "tsup": "^7.1.0", "tsx": "3.12.7", + "turbo": "^1.10.12", "typescript": "5.1.6", "vitest": "0.30.1" }, diff --git a/packages/plugin/tests/no-undefined-variables.spec.ts b/packages/plugin/tests/no-undefined-variables.spec.ts index 9a2be5e8112..155643639b3 100644 --- a/packages/plugin/tests/no-undefined-variables.spec.ts +++ b/packages/plugin/tests/no-undefined-variables.spec.ts @@ -1,5 +1,6 @@ import { join } from 'node:path'; -import { RuleTester, rules } from '../src'; +import { RuleTester } from '@theguild/eslint-rule-tester'; +import { rules } from '../src'; const ruleTester = new RuleTester(); diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index a0418e48b4b..ce5407a4c72 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -7,7 +7,7 @@ "node": ">=18" }, "exports": { - ".": "./dist/index.js", + ".": "./src/index.ts", "./package.json": "./package.json" }, "types": "./dist/index.d.ts", diff --git a/patches/eslint@8.46.0.patch b/patches/eslint@8.46.0.patch index 934a58a571b..62e9c72f67d 100644 --- a/patches/eslint@8.46.0.patch +++ b/patches/eslint@8.46.0.patch @@ -13,7 +13,7 @@ index 233cbed5b5ccdf89806df9786a0902a317dd451e..7db8fa9c1fca4183460164ca1fd8fa0a const DEFAULT_ECMA_VERSION = 5; const commentParser = new ConfigCommentParser(); diff --git a/lib/rule-tester/flat-rule-tester.js b/lib/rule-tester/flat-rule-tester.js -index f143873f7bc76737acc5ff00871e462ef058bf4b..ac6ecbbda2854bf927c6de3632588c5b6ea8a9a8 100644 +index f143873f7bc76737acc5ff00871e462ef058bf4b..a0b6283b653a9f9cd478711c34bbf4a07ad9008f 100644 --- a/lib/rule-tester/flat-rule-tester.js +++ b/lib/rule-tester/flat-rule-tester.js @@ -998,11 +998,7 @@ class FlatRuleTester { @@ -30,10 +30,10 @@ index f143873f7bc76737acc5ff00871e462ef058bf4b..ac6ecbbda2854bf927c6de3632588c5b assertASTDidntChange(result.beforeAST, result.afterAST); diff --git a/lib/rule-tester/rule-tester.js b/lib/rule-tester/rule-tester.js -index e4dc126783c8232a67268c72def615829c4508b9..9b38bf58032a161dfbed70e6bb3974644297dd8f 100644 +index e4dc126783c8232a67268c72def615829c4508b9..6e1de73fd06e8bfec07e14c8779b050959f3add4 100644 --- a/lib/rule-tester/rule-tester.js +++ b/lib/rule-tester/rule-tester.js -@@ -1008,11 +1008,7 @@ class RuleTester { +@@ -1008,13 +1008,10 @@ class RuleTester { assert.strictEqual(result.output, item.output, "Output is incorrect."); } } else { @@ -45,4 +45,7 @@ index e4dc126783c8232a67268c72def615829c4508b9..9b38bf58032a161dfbed70e6bb397464 + // 🚨 Don't need, as we assert autofix output with snapshots } ++ item.assertMessages(item) assertASTDidntChange(result.beforeAST, result.afterAST); + } + \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e186f96630..056bcc4e1ae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,7 +15,7 @@ patchedDependencies: hash: cdhdgvmsbh3fbusrlxsl6de2he path: patches/eslint-plugin-eslint-plugin@5.0.6.patch eslint@8.46.0: - hash: t2nfsf5qfxmsuzmwslg2btnxeq + hash: 7xckwst2ekw7c3pf6pfwcsuiwu path: patches/eslint@8.46.0.patch json-schema-to-markdown@1.1.1: hash: beglqnggvhpsclgwbdw27hzvu4 @@ -60,7 +60,7 @@ importers: version: 2.4.0 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-plugin-eslint-plugin: specifier: 5.0.7 version: 5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0) @@ -91,6 +91,9 @@ importers: tsx: specifier: 3.12.7 version: 3.12.7 + turbo: + specifier: ^1.10.12 + version: 1.10.12 typescript: specifier: 5.1.6 version: 5.1.6 @@ -112,7 +115,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) examples/code-file: dependencies: @@ -128,7 +131,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) examples/graphql-config: dependencies: @@ -144,7 +147,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) examples/graphql-config-code-file: dependencies: @@ -163,7 +166,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) examples/monorepo: dependencies: @@ -179,7 +182,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) examples/multiple-projects-graphql-config: dependencies: @@ -195,7 +198,7 @@ importers: version: 5.0.0(@types/node@18.17.1)(cosmiconfig@8.2.0)(typescript@5.1.6) eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) ts-node: specifier: 10.9.1 version: 10.9.1(@types/node@18.17.1)(typescript@5.1.6) @@ -217,7 +220,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-config-prettier: specifier: 8.8.0 version: 8.8.0(eslint@8.46.0) @@ -239,7 +242,7 @@ importers: version: link:../../packages/plugin/dist eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) svelte: specifier: 4.1.1 version: 4.1.1 @@ -264,7 +267,7 @@ importers: version: 3.3.4 eslint: specifier: 8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) vue-eslint-parser: specifier: 9.3.1 version: 9.3.1(eslint@8.46.0) @@ -337,6 +340,9 @@ importers: specifier: ^7.18.6 version: 7.18.6 devDependencies: + '@graphql-eslint/eslint-plugin': + specifier: workspace:* + version: link:../plugin/dist '@types/babel__code-frame': specifier: 7.0.3 version: 7.0.3 @@ -345,7 +351,7 @@ importers: version: 18.17.1 eslint: specifier: ^8.46.0 - version: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + version: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) website: dependencies: @@ -1529,7 +1535,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-visitor-keys: 3.4.2 dev: true @@ -2926,7 +2932,7 @@ packages: '@rushstack/eslint-patch': 1.3.2 '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-config-prettier: 8.8.0(eslint@8.46.0) eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) @@ -3202,7 +3208,7 @@ packages: '@typescript-eslint/type-utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -3227,7 +3233,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) typescript: 5.1.6 transitivePeerDependencies: - supports-color @@ -3254,7 +3260,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 4.3.4 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) tsutils: 3.21.0(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: @@ -3299,7 +3305,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -5722,7 +5728,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) dev: true /eslint-import-resolver-node@0.3.7: @@ -5744,7 +5750,7 @@ packages: dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) get-tsconfig: 4.6.2 @@ -5767,7 +5773,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) espree: 9.6.1 estree-util-visit: 1.2.1 remark-mdx: 2.3.0 @@ -5807,7 +5813,7 @@ packages: dependencies: '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.1.6) debug: 3.2.7 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-import-resolver-node: 0.3.7 eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.27.5)(eslint@8.46.0) transitivePeerDependencies: @@ -5822,7 +5828,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) '@eslint-community/regexpp': 4.6.0 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) dev: true /eslint-plugin-eslint-plugin@5.0.7(patch_hash=cdhdgvmsbh3fbusrlxsl6de2he)(eslint@8.46.0): @@ -5831,7 +5837,7 @@ packages: peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-utils: 3.0.0(eslint@8.46.0) estraverse: 5.3.0 dev: true @@ -5853,7 +5859,7 @@ packages: array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-import-resolver-node: 0.3.7 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.46.0) has: 1.0.3 @@ -5877,7 +5883,7 @@ packages: eslint: '>=6.0.0' dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) jsonc-eslint-parser: 2.3.0 natural-compare: 1.4.0 dev: true @@ -5897,7 +5903,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) has: 1.0.3 jsx-ast-utils: 3.3.4 language-tags: 1.0.5 @@ -5913,7 +5919,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) mdast-util-from-markdown: 0.8.5 transitivePeerDependencies: - supports-color @@ -5925,7 +5931,7 @@ packages: peerDependencies: eslint: '>=8.0.0' dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-mdx: 2.1.0(eslint@8.46.0) eslint-plugin-markdown: 3.0.0(eslint@8.46.0) remark-mdx: 2.3.0 @@ -5946,7 +5952,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) builtins: 5.0.1 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-plugin-es-x: 7.2.0(eslint@8.46.0) ignore: 5.2.4 is-core-module: 2.12.1 @@ -5966,7 +5972,7 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-config-prettier: 8.8.0(eslint@8.46.0) prettier: 2.8.8 prettier-linter-helpers: 1.0.0 @@ -5978,7 +5984,7 @@ packages: peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) dev: true /eslint-plugin-react-hooks@4.6.0(eslint@8.46.0): @@ -5987,7 +5993,7 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) dev: true /eslint-plugin-react@7.33.0(eslint@8.46.0): @@ -6000,7 +6006,7 @@ packages: array.prototype.flatmap: 1.3.1 array.prototype.tosorted: 1.1.1 doctrine: 2.1.0 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) estraverse: 5.3.0 jsx-ast-utils: 3.3.4 minimatch: 3.1.2 @@ -6020,7 +6026,7 @@ packages: peerDependencies: eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) dev: true /eslint-plugin-tailwindcss@3.13.0(tailwindcss@3.3.3): @@ -6044,7 +6050,7 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.46.0) ci-info: 3.8.0 clean-regexp: 1.0.0 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 @@ -6066,7 +6072,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -6112,7 +6118,7 @@ packages: peerDependencies: eslint: '>=5' dependencies: - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-visitor-keys: 2.1.0 dev: true @@ -6131,7 +6137,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq): + /eslint@8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu): resolution: {integrity: sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true @@ -11993,6 +11999,67 @@ packages: yargs: 17.7.2 dev: true + /turbo-darwin-64@1.10.12: + resolution: {integrity: sha512-vmDfGVPl5/aFenAbOj3eOx3ePNcWVUyZwYr7taRl0ZBbmv2TzjRiFotO4vrKCiTVnbqjQqAFQWY2ugbqCI1kOQ==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-darwin-arm64@1.10.12: + resolution: {integrity: sha512-3JliEESLNX2s7g54SOBqqkqJ7UhcOGkS0ywMr5SNuvF6kWVTbuUq7uBU/sVbGq8RwvK1ONlhPvJne5MUqBCTCQ==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-64@1.10.12: + resolution: {integrity: sha512-siYhgeX0DidIfHSgCR95b8xPee9enKSOjCzx7EjTLmPqPaCiVebRYvbOIYdQWRqiaKh9yfhUtFmtMOMScUf1gg==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-linux-arm64@1.10.12: + resolution: {integrity: sha512-K/ZhvD9l4SslclaMkTiIrnfcACgos79YcAo4kwc8bnMQaKuUeRpM15sxLpZp3xDjDg8EY93vsKyjaOhdFG2UbA==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-64@1.10.12: + resolution: {integrity: sha512-7FSgSwvktWDNOqV65l9AbZwcoueAILeE4L7JvjauNASAjjbuzXGCEq5uN8AQU3U5BOFj4TdXrVmO2dX+lLu8Zg==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo-windows-arm64@1.10.12: + resolution: {integrity: sha512-gCNXF52dwom1HLY9ry/cneBPOKTBHhzpqhMylcyvJP0vp9zeMQQkt6yjYv+6QdnmELC92CtKNp2FsNZo+z0pyw==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /turbo@1.10.12: + resolution: {integrity: sha512-WM3+jTfQWnB9W208pmP4oeehZcC6JQNlydb/ZHMRrhmQa+htGhWLCzd6Q9rLe0MwZLPpSPFV2/bN5egCLyoKjQ==} + hasBin: true + requiresBuild: true + optionalDependencies: + turbo-darwin-64: 1.10.12 + turbo-darwin-arm64: 1.10.12 + turbo-linux-64: 1.10.12 + turbo-linux-arm64: 1.10.12 + turbo-windows-64: 1.10.12 + turbo-windows-arm64: 1.10.12 + dev: true + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -12634,7 +12701,7 @@ packages: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.46.0(patch_hash=t2nfsf5qfxmsuzmwslg2btnxeq) + eslint: 8.46.0(patch_hash=7xckwst2ekw7c3pf6pfwcsuiwu) eslint-scope: 7.2.1 eslint-visitor-keys: 3.4.1 espree: 9.6.1 From 46ab94ff3358dce8a54969d0131d385932d8d9f3 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:10:28 +0200 Subject: [PATCH 25/39] more --- package.json | 2 +- packages/plugin/package.json | 3 ++- .../plugin/serializer.ts | 0 packages/plugin/tests/examples.spec.ts | 4 +++- packages/plugin/tests/schema.spec.ts | 3 ++- .../plugin/vite.config.ts | 2 +- packages/rule-tester/package.json | 2 +- packages/rule-tester/src/index.ts | 19 +++++++++++-------- turbo.json | 6 ++++++ 9 files changed, 27 insertions(+), 14 deletions(-) rename serializer.ts => packages/plugin/serializer.ts (100%) rename vite.config.ts => packages/plugin/vite.config.ts (80%) diff --git a/package.json b/package.json index c8e87d12f46..c2d7fba4f8d 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "prerelease": "NODE_ENV=production pnpm build", "prettier": "pnpm lint:prettier --write", "release": "changeset publish", - "test": "vitest ." + "test": "turbo run test" }, "devDependencies": { "@changesets/changelog-github": "0.4.8", diff --git a/packages/plugin/package.json b/packages/plugin/package.json index b435e5b32c3..4d406fbdc6e 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -35,7 +35,8 @@ "graphql" ], "scripts": { - "build": "tsup" + "build": "tsup", + "test": "vitest" }, "peerDependencies": { "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" diff --git a/serializer.ts b/packages/plugin/serializer.ts similarity index 100% rename from serializer.ts rename to packages/plugin/serializer.ts diff --git a/packages/plugin/tests/examples.spec.ts b/packages/plugin/tests/examples.spec.ts index 2feeef05d57..6ad98e5f525 100644 --- a/packages/plugin/tests/examples.spec.ts +++ b/packages/plugin/tests/examples.spec.ts @@ -1,7 +1,9 @@ import { spawnSync } from 'node:child_process'; import { join, relative } from 'node:path'; import { ESLint } from 'eslint'; -import { CWD } from '../src/utils'; +import { CWD as PROJECT_CWD } from '../src/utils'; + +const CWD = join(PROJECT_CWD, '..', '..'); function countErrors(results: ESLint.LintResult[]): number { return results.reduce((acc, curr: ESLint.LintResult & { fatalErrorCount: number }) => { diff --git a/packages/plugin/tests/schema.spec.ts b/packages/plugin/tests/schema.spec.ts index 1256a941eda..63ebf016088 100644 --- a/packages/plugin/tests/schema.spec.ts +++ b/packages/plugin/tests/schema.spec.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import { GraphQLSchema, printSchema, version } from 'graphql'; import { loadGraphQLConfig } from '../src/graphql-config'; import { getSchema } from '../src/schema'; +import { CWD } from '../src/utils'; describe('schema', async () => { const SCHEMA_GRAPHQL_PATH = path.resolve(__dirname, 'mocks/user-schema.graphql'); @@ -57,7 +58,7 @@ directive @specifiedBy( beforeAll( () => new Promise(resolve => { - const tsNodeCommand = path.resolve(process.cwd(), 'node_modules/.bin/tsx'); + const tsNodeCommand = path.resolve(CWD, '..', '..', 'node_modules', '.bin', 'tsx'); const serverPath = path.resolve(__dirname, 'mocks/graphql-server.ts'); // Import `TestGraphQLServer` and run it in this file will don't work diff --git a/vite.config.ts b/packages/plugin/vite.config.ts similarity index 80% rename from vite.config.ts rename to packages/plugin/vite.config.ts index ea843fba4ed..06f7afe2ad5 100644 --- a/vite.config.ts +++ b/packages/plugin/vite.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ testPath.replace('tests/', 'tests/__snapshots__/').replace(/\.ts$/, '.md'), setupFiles: ['./serializer.ts'], alias: { - '@graphql-eslint/eslint-plugin': 'packages/plugin/src/index.ts', + '@graphql-eslint/eslint-plugin': 'src/index.ts', }, }, }); diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index ce5407a4c72..a0418e48b4b 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -7,7 +7,7 @@ "node": ">=18" }, "exports": { - ".": "./src/index.ts", + ".": "./dist/index.js", "./package.json": "./package.json" }, "types": "./dist/index.d.ts", diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index f5ac037408e..f68cd2a3b2b 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -1,10 +1,12 @@ import { readFileSync } from 'node:fs'; -import { resolve } from 'node:path'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { createRequire } from 'node:module'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; const require = createRequire(import.meta.url); +const __dirname = dirname(fileURLToPath(import.meta.url)); type ValidTestCase> = Omit< ESLintRuleTester.ValidTestCase, @@ -36,10 +38,10 @@ export class RuleTester extends ESLintRuleTester { } fromMockFile(path: string): string { - return readFileSync(resolve(__dirname, `../tests/mocks/${path}`), 'utf-8'); + return readFileSync(resolve(__dirname, `../../plugin/tests/mocks/${path}`), 'utf-8'); } - // @ts-expect-error + // @ts-expect-error -- fix later run( ruleId: string, rule: Rule.RuleModule, @@ -49,10 +51,10 @@ export class RuleTester extends ESLintRuleTester { Pick)[]; }, ): void { - // @ts-expect-error + // @ts-expect-error -- fix later const { testerConfig, linter } = this; - const getMessages = (testCase: ESLintRuleTester.InvalidTestCase) => () => { + const getMessages = (testCase: ESLintRuleTester.InvalidTestCase) => { const { options, code: rawCode, filename, parserOptions } = testCase; const config = { @@ -109,11 +111,12 @@ export class RuleTester extends ESLintRuleTester { for (const [id, testCase] of tests.invalid.entries()) { testCase.name ||= `Invalid #${id + 1}`; - // @ts-expect-error - testCase.getMessages = getMessages(testCase); + Object.defineProperty(testCase, 'assertMessages', { + value: getMessages, + }); } - // @ts-expect-error + // @ts-expect-error -- fix later super.run(ruleId, rule as any, tests); } } diff --git a/turbo.json b/turbo.json index 8d732008744..72490ff6746 100644 --- a/turbo.json +++ b/turbo.json @@ -21,6 +21,12 @@ // Run `build` in workspaces I depend on first "^build" ] + }, + "test": { + "dependsOn": [ + // A workspace's `test` command depends on its own `build` commands first being completed + "build" + ] } } } From 7a4b29e1b7db21414fd1903ed3e00c9d188c8a8c Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:13:55 +0200 Subject: [PATCH 26/39] aaa --- .github/workflows/tests.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 802d62cb717..1d4e20da8bd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,12 +44,6 @@ jobs: - name: Build run: pnpm build - - name: Upload Build Artifact - uses: actions/upload-artifact@v3 - with: - name: build-artifact - path: packages/plugin/dist - test: name: Node.js v${{matrix.node_version}} / GraphQL v${{matrix.graphql_version}} / ESLint v8 timeout-minutes: 60 @@ -78,14 +72,6 @@ jobs: - name: Install Dependencies run: pnpm i --no-frozen-lockfile - # We need build for examples.spec.ts test - # Otherwise we'll get error - Cannot find module 'node_modules/@graphql-eslint/eslint-plugin/dist/index.js' - - name: Download Build Artifact - uses: actions/download-artifact@v3 - with: - name: build-artifact - path: packages/plugin/dist - - name: Test run: pnpm test env: From cf823c0bb372685e46e8ba63fcda89049b77243a Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:14:44 +0200 Subject: [PATCH 27/39] prettier --- packages/plugin/package.json | 4 +- .../tests/lone-schema-definition.spec.ts | 56 +++++++++---------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 4d406fbdc6e..5a8f7627ffe 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -54,6 +54,7 @@ "tslib": "^2.4.1" }, "devDependencies": { + "@theguild/eslint-rule-tester": "workspace:*", "@types/debug": "4.1.8", "@types/eslint": "8.37.0", "@types/estree": "1.0.1", @@ -61,8 +62,7 @@ "@types/json-schema": "7.0.12", "@types/lodash.lowercase": "4.3.7", "graphql": "16.7.1", - "json-schema-to-ts": "2.9.1", - "@theguild/eslint-rule-tester": "workspace:*" + "json-schema-to-ts": "2.9.1" }, "publishConfig": { "directory": "dist", diff --git a/packages/plugin/tests/lone-schema-definition.spec.ts b/packages/plugin/tests/lone-schema-definition.spec.ts index 598476756df..16636f75954 100644 --- a/packages/plugin/tests/lone-schema-definition.spec.ts +++ b/packages/plugin/tests/lone-schema-definition.spec.ts @@ -3,12 +3,21 @@ import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; const ruleTester = new RuleTester(); -ruleTester.run( - 'lone-schema-definition', - GRAPHQL_JS_VALIDATIONS['lone-schema-definition'], - { - valid: [ - /* GraphQL */ ` +ruleTester.run('lone-schema-definition', GRAPHQL_JS_VALIDATIONS['lone-schema-definition'], { + valid: [ + /* GraphQL */ ` + type Query { + foo: String + } + + schema { + query: Query + } + `, + ], + invalid: [ + { + code: /* GraphQL */ ` type Query { foo: String } @@ -16,29 +25,16 @@ ruleTester.run( schema { query: Query } - `, - ], - invalid: [ - { - code: /* GraphQL */ ` - type Query { - foo: String - } - schema { - query: Query - } - - type RootQuery { - foo: String - } + type RootQuery { + foo: String + } - schema { - query: RootQuery - } - `, - errors: [{ message: 'Must provide only one schema definition.' }], - }, - ], - }, -); + schema { + query: RootQuery + } + `, + errors: [{ message: 'Must provide only one schema definition.' }], + }, + ], +}); From 3e05180ce802f2ea5876bf7196715334d3dfef58 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:20:33 +0200 Subject: [PATCH 28/39] add changeset --- .changeset/strong-needles-compare.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .changeset/strong-needles-compare.md diff --git a/.changeset/strong-needles-compare.md b/.changeset/strong-needles-compare.md new file mode 100644 index 00000000000..847d6c78ae9 --- /dev/null +++ b/.changeset/strong-needles-compare.md @@ -0,0 +1,13 @@ +--- +'@graphql-eslint/eslint-plugin': major +--- + +Remove `GraphQLRuleTester` from bundle, to test your rules use regular `RuleTester` from eslint + +```js +import { RuleTester } from 'eslint' + +const ruleTester = new RuleTester({ + parser: require.resolve('@graphql-eslint/eslint-plugin') +}) +``` From 7ba2d43168773e9fff4da0b936dbb073597f1452 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:24:50 +0200 Subject: [PATCH 29/39] polish --- .github/workflows/pr.yaml | 3 +-- .github/workflows/release.yml | 3 +-- .github/workflows/tests.yml | 4 ++-- .github/workflows/website-integrity.yml | 6 +++--- .github/workflows/website.yml | 6 ++---- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index a25042531bb..fe6b5f1a9f3 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,8 +1,7 @@ name: pr on: pull_request: - branches: - - master + branches: [master, v4] jobs: dependencies: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b09f0c222e..45560fe9268 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,7 @@ name: release on: push: - branches: - - master + branches: [master] jobs: stable: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1d4e20da8bd..0ac5cd47a23 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,9 +2,9 @@ name: test on: push: - branches: [master] + branches: [master, v4] pull_request: - branches: [master] + branches: [master, v4] jobs: lint: diff --git a/.github/workflows/website-integrity.yml b/.github/workflows/website-integrity.yml index e59fa532a3e..3ab1ac2576a 100644 --- a/.github/workflows/website-integrity.yml +++ b/.github/workflows/website-integrity.yml @@ -13,7 +13,7 @@ jobs: - name: Fetch run: git fetch origin master - - name: Setup env + - name: Setup ENV uses: the-guild-org/shared-config/setup@main with: nodeVersion: 18 @@ -28,7 +28,7 @@ jobs: - name: Compare run: git diff origin/${{ github.base_ref }}.. -- website/route-lockfile.txt - - name: Diff to file + - name: Diff to File if: always() id: diff_result run: | @@ -36,7 +36,7 @@ jobs: echo "$(git diff origin/${{ github.base_ref }}.. -- website/route-lockfile.txt)" >> $GITHUB_OUTPUT echo EOF >> $GITHUB_OUTPUT - - name: Publish a message + - name: Publish a Message if: always() && contains(steps.diff_result.outputs.result, 'diff') uses: marocchino/sticky-pull-request-comment@v2 with: diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 2f140c430be..36dc26c895c 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -2,11 +2,9 @@ name: website on: push: - branches: - - master + branches: [master, v4] pull_request: - branches: - - master + branches: [master, v4] jobs: deployment: From 8bc4340bd165a46ab318bb7a70c66d68790d7fa2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 1 Aug 2023 16:32:02 +0000 Subject: [PATCH 30/39] chore(dependencies): updated changesets for modified dependencies --- .../@graphql-eslint_eslint-plugin-1792-dependencies.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md diff --git a/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md b/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md new file mode 100644 index 00000000000..c6199d14d8d --- /dev/null +++ b/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md @@ -0,0 +1,5 @@ +--- +"@graphql-eslint/eslint-plugin": patch +--- +dependencies updates: + - Removed dependency [`@babel/code-frame@^7.18.6` ↗︎](https://www.npmjs.com/package/@babel/code-frame/v/7.18.6) (from `dependencies`) From b5e8fc3e4d9135c362f7c70a6fb59946a0f7255b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 18:37:56 +0200 Subject: [PATCH 31/39] yoyou --- .changeset/strong-needles-compare.md | 2 ++ .github/workflows/pr.yaml | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/strong-needles-compare.md b/.changeset/strong-needles-compare.md index 847d6c78ae9..d29c6605f94 100644 --- a/.changeset/strong-needles-compare.md +++ b/.changeset/strong-needles-compare.md @@ -4,6 +4,8 @@ Remove `GraphQLRuleTester` from bundle, to test your rules use regular `RuleTester` from eslint +> **Note**: with this change unnecessary dependency `@babel/code-frame` was removed too + ```js import { RuleTester } from 'eslint' diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index fe6b5f1a9f3..a4cb02f78f1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,7 +1,7 @@ name: pr on: pull_request: - branches: [master, v4] + branches: [master] jobs: dependencies: diff --git a/package.json b/package.json index e83554c65a2..b7a74548701 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "prerelease": "NODE_ENV=production pnpm build", "prettier": "pnpm lint:prettier --write", "release": "changeset publish", - "test": "turbo run test" + "test": "turbo run test --filter=!website" }, "devDependencies": { "@changesets/changelog-github": "0.4.8", From 9f16e4ff1a53ee0ceaa66aae7abd481e4465b031 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:03:42 +0200 Subject: [PATCH 32/39] try --- packages/plugin/src/test-utils.ts | 8 ++++++++ packages/plugin/tests/alphabetize.spec.ts | 4 +--- packages/plugin/tests/description-style.spec.ts | 4 +--- packages/plugin/tests/eslint-directives.spec.ts | 4 +--- packages/plugin/tests/executable-definitions.spec.ts | 4 +--- packages/plugin/tests/fields-on-correct-type.spec.ts | 3 +-- packages/plugin/tests/no-undefined-variables.spec.ts | 4 +--- packages/rule-tester/src/index.ts | 10 ---------- 8 files changed, 14 insertions(+), 27 deletions(-) create mode 100644 packages/plugin/src/test-utils.ts diff --git a/packages/plugin/src/test-utils.ts b/packages/plugin/src/test-utils.ts new file mode 100644 index 00000000000..043ae0eee64 --- /dev/null +++ b/packages/plugin/src/test-utils.ts @@ -0,0 +1,8 @@ +import { RuleTester } from '@theguild/eslint-rule-tester'; + +export const ruleTester = new RuleTester({ + parser: require.resolve('@graphql-eslint/eslint-plugin'), + parserOptions: { + skipGraphQLConfig: true, + }, +}); diff --git a/packages/plugin/tests/alphabetize.spec.ts b/packages/plugin/tests/alphabetize.spec.ts index a9f52954d13..0462a617938 100644 --- a/packages/plugin/tests/alphabetize.spec.ts +++ b/packages/plugin/tests/alphabetize.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/alphabetize'; - -const ruleTester = new RuleTester(); +import { ruleTester } from '../src/test-utils'; const GROUP_ORDER_TEST = /* GraphQL */ ` type User { diff --git a/packages/plugin/tests/description-style.spec.ts b/packages/plugin/tests/description-style.spec.ts index 8f8818bbf1a..3a16482a37f 100644 --- a/packages/plugin/tests/description-style.spec.ts +++ b/packages/plugin/tests/description-style.spec.ts @@ -1,5 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/description-style'; +import { ruleTester } from '../src/test-utils'; const INLINE_SDL = /* GraphQL */ ` " Test " @@ -29,8 +29,6 @@ export const BLOCK_SDL = /* GraphQL */ ` } `; -const ruleTester = new RuleTester(); - ruleTester.run('description-style', rule, { valid: [ BLOCK_SDL, diff --git a/packages/plugin/tests/eslint-directives.spec.ts b/packages/plugin/tests/eslint-directives.spec.ts index 4745c43308c..ffbd007e170 100644 --- a/packages/plugin/tests/eslint-directives.spec.ts +++ b/packages/plugin/tests/eslint-directives.spec.ts @@ -1,9 +1,7 @@ import { join } from 'node:path'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule as noAnonymousOperations } from '../src/rules/no-anonymous-operations'; import { rule as noTypenamePrefix } from '../src/rules/no-typename-prefix'; - -const ruleTester = new RuleTester(); +import { ruleTester } from '../src/test-utils'; ruleTester.run('no-typename-prefix', noTypenamePrefix, { valid: [ diff --git a/packages/plugin/tests/executable-definitions.spec.ts b/packages/plugin/tests/executable-definitions.spec.ts index da8581a6a99..bcdbfb00988 100644 --- a/packages/plugin/tests/executable-definitions.spec.ts +++ b/packages/plugin/tests/executable-definitions.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; +import { ruleTester } from '../src/test-utils'; const TEST_SCHEMA = /* GraphQL */ ` type Query { @@ -23,8 +23,6 @@ const WITH_SCHEMA = { } as ParserOptions, }; -const ruleTester = new RuleTester(); - ruleTester.run('executable-definitions', GRAPHQL_JS_VALIDATIONS['executable-definitions'], { valid: [ { diff --git a/packages/plugin/tests/fields-on-correct-type.spec.ts b/packages/plugin/tests/fields-on-correct-type.spec.ts index 5079f37948e..29bfaf47d94 100644 --- a/packages/plugin/tests/fields-on-correct-type.spec.ts +++ b/packages/plugin/tests/fields-on-correct-type.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions, rules } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; +import { ruleTester } from '../src/test-utils'; const parserOptions: Pick = { schema: /* GraphQL */ ` @@ -13,7 +13,6 @@ const parserOptions: Pick = { } `, }; -const ruleTester = new RuleTester(); ruleTester.run('fields-on-correct-type', rules['fields-on-correct-type'], { valid: [], diff --git a/packages/plugin/tests/no-undefined-variables.spec.ts b/packages/plugin/tests/no-undefined-variables.spec.ts index 155643639b3..e7c76c7d129 100644 --- a/packages/plugin/tests/no-undefined-variables.spec.ts +++ b/packages/plugin/tests/no-undefined-variables.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rules } from '../src'; - -const ruleTester = new RuleTester(); +import { ruleTester } from '../src/test-utils'; ruleTester.run('no-undefined-variables', rules['no-undefined-variables'], { valid: [], diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index f68cd2a3b2b..5e28e6ed943 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -27,16 +27,6 @@ function applyFix(code: string, { range, text }: Rule.Fix): string { } export class RuleTester extends ESLintRuleTester { - constructor(parserOptions: ParserOptions) { - super({ - parser: require.resolve('@graphql-eslint/eslint-plugin'), - parserOptions: { - ...parserOptions, - skipGraphQLConfig: true, - }, - }); - } - fromMockFile(path: string): string { return readFileSync(resolve(__dirname, `../../plugin/tests/mocks/${path}`), 'utf-8'); } From 717865d50295656e84c0c40982912287f31ed7f8 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:06:23 +0200 Subject: [PATCH 33/39] try --- packages/plugin/tests/input-name.spec.ts | 4 +--- packages/plugin/tests/known-directives.spec.ts | 1 - packages/plugin/tests/known-fragment-names.spec.ts | 4 +--- packages/plugin/tests/lone-executable-definition.spec.ts | 4 +--- packages/plugin/tests/lone-schema-definition.spec.ts | 4 +--- packages/plugin/tests/match-document-filename.spec.ts | 4 +--- packages/plugin/tests/naming-convention.spec.ts | 4 +--- packages/plugin/tests/no-anonymous-operations.spec.ts | 4 +--- .../tests/no-case-insensitive-enum-values-duplicates.spec.ts | 4 +--- packages/plugin/tests/no-undefined-variables.spec.ts | 2 +- packages/plugin/{src => tests}/test-utils.ts | 0 11 files changed, 9 insertions(+), 26 deletions(-) rename packages/plugin/{src => tests}/test-utils.ts (100%) diff --git a/packages/plugin/tests/input-name.spec.ts b/packages/plugin/tests/input-name.spec.ts index c3000a43d5c..382346586e5 100644 --- a/packages/plugin/tests/input-name.spec.ts +++ b/packages/plugin/tests/input-name.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/input-name'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('input-name', rule, { valid: [ diff --git a/packages/plugin/tests/known-directives.spec.ts b/packages/plugin/tests/known-directives.spec.ts index 63d18949a9b..f5cece067e1 100644 --- a/packages/plugin/tests/known-directives.spec.ts +++ b/packages/plugin/tests/known-directives.spec.ts @@ -1,5 +1,4 @@ import { rules } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; const ruleTester = new RuleTester({ schema: /* GraphQL */ ` diff --git a/packages/plugin/tests/known-fragment-names.spec.ts b/packages/plugin/tests/known-fragment-names.spec.ts index 53fd989d1ba..e669f412c58 100644 --- a/packages/plugin/tests/known-fragment-names.spec.ts +++ b/packages/plugin/tests/known-fragment-names.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('known-fragment-names', rules['known-fragment-names'], { valid: [ diff --git a/packages/plugin/tests/lone-executable-definition.spec.ts b/packages/plugin/tests/lone-executable-definition.spec.ts index 31480d2faa3..75323ae093b 100644 --- a/packages/plugin/tests/lone-executable-definition.spec.ts +++ b/packages/plugin/tests/lone-executable-definition.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/lone-executable-definition'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('lone-executable-definition', rule, { valid: [ diff --git a/packages/plugin/tests/lone-schema-definition.spec.ts b/packages/plugin/tests/lone-schema-definition.spec.ts index 16636f75954..d40659c92ad 100644 --- a/packages/plugin/tests/lone-schema-definition.spec.ts +++ b/packages/plugin/tests/lone-schema-definition.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('lone-schema-definition', GRAPHQL_JS_VALIDATIONS['lone-schema-definition'], { valid: [ diff --git a/packages/plugin/tests/match-document-filename.spec.ts b/packages/plugin/tests/match-document-filename.spec.ts index e95eb670623..e6034889c9b 100644 --- a/packages/plugin/tests/match-document-filename.spec.ts +++ b/packages/plugin/tests/match-document-filename.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/match-document-filename'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('match-document-filename', rule, { valid: [ diff --git a/packages/plugin/tests/naming-convention.spec.ts b/packages/plugin/tests/naming-convention.spec.ts index 9ee0733e66e..0607dc2f5a9 100644 --- a/packages/plugin/tests/naming-convention.spec.ts +++ b/packages/plugin/tests/naming-convention.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/naming-convention'; - -const ruleTester = new RuleTester(); +import { ruleTester } from "./test-utils"; ruleTester.run('naming-convention', rule, { valid: [ diff --git a/packages/plugin/tests/no-anonymous-operations.spec.ts b/packages/plugin/tests/no-anonymous-operations.spec.ts index 28c60acd1fd..62bee2f51cb 100644 --- a/packages/plugin/tests/no-anonymous-operations.spec.ts +++ b/packages/plugin/tests/no-anonymous-operations.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-anonymous-operations'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-anonymous-operations', rule, { valid: ['query myQuery { a }', 'mutation doSomething { a }', 'subscription myData { a }'], diff --git a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts index 009ff1bb78a..f29ef3e181e 100644 --- a/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts +++ b/packages/plugin/tests/no-case-insensitive-enum-values-duplicates.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-case-insensitive-enum-values-duplicates'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-case-insensitive-enum-values-duplicates', rule, { valid: [], diff --git a/packages/plugin/tests/no-undefined-variables.spec.ts b/packages/plugin/tests/no-undefined-variables.spec.ts index e7c76c7d129..95de47b0b14 100644 --- a/packages/plugin/tests/no-undefined-variables.spec.ts +++ b/packages/plugin/tests/no-undefined-variables.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; ruleTester.run('no-undefined-variables', rules['no-undefined-variables'], { valid: [], diff --git a/packages/plugin/src/test-utils.ts b/packages/plugin/tests/test-utils.ts similarity index 100% rename from packages/plugin/src/test-utils.ts rename to packages/plugin/tests/test-utils.ts From 10dde923dfdc5b52699b5870bf6220749f65292b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:08:37 +0200 Subject: [PATCH 34/39] try --- .../@graphql-eslint_eslint-plugin-1792-dependencies.md | 8 ++++++-- .changeset/strong-needles-compare.md | 2 +- packages/plugin/tests/input-name.spec.ts | 2 +- packages/plugin/tests/known-fragment-names.spec.ts | 2 +- packages/plugin/tests/lone-executable-definition.spec.ts | 2 +- packages/plugin/tests/lone-schema-definition.spec.ts | 2 +- packages/plugin/tests/match-document-filename.spec.ts | 2 +- packages/plugin/tests/naming-convention.spec.ts | 2 +- packages/plugin/tests/no-deprecated.spec.ts | 3 +-- packages/plugin/tests/no-duplicate-fields.spec.ts | 4 +--- packages/plugin/tests/no-hashtag-description.spec.ts | 4 +--- packages/plugin/tests/no-one-place-fragments.spec.ts | 4 +--- packages/plugin/tests/no-root-type.spec.ts | 4 +--- .../tests/no-scalar-result-type-on-mutation.spec.ts | 4 +--- packages/plugin/tests/no-typename-prefix.spec.ts | 4 +--- packages/plugin/tests/no-unreachable-types.spec.ts | 4 +--- .../plugin/tests/require-nullable-result-in-root.spec.ts | 4 +--- 17 files changed, 22 insertions(+), 35 deletions(-) diff --git a/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md b/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md index c6199d14d8d..ff7f426e403 100644 --- a/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md +++ b/.changeset/@graphql-eslint_eslint-plugin-1792-dependencies.md @@ -1,5 +1,9 @@ --- -"@graphql-eslint/eslint-plugin": patch +'@graphql-eslint/eslint-plugin': patch --- + dependencies updates: - - Removed dependency [`@babel/code-frame@^7.18.6` ↗︎](https://www.npmjs.com/package/@babel/code-frame/v/7.18.6) (from `dependencies`) + +- Removed dependency + [`@babel/code-frame@^7.18.6` ↗︎](https://www.npmjs.com/package/@babel/code-frame/v/7.18.6) (from + `dependencies`) diff --git a/.changeset/strong-needles-compare.md b/.changeset/strong-needles-compare.md index d29c6605f94..d4250b75cda 100644 --- a/.changeset/strong-needles-compare.md +++ b/.changeset/strong-needles-compare.md @@ -4,7 +4,7 @@ Remove `GraphQLRuleTester` from bundle, to test your rules use regular `RuleTester` from eslint -> **Note**: with this change unnecessary dependency `@babel/code-frame` was removed too +> **Note**: with this change unnecessary dependency `@babel/code-frame` was removed too ```js import { RuleTester } from 'eslint' diff --git a/packages/plugin/tests/input-name.spec.ts b/packages/plugin/tests/input-name.spec.ts index 382346586e5..6e5e75efe4c 100644 --- a/packages/plugin/tests/input-name.spec.ts +++ b/packages/plugin/tests/input-name.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/input-name'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('input-name', rule, { valid: [ diff --git a/packages/plugin/tests/known-fragment-names.spec.ts b/packages/plugin/tests/known-fragment-names.spec.ts index e669f412c58..d8ecbdb45be 100644 --- a/packages/plugin/tests/known-fragment-names.spec.ts +++ b/packages/plugin/tests/known-fragment-names.spec.ts @@ -1,6 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('known-fragment-names', rules['known-fragment-names'], { valid: [ diff --git a/packages/plugin/tests/lone-executable-definition.spec.ts b/packages/plugin/tests/lone-executable-definition.spec.ts index 75323ae093b..b6f18100ae8 100644 --- a/packages/plugin/tests/lone-executable-definition.spec.ts +++ b/packages/plugin/tests/lone-executable-definition.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/lone-executable-definition'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('lone-executable-definition', rule, { valid: [ diff --git a/packages/plugin/tests/lone-schema-definition.spec.ts b/packages/plugin/tests/lone-schema-definition.spec.ts index d40659c92ad..bc1b9da3a68 100644 --- a/packages/plugin/tests/lone-schema-definition.spec.ts +++ b/packages/plugin/tests/lone-schema-definition.spec.ts @@ -1,5 +1,5 @@ import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('lone-schema-definition', GRAPHQL_JS_VALIDATIONS['lone-schema-definition'], { valid: [ diff --git a/packages/plugin/tests/match-document-filename.spec.ts b/packages/plugin/tests/match-document-filename.spec.ts index e6034889c9b..08dbaa77158 100644 --- a/packages/plugin/tests/match-document-filename.spec.ts +++ b/packages/plugin/tests/match-document-filename.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/match-document-filename'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('match-document-filename', rule, { valid: [ diff --git a/packages/plugin/tests/naming-convention.spec.ts b/packages/plugin/tests/naming-convention.spec.ts index 0607dc2f5a9..9b144a1168b 100644 --- a/packages/plugin/tests/naming-convention.spec.ts +++ b/packages/plugin/tests/naming-convention.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/naming-convention'; -import { ruleTester } from "./test-utils"; +import { ruleTester } from './test-utils'; ruleTester.run('naming-convention', rule, { valid: [ diff --git a/packages/plugin/tests/no-deprecated.spec.ts b/packages/plugin/tests/no-deprecated.spec.ts index 95367c10cc4..e0a0eb809e6 100644 --- a/packages/plugin/tests/no-deprecated.spec.ts +++ b/packages/plugin/tests/no-deprecated.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-deprecated'; +import { ruleTester } from './test-utils'; const TEST_SCHEMA = /* GraphQL */ ` type Query { @@ -26,7 +26,6 @@ const WITH_SCHEMA = { documents: [], } as ParserOptions, }; -const ruleTester = new RuleTester(); ruleTester.run('no-deprecated', rule, { valid: [ diff --git a/packages/plugin/tests/no-duplicate-fields.spec.ts b/packages/plugin/tests/no-duplicate-fields.spec.ts index 9052bb73165..32e0b3a7afb 100644 --- a/packages/plugin/tests/no-duplicate-fields.spec.ts +++ b/packages/plugin/tests/no-duplicate-fields.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-duplicate-fields'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-duplicate-fields', rule, { valid: [], diff --git a/packages/plugin/tests/no-hashtag-description.spec.ts b/packages/plugin/tests/no-hashtag-description.spec.ts index b888e93bb94..4f577d41372 100644 --- a/packages/plugin/tests/no-hashtag-description.spec.ts +++ b/packages/plugin/tests/no-hashtag-description.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RULE_ID } from '../src/rules/no-hashtag-description'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-hashtag-description', rule, { valid: [ diff --git a/packages/plugin/tests/no-one-place-fragments.spec.ts b/packages/plugin/tests/no-one-place-fragments.spec.ts index 8921828dc7e..28deb2d4d80 100644 --- a/packages/plugin/tests/no-one-place-fragments.spec.ts +++ b/packages/plugin/tests/no-one-place-fragments.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-one-place-fragments'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-one-place-fragments', rule, { valid: [ diff --git a/packages/plugin/tests/no-root-type.spec.ts b/packages/plugin/tests/no-root-type.spec.ts index 96d042d0b47..2e94f8813c8 100644 --- a/packages/plugin/tests/no-root-type.spec.ts +++ b/packages/plugin/tests/no-root-type.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/no-root-type'; +import { ruleTester } from './test-utils'; const useSchema = ( code: string, @@ -12,8 +12,6 @@ const useSchema = ( }, }); -const ruleTester = new RuleTester(); - ruleTester.run('no-root-type', rule, { valid: [ { diff --git a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts index 3e718091e44..bcfc821e17a 100644 --- a/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts +++ b/packages/plugin/tests/no-scalar-result-type-on-mutation.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-scalar-result-type-on-mutation'; +import { ruleTester } from './test-utils'; const useSchema = ( code: string, @@ -17,8 +17,6 @@ const useSchema = ( }, }); -const ruleTester = new RuleTester(); - ruleTester.run('no-scalar-result-type-on-mutation', rule, { valid: [ useSchema(/* GraphQL */ ` diff --git a/packages/plugin/tests/no-typename-prefix.spec.ts b/packages/plugin/tests/no-typename-prefix.spec.ts index 96edd9c319e..8d5e0ee68ae 100644 --- a/packages/plugin/tests/no-typename-prefix.spec.ts +++ b/packages/plugin/tests/no-typename-prefix.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-typename-prefix'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-typename-prefix', rule, { valid: [ diff --git a/packages/plugin/tests/no-unreachable-types.spec.ts b/packages/plugin/tests/no-unreachable-types.spec.ts index 9af33febd69..52d562ea288 100644 --- a/packages/plugin/tests/no-unreachable-types.spec.ts +++ b/packages/plugin/tests/no-unreachable-types.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-unreachable-types'; +import { ruleTester } from './test-utils'; const useSchema = ( schema: string, @@ -11,8 +11,6 @@ const useSchema = ( }; }; -const ruleTester = new RuleTester(); - ruleTester.run('no-unreachable-types', rule, { valid: [ useSchema(/* GraphQL */ ` diff --git a/packages/plugin/tests/require-nullable-result-in-root.spec.ts b/packages/plugin/tests/require-nullable-result-in-root.spec.ts index 9e6c169ad6f..6748d750275 100644 --- a/packages/plugin/tests/require-nullable-result-in-root.spec.ts +++ b/packages/plugin/tests/require-nullable-result-in-root.spec.ts @@ -1,8 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-nullable-result-in-root'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function useSchema(code: string): { code: string; parserOptions: Omit } { return { From fec413feaba04d2b2b11ed5f20bd42414ab2d19d Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:10:51 +0200 Subject: [PATCH 35/39] try --- packages/plugin/tests/no-unused-fields.spec.ts | 1 - packages/plugin/tests/no-unused-fragments.spec.ts | 4 +--- packages/plugin/tests/no-unused-variables.spec.ts | 4 +--- packages/plugin/tests/possible-type-extension.spec.ts | 4 +--- packages/plugin/tests/relay-arguments.spec.ts | 4 +--- packages/plugin/tests/relay-connection-types.spec.ts | 4 +--- packages/plugin/tests/relay-edge-types.spec.ts | 4 +--- packages/plugin/tests/relay-page-info.spec.ts | 4 +--- packages/plugin/tests/require-deprecation-date.spec.ts | 4 +--- packages/plugin/tests/require-description.spec.ts | 3 +-- packages/plugin/tests/unique-fragment-name.spec.ts | 4 +--- packages/plugin/tests/unique-operation-name.spec.ts | 4 +--- packages/plugin/tests/unique-type-names.spec.ts | 4 +--- 13 files changed, 12 insertions(+), 36 deletions(-) diff --git a/packages/plugin/tests/no-unused-fields.spec.ts b/packages/plugin/tests/no-unused-fields.spec.ts index b192d0a88b0..2248120f0a0 100644 --- a/packages/plugin/tests/no-unused-fields.spec.ts +++ b/packages/plugin/tests/no-unused-fields.spec.ts @@ -1,4 +1,3 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/no-unused-fields'; const SCHEMA = /* GraphQL */ ` diff --git a/packages/plugin/tests/no-unused-fragments.spec.ts b/packages/plugin/tests/no-unused-fragments.spec.ts index 0a255d75fcf..9d2c273743e 100644 --- a/packages/plugin/tests/no-unused-fragments.spec.ts +++ b/packages/plugin/tests/no-unused-fragments.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; import { rules } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-unused-fragments', rules['no-unused-fragments'], { valid: [ diff --git a/packages/plugin/tests/no-unused-variables.spec.ts b/packages/plugin/tests/no-unused-variables.spec.ts index 5b18e2f593e..d7b4b8b6d3c 100644 --- a/packages/plugin/tests/no-unused-variables.spec.ts +++ b/packages/plugin/tests/no-unused-variables.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rules } from '../src'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('no-unused-variables', rules['no-unused-variables'], { valid: [ diff --git a/packages/plugin/tests/possible-type-extension.spec.ts b/packages/plugin/tests/possible-type-extension.spec.ts index f43dbbaccd8..5ac68d5072d 100644 --- a/packages/plugin/tests/possible-type-extension.spec.ts +++ b/packages/plugin/tests/possible-type-extension.spec.ts @@ -1,8 +1,6 @@ import { join } from 'node:path'; import { ParserOptions, rules } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; const useUserSchema = ( code: string, diff --git a/packages/plugin/tests/relay-arguments.spec.ts b/packages/plugin/tests/relay-arguments.spec.ts index eb1af10e3db..9d161cf18b7 100644 --- a/packages/plugin/tests/relay-arguments.spec.ts +++ b/packages/plugin/tests/relay-arguments.spec.ts @@ -1,8 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/relay-arguments'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function useSchema(code: string): { code: string; parserOptions: Pick } { return { diff --git a/packages/plugin/tests/relay-connection-types.spec.ts b/packages/plugin/tests/relay-connection-types.spec.ts index a3db2ef503c..a988f0c4360 100644 --- a/packages/plugin/tests/relay-connection-types.spec.ts +++ b/packages/plugin/tests/relay-connection-types.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/relay-connection-types'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('relay-connection-types', rule, { valid: [ diff --git a/packages/plugin/tests/relay-edge-types.spec.ts b/packages/plugin/tests/relay-edge-types.spec.ts index 2bfd20493c9..c43466e2718 100644 --- a/packages/plugin/tests/relay-edge-types.spec.ts +++ b/packages/plugin/tests/relay-edge-types.spec.ts @@ -1,8 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/relay-edge-types'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function useSchema(code: string): { code: string; parserOptions: Pick } { return { diff --git a/packages/plugin/tests/relay-page-info.spec.ts b/packages/plugin/tests/relay-page-info.spec.ts index 5ea0c7ee7bb..3ae600eaf85 100644 --- a/packages/plugin/tests/relay-page-info.spec.ts +++ b/packages/plugin/tests/relay-page-info.spec.ts @@ -1,8 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/relay-page-info'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function useSchema(code: string): { code: string; parserOptions: Pick } { return { diff --git a/packages/plugin/tests/require-deprecation-date.spec.ts b/packages/plugin/tests/require-deprecation-date.spec.ts index 0021ad29742..077633a5a4f 100644 --- a/packages/plugin/tests/require-deprecation-date.spec.ts +++ b/packages/plugin/tests/require-deprecation-date.spec.ts @@ -1,5 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/require-deprecation-date'; +import { ruleTester } from './test-utils'; const now = new Date(); now.setDate(now.getDate() + 1); @@ -10,8 +10,6 @@ const year = now.getFullYear(); const tomorrow = `${day}/${month}/${year}`; -const ruleTester = new RuleTester(); - ruleTester.run('require-deprecation-date', rule, { valid: [ 'type User { firstName: String }', diff --git a/packages/plugin/tests/require-description.spec.ts b/packages/plugin/tests/require-description.spec.ts index e6674e251c6..10f126d8b91 100644 --- a/packages/plugin/tests/require-description.spec.ts +++ b/packages/plugin/tests/require-description.spec.ts @@ -1,8 +1,7 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions, RULE_ID } from '../src/rules/require-description'; +import { ruleTester } from './test-utils'; -const ruleTester = new RuleTester(); const OPERATION = { OperationDefinition: true }; ruleTester.run('require-description', rule, { diff --git a/packages/plugin/tests/unique-fragment-name.spec.ts b/packages/plugin/tests/unique-fragment-name.spec.ts index 1d358fdbd0a..7697cd44efe 100644 --- a/packages/plugin/tests/unique-fragment-name.spec.ts +++ b/packages/plugin/tests/unique-fragment-name.spec.ts @@ -1,7 +1,7 @@ import { join } from 'node:path'; import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/unique-fragment-name'; +import { ruleTester } from './test-utils'; const TEST_FRAGMENT = /* GraphQL */ ` fragment HasIdFields on HasId { @@ -17,8 +17,6 @@ const SIBLING_FRAGMENTS = ( }, }); -const ruleTester = new RuleTester(); - ruleTester.run('unique-fragment-name', rule, { valid: [ { diff --git a/packages/plugin/tests/unique-operation-name.spec.ts b/packages/plugin/tests/unique-operation-name.spec.ts index df7c961c5a2..fe745d2f4e5 100644 --- a/packages/plugin/tests/unique-operation-name.spec.ts +++ b/packages/plugin/tests/unique-operation-name.spec.ts @@ -1,7 +1,7 @@ import { join } from 'node:path'; import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/unique-operation-name'; +import { ruleTester } from './test-utils'; const TEST_OPERATION = 'query test { foo }'; @@ -13,8 +13,6 @@ const SIBLING_OPERATIONS = ( }, }); -const ruleTester = new RuleTester(); - ruleTester.run('unique-operation-name', rule, { valid: [ { diff --git a/packages/plugin/tests/unique-type-names.spec.ts b/packages/plugin/tests/unique-type-names.spec.ts index 2504513f6ae..5725b8974d3 100644 --- a/packages/plugin/tests/unique-type-names.spec.ts +++ b/packages/plugin/tests/unique-type-names.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; +import { ruleTester } from './test-utils'; const TEST_SCHEMA = /* GraphQL */ ` type Query { @@ -16,8 +16,6 @@ const WITH_SCHEMA = { } as ParserOptions, }; -const ruleTester = new RuleTester(); - ruleTester.run('unique-type-names', GRAPHQL_JS_VALIDATIONS['unique-type-names'], { valid: [ { ...WITH_SCHEMA, code: TEST_SCHEMA }, From dc1edb536c0d181e14f6c9357a1b991392bfb36a Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:13:12 +0200 Subject: [PATCH 36/39] try --- packages/plugin/tests/require-deprecation-reason.spec.ts | 4 +--- .../require-field-of-type-query-in-mutation-result.spec.ts | 4 +--- packages/plugin/tests/require-id-when-available.spec.ts | 3 +-- packages/plugin/tests/require-import-fragment.spec.ts | 4 +--- .../plugin/tests/require-nullable-fields-with-oneof.spec.ts | 4 +--- packages/plugin/tests/require-type-pattern-with-oneof.spec.ts | 4 +--- packages/plugin/tests/selection-set-depth.spec.ts | 4 +--- packages/plugin/tests/strict-id-in-types.spec.ts | 4 +--- 8 files changed, 8 insertions(+), 23 deletions(-) diff --git a/packages/plugin/tests/require-deprecation-reason.spec.ts b/packages/plugin/tests/require-deprecation-reason.spec.ts index c4080d0ffd8..6c2284b281c 100644 --- a/packages/plugin/tests/require-deprecation-reason.spec.ts +++ b/packages/plugin/tests/require-deprecation-reason.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-deprecation-reason'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('require-deprecation-reason', rule, { valid: [ diff --git a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts index bcaf5bf27e2..df6c0440f34 100644 --- a/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts +++ b/packages/plugin/tests/require-field-of-type-query-in-mutation-result.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-field-of-type-query-in-mutation-result'; +import { ruleTester } from './test-utils'; const useSchema = ( code: string, @@ -17,8 +17,6 @@ const useSchema = ( }, }); -const ruleTester = new RuleTester(); - ruleTester.run('require-field-of-type-query-in-mutation-result', rule, { valid: [ useSchema(/* GraphQL */ ` diff --git a/packages/plugin/tests/require-id-when-available.spec.ts b/packages/plugin/tests/require-id-when-available.spec.ts index 6d82158e948..9d8498744cc 100644 --- a/packages/plugin/tests/require-id-when-available.spec.ts +++ b/packages/plugin/tests/require-id-when-available.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/require-id-when-available'; +import { ruleTester } from './test-utils'; const TEST_SCHEMA = /* GraphQL */ ` type Query { @@ -67,7 +67,6 @@ const WITH_SCHEMA = { } as ParserOptions, }; -const ruleTester = new RuleTester(); const MESSAGE_ID = { messageId: 'require-id-when-available' }; const DOCUMENT_WITH_UNION = /* GraphQL */ ` diff --git a/packages/plugin/tests/require-import-fragment.spec.ts b/packages/plugin/tests/require-import-fragment.spec.ts index acb08c9848f..b06976db197 100644 --- a/packages/plugin/tests/require-import-fragment.spec.ts +++ b/packages/plugin/tests/require-import-fragment.spec.ts @@ -1,11 +1,9 @@ import { join } from 'node:path'; import { GraphQLInvalidTestCase } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-import-fragment'; import { Linter } from 'eslint'; import ParserOptions = Linter.ParserOptions; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function withMocks({ name, diff --git a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts index f052850d2f7..1e64c9465dd 100644 --- a/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts +++ b/packages/plugin/tests/require-nullable-fields-with-oneof.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-nullable-fields-with-oneof'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('require-nullable-fields-with-oneof', rule, { valid: [ diff --git a/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts b/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts index 213b84c0b22..9cb82548585 100644 --- a/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts +++ b/packages/plugin/tests/require-type-pattern-with-oneof.spec.ts @@ -1,7 +1,5 @@ -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule } from '../src/rules/require-type-pattern-with-oneof'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; ruleTester.run('require-type-pattern-with-oneof', rule, { valid: [ diff --git a/packages/plugin/tests/selection-set-depth.spec.ts b/packages/plugin/tests/selection-set-depth.spec.ts index b9552db29b6..d130d3664de 100644 --- a/packages/plugin/tests/selection-set-depth.spec.ts +++ b/packages/plugin/tests/selection-set-depth.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/selection-set-depth'; +import { ruleTester } from './test-utils'; const WITH_SIBLINGS = { parserOptions: { @@ -8,8 +8,6 @@ const WITH_SIBLINGS = { } as ParserOptions, }; -const ruleTester = new RuleTester(); - ruleTester.run('selection-set-depth', rule, { valid: [ { diff --git a/packages/plugin/tests/strict-id-in-types.spec.ts b/packages/plugin/tests/strict-id-in-types.spec.ts index 04046581b32..131e2f4143d 100644 --- a/packages/plugin/tests/strict-id-in-types.spec.ts +++ b/packages/plugin/tests/strict-id-in-types.spec.ts @@ -1,8 +1,6 @@ import { ParserOptions } from '../src'; -import { RuleTester } from '@theguild/eslint-rule-tester'; import { rule, RuleOptions } from '../src/rules/strict-id-in-types'; - -const ruleTester = new RuleTester(); +import { ruleTester } from './test-utils'; function useSchema(code: string): { code: string; parserOptions: Pick } { return { From 55748dac7141b0830f0211090b9b905a6c605bde Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:16:57 +0200 Subject: [PATCH 37/39] try --- packages/plugin/tests/known-directives.spec.ts | 3 +++ packages/plugin/tests/no-unused-fields.spec.ts | 4 +++- packages/plugin/tests/test-utils.ts | 6 ++++-- packages/rule-tester/src/index.ts | 2 -- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/plugin/tests/known-directives.spec.ts b/packages/plugin/tests/known-directives.spec.ts index f5cece067e1..b9d1e2405b0 100644 --- a/packages/plugin/tests/known-directives.spec.ts +++ b/packages/plugin/tests/known-directives.spec.ts @@ -1,6 +1,9 @@ import { rules } from '../src'; +import { RuleTester } from '@theguild/eslint-rule-tester'; +import { DEFAULT_CONFIG } from './test-utils'; const ruleTester = new RuleTester({ + ...DEFAULT_CONFIG, schema: /* GraphQL */ ` type User { id: ID! diff --git a/packages/plugin/tests/no-unused-fields.spec.ts b/packages/plugin/tests/no-unused-fields.spec.ts index 2248120f0a0..c57c1b48372 100644 --- a/packages/plugin/tests/no-unused-fields.spec.ts +++ b/packages/plugin/tests/no-unused-fields.spec.ts @@ -1,4 +1,6 @@ import { rule } from '../src/rules/no-unused-fields'; +import { RuleTester } from '@theguild/eslint-rule-tester'; +import { DEFAULT_CONFIG } from './test-utils'; const SCHEMA = /* GraphQL */ ` type User { @@ -37,7 +39,7 @@ const SCHEMA = /* GraphQL */ ` } `; -const ruleTester = new RuleTester({ schema: SCHEMA }); +const ruleTester = new RuleTester({ ...DEFAULT_CONFIG, schema: SCHEMA }); ruleTester.run('no-unused-fields', rule, { valid: [ diff --git a/packages/plugin/tests/test-utils.ts b/packages/plugin/tests/test-utils.ts index 043ae0eee64..ba9eb412c54 100644 --- a/packages/plugin/tests/test-utils.ts +++ b/packages/plugin/tests/test-utils.ts @@ -1,8 +1,10 @@ import { RuleTester } from '@theguild/eslint-rule-tester'; -export const ruleTester = new RuleTester({ +export const DEFAULT_CONFIG = { parser: require.resolve('@graphql-eslint/eslint-plugin'), parserOptions: { skipGraphQLConfig: true, }, -}); +}; + +export const ruleTester = new RuleTester(DEFAULT_CONFIG); diff --git a/packages/rule-tester/src/index.ts b/packages/rule-tester/src/index.ts index 5e28e6ed943..47a3579e670 100644 --- a/packages/rule-tester/src/index.ts +++ b/packages/rule-tester/src/index.ts @@ -1,11 +1,9 @@ import { readFileSync } from 'node:fs'; import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { createRequire } from 'node:module'; import { codeFrameColumns } from '@babel/code-frame'; import { AST, Linter, Rule, RuleTester as ESLintRuleTester } from 'eslint'; -const require = createRequire(import.meta.url); const __dirname = dirname(fileURLToPath(import.meta.url)); type ValidTestCase> = Omit< From 26fe76c0eacf0594a9194dfe031e71f52966287c Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:18:40 +0200 Subject: [PATCH 38/39] try --- .../plugin/tests/known-directives.spec.ts | 19 +++++++++++-------- .../plugin/tests/no-unused-fields.spec.ts | 8 +++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/plugin/tests/known-directives.spec.ts b/packages/plugin/tests/known-directives.spec.ts index b9d1e2405b0..fa60d40dfc0 100644 --- a/packages/plugin/tests/known-directives.spec.ts +++ b/packages/plugin/tests/known-directives.spec.ts @@ -4,15 +4,18 @@ import { DEFAULT_CONFIG } from './test-utils'; const ruleTester = new RuleTester({ ...DEFAULT_CONFIG, - schema: /* GraphQL */ ` - type User { - id: ID! - } + parserOptions: { + ...DEFAULT_CONFIG.parserOptions, + schema: /* GraphQL */ ` + type User { + id: ID! + } - type Query { - user: User - } - `, + type Query { + user: User + } + `, + }, }); ruleTester.run<[{ ignoreClientDirectives: string[] }]>( diff --git a/packages/plugin/tests/no-unused-fields.spec.ts b/packages/plugin/tests/no-unused-fields.spec.ts index c57c1b48372..3ce922792e3 100644 --- a/packages/plugin/tests/no-unused-fields.spec.ts +++ b/packages/plugin/tests/no-unused-fields.spec.ts @@ -39,7 +39,13 @@ const SCHEMA = /* GraphQL */ ` } `; -const ruleTester = new RuleTester({ ...DEFAULT_CONFIG, schema: SCHEMA }); +const ruleTester = new RuleTester({ + ...DEFAULT_CONFIG, + parserOptions: { + ...DEFAULT_CONFIG.parserOptions, + schema: SCHEMA, + }, +}); ruleTester.run('no-unused-fields', rule, { valid: [ From 3360336d86fc9e738d42c78a6a57c2cd4bf0d657 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 1 Aug 2023 19:21:51 +0200 Subject: [PATCH 39/39] try --- .../lone-schema-definition.spec.md | 30 +++++++++---------- packages/plugin/tests/alphabetize.spec.ts | 2 +- .../plugin/tests/description-style.spec.ts | 2 +- .../plugin/tests/eslint-directives.spec.ts | 2 +- .../tests/executable-definitions.spec.ts | 2 +- .../tests/fields-on-correct-type.spec.ts | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md b/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md index 60a3d2719b9..261ac984ca7 100644 --- a/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md +++ b/packages/plugin/tests/__snapshots__/lone-schema-definition.spec.md @@ -3,26 +3,26 @@ exports[`lone-schema-definition > invalid > Invalid #1 1`] = ` #### ⌨️ Code - 1 | type Query { - 2 | foo: String - 3 | } + 1 | type Query { + 2 | foo: String + 3 | } 4 | - 5 | schema { - 6 | query: Query - 7 | } + 5 | schema { + 6 | query: Query + 7 | } 8 | - 9 | type RootQuery { - 10 | foo: String - 11 | } + 9 | type RootQuery { + 10 | foo: String + 11 | } 12 | - 13 | schema { - 14 | query: RootQuery - 15 | } + 13 | schema { + 14 | query: RootQuery + 15 | } #### ❌ Error 12 | - > 13 | schema { - | ^^^^^^ Must provide only one schema definition. - 14 | query: RootQuery + > 13 | schema { + | ^^^^^^ Must provide only one schema definition. + 14 | query: RootQuery `; diff --git a/packages/plugin/tests/alphabetize.spec.ts b/packages/plugin/tests/alphabetize.spec.ts index 0462a617938..a5be17f3079 100644 --- a/packages/plugin/tests/alphabetize.spec.ts +++ b/packages/plugin/tests/alphabetize.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/alphabetize'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; const GROUP_ORDER_TEST = /* GraphQL */ ` type User { diff --git a/packages/plugin/tests/description-style.spec.ts b/packages/plugin/tests/description-style.spec.ts index 3a16482a37f..3c538eb5a0c 100644 --- a/packages/plugin/tests/description-style.spec.ts +++ b/packages/plugin/tests/description-style.spec.ts @@ -1,5 +1,5 @@ import { rule, RuleOptions } from '../src/rules/description-style'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; const INLINE_SDL = /* GraphQL */ ` " Test " diff --git a/packages/plugin/tests/eslint-directives.spec.ts b/packages/plugin/tests/eslint-directives.spec.ts index ffbd007e170..e3a6114088d 100644 --- a/packages/plugin/tests/eslint-directives.spec.ts +++ b/packages/plugin/tests/eslint-directives.spec.ts @@ -1,7 +1,7 @@ import { join } from 'node:path'; import { rule as noAnonymousOperations } from '../src/rules/no-anonymous-operations'; import { rule as noTypenamePrefix } from '../src/rules/no-typename-prefix'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; ruleTester.run('no-typename-prefix', noTypenamePrefix, { valid: [ diff --git a/packages/plugin/tests/executable-definitions.spec.ts b/packages/plugin/tests/executable-definitions.spec.ts index bcdbfb00988..7135f77fe24 100644 --- a/packages/plugin/tests/executable-definitions.spec.ts +++ b/packages/plugin/tests/executable-definitions.spec.ts @@ -1,6 +1,6 @@ import { ParserOptions } from '../src'; import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; const TEST_SCHEMA = /* GraphQL */ ` type Query { diff --git a/packages/plugin/tests/fields-on-correct-type.spec.ts b/packages/plugin/tests/fields-on-correct-type.spec.ts index 29bfaf47d94..a312df67d03 100644 --- a/packages/plugin/tests/fields-on-correct-type.spec.ts +++ b/packages/plugin/tests/fields-on-correct-type.spec.ts @@ -1,5 +1,5 @@ import { ParserOptions, rules } from '../src'; -import { ruleTester } from '../src/test-utils'; +import { ruleTester } from './test-utils'; const parserOptions: Pick = { schema: /* GraphQL */ `