@graphql-eslint/eslint-plugin 4.0.0-alpha.8 → 4.0.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.
Files changed (136) hide show
  1. package/cjs/cache.js +1 -2
  2. package/cjs/configs/index.d.cts +427 -10
  3. package/cjs/configs/index.js +1 -2
  4. package/cjs/configs/operations-all.d.cts +8 -8
  5. package/cjs/configs/operations-all.js +30 -33
  6. package/cjs/configs/operations-recommended.d.cts +35 -35
  7. package/cjs/configs/operations-recommended.js +56 -59
  8. package/cjs/configs/schema-all.d.cts +12 -12
  9. package/cjs/configs/schema-all.js +26 -29
  10. package/cjs/configs/schema-recommended.d.cts +23 -23
  11. package/cjs/configs/schema-recommended.js +70 -73
  12. package/cjs/configs/schema-relay.d.cts +5 -5
  13. package/cjs/configs/schema-relay.js +14 -17
  14. package/cjs/documents.js +8 -4
  15. package/cjs/estree-converter/converter.js +1 -2
  16. package/cjs/estree-converter/utils.js +1 -2
  17. package/cjs/graphql-config.d.cts +6 -1
  18. package/cjs/graphql-config.js +9 -3
  19. package/cjs/index.d.cts +436 -16
  20. package/cjs/index.js +2 -3
  21. package/cjs/meta.js +1 -2
  22. package/cjs/parser.js +2 -6
  23. package/cjs/processor.js +5 -2
  24. package/cjs/rules/alphabetize/index.js +1 -2
  25. package/cjs/rules/description-style/index.js +1 -2
  26. package/cjs/rules/graphql-js-validation.js +4 -5
  27. package/cjs/rules/index.d.cts +6 -4
  28. package/cjs/rules/index.js +1 -2
  29. package/cjs/rules/input-name/index.js +1 -2
  30. package/cjs/rules/lone-executable-definition/index.js +1 -2
  31. package/cjs/rules/match-document-filename/index.js +1 -2
  32. package/cjs/rules/naming-convention/index.js +4 -3
  33. package/cjs/rules/no-anonymous-operations/index.js +1 -2
  34. package/cjs/rules/no-deprecated/index.js +20 -8
  35. package/cjs/rules/no-duplicate-fields/index.js +1 -2
  36. package/cjs/rules/no-hashtag-description/index.js +1 -2
  37. package/cjs/rules/no-one-place-fragments/index.js +2 -3
  38. package/cjs/rules/no-root-type/index.js +2 -3
  39. package/cjs/rules/no-scalar-result-type-on-mutation/index.js +2 -3
  40. package/cjs/rules/no-typename-prefix/index.js +1 -2
  41. package/cjs/rules/no-unreachable-types/index.js +4 -6
  42. package/cjs/rules/no-unused-fields/index.d.cts +24 -3
  43. package/cjs/rules/no-unused-fields/index.js +119 -10
  44. package/cjs/rules/relay-arguments/index.js +2 -3
  45. package/cjs/rules/relay-connection-types/index.js +1 -2
  46. package/cjs/rules/relay-edge-types/index.js +2 -3
  47. package/cjs/rules/relay-page-info/index.js +2 -3
  48. package/cjs/rules/require-deprecation-date/index.js +1 -2
  49. package/cjs/rules/require-deprecation-reason/index.js +1 -2
  50. package/cjs/rules/require-description/index.js +2 -8
  51. package/cjs/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
  52. package/cjs/rules/require-import-fragment/index.js +9 -5
  53. package/cjs/rules/require-nullable-fields-with-oneof/index.js +1 -2
  54. package/cjs/rules/require-nullable-result-in-root/index.js +2 -3
  55. package/cjs/rules/require-selections/index.js +14 -8
  56. package/cjs/rules/require-type-pattern-with-oneof/index.js +1 -2
  57. package/cjs/rules/selection-set-depth/index.js +4 -5
  58. package/cjs/rules/strict-id-in-types/index.js +2 -3
  59. package/cjs/rules/unique-enum-value-names/index.js +1 -2
  60. package/cjs/rules/unique-fragment-name/index.js +2 -3
  61. package/cjs/rules/unique-operation-name/index.js +1 -2
  62. package/cjs/schema.js +1 -2
  63. package/cjs/siblings.js +1 -2
  64. package/cjs/types.d.cts +1 -0
  65. package/cjs/utils.d.cts +4 -4
  66. package/cjs/utils.js +8 -9
  67. package/esm/cache.js +0 -1
  68. package/esm/configs/index.d.ts +427 -10
  69. package/esm/configs/index.js +0 -1
  70. package/esm/configs/operations-all.d.ts +7 -7
  71. package/esm/configs/operations-all.js +28 -33
  72. package/esm/configs/operations-recommended.d.ts +34 -34
  73. package/esm/configs/operations-recommended.js +54 -59
  74. package/esm/configs/schema-all.d.ts +11 -11
  75. package/esm/configs/schema-all.js +24 -29
  76. package/esm/configs/schema-recommended.d.ts +22 -22
  77. package/esm/configs/schema-recommended.js +68 -73
  78. package/esm/configs/schema-relay.d.ts +4 -4
  79. package/esm/configs/schema-relay.js +12 -17
  80. package/esm/documents.js +8 -4
  81. package/esm/estree-converter/converter.js +0 -1
  82. package/esm/estree-converter/utils.js +0 -1
  83. package/esm/graphql-config.d.ts +6 -1
  84. package/esm/graphql-config.js +8 -2
  85. package/esm/index.d.ts +436 -16
  86. package/esm/index.js +3 -4
  87. package/esm/meta.js +1 -2
  88. package/esm/parser.js +3 -7
  89. package/esm/processor.js +4 -1
  90. package/esm/rules/alphabetize/index.js +0 -1
  91. package/esm/rules/description-style/index.js +0 -1
  92. package/esm/rules/graphql-js-validation.js +5 -6
  93. package/esm/rules/index.d.ts +6 -4
  94. package/esm/rules/index.js +0 -1
  95. package/esm/rules/input-name/index.js +0 -1
  96. package/esm/rules/lone-executable-definition/index.js +0 -1
  97. package/esm/rules/match-document-filename/index.js +0 -1
  98. package/esm/rules/naming-convention/index.js +3 -2
  99. package/esm/rules/no-anonymous-operations/index.js +0 -1
  100. package/esm/rules/no-deprecated/index.js +20 -8
  101. package/esm/rules/no-duplicate-fields/index.js +0 -1
  102. package/esm/rules/no-hashtag-description/index.js +0 -1
  103. package/esm/rules/no-one-place-fragments/index.js +2 -3
  104. package/esm/rules/no-root-type/index.js +2 -3
  105. package/esm/rules/no-scalar-result-type-on-mutation/index.js +2 -3
  106. package/esm/rules/no-typename-prefix/index.js +0 -1
  107. package/esm/rules/no-unreachable-types/index.js +5 -7
  108. package/esm/rules/no-unused-fields/index.d.ts +24 -3
  109. package/esm/rules/no-unused-fields/index.js +119 -10
  110. package/esm/rules/relay-arguments/index.js +2 -3
  111. package/esm/rules/relay-connection-types/index.js +0 -1
  112. package/esm/rules/relay-edge-types/index.js +2 -3
  113. package/esm/rules/relay-page-info/index.js +2 -3
  114. package/esm/rules/require-deprecation-date/index.js +0 -1
  115. package/esm/rules/require-deprecation-reason/index.js +0 -1
  116. package/esm/rules/require-description/index.js +2 -8
  117. package/esm/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
  118. package/esm/rules/require-import-fragment/index.js +9 -5
  119. package/esm/rules/require-nullable-fields-with-oneof/index.js +0 -1
  120. package/esm/rules/require-nullable-result-in-root/index.js +2 -3
  121. package/esm/rules/require-selections/index.js +15 -9
  122. package/esm/rules/require-type-pattern-with-oneof/index.js +0 -1
  123. package/esm/rules/selection-set-depth/index.js +4 -5
  124. package/esm/rules/strict-id-in-types/index.js +2 -3
  125. package/esm/rules/unique-enum-value-names/index.js +0 -1
  126. package/esm/rules/unique-fragment-name/index.js +2 -3
  127. package/esm/rules/unique-operation-name/index.js +0 -1
  128. package/esm/schema.js +0 -1
  129. package/esm/siblings.js +0 -1
  130. package/esm/types.d.ts +1 -0
  131. package/esm/utils.d.ts +4 -4
  132. package/esm/utils.js +8 -9
  133. package/index.browser.js +514 -426
  134. package/package.json +2 -2
  135. package/cjs/chunk-UIAXBAMD.js +0 -8
  136. package/esm/chunk-UIAXBAMD.js +0 -8
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _nodepath = require('node:path'); var _nodepath2 = _interopRequireDefault(_nodepath);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }var _nodepath = require('node:path'); var _nodepath2 = _interopRequireDefault(_nodepath);
3
2
  var _utilsjs = require('../../utils.js');
