@graphql-eslint/eslint-plugin 4.0.0-alpha.3 → 4.0.0-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -0
- package/cjs/meta.d.cts +1 -2
- package/cjs/meta.js +3 -5
- package/esm/meta.d.ts +1 -2
- package/esm/meta.js +2 -3
- package/index.browser.js +38 -38
- package/package.json +2 -2
package/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/bdb8cd5d-5186-4ece-b06b-b00a499b7868)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_eslint&utm_campaign=readme)
|
2
|
+
|
1
3
|
# GraphQL-ESLint
|
2
4
|
|
3
5
|
[![npm version](https://badge.fury.io/js/%40graphql-eslint%2Feslint-plugin.svg)](https://badge.fury.io/js/%40graphql-eslint%2Feslint-plugin)
|
package/cjs/meta.d.cts
CHANGED
package/cjs/meta.js
CHANGED
@@ -5,8 +5,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
7
|
var __export = (target, all) => {
|
8
|
-
for (var
|
9
|
-
__defProp(target,
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
10
10
|
}, __copyProps = (to, from, except, desc) => {
|
11
11
|
if (from && typeof from == "object" || typeof from == "function")
|
12
12
|
for (let key of __getOwnPropNames(from))
|
@@ -23,14 +23,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
23
23
|
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
24
24
|
var meta_exports = {};
|
25
25
|
__export(meta_exports, {
|
26
|
-
name: () => name,
|
27
26
|
version: () => version
|
28
27
|
});
|
29
28
|
module.exports = __toCommonJS(meta_exports);
|
30
29
|
var import_package = __toESM(require("../package.json"), 1);
|
31
|
-
const {
|
30
|
+
const { version } = import_package.default;
|
32
31
|
// Annotate the CommonJS export names for ESM import in node:
|
33
32
|
0 && (module.exports = {
|
34
|
-
name,
|
35
33
|
version
|
36
34
|
});
|
package/esm/meta.d.ts
CHANGED
package/esm/meta.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import "./chunk-UIAXBAMD.js";
|
2
|
-
import packageJson from "../package.json"
|
3
|
-
const {
|
2
|
+
import packageJson from "../package.json" with { type: "json" };
|
3
|
+
const { version } = packageJson;
|
4
4
|
export {
|
5
|
-
name,
|
6
5
|
version
|
7
6
|
};
|
package/index.browser.js
CHANGED
@@ -390,7 +390,7 @@ function convertToESTree(node, schema15) {
|
|
390
390
|
// package.json
|
391
391
|
var package_default = {
|
392
392
|
name: "@graphql-eslint/eslint-plugin",
|
393
|
-
version: "4.0.0-alpha.
|
393
|
+
version: "4.0.0-alpha.4",
|
394
394
|
type: "module",
|
395
395
|
description: "GraphQL plugin for ESLint",
|
396
396
|
repository: "https://github.com/B2o5T/graphql-eslint",
|
@@ -435,7 +435,7 @@ var package_default = {
|
|
435
435
|
},
|
436
436
|
dependencies: {
|
437
437
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
438
|
-
"@graphql-tools/graphql-tag-pluck": "8.3.2
|
438
|
+
"@graphql-tools/graphql-tag-pluck": "8.3.2",
|
439
439
|
"@graphql-tools/utils": "^10.0.0",
|
440
440
|
debug: "^4.3.4",
|
441
441
|
"fast-glob": "^3.2.12",
|
@@ -453,7 +453,7 @@ var package_default = {
|
|
453
453
|
"@types/lodash.lowercase": "4.3.9",
|
454
454
|
graphql: "16.9.0",
|
455
455
|
"json-schema-to-ts": "2.12.0",
|
456
|
-
"vite-tsconfig-paths": "^
|
456
|
+
"vite-tsconfig-paths": "^5.0.0"
|
457
457
|
},
|
458
458
|
publishConfig: {
|
459
459
|
directory: "dist",
|
@@ -463,7 +463,7 @@ var package_default = {
|
|
463
463
|
};
|
464
464
|
|
465
465
|
// src/meta.ts
|
466
|
-
var {
|
466
|
+
var { version } = package_default;
|
467
467
|
|
468
468
|
// src/siblings.ts
|
469
469
|
import {
|
@@ -641,7 +641,7 @@ function getSiblings(documents) {
|
|
641
641
|
cachedOperations = result;
|
642
642
|
}
|
643
643
|
return cachedOperations;
|
644
|
-
}, getFragment = (
|
644
|
+
}, getFragment = (name) => getFragments().filter((f) => f.document.name.value === name), collectFragments = (selectable, recursive, collected = /* @__PURE__ */ new Map()) => (visit2(selectable, {
|
645
645
|
FragmentSpread(spread) {
|
646
646
|
let fragmentName = spread.name.value, [fragment] = getFragment(fragmentName);
|
647
647
|
if (!fragment) {
|
@@ -658,7 +658,7 @@ function getSiblings(documents) {
|
|
658
658
|
getFragments,
|
659
659
|
getFragmentByType: (typeName) => getFragments().filter((f) => f.document.typeCondition.name.value === typeName),
|
660
660
|
getFragmentsInUse: (selectable, recursive = !0) => Array.from(collectFragments(selectable, recursive).values()),
|
661
|
-
getOperation: (
|
661
|
+
getOperation: (name) => getOperations().filter((o) => o.document.name?.value === name),
|
662
662
|
getOperations,
|
663
663
|
getOperationByType: (type) => getOperations().filter((o) => o.document.operation === type)
|
664
664
|
};
|
@@ -1176,10 +1176,10 @@ function validateDocument({
|
|
1176
1176
|
loc,
|
1177
1177
|
message: error.message,
|
1178
1178
|
suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
|
1179
|
-
let { name
|
1179
|
+
let { name } = match.groups;
|
1180
1180
|
return {
|
1181
|
-
desc: `Rename to \`${
|
1182
|
-
fix: (fixer) => fixer.replaceText(token,
|
1181
|
+
desc: `Rename to \`${name}\``,
|
1182
|
+
fix: (fixer) => fixer.replaceText(token, name)
|
1183
1183
|
};
|
1184
1184
|
}) : []
|
1185
1185
|
});
|
@@ -1203,7 +1203,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1203
1203
|
}), { fragmentDefs, fragmentSpreads };
|
1204
1204
|
}, getMissingFragments = (node) => {
|
1205
1205
|
let { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
|
1206
|
-
return [...fragmentSpreads].filter((
|
1206
|
+
return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
|
1207
1207
|
}, handleMissingFragments = ({ ruleId, context, node }) => {
|
1208
1208
|
let missingFragments = getMissingFragments(node);
|
1209
1209
|
if (missingFragments.length > 0) {
|
@@ -1840,10 +1840,10 @@ Using the same name for all input parameters will make your schemas easier to co
|
|
1840
1840
|
return currentNode;
|
1841
1841
|
})(node);
|
1842
1842
|
if (shouldCheckType(inputValueNode.parent.parent)) {
|
1843
|
-
let mutationName = `${inputValueNode.parent.name.value}Input`,
|
1844
|
-
(options.caseSensitiveInputType && node.name.value !== mutationName ||
|
1843
|
+
let mutationName = `${inputValueNode.parent.name.value}Input`, name = node.name.value;
|
1844
|
+
(options.caseSensitiveInputType && node.name.value !== mutationName || name.toLowerCase() !== mutationName.toLowerCase()) && context.report({
|
1845
1845
|
node: node.name,
|
1846
|
-
message: `Input type \`${
|
1846
|
+
message: `Input type \`${name}\` name should be \`${mutationName}\`.`,
|
1847
1847
|
suggest: [
|
1848
1848
|
{
|
1849
1849
|
desc: `Rename to \`${mutationName}\``,
|
@@ -1926,11 +1926,11 @@ var RULE_ID2 = "lone-executable-definition", definitionTypes = ["fragment", ...O
|
|
1926
1926
|
},
|
1927
1927
|
"Document:exit"() {
|
1928
1928
|
for (let { node, type } of definitions.slice(1)) {
|
1929
|
-
let
|
1930
|
-
definitionName && (
|
1929
|
+
let name = pascalCase(type), definitionName = node.name?.value;
|
1930
|
+
definitionName && (name += ` "${definitionName}"`), context.report({
|
1931
1931
|
loc: node.name?.loc || getLocation(node.loc.start, type),
|
1932
1932
|
messageId: RULE_ID2,
|
1933
|
-
data: { name
|
1933
|
+
data: { name }
|
1934
1934
|
});
|
1935
1935
|
}
|
1936
1936
|
}
|
@@ -2497,51 +2497,51 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
2497
2497
|
report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
|
2498
2498
|
}
|
2499
2499
|
function getError() {
|
2500
|
-
let
|
2501
|
-
if (ignorePattern && new RegExp(ignorePattern, "u").test(
|
2500
|
+
let name = nodeName.replace(/(^_+)|(_+$)/g, "");
|
2501
|
+
if (ignorePattern && new RegExp(ignorePattern, "u").test(name))
|
2502
2502
|
return;
|
2503
|
-
if (prefix && !
|
2503
|
+
if (prefix && !name.startsWith(prefix))
|
2504
2504
|
return {
|
2505
2505
|
errorMessage: `have "${prefix}" prefix`,
|
2506
|
-
renameToNames: [prefix +
|
2506
|
+
renameToNames: [prefix + name]
|
2507
2507
|
};
|
2508
|
-
if (suffix && !
|
2508
|
+
if (suffix && !name.endsWith(suffix))
|
2509
2509
|
return {
|
2510
2510
|
errorMessage: `have "${suffix}" suffix`,
|
2511
|
-
renameToNames: [
|
2511
|
+
renameToNames: [name + suffix]
|
2512
2512
|
};
|
2513
|
-
let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) =>
|
2513
|
+
let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
|
2514
2514
|
if (forbiddenPrefix)
|
2515
2515
|
return {
|
2516
2516
|
errorMessage: `not have "${forbiddenPrefix}" prefix`,
|
2517
|
-
renameToNames: [
|
2517
|
+
renameToNames: [name.replace(new RegExp(`^${forbiddenPrefix}`), "")]
|
2518
2518
|
};
|
2519
|
-
let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) =>
|
2519
|
+
let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) => name.endsWith(suffix2));
|
2520
2520
|
if (forbiddenSuffix)
|
2521
2521
|
return {
|
2522
2522
|
errorMessage: `not have "${forbiddenSuffix}" suffix`,
|
2523
|
-
renameToNames: [
|
2523
|
+
renameToNames: [name.replace(new RegExp(`${forbiddenSuffix}$`), "")]
|
2524
2524
|
};
|
2525
|
-
if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) =>
|
2525
|
+
if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) => name.startsWith(requiredPrefix)))
|
2526
2526
|
return {
|
2527
2527
|
errorMessage: `have one of the following prefixes: ${englishJoinWords(
|
2528
2528
|
requiredPrefixes
|
2529
2529
|
)}`,
|
2530
|
-
renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${
|
2530
|
+
renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${name}`)) : requiredPrefixes.map((prefix2) => `${prefix2}${name}`)
|
2531
2531
|
};
|
2532
|
-
if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) =>
|
2532
|
+
if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) => name.endsWith(requiredSuffix)))
|
2533
2533
|
return {
|
2534
2534
|
errorMessage: `have one of the following suffixes: ${englishJoinWords(
|
2535
2535
|
requiredSuffixes
|
2536
2536
|
)}`,
|
2537
|
-
renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${
|
2537
|
+
renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${name} ${suffix2}`)) : requiredSuffixes.map((suffix2) => `${name}${suffix2}`)
|
2538
2538
|
};
|
2539
2539
|
if (!style)
|
2540
2540
|
return;
|
2541
|
-
if (!StyleToRegex[style].test(
|
2541
|
+
if (!StyleToRegex[style].test(name))
|
2542
2542
|
return {
|
2543
2543
|
errorMessage: `be in ${style} format`,
|
2544
|
-
renameToNames: [convertCase(style,
|
2544
|
+
renameToNames: [convertCase(style, name)]
|
2545
2545
|
};
|
2546
2546
|
}
|
2547
2547
|
}, checkUnderscore = (isLeading) => (node) => {
|
@@ -3028,8 +3028,8 @@ var RULE_ID7 = "no-one-place-fragments", rule11 = {
|
|
3028
3028
|
for (let { document, filePath } of allDocuments) {
|
3029
3029
|
let relativeFilePath = relative(CWD, filePath);
|
3030
3030
|
visit4(document, {
|
3031
|
-
FragmentSpread({ name
|
3032
|
-
let spreadName =
|
3031
|
+
FragmentSpread({ name }) {
|
3032
|
+
let spreadName = name.value;
|
3033
3033
|
usedFragmentsMap[spreadName] ||= [], usedFragmentsMap[spreadName].push(relativeFilePath);
|
3034
3034
|
}
|
3035
3035
|
});
|
@@ -4563,7 +4563,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
|
4563
4563
|
for (let field of node.fields || []) {
|
4564
4564
|
if (field.gqlType.type !== Kind20.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind20.NAMED_TYPE)
|
4565
4565
|
continue;
|
4566
|
-
let
|
4566
|
+
let name = field.gqlType.gqlType.name.value, type = schema15.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
|
4567
4567
|
context.report({
|
4568
4568
|
node: field.gqlType,
|
4569
4569
|
messageId: RULE_ID18,
|
@@ -4723,7 +4723,7 @@ Include it in your selection set{{ addition }}.`
|
|
4723
4723
|
}
|
4724
4724
|
function checkFields(rawType2) {
|
4725
4725
|
let fields = rawType2.getFields();
|
4726
|
-
if (!idNames.some((
|
4726
|
+
if (!idNames.some((name) => fields[name]))
|
4727
4727
|
return;
|
4728
4728
|
function hasIdField({ selections }) {
|
4729
4729
|
return selections.some((selection) => {
|
@@ -4745,8 +4745,8 @@ Include it in your selection set{{ addition }}.`
|
|
4745
4745
|
if (checkFragments(node), hasId)
|
4746
4746
|
return;
|
4747
4747
|
let pluralSuffix = idNames.length > 1 ? "s" : "", fieldName2 = englishJoinWords(
|
4748
|
-
idNames.map((
|
4749
|
-
), addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${englishJoinWords([...checkedFragmentSpreads].map((
|
4748
|
+
idNames.map((name) => `\`${(parent.alias || parent.name).value}.${name}\``)
|
4749
|
+
), addition = checkedFragmentSpreads.size === 0 ? "" : ` or add to used fragment${checkedFragmentSpreads.size > 1 ? "s" : ""} ${englishJoinWords([...checkedFragmentSpreads].map((name) => `\`${name}\``))}`, problem = {
|
4750
4750
|
loc,
|
4751
4751
|
messageId: RULE_ID19,
|
4752
4752
|
data: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "4.0.0-alpha.
|
3
|
+
"version": "4.0.0-alpha.4",
|
4
4
|
"type": "module",
|
5
5
|
"description": "GraphQL plugin for ESLint",
|
6
6
|
"repository": "https://github.com/B2o5T/graphql-eslint",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
42
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
43
|
-
"@graphql-tools/graphql-tag-pluck": "8.3.2
|
43
|
+
"@graphql-tools/graphql-tag-pluck": "8.3.2",
|
44
44
|
"@graphql-tools/utils": "^10.0.0",
|
45
45
|
"debug": "^4.3.4",
|
46
46
|
"fast-glob": "^3.2.12",
|