@graphql-eslint/eslint-plugin 4.0.0-alpha.12 → 4.0.0-alpha.13

Sign up to get free protection for your applications and to get access to all the features.
package/cjs/meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UIAXBAMD.js');
2
- const version = "4.0.0-alpha.12";
2
+ const version = "4.0.0-alpha.13";
3
3
 
4
4
 
5
5
  exports.version = version;
@@ -1,5 +1,4 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../../chunk-UIAXBAMD.js');
2
- var _graphql = require('graphql');
3
2
  var _utilsjs = require('../../utils.js');
4
3
  const RULE_ID = "no-deprecated", rule = exports.rule = {
5
4
  meta: {
@@ -84,24 +83,24 @@ const RULE_ID = "no-deprecated", rule = exports.rule = {
84
83
  recommended: !0
85
84
  },
86
85
  messages: {
87
- [RULE_ID]: "This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
86
+ [RULE_ID]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
88
87
  },
89
88
  schema: []
90
89
  },
91
90
  create(context) {
92
91
  _utilsjs.requireGraphQLSchemaFromContext.call(void 0, RULE_ID, context);
93
92
  function report(node, reason) {
94
- const nodeName = node.kind === _graphql.Kind.ENUM ? node.value : node.name.value, nodeType = node.kind === _graphql.Kind.ENUM ? "enum value" : "field";
93
+ const nodeType = _utilsjs.displayNodeName.call(void 0, node);
95
94
  context.report({
96
95
  node,
97
96
  messageId: RULE_ID,
98
97
  data: {
99
- type: nodeType,
98
+ type: nodeType[0].toUpperCase() + nodeType.slice(1),
100
99
  reason
101
100
  },
102
101
  suggest: [
103
102
  {
104
- desc: `Remove \`${nodeName}\` ${nodeType}`,
103
+ desc: `Remove ${nodeType}`,
105
104
  fix: (fixer) => fixer.remove(node)
106
105
  }
107
106
  ]
@@ -115,6 +114,17 @@ const RULE_ID = "no-deprecated", rule = exports.rule = {
115
114
  Field(node) {
116
115
  const reason = _optionalChain([node, 'access', _5 => _5.typeInfo, 'call', _6 => _6(), 'access', _7 => _7.fieldDef, 'optionalAccess', _8 => _8.deprecationReason]);
117
116
  reason && report(node, reason);
117
+ },
118
+ Argument(node) {
119
+ const reason = _optionalChain([node, 'access', _9 => _9.typeInfo, 'call', _10 => _10(), 'access', _11 => _11.argument, 'optionalAccess', _12 => _12.deprecationReason]);
120
+ reason && report(node, reason);
121
+ },
122
+ ObjectValue(node) {
123
+ const fields = node.typeInfo().inputType.getFields();
124
+ for (const field of node.fields) {
125
+ const fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
126
+ reason && report(field, reason);
127
+ }
118
128
  }
119
129
  };
120
130
  }
package/cjs/utils.d.cts CHANGED
@@ -39,7 +39,7 @@ declare const ARRAY_DEFAULT_OPTIONS: {
39
39
  declare const englishJoinWords: (words: string[]) => string;
40
40
  type Truthy<T> = T extends '' | 0 | false | null | undefined ? never : T;
41
41
  declare function truthy<T>(value: T): value is Truthy<T>;
42
- declare function displayNodeName(node: GraphQLESTreeNode<ASTNode>): string;
42
+ declare function displayNodeName(node: GraphQLESTreeNode<ASTNode, boolean>): string;
43
43
  declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
44
44
 
45
45
  export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, slash, truthy };
package/cjs/utils.js CHANGED
@@ -123,7 +123,7 @@ const DisplayNodeNameMap = {
123
123
  [_graphql.Kind.VARIABLE]: "variable"
124
124
  };
125
125
  function displayNodeName(node) {
126
- return `${node.kind === _graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && _optionalChain([node, 'access', _ => _.alias, 'optionalAccess', _2 => _2.value]) || "name" in node && _optionalChain([node, 'access', _3 => _3.name, 'optionalAccess', _4 => _4.value])}"`;
126
+ return `${node.kind === _graphql.Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && _optionalChain([node, 'access', _ => _.alias, 'optionalAccess', _2 => _2.value]) || "name" in node && _optionalChain([node, 'access', _3 => _3.name, 'optionalAccess', _4 => _4.value]) || node.value}"`;
127
127
  }
128
128
  function getNodeName(node) {
129
129
  switch (node.kind) {
package/esm/index.d.ts CHANGED
@@ -48,10 +48,10 @@ declare const _default: {
48
48
  };
49
49
  rules: {
50
50
  alphabetize: GraphQLESLintRule<{
51
- values?: boolean | undefined;
52
51
  definitions?: boolean | undefined;
53
52
  selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
54
53
  arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
54
+ values?: boolean | undefined;
55
55
  fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
56
56
  variables?: boolean | undefined;
57
57
  groups?: string[] | undefined;
package/esm/meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-UIAXBAMD.js";
2
- const version = "4.0.0-alpha.12";
2
+ const version = "4.0.0-alpha.13";
3
3
  export {
4
4
  version
5
5
  };
@@ -12,10 +12,10 @@ import 'json-schema-to-ts';
12
12
 
13
13
  declare const rules: {
14
14
  alphabetize: GraphQLESLintRule<{
15
- values?: boolean | undefined;
16
15
  definitions?: boolean | undefined;
17
16
  selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
18
17
  arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
18
+ values?: boolean | undefined;
19
19
  fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
20
20
  variables?: boolean | undefined;
21
21
  groups?: string[] | undefined;
@@ -1,6 +1,5 @@
1
1
  import "../../chunk-UIAXBAMD.js";
2
- import { Kind } from "graphql";
3
- import { requireGraphQLSchemaFromContext } from "../../utils.js";
2
+ import { displayNodeName, requireGraphQLSchemaFromContext } from "../../utils.js";
4
3
  const RULE_ID = "no-deprecated", rule = {
5
4
  meta: {
6
5
  type: "suggestion",
@@ -84,24 +83,24 @@ const RULE_ID = "no-deprecated", rule = {
84
83
  recommended: !0
85
84
  },
86
85
  messages: {
87
- [RULE_ID]: "This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
86
+ [RULE_ID]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
88
87
  },
89
88
  schema: []
90
89
  },
91
90
  create(context) {
92
91
  requireGraphQLSchemaFromContext(RULE_ID, context);
93
92
  function report(node, reason) {
94
- const nodeName = node.kind === Kind.ENUM ? node.value : node.name.value, nodeType = node.kind === Kind.ENUM ? "enum value" : "field";
93
+ const nodeType = displayNodeName(node);
95
94
  context.report({
96
95
  node,
97
96
  messageId: RULE_ID,
98
97
  data: {
99
- type: nodeType,
98
+ type: nodeType[0].toUpperCase() + nodeType.slice(1),
100
99
  reason
101
100
  },
102
101
  suggest: [
103
102
  {
104
- desc: `Remove \`${nodeName}\` ${nodeType}`,
103
+ desc: `Remove ${nodeType}`,
105
104
  fix: (fixer) => fixer.remove(node)
106
105
  }
107
106
  ]
@@ -115,6 +114,17 @@ const RULE_ID = "no-deprecated", rule = {
115
114
  Field(node) {
116
115
  const reason = node.typeInfo().fieldDef?.deprecationReason;
117
116
  reason && report(node, reason);
117
+ },
118
+ Argument(node) {
119
+ const reason = node.typeInfo().argument?.deprecationReason;
120
+ reason && report(node, reason);
121
+ },
122
+ ObjectValue(node) {
123
+ const fields = node.typeInfo().inputType.getFields();
124
+ for (const field of node.fields) {
125
+ const fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
126
+ reason && report(field, reason);
127
+ }
118
128
  }
119
129
  };
120
130
  }
package/esm/utils.d.ts CHANGED
@@ -39,7 +39,7 @@ declare const ARRAY_DEFAULT_OPTIONS: {
39
39
  declare const englishJoinWords: (words: string[]) => string;
40
40
  type Truthy<T> = T extends '' | 0 | false | null | undefined ? never : T;
41
41
  declare function truthy<T>(value: T): value is Truthy<T>;
42
- declare function displayNodeName(node: GraphQLESTreeNode<ASTNode>): string;
42
+ declare function displayNodeName(node: GraphQLESTreeNode<ASTNode, boolean>): string;
43
43
  declare function getNodeName(node: GraphQLESTreeNode<ASTNode>): string;
44
44
 
45
45
  export { ARRAY_DEFAULT_OPTIONS, CWD, type CaseStyle, REPORT_ON_FIRST_CHARACTER, TYPES_KINDS, VIRTUAL_DOCUMENT_REGEX, camelCase, convertCase, displayNodeName, englishJoinWords, getLocation, getNodeName, getTypeName, logger, pascalCase, requireGraphQLSchemaFromContext, requireSiblingsOperations, slash, truthy };
package/esm/utils.js CHANGED
@@ -123,7 +123,7 @@ const DisplayNodeNameMap = {
123
123
  [Kind.VARIABLE]: "variable"
124
124
  };
125
125
  function displayNodeName(node) {
126
- return `${node.kind === Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
126
+ return `${node.kind === Kind.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value || node.value}"`;
127
127
  }
128
128
  function getNodeName(node) {
129
129
  switch (node.kind) {
package/index.browser.js CHANGED
@@ -521,7 +521,7 @@ var DisplayNodeNameMap = {
521
521
  [Kind2.VARIABLE]: "variable"
522
522
  };
523
523
  function displayNodeName(node) {
524
- return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value}"`;
524
+ return `${node.kind === Kind2.OPERATION_DEFINITION ? node.operation : DisplayNodeNameMap[node.kind]} "${"alias" in node && node.alias?.value || "name" in node && node.name?.value || node.value}"`;
525
525
  }
526
526
  function getNodeName(node) {
527
527
  switch (node.kind) {
@@ -2596,7 +2596,6 @@ var RULE_ID3 = "no-anonymous-operations", rule7 = {
2596
2596
  };
2597
2597
 
2598
2598
  // src/rules/no-deprecated/index.ts
2599
- import { Kind as Kind10 } from "graphql";
2600
2599
  var RULE_ID4 = "no-deprecated", rule8 = {
2601
2600
  meta: {
2602
2601
  type: "suggestion",
@@ -2680,24 +2679,24 @@ var RULE_ID4 = "no-deprecated", rule8 = {
2680
2679
  recommended: !0
2681
2680
  },
2682
2681
  messages: {
2683
- [RULE_ID4]: "This {{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
2682
+ [RULE_ID4]: "{{ type }} is marked as deprecated in your GraphQL schema (reason: {{ reason }})"
2684
2683
  },
2685
2684
  schema: []
2686
2685
  },
2687
2686
  create(context) {
2688
2687
  requireGraphQLSchemaFromContext(RULE_ID4, context);
2689
2688
  function report(node, reason) {
2690
- let nodeName = node.kind === Kind10.ENUM ? node.value : node.name.value, nodeType = node.kind === Kind10.ENUM ? "enum value" : "field";
2689
+ let nodeType = displayNodeName(node);
2691
2690
  context.report({
2692
2691
  node,
2693
2692
  messageId: RULE_ID4,
2694
2693
  data: {
2695
- type: nodeType,
2694
+ type: nodeType[0].toUpperCase() + nodeType.slice(1),
2696
2695
  reason
2697
2696
  },
2698
2697
  suggest: [
2699
2698
  {
2700
- desc: `Remove \`${nodeName}\` ${nodeType}`,
2699
+ desc: `Remove ${nodeType}`,
2701
2700
  fix: (fixer) => fixer.remove(node)
2702
2701
  }
2703
2702
  ]
@@ -2711,13 +2710,24 @@ var RULE_ID4 = "no-deprecated", rule8 = {
2711
2710
  Field(node) {
2712
2711
  let reason = node.typeInfo().fieldDef?.deprecationReason;
2713
2712
  reason && report(node, reason);
2713
+ },
2714
+ Argument(node) {
2715
+ let reason = node.typeInfo().argument?.deprecationReason;
2716
+ reason && report(node, reason);
2717
+ },
2718
+ ObjectValue(node) {
2719
+ let fields = node.typeInfo().inputType.getFields();
2720
+ for (let field of node.fields) {
2721
+ let fieldName = field.name.value, reason = fields[fieldName].deprecationReason;
2722
+ reason && report(field, reason);
2723
+ }
2714
2724
  }
2715
2725
  };
2716
2726
  }
2717
2727
  };
2718
2728
 
2719
2729
  // src/rules/no-duplicate-fields/index.ts
2720
- import { Kind as Kind11 } from "graphql";
2730
+ import { Kind as Kind10 } from "graphql";
2721
2731
  var RULE_ID5 = "no-duplicate-fields", rule9 = {
2722
2732
  meta: {
2723
2733
  type: "suggestion",
@@ -2801,7 +2811,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
2801
2811
  desc: `Remove \`${fieldName}\` ${parent.type.toLowerCase()}`,
2802
2812
  fix(fixer) {
2803
2813
  return fixer.remove(
2804
- parent.type === Kind11.VARIABLE ? parent.parent : parent
2814
+ parent.type === Kind10.VARIABLE ? parent.parent : parent
2805
2815
  );
2806
2816
  }
2807
2817
  }
@@ -2824,7 +2834,7 @@ var RULE_ID5 = "no-duplicate-fields", rule9 = {
2824
2834
  SelectionSet(node) {
2825
2835
  let set = /* @__PURE__ */ new Set();
2826
2836
  for (let selection of node.selections)
2827
- selection.kind === Kind11.FIELD && checkNode2(set, selection.alias || selection.name);
2837
+ selection.kind === Kind10.FIELD && checkNode2(set, selection.alias || selection.name);
2828
2838
  }
2829
2839
  };
2830
2840
  }
@@ -3094,7 +3104,7 @@ var schema7 = {
3094
3104
  };
3095
3105
 
3096
3106
  // src/rules/no-scalar-result-type-on-mutation/index.ts
3097
- import { isScalarType, Kind as Kind12 } from "graphql";
3107
+ import { isScalarType, Kind as Kind11 } from "graphql";
3098
3108
  var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
3099
3109
  meta: {
3100
3110
  type: "suggestion",
@@ -3141,7 +3151,7 @@ var RULE_ID8 = "no-scalar-result-type-on-mutation", rule13 = {
3141
3151
  let typeName = node.value, graphQLType = schema16.getType(typeName);
3142
3152
  if (isScalarType(graphQLType)) {
3143
3153
  let fieldDef = node.parent;
3144
- for (; fieldDef.kind !== Kind12.FIELD_DEFINITION; )
3154
+ for (; fieldDef.kind !== Kind11.FIELD_DEFINITION; )
3145
3155
  fieldDef = fieldDef.parent;
3146
3156
  context.report({
3147
3157
  node,
@@ -3232,24 +3242,24 @@ var NO_TYPENAME_PREFIX = "NO_TYPENAME_PREFIX", rule14 = {
3232
3242
  import {
3233
3243
  DirectiveLocation,
3234
3244
  isInterfaceType,
3235
- Kind as Kind13,
3245
+ Kind as Kind12,
3236
3246
  visit as visit5
3237
3247
  } from "graphql";
3238
3248
  import lowerCase3 from "lodash.lowercase";
3239
3249
  var RULE_ID9 = "no-unreachable-types", KINDS = [
3240
- Kind13.DIRECTIVE_DEFINITION,
3241
- Kind13.OBJECT_TYPE_DEFINITION,
3242
- Kind13.OBJECT_TYPE_EXTENSION,
3243
- Kind13.INTERFACE_TYPE_DEFINITION,
3244
- Kind13.INTERFACE_TYPE_EXTENSION,
3245
- Kind13.SCALAR_TYPE_DEFINITION,
3246
- Kind13.SCALAR_TYPE_EXTENSION,
3247
- Kind13.INPUT_OBJECT_TYPE_DEFINITION,
3248
- Kind13.INPUT_OBJECT_TYPE_EXTENSION,
3249
- Kind13.UNION_TYPE_DEFINITION,
3250
- Kind13.UNION_TYPE_EXTENSION,
3251
- Kind13.ENUM_TYPE_DEFINITION,
3252
- Kind13.ENUM_TYPE_EXTENSION
3250
+ Kind12.DIRECTIVE_DEFINITION,
3251
+ Kind12.OBJECT_TYPE_DEFINITION,
3252
+ Kind12.OBJECT_TYPE_EXTENSION,
3253
+ Kind12.INTERFACE_TYPE_DEFINITION,
3254
+ Kind12.INTERFACE_TYPE_EXTENSION,
3255
+ Kind12.SCALAR_TYPE_DEFINITION,
3256
+ Kind12.SCALAR_TYPE_EXTENSION,
3257
+ Kind12.INPUT_OBJECT_TYPE_DEFINITION,
3258
+ Kind12.INPUT_OBJECT_TYPE_EXTENSION,
3259
+ Kind12.UNION_TYPE_DEFINITION,
3260
+ Kind12.UNION_TYPE_EXTENSION,
3261
+ Kind12.ENUM_TYPE_DEFINITION,
3262
+ Kind12.ENUM_TYPE_EXTENSION
3253
3263
  ], reachableTypesCache = new ModuleCache(), RequestDirectiveLocations = /* @__PURE__ */ new Set([
3254
3264
  DirectiveLocation.QUERY,
3255
3265
  DirectiveLocation.MUTATION,
@@ -3600,7 +3610,7 @@ var rule16 = {
3600
3610
  };
3601
3611
 
3602
3612
  // src/rules/relay-arguments/index.ts
3603
- import { isScalarType as isScalarType2, Kind as Kind14 } from "graphql";
3613
+ import { isScalarType as isScalarType2, Kind as Kind13 } from "graphql";
3604
3614
  var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", schema9 = {
3605
3615
  type: "array",
3606
3616
  maxItems: 1,
@@ -3674,7 +3684,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
3674
3684
  return {
3675
3685
  "FieldDefinition > .gqlType Name[value=/Connection$/]"(node) {
3676
3686
  let fieldNode = node.parent;
3677
- for (; fieldNode.kind !== Kind14.FIELD_DEFINITION; )
3687
+ for (; fieldNode.kind !== Kind13.FIELD_DEFINITION; )
3678
3688
  fieldNode = fieldNode.parent;
3679
3689
  let args = Object.fromEntries(
3680
3690
  fieldNode.arguments?.map((argument) => [argument.name.value, argument]) || []
@@ -3688,7 +3698,7 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
3688
3698
  }
3689
3699
  function checkField(typeName, argumentName) {
3690
3700
  let argument = args[argumentName], hasArgument = !!argument, type = argument;
3691
- if (hasArgument && type.gqlType.kind === Kind14.NON_NULL_TYPE && (type = type.gqlType), !(hasArgument && type.gqlType.kind === Kind14.NAMED_TYPE && (type.gqlType.name.value === typeName || typeName === "String" && isScalarType2(schema16.getType(type.gqlType.name.value))))) {
3701
+ if (hasArgument && type.gqlType.kind === Kind13.NON_NULL_TYPE && (type = type.gqlType), !(hasArgument && type.gqlType.kind === Kind13.NAMED_TYPE && (type.gqlType.name.value === typeName || typeName === "String" && isScalarType2(schema16.getType(type.gqlType.name.value))))) {
3692
3702
  let returnType = typeName === "String" ? "String or Scalar" : typeName;
3693
3703
  context.report({
3694
3704
  node: (argument || fieldNode).name,
@@ -3703,17 +3713,17 @@ var RULE_ID11 = "relay-arguments", MISSING_ARGUMENTS = "MISSING_ARGUMENTS", sche
3703
3713
  };
3704
3714
 
3705
3715
  // src/rules/relay-connection-types/index.ts
3706
- import { Kind as Kind15 } from "graphql";
3716
+ import { Kind as Kind14 } from "graphql";
3707
3717
  var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUST_CONTAIN_FIELD_EDGES", MUST_CONTAIN_FIELD_PAGE_INFO = "MUST_CONTAIN_FIELD_PAGE_INFO", MUST_HAVE_CONNECTION_SUFFIX = "MUST_HAVE_CONNECTION_SUFFIX", EDGES_FIELD_MUST_RETURN_LIST_TYPE = "EDGES_FIELD_MUST_RETURN_LIST_TYPE", PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE = "PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE", NON_OBJECT_TYPES = [
3708
- Kind15.SCALAR_TYPE_DEFINITION,
3709
- Kind15.UNION_TYPE_DEFINITION,
3710
- Kind15.UNION_TYPE_EXTENSION,
3711
- Kind15.INPUT_OBJECT_TYPE_DEFINITION,
3712
- Kind15.INPUT_OBJECT_TYPE_EXTENSION,
3713
- Kind15.ENUM_TYPE_DEFINITION,
3714
- Kind15.ENUM_TYPE_EXTENSION,
3715
- Kind15.INTERFACE_TYPE_DEFINITION,
3716
- Kind15.INTERFACE_TYPE_EXTENSION
3718
+ Kind14.SCALAR_TYPE_DEFINITION,
3719
+ Kind14.UNION_TYPE_DEFINITION,
3720
+ Kind14.UNION_TYPE_EXTENSION,
3721
+ Kind14.INPUT_OBJECT_TYPE_DEFINITION,
3722
+ Kind14.INPUT_OBJECT_TYPE_EXTENSION,
3723
+ Kind14.ENUM_TYPE_DEFINITION,
3724
+ Kind14.ENUM_TYPE_EXTENSION,
3725
+ Kind14.INTERFACE_TYPE_DEFINITION,
3726
+ Kind14.INTERFACE_TYPE_EXTENSION
3717
3727
  ], notConnectionTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=/Connection$/] > .name`, hasEdgesField = (node) => node.fields?.some((field) => field.name.value === "edges"), hasPageInfoField = (node) => node.fields?.some((field) => field.name.value === "pageInfo"), rule18 = {
3718
3728
  meta: {
3719
3729
  type: "problem",
@@ -3780,10 +3790,10 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
3780
3790
  hasEdgesField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_EDGES }), hasPageInfoField(node) || context.report({ node: node.name, messageId: MUST_CONTAIN_FIELD_PAGE_INFO });
3781
3791
  },
3782
3792
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=edges] > .gqlType"(node) {
3783
- node.kind === Kind15.LIST_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.LIST_TYPE || context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
3793
+ node.kind === Kind14.LIST_TYPE || node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.LIST_TYPE || context.report({ node, messageId: EDGES_FIELD_MUST_RETURN_LIST_TYPE });
3784
3794
  },
3785
3795
  ":matches(ObjectTypeDefinition, ObjectTypeExtension)[name.value=/Connection$/] > FieldDefinition[name.value=pageInfo] > .gqlType"(node) {
3786
- node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.NAMED_TYPE && node.gqlType.name.value === "PageInfo" || context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
3796
+ node.kind === Kind14.NON_NULL_TYPE && node.gqlType.kind === Kind14.NAMED_TYPE && node.gqlType.name.value === "PageInfo" || context.report({ node, messageId: PAGE_INFO_FIELD_MUST_RETURN_NON_NULL_TYPE });
3787
3797
  }
3788
3798
  };
3789
3799
  }
@@ -3793,7 +3803,7 @@ var MUST_BE_OBJECT_TYPE = "MUST_BE_OBJECT_TYPE", MUST_CONTAIN_FIELD_EDGES = "MUS
3793
3803
  import {
3794
3804
  isObjectType as isObjectType2,
3795
3805
  isScalarType as isScalarType3,
3796
- Kind as Kind16,
3806
+ Kind as Kind15,
3797
3807
  visit as visit7
3798
3808
  } from "graphql";
3799
3809
  import { getDocumentNodeFromSchema } from "@graphql-tools/utils";
@@ -3888,7 +3898,7 @@ var schema10 = {
3888
3898
  shouldImplementNode: !0,
3889
3899
  listTypeCanWrapOnlyEdgeType: !0,
3890
3900
  ...context.options[0]
3891
- }, isNamedOrNonNullNamed = (node) => node.kind === Kind16.NAMED_TYPE || node.kind === Kind16.NON_NULL_TYPE && node.gqlType.kind === Kind16.NAMED_TYPE, checkNodeField = (node) => {
3901
+ }, isNamedOrNonNullNamed = (node) => node.kind === Kind15.NAMED_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.NAMED_TYPE, checkNodeField = (node) => {
3892
3902
  let nodeField = node.fields?.find((field) => field.name.value === "node"), message = "return either a Scalar, Enum, Object, Interface, Union, or a non-null wrapper around one of those types.";
3893
3903
  if (!nodeField)
3894
3904
  context.report({
@@ -3925,7 +3935,7 @@ var schema10 = {
3925
3935
  }
3926
3936
  };
3927
3937
  return options.listTypeCanWrapOnlyEdgeType && (listeners["FieldDefinition > .gqlType"] = (node) => {
3928
- if (node.kind === Kind16.LIST_TYPE || node.kind === Kind16.NON_NULL_TYPE && node.gqlType.kind === Kind16.LIST_TYPE) {
3938
+ if (node.kind === Kind15.LIST_TYPE || node.kind === Kind15.NON_NULL_TYPE && node.gqlType.kind === Kind15.LIST_TYPE) {
3929
3939
  let typeName = getTypeName(node.rawNode());
3930
3940
  edgeTypes.has(typeName) || context.report({ node, messageId: MESSAGE_LIST_TYPE_ONLY_EDGE_TYPE });
3931
3941
  }
@@ -3934,7 +3944,7 @@ var schema10 = {
3934
3944
  };
3935
3945
 
3936
3946
  // src/rules/relay-page-info/index.ts
3937
- import { isScalarType as isScalarType4, Kind as Kind17 } from "graphql";
3947
+ import { isScalarType as isScalarType4, Kind as Kind16 } from "graphql";
3938
3948
  var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", MESSAGE_MUST_BE_OBJECT_TYPE2 = "MESSAGE_MUST_BE_OBJECT_TYPE", notPageInfoTypesSelector = `:matches(${NON_OBJECT_TYPES})[name.value=PageInfo] > .name`, hasPageInfoChecked = !1, rule20 = {
3939
3949
  meta: {
3940
3950
  type: "problem",
@@ -3990,7 +4000,7 @@ var RULE_ID13 = "relay-page-info", MESSAGE_MUST_EXIST = "MESSAGE_MUST_EXIST", ME
3990
4000
  let field = fieldMap[fieldName], isAllowedType = !1;
3991
4001
  if (field) {
3992
4002
  let type = field.gqlType;
3993
- typeName === "Boolean" ? isAllowedType = type.kind === Kind17.NON_NULL_TYPE && type.gqlType.kind === Kind17.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === Kind17.NAMED_TYPE && (isAllowedType = type.name.value === "String" || isScalarType4(schema16.getType(type.name.value)));
4003
+ typeName === "Boolean" ? isAllowedType = type.kind === Kind16.NON_NULL_TYPE && type.gqlType.kind === Kind16.NAMED_TYPE && type.gqlType.name.value === "Boolean" : type.kind === Kind16.NAMED_TYPE && (isAllowedType = type.name.value === "String" || isScalarType4(schema16.getType(type.name.value)));
3994
4004
  }
3995
4005
  if (!isAllowedType) {
3996
4006
  let returnType = typeName === "Boolean" ? "non-null Boolean" : "either String or Scalar, which can be null if there are no results";
@@ -4194,15 +4204,15 @@ var rule22 = {
4194
4204
  };
4195
4205
 
4196
4206
  // src/rules/require-description/index.ts
4197
- import { Kind as Kind18, TokenKind as TokenKind3 } from "graphql";
4207
+ import { Kind as Kind17, TokenKind as TokenKind3 } from "graphql";
4198
4208
  import { getRootTypeNames } from "@graphql-tools/utils";
4199
4209
  var RULE_ID14 = "require-description", ALLOWED_KINDS2 = [
4200
4210
  ...TYPES_KINDS,
4201
- Kind18.DIRECTIVE_DEFINITION,
4202
- Kind18.FIELD_DEFINITION,
4203
- Kind18.INPUT_VALUE_DEFINITION,
4204
- Kind18.ENUM_VALUE_DEFINITION,
4205
- Kind18.OPERATION_DEFINITION
4211
+ Kind17.DIRECTIVE_DEFINITION,
4212
+ Kind17.FIELD_DEFINITION,
4213
+ Kind17.INPUT_VALUE_DEFINITION,
4214
+ Kind17.ENUM_VALUE_DEFINITION,
4215
+ Kind17.OPERATION_DEFINITION
4206
4216
  ], schema12 = {
4207
4217
  type: "array",
4208
4218
  minItems: 1,
@@ -4225,7 +4235,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
4225
4235
  ...Object.fromEntries(
4226
4236
  [...ALLOWED_KINDS2].sort().map((kind) => {
4227
4237
  let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
4228
- return kind === Kind18.OPERATION_DEFINITION && (description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.'), [kind, { type: "boolean", description }];
4238
+ return kind === Kind17.OPERATION_DEFINITION && (description += '\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.'), [kind, { type: "boolean", description }];
4229
4239
  })
4230
4240
  )
4231
4241
  }
@@ -4301,7 +4311,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
4301
4311
  configOptions: [
4302
4312
  {
4303
4313
  types: !0,
4304
- [Kind18.DIRECTIVE_DEFINITION]: !0,
4314
+ [Kind17.DIRECTIVE_DEFINITION]: !0,
4305
4315
  rootField: !0
4306
4316
  }
4307
4317
  ],
@@ -4327,7 +4337,7 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
4327
4337
  }
4328
4338
  return {
4329
4339
  [[...kinds].join(",")](node) {
4330
- let description = "", isOperation = node.kind === Kind18.OPERATION_DEFINITION;
4340
+ let description = "", isOperation = node.kind === Kind17.OPERATION_DEFINITION;
4331
4341
  if (isOperation) {
4332
4342
  let rawNode = node.rawNode(), { prev, line } = rawNode.loc.startToken;
4333
4343
  if (prev?.kind === TokenKind3.COMMENT) {
@@ -4533,7 +4543,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
4533
4543
  };
4534
4544
 
4535
4545
  // src/rules/require-nullable-fields-with-oneof/index.ts
4536
- import { Kind as Kind19 } from "graphql";
4546
+ import { Kind as Kind18 } from "graphql";
4537
4547
  var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
4538
4548
  meta: {
4539
4549
  type: "suggestion",
@@ -4577,11 +4587,11 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
4577
4587
  return {
4578
4588
  "Directive[name.value=oneOf]"({ parent }) {
4579
4589
  if ([
4580
- Kind19.OBJECT_TYPE_DEFINITION,
4581
- Kind19.INPUT_OBJECT_TYPE_DEFINITION
4590
+ Kind18.OBJECT_TYPE_DEFINITION,
4591
+ Kind18.INPUT_OBJECT_TYPE_DEFINITION
4582
4592
  ].includes(parent.kind))
4583
4593
  for (let field of parent.fields || [])
4584
- field.gqlType.kind === Kind19.NON_NULL_TYPE && context.report({
4594
+ field.gqlType.kind === Kind18.NON_NULL_TYPE && context.report({
4585
4595
  node: field.name,
4586
4596
  messageId: RULE_ID17,
4587
4597
  data: { nodeName: getNodeName(field) }
@@ -4592,7 +4602,7 @@ var RULE_ID17 = "require-nullable-fields-with-oneof", rule26 = {
4592
4602
  };
4593
4603
 
4594
4604
  // src/rules/require-nullable-result-in-root/index.ts
4595
- import { Kind as Kind20 } from "graphql";
4605
+ import { Kind as Kind19 } from "graphql";
4596
4606
  var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
4597
4607
  meta: {
4598
4608
  type: "suggestion",
@@ -4642,7 +4652,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
4642
4652
  "ObjectTypeDefinition,ObjectTypeExtension"(node) {
4643
4653
  if (rootTypeNames.has(node.name.value))
4644
4654
  for (let field of node.fields || []) {
4645
- if (field.gqlType.type !== Kind20.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind20.NAMED_TYPE)
4655
+ if (field.gqlType.type !== Kind19.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind19.NAMED_TYPE)
4646
4656
  continue;
4647
4657
  let name = field.gqlType.gqlType.name.value, type = schema16.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
4648
4658
  context.report({
@@ -4673,7 +4683,7 @@ import {
4673
4683
  GraphQLInterfaceType,
4674
4684
  GraphQLObjectType,
4675
4685
  GraphQLUnionType,
4676
- Kind as Kind21,
4686
+ Kind as Kind20,
4677
4687
  TypeInfo as TypeInfo3,
4678
4688
  visit as visit8,
4679
4689
  visitWithTypeInfo as visitWithTypeInfo3
@@ -4770,7 +4780,7 @@ Include it in your selection set{{ addition }}.`
4770
4780
  let schema16 = requireGraphQLSchemaFromContext(RULE_ID19, context), siblings = requireSiblingsOperations(RULE_ID19, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = asArray(fieldName), selector = "SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new TypeInfo3(schema16);
4771
4781
  function checkFragments(node) {
4772
4782
  for (let selection of node.selections) {
4773
- if (selection.kind !== Kind21.FRAGMENT_SPREAD)
4783
+ if (selection.kind !== Kind20.FRAGMENT_SPREAD)
4774
4784
  continue;
4775
4785
  let [foundSpread] = siblings.getFragment(selection.name.value);
4776
4786
  if (!foundSpread)
@@ -4778,7 +4788,7 @@ Include it in your selection set{{ addition }}.`
4778
4788
  let checkedFragmentSpreads = /* @__PURE__ */ new Set(), visitor = visitWithTypeInfo3(typeInfo, {
4779
4789
  SelectionSet(node2, key, _parent) {
4780
4790
  let parent = _parent;
4781
- parent.kind === Kind21.FRAGMENT_DEFINITION ? checkedFragmentSpreads.add(parent.name.value) : parent.kind !== Kind21.INLINE_FRAGMENT && checkSelections(
4791
+ parent.kind === Kind20.FRAGMENT_DEFINITION ? checkedFragmentSpreads.add(parent.name.value) : parent.kind !== Kind20.INLINE_FRAGMENT && checkSelections(
4782
4792
  node2,
4783
4793
  typeInfo.getType(),
4784
4794
  selection.loc.start,
@@ -4797,10 +4807,10 @@ Include it in your selection set{{ addition }}.`
4797
4807
  else if (rawType instanceof GraphQLUnionType)
4798
4808
  for (let selection of node.selections) {
4799
4809
  let types = rawType.getTypes();
4800
- if (selection.kind === Kind21.INLINE_FRAGMENT) {
4810
+ if (selection.kind === Kind20.INLINE_FRAGMENT) {
4801
4811
  let t = types.find((t2) => t2.name === selection.typeCondition.name.value);
4802
4812
  t && checkFields(t);
4803
- } else if (selection.kind === Kind21.FRAGMENT_SPREAD) {
4813
+ } else if (selection.kind === Kind20.FRAGMENT_SPREAD) {
4804
4814
  let [foundSpread] = siblings.getFragment(selection.name.value);
4805
4815
  if (!foundSpread) return;
4806
4816
  let fragmentSpread = foundSpread.document, t = fragmentSpread.typeCondition.name.value === rawType.name ? rawType : types.find((t2) => t2.name === fragmentSpread.typeCondition.name.value);
@@ -4813,11 +4823,11 @@ Include it in your selection set{{ addition }}.`
4813
4823
  return;
4814
4824
  function hasIdField({ selections }) {
4815
4825
  return selections.some((selection) => {
4816
- if (selection.kind === Kind21.FIELD)
4826
+ if (selection.kind === Kind20.FIELD)
4817
4827
  return selection.alias && idNames.includes(selection.alias.value) ? !0 : idNames.includes(selection.name.value);
4818
- if (selection.kind === Kind21.INLINE_FRAGMENT)
4828
+ if (selection.kind === Kind20.INLINE_FRAGMENT)
4819
4829
  return hasIdField(selection.selectionSet);
4820
- if (selection.kind === Kind21.FRAGMENT_SPREAD) {
4830
+ if (selection.kind === Kind20.FRAGMENT_SPREAD) {
4821
4831
  let [foundSpread] = siblings.getFragment(selection.name.value);
4822
4832
  if (foundSpread) {
4823
4833
  let fragmentSpread = foundSpread.document;
@@ -4845,7 +4855,7 @@ Include it in your selection set{{ addition }}.`
4845
4855
  desc: `Add \`${idName}\` selection`,
4846
4856
  fix: (fixer) => {
4847
4857
  let insertNode = node.selections[0];
4848
- return insertNode = insertNode.kind === Kind21.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode, fixer.insertTextBefore(insertNode, `${idName} `);
4858
+ return insertNode = insertNode.kind === Kind20.INLINE_FRAGMENT ? insertNode.selectionSet.selections[0] : insertNode, fixer.insertTextBefore(insertNode, `${idName} `);
4849
4859
  }
4850
4860
  }))), context.report(problem);
4851
4861
  }
@@ -4920,7 +4930,7 @@ var RULE_ID20 = "require-type-pattern-with-oneof", rule29 = {
4920
4930
  };
4921
4931
 
4922
4932
  // src/rules/selection-set-depth/index.ts
4923
- import { Kind as Kind22 } from "graphql";
4933
+ import { Kind as Kind21 } from "graphql";
4924
4934
  import depthLimit from "graphql-depth-limit";
4925
4935
  var RULE_ID21 = "selection-set-depth", schema14 = {
4926
4936
  type: "array",
@@ -5006,7 +5016,7 @@ var RULE_ID21 = "selection-set-depth", schema14 = {
5006
5016
  "OperationDefinition, FragmentDefinition"(node) {
5007
5017
  try {
5008
5018
  let rawNode = node.rawNode(), fragmentsInUse = siblings ? siblings.getFragmentsInUse(rawNode) : [], document = {
5009
- kind: Kind22.DOCUMENT,
5019
+ kind: Kind21.DOCUMENT,
5010
5020
  definitions: [rawNode, ...fragmentsInUse]
5011
5021
  };
5012
5022
  checkFn({
@@ -5050,7 +5060,7 @@ var RULE_ID21 = "selection-set-depth", schema14 = {
5050
5060
  };
5051
5061
 
5052
5062
  // src/rules/strict-id-in-types/index.ts
5053
- import { Kind as Kind23 } from "graphql";
5063
+ import { Kind as Kind22 } from "graphql";
5054
5064
  var RULE_ID22 = "strict-id-in-types", schema15 = {
5055
5065
  type: "array",
5056
5066
  maxItems: 1,
@@ -5179,7 +5189,7 @@ var RULE_ID22 = "strict-id-in-types", schema15 = {
5179
5189
  return;
5180
5190
  if (node.fields?.filter((field) => {
5181
5191
  let fieldNode = field.rawNode(), isValidIdName = options.acceptedIdNames.includes(fieldNode.name.value), isValidIdType = !1;
5182
- return fieldNode.type.kind === Kind23.NON_NULL_TYPE && fieldNode.type.type.kind === Kind23.NAMED_TYPE && (isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value)), isValidIdName && isValidIdType;
5192
+ return fieldNode.type.kind === Kind22.NON_NULL_TYPE && fieldNode.type.type.kind === Kind22.NAMED_TYPE && (isValidIdType = options.acceptedIdTypes.includes(fieldNode.type.type.name.value)), isValidIdName && isValidIdType;
5183
5193
  })?.length !== 1) {
5184
5194
  let pluralNamesSuffix = options.acceptedIdNames.length > 1 ? "s" : "", pluralTypesSuffix = options.acceptedIdTypes.length > 1 ? "s" : "";
5185
5195
  context.report({
@@ -5195,7 +5205,7 @@ Accepted type${pluralTypesSuffix}: ${englishJoinWords(options.acceptedIdTypes)}.
5195
5205
  };
5196
5206
 
5197
5207
  // src/rules/unique-enum-value-names/index.ts
5198
- import { Kind as Kind24 } from "graphql";
5208
+ import { Kind as Kind23 } from "graphql";
5199
5209
  var rule32 = {
5200
5210
  meta: {
5201
5211
  type: "suggestion",
@@ -5239,7 +5249,7 @@ var rule32 = {
5239
5249
  },
5240
5250
  create(context) {
5241
5251
  return {
5242
- [[Kind24.ENUM_TYPE_DEFINITION, Kind24.ENUM_TYPE_EXTENSION].join(",")](node) {
5252
+ [[Kind23.ENUM_TYPE_DEFINITION, Kind23.ENUM_TYPE_EXTENSION].join(",")](node) {
5243
5253
  let duplicates = node.values?.filter(
5244
5254
  (item, index, array) => array.findIndex((v) => v.name.value.toLowerCase() === item.name.value.toLowerCase()) !== index
5245
5255
  );
@@ -5265,9 +5275,9 @@ var rule32 = {
5265
5275
 
5266
5276
  // src/rules/unique-fragment-name/index.ts
5267
5277
  import { relative as relative2 } from "node:path";
5268
- import { Kind as Kind25 } from "graphql";
5278
+ import { Kind as Kind24 } from "graphql";
5269
5279
  var RULE_ID23 = "unique-fragment-name", checkNode = (context, node, ruleId) => {
5270
- let documentName = node.name.value, siblings = requireSiblingsOperations(ruleId, context), siblingDocuments = node.kind === Kind25.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
5280
+ let documentName = node.name.value, siblings = requireSiblingsOperations(ruleId, context), siblingDocuments = node.kind === Kind24.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
5271
5281
  let isSameName = f.document.name?.value === documentName, isSamePath = slash(f.filePath) === slash(filepath);
5272
5282
  return isSameName && !isSamePath;
5273
5283
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.0.0-alpha.12",
3
+ "version": "4.0.0-alpha.13",
4
4
  "type": "module",
5
5
  "description": "GraphQL plugin for ESLint",
6
6
  "repository": "https://github.com/B2o5T/graphql-eslint",