@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
80 lines (79 loc) • 2.9 kB
TypeScript
import { Rule, AST, Linter } from 'eslint';
import * as ESTree from 'estree';
import { GraphQLSchema } from 'graphql';
import { IExtensions, IGraphQLProject } from 'graphql-config';
import { GraphQLParseOptions } from '@graphql-tools/utils';
import { GraphQLESLintRuleListener } from './testkit';
import { SiblingOperations } from './documents';
export declare type Schema = GraphQLSchema | Error | null;
export declare type Pointer = string | string[];
export interface ParserOptions {
schema?: Pointer | Record<string, {
headers: Record<string, string>;
}>;
documents?: Pointer;
operations?: Pointer;
extensions?: IExtensions;
include?: Pointer;
exclude?: Pointer;
projects?: Record<string, IGraphQLProject>;
schemaOptions?: Omit<GraphQLParseOptions, 'assumeValidSDL'> & {
headers: Record<string, string>;
};
graphQLParserOptions?: Omit<GraphQLParseOptions, 'noLocation'>;
skipGraphQLConfig?: boolean;
filePath: string;
}
export declare type ParserServices = {
schema: Schema;
siblingOperations: SiblingOperations;
};
export declare type GraphQLESLintParseResult = Linter.ESLintParseResult & {
services: ParserServices;
};
declare type Location = AST.SourceLocation | ESTree.Position;
declare type ReportDescriptorLocation = {
node: {
loc: Location;
};
} | {
loc: Location;
};
export declare type ReportDescriptor = Rule.ReportDescriptorMessage & Rule.ReportDescriptorOptions & ReportDescriptorLocation;
export declare type GraphQLESLintRuleContext<Options = any[]> = Omit<Rule.RuleContext, 'parserServices' | 'report' | 'options'> & {
options: Options;
report(descriptor: ReportDescriptor): void;
parserServices?: ParserServices;
};
export declare type CategoryType = 'Schema' | 'Operations';
export declare type RuleDocsInfo<T> = Omit<Rule.RuleMetaData['docs'], 'category' | 'suggestion'> & {
category: CategoryType | CategoryType[];
requiresSchema?: true;
requiresSiblings?: true;
examples?: {
title: string;
code: string;
usage?: T;
}[];
configOptions?: T | {
schema?: T;
operations?: T;
};
graphQLJSRuleName?: string;
isDisabledForAllConfig?: true;
};
export declare type GraphQLESLintRule<Options = any[], WithTypeInfo extends boolean = false> = {
create(context: GraphQLESLintRuleContext<Options>): GraphQLESLintRuleListener<WithTypeInfo>;
meta: Omit<Rule.RuleMetaData, 'docs'> & {
docs?: RuleDocsInfo<Options>;
};
};
export declare type ValueOf<T> = T[keyof T];
declare type Id<T> = {} & {
[P in keyof T]: T[P];
};
declare type OmitDistributive<T, K extends PropertyKey> = T extends object ? Id<OmitRecursively<T, K>> : T;
export declare type OmitRecursively<T extends object, K extends PropertyKey> = Omit<{
[P in keyof T]: OmitDistributive<T[P], K>;
}, K>;
export {};