4
3
  const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expression", rule = exports.rule = {
5
4
  meta: {
@@ -75,7 +74,7 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
75
74
  schema: []
76
75
  },
77
76
  create(context) {
78
- const comments = context.getSourceCode().getAllComments(), siblings = _utilsjs.requireSiblingsOperations.call(void 0, RULE_ID, context), filePath = context.filename;
77
+ const comments = context.getSourceCode().getAllComments(), siblings = _utilsjs.requireGraphQLOperations.call(void 0, RULE_ID, context), filePath = context.filename;
79
78
  return {
80
79
  "FragmentSpread > .name"(node) {
81
80
  const fragmentName = node.value, fragmentsFromSiblings = siblings.getFragment(fragmentName);
@@ -85,7 +84,7 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
85
84
  ).test(comment.value)) continue;
86
85
  const extractedImportPath = _optionalChain([comment, 'access', _ => _.value, 'access', _2 => _2.match, 'call', _3 => _3(/(["'])((?:\1|.)*?)\1/), 'optionalAccess', _4 => _4[2]]);
87
86
  if (!extractedImportPath) continue;
88
- const importPath = _nodepath2.default.join(_nodepath2.default.dirname(filePath), extractedImportPath);
87
+ const importPath = _nodepath2.default.join(filePath, "..", extractedImportPath);
89
88
  if (fragmentsFromSiblings.some(
90
89
  (source) => source.filePath === importPath
91
90
  )) return;
@@ -93,7 +92,12 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
93
92
  if (fragmentsFromSiblings.some(
94
93
  (source) => source.filePath === filePath
95
94
  )) return;
96
- const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) => _nodepath2.default.relative(_nodepath2.default.dirname(filePath), o.filePath)) : ["CHANGE_ME.graphql"];
95
+ const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map(
96
+ (o) => (
97
+ // Use always forward slash for suggested import path
98
+ _utilsjs.slash.call(void 0, _nodepath2.default.relative(_nodepath2.default.dirname(filePath), o.filePath))
99
+ )
100
+ ) : ["CHANGE_ME.graphql"];
97
101
  context.report({
98
102
  node,
99
103
  messageId: RULE_ID,
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-UIAXBAMD.js');
2
- var _graphql = require('graphql');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _graphql = require('graphql');
3
2
  var _utilsjs = require('../../utils.js');
4
3
  const RULE_ID = "require-nullable-fields-with-oneof", rule = exports.rule = {
5
4
  meta: {
@@ -1,5 +1,4 @@
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');
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; }var _graphql = require('graphql');
3
2
  var _utilsjs = require('../../utils.js');
4
3
  const RULE_ID = "require-nullable-result-in-root", rule = exports.rule = {
5
4
  meta: {
@@ -43,7 +42,7 @@ const RULE_ID = "require-nullable-result-in-root", rule = exports.rule = {
43
42
  schema: []
44
43
  },
45
44
  create(context) {
46
- const schema = _utilsjs.requireGraphQLSchemaFromContext.call(void 0, RULE_ID, context), rootTypeNames = new Set(
45
+ const schema = _utilsjs.requireGraphQLSchema.call(void 0, RULE_ID, context), rootTypeNames = new Set(
47
46
  [schema.getQueryType(), schema.getMutationType()].filter(_utilsjs.truthy).map((type) => type.name)
48
47
  ), sourceCode = context.getSourceCode();
49
48
  return {
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-UIAXBAMD.js');
2
-
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
3
2
 
4
3
 
5
4
 
@@ -95,7 +94,8 @@ const RULE_ID = "require-selections", DEFAULT_ID_FIELD_NAME = "id", schema = {
95
94
  )
96
95
  }
97
96
  ],
98
- recommended: !0
97
+ recommended: !0,
98
+ whenNotToUseIt: "Relay Compiler automatically adds an `id` field to any type that has an `id` field, even if it hasn't been explicitly requested. Requesting a field that is not used directly in the code can conflict with another Relay rule: `relay/unused-fields`."
99
99
  },
100
100
  messages: {
101
101
  [RULE_ID]: `Field{{ pluralSuffix }} {{ fieldName }} must be selected when it's available on a type.
@@ -104,7 +104,7 @@ Include it in your selection set{{ addition }}.`
104
104
  schema
105
105
  },
106
106
  create(context) {
107
- const schema2 = _utilsjs.requireGraphQLSchemaFromContext.call(void 0, RULE_ID, context), siblings = _utilsjs.requireSiblingsOperations.call(void 0, RULE_ID, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = _utils.asArray.call(void 0, fieldName), selector = "OperationDefinition SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new (0, _graphql.TypeInfo)(schema2);
107
+ const schema2 = _utilsjs.requireGraphQLSchema.call(void 0, RULE_ID, context), siblings = _utilsjs.requireGraphQLOperations.call(void 0, RULE_ID, context), { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {}, idNames = _utils.asArray.call(void 0, fieldName), selector = "SelectionSet[parent.kind!=/(^OperationDefinition|InlineFragment)$/]", typeInfo = new (0, _graphql.TypeInfo)(schema2);
108
108
  function checkFragments(node) {
109
109
  for (const selection of node.selections) {
110
110
  if (selection.kind !== _graphql.Kind.FRAGMENT_SPREAD)
@@ -131,13 +131,19 @@ Include it in your selection set{{ addition }}.`
131
131
  const rawType = _indexjs.getBaseType.call(void 0, type);
132
132
  if (rawType instanceof _graphql.GraphQLObjectType || rawType instanceof _graphql.GraphQLInterfaceType)
133
133
  checkFields(rawType);
134
- else if (rawType instanceof _graphql.GraphQLUnionType) {
135
- for (const selection of node.selections)
134
+ else if (rawType instanceof _graphql.GraphQLUnionType)
135
+ for (const selection of node.selections) {
136
+ const types = rawType.getTypes();
136
137
  if (selection.kind === _graphql.Kind.INLINE_FRAGMENT) {
137
- const t = rawType.getTypes().find((t2) => t2.name === selection.typeCondition.name.value);
138
+ const t = types.find((t2) => t2.name === selection.typeCondition.name.value);
138
139
  t && checkFields(t);
140
+ } else if (selection.kind === _graphql.Kind.FRAGMENT_SPREAD) {
141
+ const [foundSpread] = siblings.getFragment(selection.name.value);
142
+ if (!foundSpread) return;
143
+ const fragmentSpread = foundSpread.document, t = fragmentSpread.typeCondition.name.value === rawType.name ? rawType : types.find((t2) => t2.name === fragmentSpread.typeCondition.name.value);
144
+ checkedFragmentSpreads.add(fragmentSpread.name.value), checkSelections(fragmentSpread.selectionSet, t, loc, parent, checkedFragmentSpreads);
139
145
  }
140
- }
146
+ }
141
147
  function checkFields(rawType2) {
142
148
  const fields = rawType2.getFields();
143
149
  if (!idNames.some((name) => fields[name]))
@@ -1,5 +1,4 @@
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 _utilsjs = require('../../utils.js');
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; }var _utilsjs = require('../../utils.js');
3
2
  const RULE_ID = "require-type-pattern-with-oneof", rule = exports.rule = {
4
3
  meta: {
5
4
  type: "suggestion",
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('../../chunk-UIAXBAMD.js');
2
- var _graphql = require('graphql');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _graphql = require('graphql');
3
2
  var _graphqldepthlimit = require('graphql-depth-limit'); var _graphqldepthlimit2 = _interopRequireDefault(_graphqldepthlimit);
4
3
  var _utilsjs = require('../../utils.js');
5
4
  const RULE_ID = "selection-set-depth", schema = {
@@ -75,10 +74,10 @@ const RULE_ID = "selection-set-depth", schema = {
75
74
  create(context) {
76
75
  let siblings = null;
77
76
  try {
78
- siblings = _utilsjs.requireSiblingsOperations.call(void 0, RULE_ID, context);
77
+ siblings = _utilsjs.requireGraphQLOperations.call(void 0, RULE_ID, context);
79
78
  } catch (e2) {
80
79
  _utilsjs.logger.warn(
81
- `Rule "${RULE_ID}" works best with siblings operations loaded. For more info: https://bit.ly/graphql-eslint-operations`
80
+ `Rule "${RULE_ID}" works best with siblings operations loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`
82
81
  );
83
82
  }
84
83
  const { maxDepth, ignore = [] } = context.options[0], checkFn = _graphqldepthlimit2.default.call(void 0, maxDepth, { ignore });
@@ -120,7 +119,7 @@ const RULE_ID = "selection-set-depth", schema = {
120
119
  });
121
120
  } catch (e) {
122
121
  _utilsjs.logger.warn(
123
- `Rule "${RULE_ID}" check failed due to a missing siblings operations. For more info: https://bit.ly/graphql-eslint-operations`,
122
+ `Rule "${RULE_ID}" check failed due to a missing siblings operations. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`,
124
123
  e
125
124
  );
126
125
  }
@@ -1,5 +1,4 @@
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');
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; }var _graphql = require('graphql');
3
2
 
4
3
 
5
4
 
@@ -123,7 +122,7 @@ const RULE_ID = "strict-id-in-types", schema = {
123
122
  acceptedIdTypes: ["ID"],
124
123
  exceptions: {},
125
124
  ...context.options[0]
126
- }, schema2 = _utilsjs.requireGraphQLSchemaFromContext.call(void 0, RULE_ID, context);
125
+ }, schema2 = _utilsjs.requireGraphQLSchema.call(void 0, RULE_ID, context);
127
126
  return {
128
127
  [`ObjectTypeDefinition[name.value!=/^(${[
129
128
  schema2.getQueryType(),
@@ -1,5 +1,4 @@
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');
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; }var _graphql = require('graphql');
3
2
  var _utilsjs = require('../../utils.js');
4
3
  const rule = {
5
4
  meta: {
@@ -1,9 +1,8 @@
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 _nodepath = require('node:path');
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; }var _nodepath = require('node:path');
3
2
  var _graphql = require('graphql');
4
3
  var _utilsjs = require('../../utils.js');
5
4
  const RULE_ID = "unique-fragment-name", checkNode = exports.checkNode = (context, node, ruleId) => {
6
- const documentName = node.name.value, siblings = _utilsjs.requireSiblingsOperations.call(void 0, ruleId, context), siblingDocuments = node.kind === _graphql.Kind.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
5
+ const documentName = node.name.value, siblings = _utilsjs.requireGraphQLOperations.call(void 0, ruleId, context), siblingDocuments = node.kind === _graphql.Kind.FRAGMENT_DEFINITION ? siblings.getFragment(documentName) : siblings.getOperation(documentName), filepath = context.filename, conflictingDocuments = siblingDocuments.filter((f) => {
7
6
  const isSameName = _optionalChain([f, 'access', _ => _.document, 'access', _2 => _2.name, 'optionalAccess', _3 => _3.value]) === documentName, isSamePath = _utilsjs.slash.call(void 0, f.filePath) === _utilsjs.slash.call(void 0, filepath);
8
7
  return isSameName && !isSamePath;
9
8
  });
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-UIAXBAMD.js');
2
- var _indexjs = require('../unique-fragment-name/index.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _indexjs = require('../unique-fragment-name/index.js');
3
2
  const RULE_ID = "unique-operation-name", rule = exports.rule = {
4
3
  meta: {
5
4
  type: "suggestion",
package/cjs/schema.js CHANGED
@@ -1,5 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-UIAXBAMD.js');
2
- var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
3
2
  var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
4
3
  var _graphql = require('graphql');
5
4
  var _cachejs = require('./cache.js');
package/cjs/siblings.js CHANGED
@@ -1,5 +1,4 @@
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
-
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; }
3
2
 
4
3
 
5
4
  var _graphql = require('graphql');
package/cjs/types.d.cts CHANGED
@@ -52,6 +52,7 @@ type RuleDocsInfo<T> = Omit<RuleMetaDataDocs, 'category' | 'suggestion'> & {
52
52
  };
53
53
  graphQLJSRuleName?: string;
54
54
  isDisabledForAllConfig?: true;
55
+ whenNotToUseIt?: string;
55
56
  };
56
57
  type GraphQLESLintRuleListener<WithTypeInfo extends boolean = false> = Record<string, any> & {
57
58
  [K in keyof ASTKindToNode]?: (node: GraphQLESTreeNode<ASTKindToNode[K], WithTypeInfo>) => void;
package/cjs/utils.d.cts CHANGED
@@ -8,8 +8,8 @@ import '@graphql-tools/utils';
8
8
  import 'graphql-config';
9
9
  import 'json-schema-to-ts';
10
10
 
11
- declare function requireSiblingsOperations(ruleId: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
12
- declare function requireGraphQLSchemaFromContext(ruleId: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
11
+ declare function requireGraphQLOperations(ruleId: string, context: GraphQLESLintRuleContext): SiblingOperations | never;
12
+ declare function requireGraphQLSchema(ruleId: string, context: GraphQLESLintRuleContext): GraphQLSchema | never;
13
13
  declare const logger: {
14
14
  error: (...args: unknown[]) => void;
15
15
  warn: (...args: unknown[]) => void;
@@ -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
- 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 };
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, requireGraphQLOperations, requireGraphQLSchema, slash, truthy };
package/cjs/utils.js CHANGED
@@ -1,19 +1,18 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }var _graphql = require('graphql');
3
2
  var _lodashlowercase = require('lodash.lowercase'); var _lodashlowercase2 = _interopRequireDefault(_lodashlowercase);
4
- function requireSiblingsOperations(ruleId, context) {
3
+ function requireGraphQLOperations(ruleId, context) {
5
4
  const { siblingOperations } = context.sourceCode.parserServices;
6
5
  if (!siblingOperations.available)
7
6
  throw new Error(
8
- `Rule \`${ruleId}\` requires graphql-config \`documents\` field to be set and loaded. See https://the-guild.dev/graphql/config/docs/user/documents for more info`
7
+ `Rule \`${ruleId}\` requires graphql-config \`documents\` field to be set and loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-operations for more info`
9
8
  );
10
9
  return siblingOperations;
11
10
  }
12
- function requireGraphQLSchemaFromContext(ruleId, context) {
11
+ function requireGraphQLSchema(ruleId, context) {
13
12
  const { schema } = context.sourceCode.parserServices;
14
13
  if (!schema)
15
14
  throw new Error(
16
- `Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/config/docs/user/schema for more info`
15
+ `Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/eslint/docs/usage#providing-schema for more info`
17
16
  );
18
17
  return schema;
19
18
  }
@@ -29,7 +28,7 @@ const chalk = {
29
28
  // eslint-disable-next-line no-console
30
29
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
31
30
  )
32
- }, slash = exports.slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = exports.VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = exports.CWD = process.cwd(), getTypeName = exports.getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = exports.TYPES_KINDS = [
31
+ }, slash = exports.slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = exports.VIRTUAL_DOCUMENT_REGEX = /[/\\]\d+_document.graphql$/, CWD = exports.CWD = process.cwd(), getTypeName = exports.getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = exports.TYPES_KINDS = [
33
32
  _graphql.Kind.OBJECT_TYPE_DEFINITION,
34
33
  _graphql.Kind.INTERFACE_TYPE_DEFINITION,
35
34
  _graphql.Kind.ENUM_TYPE_DEFINITION,
@@ -123,7 +122,7 @@ const DisplayNodeNameMap = {
123
122
  [_graphql.Kind.VARIABLE]: "variable"
124
123
  };
125
124
  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])}"`;
125
+ 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
126
  }
128
127
  function getNodeName(node) {
129
128
  switch (node.kind) {
@@ -164,4 +163,4 @@ function getNodeName(node) {
164
163
 
165
164
 
166
165
 
167
- exports.ARRAY_DEFAULT_OPTIONS = ARRAY_DEFAULT_OPTIONS; exports.CWD = CWD; exports.REPORT_ON_FIRST_CHARACTER = REPORT_ON_FIRST_CHARACTER; exports.TYPES_KINDS = TYPES_KINDS; exports.VIRTUAL_DOCUMENT_REGEX = VIRTUAL_DOCUMENT_REGEX; exports.camelCase = camelCase; exports.convertCase = convertCase; exports.displayNodeName = displayNodeName; exports.englishJoinWords = englishJoinWords; exports.getLocation = getLocation; exports.getNodeName = getNodeName; exports.getTypeName = getTypeName; exports.logger = logger; exports.pascalCase = pascalCase; exports.requireGraphQLSchemaFromContext = requireGraphQLSchemaFromContext; exports.requireSiblingsOperations = requireSiblingsOperations; exports.slash = slash; exports.truthy = truthy;
166
+ exports.ARRAY_DEFAULT_OPTIONS = ARRAY_DEFAULT_OPTIONS; exports.CWD = CWD; exports.REPORT_ON_FIRST_CHARACTER = REPORT_ON_FIRST_CHARACTER; exports.TYPES_KINDS = TYPES_KINDS; exports.VIRTUAL_DOCUMENT_REGEX = VIRTUAL_DOCUMENT_REGEX; exports.camelCase = camelCase; exports.convertCase = convertCase; exports.displayNodeName = displayNodeName; exports.englishJoinWords = englishJoinWords; exports.getLocation = getLocation; exports.getNodeName = getNodeName; exports.getTypeName = getTypeName; exports.logger = logger; exports.pascalCase = pascalCase; exports.requireGraphQLOperations = requireGraphQLOperations; exports.requireGraphQLSchema = requireGraphQLSchema; exports.slash = slash; exports.truthy = truthy;
package/esm/cache.js CHANGED
@@ -1,4 +1,3 @@
1
- import "./chunk-UIAXBAMD.js";
2
1
  import debugFactory from "debug";
3
2
  const log = debugFactory("graphql-eslint:ModuleCache");
4
3
  class ModuleCache {