@graphql-eslint/eslint-plugin 4.0.0-alpha.9 → 4.0.1-alpha-20241127205058-a4fec1a6cf7006ea913f13e6afbf7ed2d82503c3
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/cjs/cache.js +1 -2
- package/cjs/configs/index.d.cts +427 -10
- package/cjs/configs/index.js +1 -2
- package/cjs/configs/operations-all.d.cts +8 -8
- package/cjs/configs/operations-all.js +30 -33
- package/cjs/configs/operations-recommended.d.cts +35 -35
- package/cjs/configs/operations-recommended.js +56 -59
- package/cjs/configs/schema-all.d.cts +12 -12
- package/cjs/configs/schema-all.js +26 -29
- package/cjs/configs/schema-recommended.d.cts +23 -23
- package/cjs/configs/schema-recommended.js +70 -73
- package/cjs/configs/schema-relay.d.cts +5 -5
- package/cjs/configs/schema-relay.js +14 -17
- package/cjs/documents.js +1 -2
- package/cjs/estree-converter/converter.js +1 -2
- package/cjs/estree-converter/utils.js +1 -2
- package/cjs/graphql-config.d.cts +6 -1
- package/cjs/graphql-config.js +9 -3
- package/cjs/index.d.cts +436 -16
- package/cjs/index.js +2 -3
- package/cjs/meta.js +1 -2
- package/cjs/parser.js +2 -6
- package/cjs/processor.js +5 -2
- package/cjs/rules/alphabetize/index.js +1 -2
- package/cjs/rules/description-style/index.js +1 -2
- package/cjs/rules/graphql-js-validation.js +4 -5
- package/cjs/rules/index.d.cts +6 -4
- package/cjs/rules/index.js +1 -2
- package/cjs/rules/input-name/index.js +1 -2
- package/cjs/rules/lone-executable-definition/index.js +1 -2
- package/cjs/rules/match-document-filename/index.js +1 -2
- package/cjs/rules/naming-convention/index.js +4 -3
- package/cjs/rules/no-anonymous-operations/index.js +1 -2
- package/cjs/rules/no-deprecated/index.js +20 -8
- package/cjs/rules/no-duplicate-fields/index.js +1 -2
- package/cjs/rules/no-hashtag-description/index.js +1 -2
- package/cjs/rules/no-one-place-fragments/index.js +2 -3
- package/cjs/rules/no-root-type/index.js +2 -3
- package/cjs/rules/no-scalar-result-type-on-mutation/index.js +2 -3
- package/cjs/rules/no-typename-prefix/index.js +1 -2
- package/cjs/rules/no-unreachable-types/index.js +4 -6
- package/cjs/rules/no-unused-fields/index.d.cts +24 -3
- package/cjs/rules/no-unused-fields/index.js +119 -10
- package/cjs/rules/relay-arguments/index.js +2 -3
- package/cjs/rules/relay-connection-types/index.js +1 -2
- package/cjs/rules/relay-edge-types/index.js +2 -3
- package/cjs/rules/relay-page-info/index.js +2 -3
- package/cjs/rules/require-deprecation-date/index.js +1 -2
- package/cjs/rules/require-deprecation-reason/index.js +1 -2
- package/cjs/rules/require-description/index.js +4 -8
- package/cjs/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
- package/cjs/rules/require-import-fragment/index.js +2 -3
- package/cjs/rules/require-nullable-fields-with-oneof/index.js +1 -2
- package/cjs/rules/require-nullable-result-in-root/index.js +2 -3
- package/cjs/rules/require-selections/index.js +14 -8
- package/cjs/rules/require-type-pattern-with-oneof/index.js +1 -2
- package/cjs/rules/selection-set-depth/index.js +4 -5
- package/cjs/rules/strict-id-in-types/index.js +2 -3
- package/cjs/rules/unique-enum-value-names/index.js +1 -2
- package/cjs/rules/unique-fragment-name/index.js +2 -3
- package/cjs/rules/unique-operation-name/index.js +1 -2
- package/cjs/schema.js +1 -2
- package/cjs/siblings.js +1 -2
- package/cjs/types.d.cts +1 -0
- package/cjs/utils.d.cts +4 -4
- package/cjs/utils.js +7 -8
- package/esm/cache.js +0 -1
- package/esm/configs/index.d.ts +427 -10
- package/esm/configs/index.js +0 -1
- package/esm/configs/operations-all.d.ts +7 -7
- package/esm/configs/operations-all.js +28 -33
- package/esm/configs/operations-recommended.d.ts +34 -34
- package/esm/configs/operations-recommended.js +54 -59
- package/esm/configs/schema-all.d.ts +11 -11
- package/esm/configs/schema-all.js +24 -29
- package/esm/configs/schema-recommended.d.ts +22 -22
- package/esm/configs/schema-recommended.js +68 -73
- package/esm/configs/schema-relay.d.ts +4 -4
- package/esm/configs/schema-relay.js +12 -17
- package/esm/documents.js +0 -1
- package/esm/estree-converter/converter.js +0 -1
- package/esm/estree-converter/utils.js +0 -1
- package/esm/graphql-config.d.ts +6 -1
- package/esm/graphql-config.js +8 -2
- package/esm/index.d.ts +436 -16
- package/esm/index.js +3 -4
- package/esm/meta.js +1 -2
- package/esm/parser.js +3 -7
- package/esm/processor.js +4 -1
- package/esm/rules/alphabetize/index.js +0 -1
- package/esm/rules/description-style/index.js +0 -1
- package/esm/rules/graphql-js-validation.js +5 -6
- package/esm/rules/index.d.ts +6 -4
- package/esm/rules/index.js +0 -1
- package/esm/rules/input-name/index.js +0 -1
- package/esm/rules/lone-executable-definition/index.js +0 -1
- package/esm/rules/match-document-filename/index.js +0 -1
- package/esm/rules/naming-convention/index.js +3 -2
- package/esm/rules/no-anonymous-operations/index.js +0 -1
- package/esm/rules/no-deprecated/index.js +20 -8
- package/esm/rules/no-duplicate-fields/index.js +0 -1
- package/esm/rules/no-hashtag-description/index.js +0 -1
- package/esm/rules/no-one-place-fragments/index.js +2 -3
- package/esm/rules/no-root-type/index.js +2 -3
- package/esm/rules/no-scalar-result-type-on-mutation/index.js +2 -3
- package/esm/rules/no-typename-prefix/index.js +0 -1
- package/esm/rules/no-unreachable-types/index.js +5 -7
- package/esm/rules/no-unused-fields/index.d.ts +24 -3
- package/esm/rules/no-unused-fields/index.js +119 -10
- package/esm/rules/relay-arguments/index.js +2 -3
- package/esm/rules/relay-connection-types/index.js +0 -1
- package/esm/rules/relay-edge-types/index.js +2 -3
- package/esm/rules/relay-page-info/index.js +2 -3
- package/esm/rules/require-deprecation-date/index.js +0 -1
- package/esm/rules/require-deprecation-reason/index.js +0 -1
- package/esm/rules/require-description/index.js +4 -8
- package/esm/rules/require-field-of-type-query-in-mutation-result/index.js +2 -3
- package/esm/rules/require-import-fragment/index.js +2 -3
- package/esm/rules/require-nullable-fields-with-oneof/index.js +0 -1
- package/esm/rules/require-nullable-result-in-root/index.js +2 -3
- package/esm/rules/require-selections/index.js +15 -9
- package/esm/rules/require-type-pattern-with-oneof/index.js +0 -1
- package/esm/rules/selection-set-depth/index.js +4 -5
- package/esm/rules/strict-id-in-types/index.js +2 -3
- package/esm/rules/unique-enum-value-names/index.js +0 -1
- package/esm/rules/unique-fragment-name/index.js +2 -3
- package/esm/rules/unique-operation-name/index.js +0 -1
- package/esm/schema.js +0 -1
- package/esm/siblings.js +0 -1
- package/esm/types.d.ts +1 -0
- package/esm/utils.d.ts +4 -4
- package/esm/utils.js +7 -8
- package/index.browser.js +508 -423
- package/package.json +2 -2
- package/cjs/chunk-UIAXBAMD.js +0 -8
- package/esm/chunk-UIAXBAMD.js +0 -8
@@ -1,5 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('
|
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('
|
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.
|
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});
|
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.
|
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 =
|
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('../../
|
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('
|
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.
|
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.
|
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.
|
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('
|
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.
|
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('
|
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('
|
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.
|
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('
|
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('
|
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; }
|
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
|
12
|
-
declare function
|
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,
|
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('
|
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
|
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/
|
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
|
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/
|
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
|
}
|
@@ -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.
|
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