@graphql-eslint/eslint-plugin 4.0.0-alpha.2 → 4.0.0-alpha.4
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/README.md +2 -0
- package/cjs/configs/index.d.cts +5 -0
- package/cjs/configs/index.js +12 -1
- package/cjs/index.d.cts +0 -1
- package/cjs/index.js +1 -3
- package/cjs/meta.d.cts +1 -2
- package/cjs/meta.js +3 -5
- package/cjs/rules/index.d.cts +4 -4
- package/esm/configs/index.d.ts +5 -0
- package/esm/configs/index.js +12 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -2
- package/esm/meta.d.ts +1 -2
- package/esm/meta.js +2 -3
- package/esm/rules/index.d.ts +4 -4
- package/index.browser.js +50 -78
- package/package.json +3 -3
- package/cjs/flat-configs.d.cts +0 -75
- package/cjs/flat-configs.js +0 -53
- package/esm/flat-configs.d.ts +0 -75
- package/esm/flat-configs.js +0 -34
package/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_eslint&utm_campaign=readme)
|
2
|
+
|
1
3
|
# GraphQL-ESLint
|
2
4
|
|
3
5
|
[](https://badge.fury.io/js/%40graphql-eslint%2Feslint-plugin)
|
package/cjs/configs/index.d.cts
CHANGED
@@ -4,6 +4,11 @@ declare const configs: {
|
|
4
4
|
'schema-relay': any;
|
5
5
|
'operations-recommended': any;
|
6
6
|
'operations-all': any;
|
7
|
+
'flat/schema-recommended': any;
|
8
|
+
'flat/schema-all': any;
|
9
|
+
'flat/schema-relay': any;
|
10
|
+
'flat/operations-recommended': any;
|
11
|
+
'flat/operations-all': any;
|
7
12
|
};
|
8
13
|
|
9
14
|
export { configs };
|
package/cjs/configs/index.js
CHANGED
@@ -32,7 +32,18 @@ const configs = {
|
|
32
32
|
"schema-all": import_schema_all.default,
|
33
33
|
"schema-relay": import_schema_relay.default,
|
34
34
|
"operations-recommended": import_operations_recommended.default,
|
35
|
-
"operations-all": import_operations_all.default
|
35
|
+
"operations-all": import_operations_all.default,
|
36
|
+
"flat/schema-recommended": import_schema_recommended.default.rules,
|
37
|
+
"flat/schema-all": {
|
38
|
+
...import_schema_recommended.default.rules,
|
39
|
+
...import_schema_all.default.rules
|
40
|
+
},
|
41
|
+
"flat/schema-relay": import_schema_relay.default.rules,
|
42
|
+
"flat/operations-recommended": import_operations_recommended.default.rules,
|
43
|
+
"flat/operations-all": {
|
44
|
+
...import_operations_recommended.default.rules,
|
45
|
+
...import_operations_all.default.rules
|
46
|
+
}
|
36
47
|
};
|
37
48
|
// Annotate the CommonJS export names for ESM import in node:
|
38
49
|
0 && (module.exports = {
|
package/cjs/index.d.cts
CHANGED
@@ -5,7 +5,6 @@ export { rules } from './rules/index.cjs';
|
|
5
5
|
export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRule, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf } from './types.cjs';
|
6
6
|
export { requireGraphQLSchemaFromContext, requireSiblingsOperations } from './utils.cjs';
|
7
7
|
export { configs } from './configs/index.cjs';
|
8
|
-
export { flatConfigs } from './flat-configs.cjs';
|
9
8
|
export { GraphQLESTreeNode } from './estree-converter/types.cjs';
|
10
9
|
import './rules/require-description.cjs';
|
11
10
|
import 'graphql';
|
package/cjs/index.js
CHANGED
@@ -16,7 +16,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
|
|
16
16
|
var src_exports = {};
|
17
17
|
__export(src_exports, {
|
18
18
|
configs: () => import_configs.configs,
|
19
|
-
flatConfigs: () => import_flat_configs.flatConfigs,
|
20
19
|
parseForESLint: () => import_parser.parseForESLint,
|
21
20
|
parser: () => import_parser.parser,
|
22
21
|
processors: () => processors,
|
@@ -27,12 +26,11 @@ __export(src_exports, {
|
|
27
26
|
module.exports = __toCommonJS(src_exports);
|
28
27
|
var import_processor = require("./processor.js"), import_parser = require("./parser.js"), import_rules = require("./rules/index.js");
|
29
28
|
__reExport(src_exports, require("./types.js"), module.exports);
|
30
|
-
var import_utils = require("./utils.js"), import_configs = require("./configs/index.js")
|
29
|
+
var import_utils = require("./utils.js"), import_configs = require("./configs/index.js");
|
31
30
|
const processors = { graphql: import_processor.processor };
|
32
31
|
// Annotate the CommonJS export names for ESM import in node:
|
33
32
|
0 && (module.exports = {
|
34
33
|
configs,
|
35
|
-
flatConfigs,
|
36
34
|
parseForESLint,
|
37
35
|
parser,
|
38
36
|
processors,
|
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/cjs/rules/index.d.cts
CHANGED
@@ -38,22 +38,22 @@ declare const rules: {
|
|
38
38
|
suffix?: string | undefined;
|
39
39
|
prefix?: string | undefined;
|
40
40
|
} | undefined;
|
41
|
-
|
41
|
+
fileExtension?: ".gql" | ".graphql" | undefined;
|
42
|
+
query?: (CaseStyle | "matchDocumentStyle") | {
|
42
43
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
43
44
|
suffix?: string | undefined;
|
44
45
|
prefix?: string | undefined;
|
45
46
|
} | undefined;
|
46
|
-
|
47
|
+
mutation?: (CaseStyle | "matchDocumentStyle") | {
|
47
48
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
48
49
|
suffix?: string | undefined;
|
49
50
|
prefix?: string | undefined;
|
50
51
|
} | undefined;
|
51
|
-
|
52
|
+
subscription?: (CaseStyle | "matchDocumentStyle") | {
|
52
53
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
53
54
|
suffix?: string | undefined;
|
54
55
|
prefix?: string | undefined;
|
55
56
|
} | undefined;
|
56
|
-
fileExtension?: ".gql" | ".graphql" | undefined;
|
57
57
|
}[]>;
|
58
58
|
'naming-convention': GraphQLESLintRule<{
|
59
59
|
[x: string]: unknown;
|
package/esm/configs/index.d.ts
CHANGED
@@ -4,6 +4,11 @@ declare const configs: {
|
|
4
4
|
'schema-relay': any;
|
5
5
|
'operations-recommended': any;
|
6
6
|
'operations-all': any;
|
7
|
+
'flat/schema-recommended': any;
|
8
|
+
'flat/schema-all': any;
|
9
|
+
'flat/schema-relay': any;
|
10
|
+
'flat/operations-recommended': any;
|
11
|
+
'flat/operations-all': any;
|
7
12
|
};
|
8
13
|
|
9
14
|
export { configs };
|
package/esm/configs/index.js
CHANGED
@@ -9,7 +9,18 @@ const configs = {
|
|
9
9
|
"schema-all": schemaAllConfig,
|
10
10
|
"schema-relay": relayConfig,
|
11
11
|
"operations-recommended": operationsRecommendedConfig,
|
12
|
-
"operations-all": operationsAllConfig
|
12
|
+
"operations-all": operationsAllConfig,
|
13
|
+
"flat/schema-recommended": schemaRecommendedConfig.rules,
|
14
|
+
"flat/schema-all": {
|
15
|
+
...schemaRecommendedConfig.rules,
|
16
|
+
...schemaAllConfig.rules
|
17
|
+
},
|
18
|
+
"flat/schema-relay": relayConfig.rules,
|
19
|
+
"flat/operations-recommended": operationsRecommendedConfig.rules,
|
20
|
+
"flat/operations-all": {
|
21
|
+
...operationsRecommendedConfig.rules,
|
22
|
+
...operationsAllConfig.rules
|
23
|
+
}
|
13
24
|
};
|
14
25
|
export {
|
15
26
|
configs
|
package/esm/index.d.ts
CHANGED
@@ -5,7 +5,6 @@ export { rules } from './rules/index.js';
|
|
5
5
|
export { CategoryType, ConfigName, GraphQLESLintParseResult, GraphQLESLintRule, GraphQLESLintRuleContext, GraphQLESLintRuleListener, OmitRecursively, ParserOptions, ParserServices, Pointer, ReportDescriptor, RuleDocsInfo, Schema, ValueOf } from './types.js';
|
6
6
|
export { requireGraphQLSchemaFromContext, requireSiblingsOperations } from './utils.js';
|
7
7
|
export { configs } from './configs/index.js';
|
8
|
-
export { flatConfigs } from './flat-configs.js';
|
9
8
|
export { GraphQLESTreeNode } from './estree-converter/types.js';
|
10
9
|
import './rules/require-description.js';
|
11
10
|
import 'graphql';
|
package/esm/index.js
CHANGED
@@ -6,10 +6,8 @@ export * from "./types.js";
|
|
6
6
|
import { requireGraphQLSchemaFromContext, requireSiblingsOperations } from "./utils.js";
|
7
7
|
const processors = { graphql: processor };
|
8
8
|
import { configs } from "./configs/index.js";
|
9
|
-
import { flatConfigs } from "./flat-configs.js";
|
10
9
|
export {
|
11
10
|
configs,
|
12
|
-
flatConfigs,
|
13
11
|
parseForESLint,
|
14
12
|
parser,
|
15
13
|
processors,
|
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/esm/rules/index.d.ts
CHANGED
@@ -38,22 +38,22 @@ declare const rules: {
|
|
38
38
|
suffix?: string | undefined;
|
39
39
|
prefix?: string | undefined;
|
40
40
|
} | undefined;
|
41
|
-
|
41
|
+
fileExtension?: ".gql" | ".graphql" | undefined;
|
42
|
+
query?: (CaseStyle | "matchDocumentStyle") | {
|
42
43
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
43
44
|
suffix?: string | undefined;
|
44
45
|
prefix?: string | undefined;
|
45
46
|
} | undefined;
|
46
|
-
|
47
|
+
mutation?: (CaseStyle | "matchDocumentStyle") | {
|
47
48
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
48
49
|
suffix?: string | undefined;
|
49
50
|
prefix?: string | undefined;
|
50
51
|
} | undefined;
|
51
|
-
|
52
|
+
subscription?: (CaseStyle | "matchDocumentStyle") | {
|
52
53
|
style?: (CaseStyle | "matchDocumentStyle") | undefined;
|
53
54
|
suffix?: string | undefined;
|
54
55
|
prefix?: string | undefined;
|
55
56
|
} | undefined;
|
56
|
-
fileExtension?: ".gql" | ".graphql" | undefined;
|
57
57
|
}[]>;
|
58
58
|
'naming-convention': GraphQLESLintRule<{
|
59
59
|
[x: string]: unknown;
|
package/index.browser.js
CHANGED
@@ -246,20 +246,11 @@ import debugFactory from "debug";
|
|
246
246
|
var log = debugFactory("graphql-eslint:ModuleCache"), ModuleCache = class {
|
247
247
|
map = /* @__PURE__ */ new Map();
|
248
248
|
set(cacheKey, result) {
|
249
|
-
this.map.set(cacheKey, { lastSeen: process.hrtime(), result }), log("setting entry for", cacheKey);
|
250
249
|
}
|
251
250
|
get(cacheKey, settings = {
|
252
251
|
lifetime: 10
|
253
252
|
/* seconds */
|
254
253
|
}) {
|
255
|
-
let value = this.map.get(cacheKey);
|
256
|
-
if (!value) {
|
257
|
-
log("cache miss for", cacheKey);
|
258
|
-
return;
|
259
|
-
}
|
260
|
-
let { lastSeen, result } = value;
|
261
|
-
if (process.env.NODE || process.hrtime(lastSeen)[0] < settings.lifetime)
|
262
|
-
return result;
|
263
254
|
}
|
264
255
|
};
|
265
256
|
|
@@ -399,7 +390,7 @@ function convertToESTree(node, schema15) {
|
|
399
390
|
// package.json
|
400
391
|
var package_default = {
|
401
392
|
name: "@graphql-eslint/eslint-plugin",
|
402
|
-
version: "4.0.0-alpha.
|
393
|
+
version: "4.0.0-alpha.4",
|
403
394
|
type: "module",
|
404
395
|
description: "GraphQL plugin for ESLint",
|
405
396
|
repository: "https://github.com/B2o5T/graphql-eslint",
|
@@ -444,11 +435,11 @@ var package_default = {
|
|
444
435
|
},
|
445
436
|
dependencies: {
|
446
437
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
447
|
-
"@graphql-tools/graphql-tag-pluck": "
|
438
|
+
"@graphql-tools/graphql-tag-pluck": "8.3.2",
|
448
439
|
"@graphql-tools/utils": "^10.0.0",
|
449
440
|
debug: "^4.3.4",
|
450
441
|
"fast-glob": "^3.2.12",
|
451
|
-
"graphql-config": "^5.
|
442
|
+
"graphql-config": "^5.1.0",
|
452
443
|
"graphql-depth-limit": "^1.1.0",
|
453
444
|
"lodash.lowercase": "^4.3.0"
|
454
445
|
},
|
@@ -462,7 +453,7 @@ var package_default = {
|
|
462
453
|
"@types/lodash.lowercase": "4.3.9",
|
463
454
|
graphql: "16.9.0",
|
464
455
|
"json-schema-to-ts": "2.12.0",
|
465
|
-
"vite-tsconfig-paths": "^
|
456
|
+
"vite-tsconfig-paths": "^5.0.0"
|
466
457
|
},
|
467
458
|
publishConfig: {
|
468
459
|
directory: "dist",
|
@@ -472,7 +463,7 @@ var package_default = {
|
|
472
463
|
};
|
473
464
|
|
474
465
|
// src/meta.ts
|
475
|
-
var {
|
466
|
+
var { version } = package_default;
|
476
467
|
|
477
468
|
// src/siblings.ts
|
478
469
|
import {
|
@@ -650,7 +641,7 @@ function getSiblings(documents) {
|
|
650
641
|
cachedOperations = result;
|
651
642
|
}
|
652
643
|
return cachedOperations;
|
653
|
-
}, getFragment = (
|
644
|
+
}, getFragment = (name) => getFragments().filter((f) => f.document.name.value === name), collectFragments = (selectable, recursive, collected = /* @__PURE__ */ new Map()) => (visit2(selectable, {
|
654
645
|
FragmentSpread(spread) {
|
655
646
|
let fragmentName = spread.name.value, [fragment] = getFragment(fragmentName);
|
656
647
|
if (!fragment) {
|
@@ -667,7 +658,7 @@ function getSiblings(documents) {
|
|
667
658
|
getFragments,
|
668
659
|
getFragmentByType: (typeName) => getFragments().filter((f) => f.document.typeCondition.name.value === typeName),
|
669
660
|
getFragmentsInUse: (selectable, recursive = !0) => Array.from(collectFragments(selectable, recursive).values()),
|
670
|
-
getOperation: (
|
661
|
+
getOperation: (name) => getOperations().filter((o) => o.document.name?.value === name),
|
671
662
|
getOperations,
|
672
663
|
getOperationByType: (type) => getOperations().filter((o) => o.document.operation === type)
|
673
664
|
};
|
@@ -1185,10 +1176,10 @@ function validateDocument({
|
|
1185
1176
|
loc,
|
1186
1177
|
message: error.message,
|
1187
1178
|
suggest: hasDidYouMeanSuggestions ? matches.map((match) => {
|
1188
|
-
let { name
|
1179
|
+
let { name } = match.groups;
|
1189
1180
|
return {
|
1190
|
-
desc: `Rename to \`${
|
1191
|
-
fix: (fixer) => fixer.replaceText(token,
|
1181
|
+
desc: `Rename to \`${name}\``,
|
1182
|
+
fix: (fixer) => fixer.replaceText(token, name)
|
1192
1183
|
};
|
1193
1184
|
}) : []
|
1194
1185
|
});
|
@@ -1212,7 +1203,7 @@ var getFragmentDefsAndFragmentSpreads = (node) => {
|
|
1212
1203
|
}), { fragmentDefs, fragmentSpreads };
|
1213
1204
|
}, getMissingFragments = (node) => {
|
1214
1205
|
let { fragmentDefs, fragmentSpreads } = getFragmentDefsAndFragmentSpreads(node);
|
1215
|
-
return [...fragmentSpreads].filter((
|
1206
|
+
return [...fragmentSpreads].filter((name) => !fragmentDefs.has(name));
|
1216
1207
|
}, handleMissingFragments = ({ ruleId, context, node }) => {
|
1217
1208
|
let missingFragments = getMissingFragments(node);
|
1218
1209
|
if (missingFragments.length > 0) {
|
@@ -1849,10 +1840,10 @@ Using the same name for all input parameters will make your schemas easier to co
|
|
1849
1840
|
return currentNode;
|
1850
1841
|
})(node);
|
1851
1842
|
if (shouldCheckType(inputValueNode.parent.parent)) {
|
1852
|
-
let mutationName = `${inputValueNode.parent.name.value}Input`,
|
1853
|
-
(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({
|
1854
1845
|
node: node.name,
|
1855
|
-
message: `Input type \`${
|
1846
|
+
message: `Input type \`${name}\` name should be \`${mutationName}\`.`,
|
1856
1847
|
suggest: [
|
1857
1848
|
{
|
1858
1849
|
desc: `Rename to \`${mutationName}\``,
|
@@ -1935,11 +1926,11 @@ var RULE_ID2 = "lone-executable-definition", definitionTypes = ["fragment", ...O
|
|
1935
1926
|
},
|
1936
1927
|
"Document:exit"() {
|
1937
1928
|
for (let { node, type } of definitions.slice(1)) {
|
1938
|
-
let
|
1939
|
-
definitionName && (
|
1929
|
+
let name = pascalCase(type), definitionName = node.name?.value;
|
1930
|
+
definitionName && (name += ` "${definitionName}"`), context.report({
|
1940
1931
|
loc: node.name?.loc || getLocation(node.loc.start, type),
|
1941
1932
|
messageId: RULE_ID2,
|
1942
|
-
data: { name
|
1933
|
+
data: { name }
|
1943
1934
|
});
|
1944
1935
|
}
|
1945
1936
|
}
|
@@ -2506,51 +2497,51 @@ ${TYPES_KINDS.map((kind) => `- \`${kind}\``).join(`
|
|
2506
2497
|
report(node, `${nodeType} "${nodeName}" should ${errorMessage}`, suggestedNames);
|
2507
2498
|
}
|
2508
2499
|
function getError() {
|
2509
|
-
let
|
2510
|
-
if (ignorePattern && new RegExp(ignorePattern, "u").test(
|
2500
|
+
let name = nodeName.replace(/(^_+)|(_+$)/g, "");
|
2501
|
+
if (ignorePattern && new RegExp(ignorePattern, "u").test(name))
|
2511
2502
|
return;
|
2512
|
-
if (prefix && !
|
2503
|
+
if (prefix && !name.startsWith(prefix))
|
2513
2504
|
return {
|
2514
2505
|
errorMessage: `have "${prefix}" prefix`,
|
2515
|
-
renameToNames: [prefix +
|
2506
|
+
renameToNames: [prefix + name]
|
2516
2507
|
};
|
2517
|
-
if (suffix && !
|
2508
|
+
if (suffix && !name.endsWith(suffix))
|
2518
2509
|
return {
|
2519
2510
|
errorMessage: `have "${suffix}" suffix`,
|
2520
|
-
renameToNames: [
|
2511
|
+
renameToNames: [name + suffix]
|
2521
2512
|
};
|
2522
|
-
let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) =>
|
2513
|
+
let forbiddenPrefix = forbiddenPrefixes?.find((prefix2) => name.startsWith(prefix2));
|
2523
2514
|
if (forbiddenPrefix)
|
2524
2515
|
return {
|
2525
2516
|
errorMessage: `not have "${forbiddenPrefix}" prefix`,
|
2526
|
-
renameToNames: [
|
2517
|
+
renameToNames: [name.replace(new RegExp(`^${forbiddenPrefix}`), "")]
|
2527
2518
|
};
|
2528
|
-
let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) =>
|
2519
|
+
let forbiddenSuffix = forbiddenSuffixes?.find((suffix2) => name.endsWith(suffix2));
|
2529
2520
|
if (forbiddenSuffix)
|
2530
2521
|
return {
|
2531
2522
|
errorMessage: `not have "${forbiddenSuffix}" suffix`,
|
2532
|
-
renameToNames: [
|
2523
|
+
renameToNames: [name.replace(new RegExp(`${forbiddenSuffix}$`), "")]
|
2533
2524
|
};
|
2534
|
-
if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) =>
|
2525
|
+
if (requiredPrefixes && !requiredPrefixes.some((requiredPrefix) => name.startsWith(requiredPrefix)))
|
2535
2526
|
return {
|
2536
2527
|
errorMessage: `have one of the following prefixes: ${englishJoinWords(
|
2537
2528
|
requiredPrefixes
|
2538
2529
|
)}`,
|
2539
|
-
renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${
|
2530
|
+
renameToNames: style ? requiredPrefixes.map((prefix2) => convertCase(style, `${prefix2} ${name}`)) : requiredPrefixes.map((prefix2) => `${prefix2}${name}`)
|
2540
2531
|
};
|
2541
|
-
if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) =>
|
2532
|
+
if (requiredSuffixes && !requiredSuffixes.some((requiredSuffix) => name.endsWith(requiredSuffix)))
|
2542
2533
|
return {
|
2543
2534
|
errorMessage: `have one of the following suffixes: ${englishJoinWords(
|
2544
2535
|
requiredSuffixes
|
2545
2536
|
)}`,
|
2546
|
-
renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${
|
2537
|
+
renameToNames: style ? requiredSuffixes.map((suffix2) => convertCase(style, `${name} ${suffix2}`)) : requiredSuffixes.map((suffix2) => `${name}${suffix2}`)
|
2547
2538
|
};
|
2548
2539
|
if (!style)
|
2549
2540
|
return;
|
2550
|
-
if (!StyleToRegex[style].test(
|
2541
|
+
if (!StyleToRegex[style].test(name))
|
2551
2542
|
return {
|
2552
2543
|
errorMessage: `be in ${style} format`,
|
2553
|
-
renameToNames: [convertCase(style,
|
2544
|
+
renameToNames: [convertCase(style, name)]
|
2554
2545
|
};
|
2555
2546
|
}
|
2556
2547
|
}, checkUnderscore = (isLeading) => (node) => {
|
@@ -3037,8 +3028,8 @@ var RULE_ID7 = "no-one-place-fragments", rule11 = {
|
|
3037
3028
|
for (let { document, filePath } of allDocuments) {
|
3038
3029
|
let relativeFilePath = relative(CWD, filePath);
|
3039
3030
|
visit4(document, {
|
3040
|
-
FragmentSpread({ name
|
3041
|
-
let spreadName =
|
3031
|
+
FragmentSpread({ name }) {
|
3032
|
+
let spreadName = name.value;
|
3042
3033
|
usedFragmentsMap[spreadName] ||= [], usedFragmentsMap[spreadName].push(relativeFilePath);
|
3043
3034
|
}
|
3044
3035
|
});
|
@@ -4572,7 +4563,7 @@ var RULE_ID18 = "require-nullable-result-in-root", rule27 = {
|
|
4572
4563
|
for (let field of node.fields || []) {
|
4573
4564
|
if (field.gqlType.type !== Kind20.NON_NULL_TYPE || field.gqlType.gqlType.type !== Kind20.NAMED_TYPE)
|
4574
4565
|
continue;
|
4575
|
-
let
|
4566
|
+
let name = field.gqlType.gqlType.name.value, type = schema15.getType(name), resultType = type?.astNode ? getNodeName(type.astNode) : type?.name;
|
4576
4567
|
context.report({
|
4577
4568
|
node: field.gqlType,
|
4578
4569
|
messageId: RULE_ID18,
|
@@ -4732,7 +4723,7 @@ Include it in your selection set{{ addition }}.`
|
|
4732
4723
|
}
|
4733
4724
|
function checkFields(rawType2) {
|
4734
4725
|
let fields = rawType2.getFields();
|
4735
|
-
if (!idNames.some((
|
4726
|
+
if (!idNames.some((name) => fields[name]))
|
4736
4727
|
return;
|
4737
4728
|
function hasIdField({ selections }) {
|
4738
4729
|
return selections.some((selection) => {
|
@@ -4754,8 +4745,8 @@ Include it in your selection set{{ addition }}.`
|
|
4754
4745
|
if (checkFragments(node), hasId)
|
4755
4746
|
return;
|
4756
4747
|
let pluralSuffix = idNames.length > 1 ? "s" : "", fieldName2 = englishJoinWords(
|
4757
|
-
idNames.map((
|
4758
|
-
), 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 = {
|
4759
4750
|
loc,
|
4760
4751
|
messageId: RULE_ID19,
|
4761
4752
|
data: {
|
@@ -5384,40 +5375,21 @@ var import_operations_all = __toESM(require_operations_all(), 1), import_operati
|
|
5384
5375
|
"schema-all": import_schema_all.default,
|
5385
5376
|
"schema-relay": import_schema_relay.default,
|
5386
5377
|
"operations-recommended": import_operations_recommended.default,
|
5387
|
-
"operations-all": import_operations_all.default
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
"operations-all": {
|
5393
|
-
languageOptions,
|
5394
|
-
rules: {
|
5395
|
-
...configs["operations-recommended"].rules,
|
5396
|
-
...configs["operations-all"].rules
|
5397
|
-
}
|
5398
|
-
},
|
5399
|
-
"operations-recommended": {
|
5400
|
-
languageOptions,
|
5401
|
-
rules: configs["operations-recommended"].rules
|
5402
|
-
},
|
5403
|
-
"schema-relay": {
|
5404
|
-
languageOptions,
|
5405
|
-
rules: configs["schema-relay"].rules
|
5406
|
-
},
|
5407
|
-
"schema-all": {
|
5408
|
-
languageOptions,
|
5409
|
-
rules: {
|
5410
|
-
...configs["schema-recommended"].rules,
|
5411
|
-
...configs["schema-all"].rules
|
5412
|
-
}
|
5378
|
+
"operations-all": import_operations_all.default,
|
5379
|
+
"flat/schema-recommended": import_schema_recommended.default.rules,
|
5380
|
+
"flat/schema-all": {
|
5381
|
+
...import_schema_recommended.default.rules,
|
5382
|
+
...import_schema_all.default.rules
|
5413
5383
|
},
|
5414
|
-
"schema-
|
5415
|
-
|
5416
|
-
|
5384
|
+
"flat/schema-relay": import_schema_relay.default.rules,
|
5385
|
+
"flat/operations-recommended": import_operations_recommended.default.rules,
|
5386
|
+
"flat/operations-all": {
|
5387
|
+
...import_operations_recommended.default.rules,
|
5388
|
+
...import_operations_all.default.rules
|
5417
5389
|
}
|
5418
5390
|
};
|
5419
5391
|
export {
|
5420
|
-
|
5392
|
+
configs,
|
5421
5393
|
parser,
|
5422
5394
|
rules
|
5423
5395
|
};
|
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,11 +40,11 @@
|
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
42
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
43
|
-
"@graphql-tools/graphql-tag-pluck": "
|
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",
|
47
|
-
"graphql-config": "^5.
|
47
|
+
"graphql-config": "^5.1.0",
|
48
48
|
"graphql-depth-limit": "^1.1.0",
|
49
49
|
"lodash.lowercase": "^4.3.0"
|
50
50
|
},
|
package/cjs/flat-configs.d.cts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import { parseForESLint } from './parser.cjs';
|
2
|
-
import './types.cjs';
|
3
|
-
import 'eslint';
|
4
|
-
import 'estree';
|
5
|
-
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
|
-
import 'json-schema-to-ts';
|
8
|
-
import './estree-converter/types.cjs';
|
9
|
-
import './siblings.cjs';
|
10
|
-
import '@graphql-tools/utils';
|
11
|
-
|
12
|
-
declare const flatConfigs: {
|
13
|
-
'operations-all': {
|
14
|
-
languageOptions: {
|
15
|
-
parser: {
|
16
|
-
parseForESLint: typeof parseForESLint;
|
17
|
-
meta: {
|
18
|
-
name: string;
|
19
|
-
version: string;
|
20
|
-
};
|
21
|
-
};
|
22
|
-
};
|
23
|
-
rules: any;
|
24
|
-
};
|
25
|
-
'operations-recommended': {
|
26
|
-
languageOptions: {
|
27
|
-
parser: {
|
28
|
-
parseForESLint: typeof parseForESLint;
|
29
|
-
meta: {
|
30
|
-
name: string;
|
31
|
-
version: string;
|
32
|
-
};
|
33
|
-
};
|
34
|
-
};
|
35
|
-
rules: any;
|
36
|
-
};
|
37
|
-
'schema-relay': {
|
38
|
-
languageOptions: {
|
39
|
-
parser: {
|
40
|
-
parseForESLint: typeof parseForESLint;
|
41
|
-
meta: {
|
42
|
-
name: string;
|
43
|
-
version: string;
|
44
|
-
};
|
45
|
-
};
|
46
|
-
};
|
47
|
-
rules: any;
|
48
|
-
};
|
49
|
-
'schema-all': {
|
50
|
-
languageOptions: {
|
51
|
-
parser: {
|
52
|
-
parseForESLint: typeof parseForESLint;
|
53
|
-
meta: {
|
54
|
-
name: string;
|
55
|
-
version: string;
|
56
|
-
};
|
57
|
-
};
|
58
|
-
};
|
59
|
-
rules: any;
|
60
|
-
};
|
61
|
-
'schema-recommended': {
|
62
|
-
languageOptions: {
|
63
|
-
parser: {
|
64
|
-
parseForESLint: typeof parseForESLint;
|
65
|
-
meta: {
|
66
|
-
name: string;
|
67
|
-
version: string;
|
68
|
-
};
|
69
|
-
};
|
70
|
-
};
|
71
|
-
rules: any;
|
72
|
-
};
|
73
|
-
};
|
74
|
-
|
75
|
-
export { flatConfigs };
|
package/cjs/flat-configs.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
-
return to;
|
14
|
-
};
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
16
|
-
var flat_configs_exports = {};
|
17
|
-
__export(flat_configs_exports, {
|
18
|
-
flatConfigs: () => flatConfigs
|
19
|
-
});
|
20
|
-
module.exports = __toCommonJS(flat_configs_exports);
|
21
|
-
var import_configs = require("./configs/index.js"), import_parser = require("./parser.js");
|
22
|
-
const languageOptions = { parser: import_parser.parser }, flatConfigs = {
|
23
|
-
"operations-all": {
|
24
|
-
languageOptions,
|
25
|
-
rules: {
|
26
|
-
...import_configs.configs["operations-recommended"].rules,
|
27
|
-
...import_configs.configs["operations-all"].rules
|
28
|
-
}
|
29
|
-
},
|
30
|
-
"operations-recommended": {
|
31
|
-
languageOptions,
|
32
|
-
rules: import_configs.configs["operations-recommended"].rules
|
33
|
-
},
|
34
|
-
"schema-relay": {
|
35
|
-
languageOptions,
|
36
|
-
rules: import_configs.configs["schema-relay"].rules
|
37
|
-
},
|
38
|
-
"schema-all": {
|
39
|
-
languageOptions,
|
40
|
-
rules: {
|
41
|
-
...import_configs.configs["schema-recommended"].rules,
|
42
|
-
...import_configs.configs["schema-all"].rules
|
43
|
-
}
|
44
|
-
},
|
45
|
-
"schema-recommended": {
|
46
|
-
languageOptions,
|
47
|
-
rules: import_configs.configs["schema-recommended"].rules
|
48
|
-
}
|
49
|
-
};
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
51
|
-
0 && (module.exports = {
|
52
|
-
flatConfigs
|
53
|
-
});
|
package/esm/flat-configs.d.ts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import { parseForESLint } from './parser.js';
|
2
|
-
import './types.js';
|
3
|
-
import 'eslint';
|
4
|
-
import 'estree';
|
5
|
-
import 'graphql';
|
6
|
-
import 'graphql-config';
|
7
|
-
import 'json-schema-to-ts';
|
8
|
-
import './estree-converter/types.js';
|
9
|
-
import './siblings.js';
|
10
|
-
import '@graphql-tools/utils';
|
11
|
-
|
12
|
-
declare const flatConfigs: {
|
13
|
-
'operations-all': {
|
14
|
-
languageOptions: {
|
15
|
-
parser: {
|
16
|
-
parseForESLint: typeof parseForESLint;
|
17
|
-
meta: {
|
18
|
-
name: string;
|
19
|
-
version: string;
|
20
|
-
};
|
21
|
-
};
|
22
|
-
};
|
23
|
-
rules: any;
|
24
|
-
};
|
25
|
-
'operations-recommended': {
|
26
|
-
languageOptions: {
|
27
|
-
parser: {
|
28
|
-
parseForESLint: typeof parseForESLint;
|
29
|
-
meta: {
|
30
|
-
name: string;
|
31
|
-
version: string;
|
32
|
-
};
|
33
|
-
};
|
34
|
-
};
|
35
|
-
rules: any;
|
36
|
-
};
|
37
|
-
'schema-relay': {
|
38
|
-
languageOptions: {
|
39
|
-
parser: {
|
40
|
-
parseForESLint: typeof parseForESLint;
|
41
|
-
meta: {
|
42
|
-
name: string;
|
43
|
-
version: string;
|
44
|
-
};
|
45
|
-
};
|
46
|
-
};
|
47
|
-
rules: any;
|
48
|
-
};
|
49
|
-
'schema-all': {
|
50
|
-
languageOptions: {
|
51
|
-
parser: {
|
52
|
-
parseForESLint: typeof parseForESLint;
|
53
|
-
meta: {
|
54
|
-
name: string;
|
55
|
-
version: string;
|
56
|
-
};
|
57
|
-
};
|
58
|
-
};
|
59
|
-
rules: any;
|
60
|
-
};
|
61
|
-
'schema-recommended': {
|
62
|
-
languageOptions: {
|
63
|
-
parser: {
|
64
|
-
parseForESLint: typeof parseForESLint;
|
65
|
-
meta: {
|
66
|
-
name: string;
|
67
|
-
version: string;
|
68
|
-
};
|
69
|
-
};
|
70
|
-
};
|
71
|
-
rules: any;
|
72
|
-
};
|
73
|
-
};
|
74
|
-
|
75
|
-
export { flatConfigs };
|
package/esm/flat-configs.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import "./chunk-UIAXBAMD.js";
|
2
|
-
import { configs } from "./configs/index.js";
|
3
|
-
import { parser } from "./parser.js";
|
4
|
-
const languageOptions = { parser }, flatConfigs = {
|
5
|
-
"operations-all": {
|
6
|
-
languageOptions,
|
7
|
-
rules: {
|
8
|
-
...configs["operations-recommended"].rules,
|
9
|
-
...configs["operations-all"].rules
|
10
|
-
}
|
11
|
-
},
|
12
|
-
"operations-recommended": {
|
13
|
-
languageOptions,
|
14
|
-
rules: configs["operations-recommended"].rules
|
15
|
-
},
|
16
|
-
"schema-relay": {
|
17
|
-
languageOptions,
|
18
|
-
rules: configs["schema-relay"].rules
|
19
|
-
},
|
20
|
-
"schema-all": {
|
21
|
-
languageOptions,
|
22
|
-
rules: {
|
23
|
-
...configs["schema-recommended"].rules,
|
24
|
-
...configs["schema-all"].rules
|
25
|
-
}
|
26
|
-
},
|
27
|
-
"schema-recommended": {
|
28
|
-
languageOptions,
|
29
|
-
rules: configs["schema-recommended"].rules
|
30
|
-
}
|
31
|
-
};
|
32
|
-
export {
|
33
|
-
flatConfigs
|
34
|
-
};
|