UNPKG

@graphql-eslint/eslint-plugin

Version:
626 lines (622 loc) • 30.7 kB
import { CaseStyle } from './utils.cjs'; export { requireGraphQLOperations, requireGraphQLSchema } from './utils.cjs'; import * as graphql from 'graphql'; import { GraphQLESLintRule } from './types.cjs'; export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf } from './types.cjs'; import * as eslint from 'eslint'; import { Block } from './processor.cjs'; export { configs } from './configs/index.cjs'; import { parseForESLint } from './parser.cjs'; export { parser } from './parser.cjs'; export { rules } from './rules/index.cjs'; export { IGraphQLConfig } from 'graphql-config'; export { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck'; export { GraphQLESTreeNode } from './estree-converter/types.cjs'; import 'estree'; import './siblings.cjs'; import '@graphql-tools/utils'; import 'json-schema-to-ts'; declare const processors: { graphql: { meta: { name: string; version: string | undefined; }; supportsAutofix: true; preprocess(code: string, filePath: string): (string | Block)[]; postprocess(messages: eslint.Linter.LintMessage[][], filePath: string): eslint.Linter.LintMessage[]; }; }; declare const _default: { parser: { parseForESLint: typeof parseForESLint; meta: { name: string; version: string | undefined; }; }; processor: { meta: { name: string; version: string | undefined; }; supportsAutofix: true; preprocess(code: string, filePath: string): (string | Block)[]; postprocess(messages: eslint.Linter.LintMessage[][], filePath: string): eslint.Linter.LintMessage[]; }; rules: { alphabetize: GraphQLESLintRule<{ definitions?: boolean | undefined; selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined; arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined; values?: boolean | undefined; fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined; variables?: boolean | undefined; groups?: string[] | undefined; }[]>; 'description-style': GraphQLESLintRule<{ style: "block" | "inline"; }[]>; 'input-name': GraphQLESLintRule<{ checkInputType?: boolean | undefined; caseSensitiveInputType?: boolean | undefined; checkQueries?: boolean | undefined; checkMutations?: boolean | undefined; }[]>; 'lone-executable-definition': GraphQLESLintRule<{ ignore?: (graphql.OperationTypeNode | "fragment")[] | undefined; }[]>; 'match-document-filename': GraphQLESLintRule<{ fragment?: (CaseStyle | "matchDocumentStyle") | { style?: (CaseStyle | "matchDocumentStyle") | undefined; suffix?: string | undefined; prefix?: string | undefined; } | undefined; query?: (CaseStyle | "matchDocumentStyle") | { style?: (CaseStyle | "matchDocumentStyle") | undefined; suffix?: string | undefined; prefix?: string | undefined; } | undefined; mutation?: (CaseStyle | "matchDocumentStyle") | { style?: (CaseStyle | "matchDocumentStyle") | undefined; suffix?: string | undefined; prefix?: string | undefined; } | undefined; subscription?: (CaseStyle | "matchDocumentStyle") | { style?: (CaseStyle | "matchDocumentStyle") | undefined; suffix?: string | undefined; prefix?: string | undefined; } | undefined; fileExtension?: ".gql" | ".graphql" | undefined; }[]>; 'naming-convention': GraphQLESLintRule<{ [x: string]: unknown; types?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | { style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined; suffix?: string | undefined; prefix?: string | undefined; forbiddenPatterns?: { [x: string]: unknown; }[] | undefined; requiredPattern?: { [x: string]: unknown; } | undefined; forbiddenPrefixes?: string[] | undefined; forbiddenSuffixes?: string[] | undefined; requiredPrefixes?: string[] | undefined; requiredSuffixes?: string[] | undefined; ignorePattern?: string | undefined; } | undefined; allowLeadingUnderscore?: boolean | undefined; allowTrailingUnderscore?: boolean | undefined; }[]>; 'no-anonymous-operations': GraphQLESLintRule; 'no-deprecated': GraphQLESLintRule<[], true>; 'no-duplicate-fields': GraphQLESLintRule; 'no-hashtag-description': GraphQLESLintRule; 'no-one-place-fragments': GraphQLESLintRule; 'no-root-type': GraphQLESLintRule<{ disallow: ("mutation" | "subscription")[]; }[]>; 'no-scalar-result-type-on-mutation': GraphQLESLintRule; 'no-typename-prefix': GraphQLESLintRule; 'no-unreachable-types': GraphQLESLintRule; 'no-unused-fields': GraphQLESLintRule<{ ignoredFieldSelectors?: string[] | undefined; }[]>; 'relay-arguments': GraphQLESLintRule<{ includeBoth: boolean; }[], true>; 'relay-connection-types': GraphQLESLintRule; 'relay-edge-types': GraphQLESLintRule<{ withEdgeSuffix?: boolean | undefined; shouldImplementNode?: boolean | undefined; listTypeCanWrapOnlyEdgeType?: boolean | undefined; }[], true>; 'relay-page-info': GraphQLESLintRule; 'require-deprecation-date': GraphQLESLintRule<{ argumentName?: string | undefined; }[]>; 'require-deprecation-reason': GraphQLESLintRule; 'require-description': GraphQLESLintRule<{ types?: true | undefined; OperationDefinition?: boolean | undefined; ScalarTypeDefinition?: boolean | undefined; ObjectTypeDefinition?: boolean | undefined; FieldDefinition?: boolean | undefined; InputValueDefinition?: boolean | undefined; InterfaceTypeDefinition?: boolean | undefined; UnionTypeDefinition?: boolean | undefined; EnumTypeDefinition?: boolean | undefined; EnumValueDefinition?: boolean | undefined; InputObjectTypeDefinition?: boolean | undefined; DirectiveDefinition?: boolean | undefined; rootField?: true | undefined; ignoredSelectors?: string[] | undefined; }[]>; 'require-field-of-type-query-in-mutation-result': GraphQLESLintRule; 'require-import-fragment': GraphQLESLintRule; 'require-nullable-fields-with-oneof': GraphQLESLintRule; 'require-nullable-result-in-root': GraphQLESLintRule; 'require-selections': GraphQLESLintRule<{ requireAllFields?: boolean | undefined; fieldName: string | string[]; }[], true>; 'require-type-pattern-with-oneof': GraphQLESLintRule; 'selection-set-depth': GraphQLESLintRule<{ ignore?: string[] | undefined; maxDepth: number; }[]>; 'strict-id-in-types': GraphQLESLintRule<{ acceptedIdNames?: string[] | undefined; acceptedIdTypes?: string[] | undefined; exceptions?: { types?: string[] | undefined; suffixes?: string[] | undefined; } | undefined; }[]>; 'unique-enum-value-names': GraphQLESLintRule; 'unique-fragment-name': GraphQLESLintRule; 'unique-operation-name': GraphQLESLintRule; }; configs: { 'schema-recommended': { parser: string; plugins: string[]; rules: { '@graphql-eslint/description-style': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-schema-definition': "error"; '@graphql-eslint/naming-convention': ["error", { types: string; FieldDefinition: string; InputValueDefinition: string; Argument: string; DirectiveDefinition: string; EnumValueDefinition: string; 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Mutation]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Subscription]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'EnumTypeDefinition,EnumTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'InterfaceTypeDefinition,InterfaceTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'UnionTypeDefinition,UnionTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'ObjectTypeDefinition,ObjectTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-hashtag-description': "error"; '@graphql-eslint/no-typename-prefix': "error"; '@graphql-eslint/no-unreachable-types': "error"; '@graphql-eslint/possible-type-extension': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-deprecation-reason': "error"; '@graphql-eslint/require-description': ["error", { types: boolean; DirectiveDefinition: boolean; rootField: boolean; }]; '@graphql-eslint/strict-id-in-types': "error"; '@graphql-eslint/unique-directive-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-enum-value-names': "error"; '@graphql-eslint/unique-field-definition-names': "error"; '@graphql-eslint/unique-operation-types': "error"; '@graphql-eslint/unique-type-names': "error"; }; }; 'schema-all': { extends: string; rules: { '@graphql-eslint/alphabetize': ["error", { definitions: boolean; fields: string[]; values: boolean; arguments: string[]; groups: string[]; }]; '@graphql-eslint/input-name': "error"; '@graphql-eslint/no-root-type': ["error", { disallow: string[]; }]; '@graphql-eslint/no-scalar-result-type-on-mutation': "error"; '@graphql-eslint/require-deprecation-date': "error"; '@graphql-eslint/require-field-of-type-query-in-mutation-result': "error"; '@graphql-eslint/require-nullable-fields-with-oneof': "error"; '@graphql-eslint/require-nullable-result-in-root': "error"; '@graphql-eslint/require-type-pattern-with-oneof': "error"; }; }; 'schema-relay': { parser: string; plugins: string[]; rules: { '@graphql-eslint/relay-arguments': "error"; '@graphql-eslint/relay-connection-types': "error"; '@graphql-eslint/relay-edge-types': "error"; '@graphql-eslint/relay-page-info': "error"; }; }; 'operations-recommended': { parser: string; plugins: string[]; rules: { '@graphql-eslint/executable-definitions': "error"; '@graphql-eslint/fields-on-correct-type': "error"; '@graphql-eslint/fragments-on-composite-type': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-fragment-names': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-anonymous-operation': "error"; '@graphql-eslint/naming-convention': ["error", { VariableDefinition: string; OperationDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; FragmentDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-anonymous-operations': "error"; '@graphql-eslint/no-deprecated': "error"; '@graphql-eslint/no-duplicate-fields': "error"; '@graphql-eslint/no-fragment-cycles': "error"; '@graphql-eslint/no-undefined-variables': "error"; '@graphql-eslint/no-unused-fragments': "error"; '@graphql-eslint/no-unused-variables': "error"; '@graphql-eslint/one-field-subscriptions': "error"; '@graphql-eslint/overlapping-fields-can-be-merged': "error"; '@graphql-eslint/possible-fragment-spread': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-selections': "error"; '@graphql-eslint/scalar-leafs': "error"; '@graphql-eslint/selection-set-depth': ["error", { maxDepth: number; }]; '@graphql-eslint/unique-argument-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-fragment-name': "error"; '@graphql-eslint/unique-input-field-names': "error"; '@graphql-eslint/unique-operation-name': "error"; '@graphql-eslint/unique-variable-names': "error"; '@graphql-eslint/value-literals-of-correct-type': "error"; '@graphql-eslint/variables-are-input-types': "error"; '@graphql-eslint/variables-in-allowed-position': "error"; }; }; 'operations-all': { extends: string; rules: { '@graphql-eslint/alphabetize': ["error", { definitions: boolean; selections: string[]; variables: boolean; arguments: string[]; groups: string[]; }]; '@graphql-eslint/lone-executable-definition': "error"; '@graphql-eslint/match-document-filename': ["error", { query: string; mutation: string; subscription: string; fragment: string; }]; '@graphql-eslint/no-one-place-fragments': "error"; '@graphql-eslint/require-import-fragment': "error"; }; }; 'flat/schema-recommended': { rules: { '@graphql-eslint/description-style': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-schema-definition': "error"; '@graphql-eslint/naming-convention': ["error", { types: string; FieldDefinition: string; InputValueDefinition: string; Argument: string; DirectiveDefinition: string; EnumValueDefinition: string; 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Mutation]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Subscription]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'EnumTypeDefinition,EnumTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'InterfaceTypeDefinition,InterfaceTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'UnionTypeDefinition,UnionTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'ObjectTypeDefinition,ObjectTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-hashtag-description': "error"; '@graphql-eslint/no-typename-prefix': "error"; '@graphql-eslint/no-unreachable-types': "error"; '@graphql-eslint/possible-type-extension': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-deprecation-reason': "error"; '@graphql-eslint/require-description': ["error", { types: boolean; DirectiveDefinition: boolean; rootField: boolean; }]; '@graphql-eslint/strict-id-in-types': "error"; '@graphql-eslint/unique-directive-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-enum-value-names': "error"; '@graphql-eslint/unique-field-definition-names': "error"; '@graphql-eslint/unique-operation-types': "error"; '@graphql-eslint/unique-type-names': "error"; }; }; 'flat/schema-all': { rules: { '@graphql-eslint/alphabetize': ["error", { definitions: boolean; fields: string[]; values: boolean; arguments: string[]; groups: string[]; }]; '@graphql-eslint/input-name': "error"; '@graphql-eslint/no-root-type': ["error", { disallow: string[]; }]; '@graphql-eslint/no-scalar-result-type-on-mutation': "error"; '@graphql-eslint/require-deprecation-date': "error"; '@graphql-eslint/require-field-of-type-query-in-mutation-result': "error"; '@graphql-eslint/require-nullable-fields-with-oneof': "error"; '@graphql-eslint/require-nullable-result-in-root': "error"; '@graphql-eslint/require-type-pattern-with-oneof': "error"; '@graphql-eslint/description-style': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-schema-definition': "error"; '@graphql-eslint/naming-convention': ["error", { types: string; FieldDefinition: string; InputValueDefinition: string; Argument: string; DirectiveDefinition: string; EnumValueDefinition: string; 'FieldDefinition[parent.name.value=Query]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Mutation]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'FieldDefinition[parent.name.value=Subscription]': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'EnumTypeDefinition,EnumTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'InterfaceTypeDefinition,InterfaceTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'UnionTypeDefinition,UnionTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; 'ObjectTypeDefinition,ObjectTypeExtension': { forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-hashtag-description': "error"; '@graphql-eslint/no-typename-prefix': "error"; '@graphql-eslint/no-unreachable-types': "error"; '@graphql-eslint/possible-type-extension': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-deprecation-reason': "error"; '@graphql-eslint/require-description': ["error", { types: boolean; DirectiveDefinition: boolean; rootField: boolean; }]; '@graphql-eslint/strict-id-in-types': "error"; '@graphql-eslint/unique-directive-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-enum-value-names': "error"; '@graphql-eslint/unique-field-definition-names': "error"; '@graphql-eslint/unique-operation-types': "error"; '@graphql-eslint/unique-type-names': "error"; }; }; 'flat/schema-relay': { rules: { '@graphql-eslint/relay-arguments': "error"; '@graphql-eslint/relay-connection-types': "error"; '@graphql-eslint/relay-edge-types': "error"; '@graphql-eslint/relay-page-info': "error"; }; }; 'flat/operations-recommended': { rules: { '@graphql-eslint/executable-definitions': "error"; '@graphql-eslint/fields-on-correct-type': "error"; '@graphql-eslint/fragments-on-composite-type': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-fragment-names': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-anonymous-operation': "error"; '@graphql-eslint/naming-convention': ["error", { VariableDefinition: string; OperationDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; FragmentDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-anonymous-operations': "error"; '@graphql-eslint/no-deprecated': "error"; '@graphql-eslint/no-duplicate-fields': "error"; '@graphql-eslint/no-fragment-cycles': "error"; '@graphql-eslint/no-undefined-variables': "error"; '@graphql-eslint/no-unused-fragments': "error"; '@graphql-eslint/no-unused-variables': "error"; '@graphql-eslint/one-field-subscriptions': "error"; '@graphql-eslint/overlapping-fields-can-be-merged': "error"; '@graphql-eslint/possible-fragment-spread': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-selections': "error"; '@graphql-eslint/scalar-leafs': "error"; '@graphql-eslint/selection-set-depth': ["error", { maxDepth: number; }]; '@graphql-eslint/unique-argument-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-fragment-name': "error"; '@graphql-eslint/unique-input-field-names': "error"; '@graphql-eslint/unique-operation-name': "error"; '@graphql-eslint/unique-variable-names': "error"; '@graphql-eslint/value-literals-of-correct-type': "error"; '@graphql-eslint/variables-are-input-types': "error"; '@graphql-eslint/variables-in-allowed-position': "error"; }; }; 'flat/operations-all': { rules: { '@graphql-eslint/alphabetize': ["error", { definitions: boolean; selections: string[]; variables: boolean; arguments: string[]; groups: string[]; }]; '@graphql-eslint/lone-executable-definition': "error"; '@graphql-eslint/match-document-filename': ["error", { query: string; mutation: string; subscription: string; fragment: string; }]; '@graphql-eslint/no-one-place-fragments': "error"; '@graphql-eslint/require-import-fragment': "error"; '@graphql-eslint/executable-definitions': "error"; '@graphql-eslint/fields-on-correct-type': "error"; '@graphql-eslint/fragments-on-composite-type': "error"; '@graphql-eslint/known-argument-names': "error"; '@graphql-eslint/known-directives': "error"; '@graphql-eslint/known-fragment-names': "error"; '@graphql-eslint/known-type-names': "error"; '@graphql-eslint/lone-anonymous-operation': "error"; '@graphql-eslint/naming-convention': ["error", { VariableDefinition: string; OperationDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; FragmentDefinition: { style: string; forbiddenPrefixes: string[]; forbiddenSuffixes: string[]; }; }]; '@graphql-eslint/no-anonymous-operations': "error"; '@graphql-eslint/no-deprecated': "error"; '@graphql-eslint/no-duplicate-fields': "error"; '@graphql-eslint/no-fragment-cycles': "error"; '@graphql-eslint/no-undefined-variables': "error"; '@graphql-eslint/no-unused-fragments': "error"; '@graphql-eslint/no-unused-variables': "error"; '@graphql-eslint/one-field-subscriptions': "error"; '@graphql-eslint/overlapping-fields-can-be-merged': "error"; '@graphql-eslint/possible-fragment-spread': "error"; '@graphql-eslint/provided-required-arguments': "error"; '@graphql-eslint/require-selections': "error"; '@graphql-eslint/scalar-leafs': "error"; '@graphql-eslint/selection-set-depth': ["error", { maxDepth: number; }]; '@graphql-eslint/unique-argument-names': "error"; '@graphql-eslint/unique-directive-names-per-location': "error"; '@graphql-eslint/unique-fragment-name': "error"; '@graphql-eslint/unique-input-field-names': "error"; '@graphql-eslint/unique-operation-name': "error"; '@graphql-eslint/unique-variable-names': "error"; '@graphql-eslint/value-literals-of-correct-type': "error"; '@graphql-eslint/variables-are-input-types': "error"; '@graphql-eslint/variables-in-allowed-position': "error"; }; }; }; }; export { GraphQLESLintRule, _default as default, parseForESLint, processors };