@graphql-eslint/eslint-plugin 2.4.0-alpha-0a1c477.0 → 2.5.0-alpha-f60e6aa.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -149,7 +149,7 @@ function getLexer(source) {
149
149
  throw new Error(`Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!`);
150
150
  }
151
151
  function extractTokens(source) {
152
- const lexer = getLexer(new graphql.Source(source));
152
+ const lexer = getLexer(source);
153
153
  const tokens = [];
154
154
  let token = lexer.advance();
155
155
  while (token && token.kind !== '<EOF>') {
@@ -3634,7 +3634,12 @@ function getReachableTypes(schema) {
3634
3634
  Directive: collect,
3635
3635
  NamedType: collect,
3636
3636
  };
3637
- for (const type of [schema.getQueryType(), schema.getMutationType(), schema.getSubscriptionType()]) {
3637
+ for (const type of [
3638
+ schema,
3639
+ schema.getQueryType(),
3640
+ schema.getMutationType(),
3641
+ schema.getSubscriptionType(),
3642
+ ]) {
3638
3643
  if (type) {
3639
3644
  graphql.visit(type.astNode, visitor);
3640
3645
  }
@@ -3693,7 +3698,7 @@ function parseForESLint(code, options = {}) {
3693
3698
  noLocation: false,
3694
3699
  });
3695
3700
  const { rootTree, comments } = convertToESTree(graphqlAst.document, schema ? new graphql.TypeInfo(schema) : null);
3696
- const tokens = extractTokens(code);
3701
+ const tokens = extractTokens(new graphql.Source(code, filePath));
3697
3702
  return {
3698
3703
  services: parserServices,
3699
3704
  parserServices,
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Kind, Source, validate, isScalarType, TokenKind, isNonNullType, isListType, isObjectType as isObjectType$1, visit, visitWithTypeInfo, GraphQLObjectType, GraphQLInterfaceType, TypeInfo, isInterfaceType, GraphQLError } from 'graphql';
1
+ import { Kind, validate, isScalarType, TokenKind, isNonNullType, isListType, isObjectType as isObjectType$1, visit, visitWithTypeInfo, GraphQLObjectType, GraphQLInterfaceType, TypeInfo, isInterfaceType, Source, GraphQLError } from 'graphql';
2
2
  import { validateSDL } from 'graphql/validation/validate';
3
3
  import { processImport, parseImportLine } from '@graphql-tools/import';
4
4
  import { statSync, existsSync, readFileSync } from 'fs';
@@ -143,7 +143,7 @@ function getLexer(source) {
143
143
  throw new Error(`Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!`);
144
144
  }
145
145
  function extractTokens(source) {
146
- const lexer = getLexer(new Source(source));
146
+ const lexer = getLexer(source);
147
147
  const tokens = [];
148
148
  let token = lexer.advance();
149
149
  while (token && token.kind !== '<EOF>') {
@@ -3628,7 +3628,12 @@ function getReachableTypes(schema) {
3628
3628
  Directive: collect,
3629
3629
  NamedType: collect,
3630
3630
  };
3631
- for (const type of [schema.getQueryType(), schema.getMutationType(), schema.getSubscriptionType()]) {
3631
+ for (const type of [
3632
+ schema,
3633
+ schema.getQueryType(),
3634
+ schema.getMutationType(),
3635
+ schema.getSubscriptionType(),
3636
+ ]) {
3632
3637
  if (type) {
3633
3638
  visit(type.astNode, visitor);
3634
3639
  }
@@ -3687,7 +3692,7 @@ function parseForESLint(code, options = {}) {
3687
3692
  noLocation: false,
3688
3693
  });
3689
3694
  const { rootTree, comments } = convertToESTree(graphqlAst.document, schema ? new TypeInfo(schema) : null);
3690
- const tokens = extractTokens(code);
3695
+ const tokens = extractTokens(new Source(code, filePath));
3691
3696
  return {
3692
3697
  services: parserServices,
3693
3698
  parserServices,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.4.0-alpha-0a1c477.0",
3
+ "version": "2.5.0-alpha-f60e6aa.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
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"
package/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GraphQLSchema, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
1
+ import { GraphQLSchema, Source, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
2
2
  import { AST } from 'eslint';
3
3
  import { Source as LoaderSource } from '@graphql-tools/utils';
4
4
  import { GraphQLESLintRuleContext } from './types';
@@ -9,7 +9,7 @@ export declare function requireSiblingsOperations(ruleName: string, context: Gra
9
9
  export declare function requireGraphQLSchemaFromContext(ruleName: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
10
10
  export declare function requireReachableTypesFromContext(ruleName: string, context: GraphQLESLintRuleContext): ReachableTypes | never;
11
11
  export declare function requireUsedFieldsFromContext(ruleName: string, context: GraphQLESLintRuleContext): UsedFields | never;
12
- export declare function extractTokens(source: string): AST.Token[];
12
+ export declare function extractTokens(source: Source): AST.Token[];
13
13
  export declare const normalizePath: (path: string) => string;
14
14
  /**
15
15
  * https://github.com/prettier/eslint-plugin-prettier/blob/76bd45ece6d56eb52f75db6b4a1efdd2efb56392/eslint-plugin-prettier.js#L71