@graphql-eslint/eslint-plugin 3.14.0-alpha-20221222211539-5e993f5 → 3.14.0-alpha-20221223011700-eed94bd
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/configs/index.js +10 -10
- package/cjs/documents.js +5 -5
- package/cjs/estree-converter/converter.js +2 -2
- package/cjs/estree-converter/index.js +3 -3
- package/cjs/estree-converter/utils.js +2 -2
- package/cjs/flat-configs.js +36 -0
- package/cjs/index.js +16 -14
- package/cjs/parser.js +13 -13
- package/cjs/processor.js +2 -2
- package/cjs/rules/alphabetize.js +7 -7
- package/cjs/rules/graphql-js-validation.js +9 -9
- package/cjs/rules/index.js +66 -66
- package/cjs/rules/lone-executable-definition.js +4 -4
- package/cjs/rules/match-document-filename.js +4 -4
- package/cjs/rules/naming-convention.js +6 -6
- package/cjs/rules/no-anonymous-operations.js +2 -2
- package/cjs/rules/no-deprecated.js +2 -2
- package/cjs/rules/no-one-place-fragments.js +3 -4
- package/cjs/rules/no-root-type.js +3 -3
- package/cjs/rules/no-scalar-result-type-on-mutation.js +2 -2
- package/cjs/rules/no-unreachable-types.js +3 -3
- package/cjs/rules/no-unused-fields.js +3 -3
- package/cjs/rules/relay-arguments.js +2 -2
- package/cjs/rules/relay-edge-types.js +6 -6
- package/cjs/rules/relay-page-info.js +5 -5
- package/cjs/rules/require-deprecation-date.js +2 -2
- package/cjs/rules/require-deprecation-reason.js +2 -2
- package/cjs/rules/require-description.js +8 -8
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +3 -3
- package/cjs/rules/require-id-when-available.js +8 -8
- package/cjs/rules/selection-set-depth.js +5 -5
- package/cjs/rules/strict-id-in-types.js +7 -7
- package/cjs/rules/unique-fragment-name.js +4 -4
- package/cjs/rules/unique-operation-name.js +2 -2
- package/cjs/schema.js +2 -2
- package/esm/cache.js +25 -0
- package/esm/configs/base.js +4 -0
- package/esm/configs/index.js +12 -0
- package/esm/configs/operations-all.js +29 -0
- package/esm/configs/operations-recommended.js +53 -0
- package/esm/configs/relay.js +9 -0
- package/esm/configs/schema-all.js +22 -0
- package/esm/configs/schema-recommended.js +49 -0
- package/esm/documents.js +144 -0
- package/esm/estree-converter/converter.js +58 -0
- package/esm/estree-converter/index.js +3 -0
- package/esm/estree-converter/types.js +1 -0
- package/esm/estree-converter/utils.js +102 -0
- package/esm/flat-configs.js +33 -0
- package/esm/graphql-config.js +49 -0
- package/esm/index.js +9 -0
- package/esm/package.json +1 -0
- package/esm/parser.js +56 -0
- package/esm/processor.js +75 -0
- package/esm/rules/alphabetize.js +344 -0
- package/esm/rules/description-style.js +75 -0
- package/esm/rules/graphql-js-validation.js +498 -0
- package/esm/rules/index.js +71 -0
- package/esm/rules/input-name.js +133 -0
- package/esm/rules/lone-executable-definition.js +85 -0
- package/esm/rules/match-document-filename.js +232 -0
- package/esm/rules/naming-convention.js +307 -0
- package/esm/rules/no-anonymous-operations.js +64 -0
- package/esm/rules/no-case-insensitive-enum-values-duplicates.js +58 -0
- package/esm/rules/no-deprecated.js +121 -0
- package/esm/rules/no-duplicate-fields.js +109 -0
- package/esm/rules/no-hashtag-description.js +86 -0
- package/esm/rules/no-one-place-fragments.js +80 -0
- package/esm/rules/no-root-type.js +83 -0
- package/esm/rules/no-scalar-result-type-on-mutation.js +63 -0
- package/esm/rules/no-typename-prefix.js +62 -0
- package/esm/rules/no-unreachable-types.js +154 -0
- package/esm/rules/no-unused-fields.js +127 -0
- package/esm/rules/relay-arguments.js +118 -0
- package/esm/rules/relay-connection-types.js +104 -0
- package/esm/rules/relay-edge-types.js +186 -0
- package/esm/rules/relay-page-info.js +97 -0
- package/esm/rules/require-deprecation-date.js +120 -0
- package/esm/rules/require-deprecation-reason.js +53 -0
- package/esm/rules/require-description.js +190 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +69 -0
- package/esm/rules/require-id-when-available.js +196 -0
- package/esm/rules/require-nullable-fields-with-oneof.js +58 -0
- package/esm/rules/require-type-pattern-with-oneof.js +57 -0
- package/esm/rules/selection-set-depth.js +131 -0
- package/esm/rules/strict-id-in-types.js +159 -0
- package/esm/rules/unique-fragment-name.js +86 -0
- package/esm/rules/unique-operation-name.js +62 -0
- package/esm/schema.js +37 -0
- package/esm/testkit.js +181 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +83 -0
- package/package.json +10 -1
- package/typings/estree-converter/converter.d.cts +1 -1
- package/typings/estree-converter/converter.d.ts +1 -1
- package/typings/estree-converter/index.d.cts +3 -3
- package/typings/estree-converter/index.d.ts +3 -3
- package/typings/estree-converter/types.d.cts +3 -3
- package/typings/estree-converter/types.d.ts +3 -3
- package/typings/estree-converter/utils.d.cts +2 -2
- package/typings/estree-converter/utils.d.ts +2 -2
- package/typings/flat-configs.d.cts +248 -0
- package/typings/flat-configs.d.ts +248 -0
- package/typings/graphql-config.d.cts +1 -1
- package/typings/graphql-config.d.ts +1 -1
- package/typings/index.d.cts +8 -7
- package/typings/index.d.ts +8 -7
- package/typings/parser.d.cts +1 -1
- package/typings/parser.d.ts +1 -1
- package/typings/rules/alphabetize.d.cts +1 -1
- package/typings/rules/alphabetize.d.ts +1 -1
- package/typings/rules/description-style.d.cts +1 -1
- package/typings/rules/description-style.d.ts +1 -1
- package/typings/rules/graphql-js-validation.d.cts +1 -1
- package/typings/rules/graphql-js-validation.d.ts +1 -1
- package/typings/rules/index.d.cts +45 -45
- package/typings/rules/index.d.ts +45 -45
- package/typings/rules/input-name.d.cts +1 -1
- package/typings/rules/input-name.d.ts +1 -1
- package/typings/rules/lone-executable-definition.d.cts +1 -1
- package/typings/rules/lone-executable-definition.d.ts +1 -1
- package/typings/rules/match-document-filename.d.cts +2 -2
- package/typings/rules/match-document-filename.d.ts +2 -2
- package/typings/rules/naming-convention.d.cts +1 -1
- package/typings/rules/naming-convention.d.ts +1 -1
- package/typings/rules/no-anonymous-operations.d.cts +1 -1
- package/typings/rules/no-anonymous-operations.d.ts +1 -1
- package/typings/rules/no-case-insensitive-enum-values-duplicates.d.cts +1 -1
- package/typings/rules/no-case-insensitive-enum-values-duplicates.d.ts +1 -1
- package/typings/rules/no-deprecated.d.cts +1 -1
- package/typings/rules/no-deprecated.d.ts +1 -1
- package/typings/rules/no-duplicate-fields.d.cts +1 -1
- package/typings/rules/no-duplicate-fields.d.ts +1 -1
- package/typings/rules/no-hashtag-description.d.cts +1 -1
- package/typings/rules/no-hashtag-description.d.ts +1 -1
- package/typings/rules/no-one-place-fragments.d.cts +1 -1
- package/typings/rules/no-one-place-fragments.d.ts +1 -1
- package/typings/rules/no-root-type.d.cts +1 -1
- package/typings/rules/no-root-type.d.ts +1 -1
- package/typings/rules/no-scalar-result-type-on-mutation.d.cts +1 -1
- package/typings/rules/no-scalar-result-type-on-mutation.d.ts +1 -1
- package/typings/rules/no-typename-prefix.d.cts +1 -1
- package/typings/rules/no-typename-prefix.d.ts +1 -1
- package/typings/rules/no-unreachable-types.d.cts +1 -1
- package/typings/rules/no-unreachable-types.d.ts +1 -1
- package/typings/rules/no-unused-fields.d.cts +1 -1
- package/typings/rules/no-unused-fields.d.ts +1 -1
- package/typings/rules/relay-arguments.d.cts +1 -1
- package/typings/rules/relay-arguments.d.ts +1 -1
- package/typings/rules/relay-connection-types.d.cts +1 -1
- package/typings/rules/relay-connection-types.d.ts +1 -1
- package/typings/rules/relay-edge-types.d.cts +1 -1
- package/typings/rules/relay-edge-types.d.ts +1 -1
- package/typings/rules/relay-page-info.d.cts +1 -1
- package/typings/rules/relay-page-info.d.ts +1 -1
- package/typings/rules/require-deprecation-date.d.cts +1 -1
- package/typings/rules/require-deprecation-date.d.ts +1 -1
- package/typings/rules/require-deprecation-reason.d.cts +1 -1
- package/typings/rules/require-deprecation-reason.d.ts +1 -1
- package/typings/rules/require-description.d.cts +1 -1
- package/typings/rules/require-description.d.ts +1 -1
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.cts +1 -1
- package/typings/rules/require-field-of-type-query-in-mutation-result.d.ts +1 -1
- package/typings/rules/require-id-when-available.d.cts +1 -1
- package/typings/rules/require-id-when-available.d.ts +1 -1
- package/typings/rules/require-nullable-fields-with-oneof.d.cts +1 -1
- package/typings/rules/require-nullable-fields-with-oneof.d.ts +1 -1
- package/typings/rules/require-type-pattern-with-oneof.d.cts +1 -1
- package/typings/rules/require-type-pattern-with-oneof.d.ts +1 -1
- package/typings/rules/selection-set-depth.d.cts +1 -1
- package/typings/rules/selection-set-depth.d.ts +1 -1
- package/typings/rules/strict-id-in-types.d.cts +1 -1
- package/typings/rules/strict-id-in-types.d.ts +1 -1
- package/typings/rules/unique-fragment-name.d.cts +2 -2
- package/typings/rules/unique-fragment-name.d.ts +2 -2
- package/typings/rules/unique-operation-name.d.cts +1 -1
- package/typings/rules/unique-operation-name.d.ts +1 -1
- package/typings/schema.d.cts +1 -1
- package/typings/schema.d.ts +1 -1
- package/typings/testkit.d.cts +3 -3
- package/typings/testkit.d.ts +3 -3
- package/typings/types.d.cts +2 -2
- package/typings/types.d.ts +2 -2
- package/typings/utils.d.cts +2 -2
- package/typings/utils.d.ts +2 -2
package/cjs/configs/index.js
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.configs = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
5
|
+
const schema_recommended_js_1 = tslib_1.__importDefault(require("./schema-recommended.js"));
|
6
|
+
const schema_all_js_1 = tslib_1.__importDefault(require("./schema-all.js"));
|
7
|
+
const operations_recommended_js_1 = tslib_1.__importDefault(require("./operations-recommended.js"));
|
8
|
+
const operations_all_js_1 = tslib_1.__importDefault(require("./operations-all.js"));
|
9
|
+
const relay_js_1 = tslib_1.__importDefault(require("./relay.js"));
|
10
10
|
exports.configs = {
|
11
|
-
'schema-recommended':
|
12
|
-
'schema-all':
|
13
|
-
'operations-recommended':
|
14
|
-
'operations-all':
|
15
|
-
relay:
|
11
|
+
'schema-recommended': schema_recommended_js_1.default,
|
12
|
+
'schema-all': schema_all_js_1.default,
|
13
|
+
'operations-recommended': operations_recommended_js_1.default,
|
14
|
+
'operations-all': operations_all_js_1.default,
|
15
|
+
relay: relay_js_1.default,
|
16
16
|
};
|
package/cjs/documents.js
CHANGED
@@ -6,8 +6,8 @@ const path_1 = require("path");
|
|
6
6
|
const graphql_1 = require("graphql");
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
8
8
|
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
9
|
-
const
|
10
|
-
const
|
9
|
+
const utils_js_1 = require("./utils.js");
|
10
|
+
const cache_js_1 = require("./cache.js");
|
11
11
|
const debug = (0, debug_1.default)('graphql-eslint:operations');
|
12
12
|
const handleVirtualPath = (documents) => {
|
13
13
|
const filepathMap = Object.create(null);
|
@@ -25,7 +25,7 @@ const handleVirtualPath = (documents) => {
|
|
25
25
|
};
|
26
26
|
});
|
27
27
|
};
|
28
|
-
const operationsCache = new
|
28
|
+
const operationsCache = new cache_js_1.ModuleCache();
|
29
29
|
const siblingOperationsCache = new Map();
|
30
30
|
const getSiblings = (project) => {
|
31
31
|
const documentsKey = project.documents;
|
@@ -55,7 +55,7 @@ function getDocuments(project) {
|
|
55
55
|
let printed = false;
|
56
56
|
const noopWarn = () => {
|
57
57
|
if (!printed) {
|
58
|
-
|
58
|
+
utils_js_1.logger.warn('getSiblingOperations was called without any operations. Make sure to set "parserOptions.operations" to make this feature available!');
|
59
59
|
printed = true;
|
60
60
|
}
|
61
61
|
return [];
|
@@ -120,7 +120,7 @@ function getDocuments(project) {
|
|
120
120
|
const fragmentName = spread.name.value;
|
121
121
|
const [fragment] = getFragment(fragmentName);
|
122
122
|
if (!fragment) {
|
123
|
-
|
123
|
+
utils_js_1.logger.warn(`Unable to locate fragment named "${fragmentName}", please make sure it's loaded using "parserOptions.operations"`);
|
124
124
|
return;
|
125
125
|
}
|
126
126
|
if (!collected.has(fragmentName)) {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.convertToESTree = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
|
-
const
|
5
|
+
const utils_js_1 = require("./utils.js");
|
6
6
|
function convertToESTree(node, schema) {
|
7
7
|
const typeInfo = schema ? new graphql_1.TypeInfo(schema) : null;
|
8
8
|
const visitor = {
|
@@ -42,7 +42,7 @@ function convertToESTree(node, schema) {
|
|
42
42
|
const commonFields = {
|
43
43
|
...node,
|
44
44
|
type: node.kind,
|
45
|
-
loc: (0,
|
45
|
+
loc: (0, utils_js_1.convertLocation)(node.loc),
|
46
46
|
range: [node.loc.start, node.loc.end],
|
47
47
|
leadingComments,
|
48
48
|
// Use function to prevent RangeError: Maximum call stack size exceeded
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
-
tslib_1.__exportStar(require("./converter"), exports);
|
5
|
-
tslib_1.__exportStar(require("./types"), exports);
|
6
|
-
tslib_1.__exportStar(require("./utils"), exports);
|
4
|
+
tslib_1.__exportStar(require("./converter.js"), exports);
|
5
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
6
|
+
tslib_1.__exportStar(require("./utils.js"), exports);
|
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.convertLocation = exports.extractComments = exports.extractTokens = exports.convertToken = exports.getBaseType = exports.valueFromNode = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
|
-
const
|
5
|
+
const valueFromASTUntyped_js_1 = require("graphql/utilities/valueFromASTUntyped.js");
|
6
6
|
const valueFromNode = (...args) => {
|
7
|
-
return (0,
|
7
|
+
return (0, valueFromASTUntyped_js_1.valueFromASTUntyped)(...args);
|
8
8
|
};
|
9
9
|
exports.valueFromNode = valueFromNode;
|
10
10
|
function getBaseType(type) {
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.flatConfigs = void 0;
|
4
|
+
const parser_js_1 = require("./parser.js");
|
5
|
+
const index_js_1 = require("./configs/index.js");
|
6
|
+
const languageOptions = {
|
7
|
+
parser: { parseForESLint: parser_js_1.parseForESLint },
|
8
|
+
};
|
9
|
+
exports.flatConfigs = {
|
10
|
+
'operations-all': {
|
11
|
+
languageOptions,
|
12
|
+
rules: {
|
13
|
+
...index_js_1.configs['operations-recommended'].rules,
|
14
|
+
...index_js_1.configs['operations-all'].rules,
|
15
|
+
},
|
16
|
+
},
|
17
|
+
'operations-recommended': {
|
18
|
+
languageOptions,
|
19
|
+
rules: index_js_1.configs['operations-recommended'].rules,
|
20
|
+
},
|
21
|
+
relay: {
|
22
|
+
languageOptions,
|
23
|
+
rules: index_js_1.configs.relay.rules,
|
24
|
+
},
|
25
|
+
'schema-all': {
|
26
|
+
languageOptions,
|
27
|
+
rules: {
|
28
|
+
...index_js_1.configs['schema-recommended'].rules,
|
29
|
+
...index_js_1.configs['schema-all'].rules,
|
30
|
+
},
|
31
|
+
},
|
32
|
+
'schema-recommended': {
|
33
|
+
languageOptions,
|
34
|
+
rules: index_js_1.configs['schema-recommended'].rules,
|
35
|
+
},
|
36
|
+
};
|
package/cjs/index.js
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.configs = exports.processors = exports.requireSiblingsOperations = exports.requireGraphQLSchemaFromContext = exports.parseForESLint = exports.rules = void 0;
|
3
|
+
exports.flatConfigs = exports.configs = exports.processors = exports.requireSiblingsOperations = exports.requireGraphQLSchemaFromContext = exports.parseForESLint = exports.rules = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
-
const
|
6
|
-
var
|
7
|
-
Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return
|
8
|
-
var
|
9
|
-
Object.defineProperty(exports, "parseForESLint", { enumerable: true, get: function () { return
|
10
|
-
tslib_1.__exportStar(require("./testkit"), exports);
|
11
|
-
tslib_1.__exportStar(require("./types"), exports);
|
12
|
-
var
|
13
|
-
Object.defineProperty(exports, "requireGraphQLSchemaFromContext", { enumerable: true, get: function () { return
|
14
|
-
Object.defineProperty(exports, "requireSiblingsOperations", { enumerable: true, get: function () { return
|
15
|
-
exports.processors = { graphql:
|
16
|
-
var
|
17
|
-
Object.defineProperty(exports, "configs", { enumerable: true, get: function () { return
|
5
|
+
const processor_js_1 = require("./processor.js");
|
6
|
+
var index_js_1 = require("./rules/index.js");
|
7
|
+
Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return index_js_1.rules; } });
|
8
|
+
var parser_js_1 = require("./parser.js");
|
9
|
+
Object.defineProperty(exports, "parseForESLint", { enumerable: true, get: function () { return parser_js_1.parseForESLint; } });
|
10
|
+
tslib_1.__exportStar(require("./testkit.js"), exports);
|
11
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
12
|
+
var utils_js_1 = require("./utils.js");
|
13
|
+
Object.defineProperty(exports, "requireGraphQLSchemaFromContext", { enumerable: true, get: function () { return utils_js_1.requireGraphQLSchemaFromContext; } });
|
14
|
+
Object.defineProperty(exports, "requireSiblingsOperations", { enumerable: true, get: function () { return utils_js_1.requireSiblingsOperations; } });
|
15
|
+
exports.processors = { graphql: processor_js_1.processor };
|
16
|
+
var index_js_2 = require("./configs/index.js");
|
17
|
+
Object.defineProperty(exports, "configs", { enumerable: true, get: function () { return index_js_2.configs; } });
|
18
|
+
var flat_configs_js_1 = require("./flat-configs.js");
|
19
|
+
Object.defineProperty(exports, "flatConfigs", { enumerable: true, get: function () { return flat_configs_js_1.flatConfigs; } });
|
package/cjs/parser.js
CHANGED
@@ -5,13 +5,13 @@ const tslib_1 = require("tslib");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
6
6
|
const graphql_1 = require("graphql");
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
8
|
+
const index_js_1 = require("./estree-converter/index.js");
|
9
|
+
const schema_js_1 = require("./schema.js");
|
10
|
+
const documents_js_1 = require("./documents.js");
|
11
|
+
const graphql_config_js_1 = require("./graphql-config.js");
|
12
|
+
const utils_js_1 = require("./utils.js");
|
13
13
|
const debug = (0, debug_1.default)('graphql-eslint:parser');
|
14
|
-
debug('cwd %o',
|
14
|
+
debug('cwd %o', utils_js_1.CWD);
|
15
15
|
function parseForESLint(code, options) {
|
16
16
|
try {
|
17
17
|
const { filePath } = options;
|
@@ -21,19 +21,19 @@ function parseForESLint(code, options) {
|
|
21
21
|
...options.graphQLParserOptions,
|
22
22
|
noLocation: false,
|
23
23
|
});
|
24
|
-
const gqlConfig = (0,
|
25
|
-
const realFilepath = filePath.replace(
|
24
|
+
const gqlConfig = (0, graphql_config_js_1.loadGraphQLConfig)(options);
|
25
|
+
const realFilepath = filePath.replace(utils_js_1.VIRTUAL_DOCUMENT_REGEX, '');
|
26
26
|
const project = gqlConfig.getProjectForFile(realFilepath);
|
27
|
-
const schema = (0,
|
28
|
-
const rootTree = (0,
|
27
|
+
const schema = (0, schema_js_1.getSchema)(project, options.schemaOptions);
|
28
|
+
const rootTree = (0, index_js_1.convertToESTree)(document, schema instanceof graphql_1.GraphQLSchema ? schema : null);
|
29
29
|
return {
|
30
30
|
services: {
|
31
31
|
schema,
|
32
|
-
siblingOperations: (0,
|
32
|
+
siblingOperations: (0, documents_js_1.getDocuments)(project),
|
33
33
|
},
|
34
34
|
ast: {
|
35
|
-
comments: (0,
|
36
|
-
tokens: (0,
|
35
|
+
comments: (0, index_js_1.extractComments)(document.loc),
|
36
|
+
tokens: (0, index_js_1.extractTokens)(filePath, code),
|
37
37
|
loc: rootTree.loc,
|
38
38
|
range: rootTree.range,
|
39
39
|
type: 'Program',
|
package/cjs/processor.js
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processor = void 0;
|
4
4
|
const graphql_tag_pluck_1 = require("@graphql-tools/graphql-tag-pluck");
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
6
|
-
const
|
6
|
+
const graphql_config_js_1 = require("./graphql-config.js");
|
7
7
|
const blocksMap = new Map();
|
8
8
|
let onDiskConfig;
|
9
9
|
let onDiskConfigLoaded = false;
|
@@ -12,7 +12,7 @@ exports.processor = {
|
|
12
12
|
supportsAutofix: true,
|
13
13
|
preprocess(code, filePath) {
|
14
14
|
if (!onDiskConfigLoaded) {
|
15
|
-
onDiskConfig = (0,
|
15
|
+
onDiskConfig = (0, graphql_config_js_1.loadOnDiskGraphQLConfig)(filePath);
|
16
16
|
onDiskConfigLoaded = true;
|
17
17
|
}
|
18
18
|
let keywords = RELEVANT_KEYWORDS;
|
package/cjs/rules/alphabetize.js
CHANGED
@@ -4,7 +4,7 @@ exports.rule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const graphql_1 = require("graphql");
|
6
6
|
const lodash_lowercase_1 = tslib_1.__importDefault(require("lodash.lowercase"));
|
7
|
-
const
|
7
|
+
const utils_js_1 = require("../utils.js");
|
8
8
|
const RULE_ID = 'alphabetize';
|
9
9
|
const fieldsEnum = [
|
10
10
|
graphql_1.Kind.OBJECT_TYPE_DEFINITION,
|
@@ -33,35 +33,35 @@ const schema = {
|
|
33
33
|
minProperties: 1,
|
34
34
|
properties: {
|
35
35
|
fields: {
|
36
|
-
...
|
36
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
37
37
|
items: {
|
38
38
|
enum: fieldsEnum,
|
39
39
|
},
|
40
40
|
description: 'Fields of `type`, `interface`, and `input`.',
|
41
41
|
},
|
42
42
|
values: {
|
43
|
-
...
|
43
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
44
44
|
items: {
|
45
45
|
enum: valuesEnum,
|
46
46
|
},
|
47
47
|
description: 'Values of `enum`.',
|
48
48
|
},
|
49
49
|
selections: {
|
50
|
-
...
|
50
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
51
51
|
items: {
|
52
52
|
enum: selectionsEnum,
|
53
53
|
},
|
54
54
|
description: 'Selections of `fragment` and operations `query`, `mutation` and `subscription`.',
|
55
55
|
},
|
56
56
|
variables: {
|
57
|
-
...
|
57
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
58
58
|
items: {
|
59
59
|
enum: variablesEnum,
|
60
60
|
},
|
61
61
|
description: 'Variables of operations `query`, `mutation` and `subscription`.',
|
62
62
|
},
|
63
63
|
arguments: {
|
64
|
-
...
|
64
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
65
65
|
items: {
|
66
66
|
enum: argumentsEnum,
|
67
67
|
},
|
@@ -73,7 +73,7 @@ const schema = {
|
|
73
73
|
default: false,
|
74
74
|
},
|
75
75
|
groups: {
|
76
|
-
...
|
76
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
77
77
|
minItems: 2,
|
78
78
|
description: "Custom order group. Example: `['id', '*', 'createdAt', 'updatedAt']` where `*` says for everything else.",
|
79
79
|
},
|
@@ -2,8 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.GRAPHQL_JS_VALIDATIONS = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
|
-
const
|
6
|
-
const
|
5
|
+
const validate_js_1 = require("graphql/validation/validate.js");
|
6
|
+
const utils_js_1 = require("../utils.js");
|
7
7
|
function validateDocument({ context, schema = null, documentNode, rule, hasDidYouMeanSuggestions, }) {
|
8
8
|
var _a;
|
9
9
|
if (documentNode.definitions.length === 0) {
|
@@ -12,7 +12,7 @@ function validateDocument({ context, schema = null, documentNode, rule, hasDidYo
|
|
12
12
|
try {
|
13
13
|
const validationErrors = schema
|
14
14
|
? (0, graphql_1.validate)(schema, documentNode, [rule])
|
15
|
-
: (0,
|
15
|
+
: (0, validate_js_1.validateSDL)(documentNode, null, [rule]);
|
16
16
|
for (const error of validationErrors) {
|
17
17
|
const { line, column } = error.locations[0];
|
18
18
|
const sourceCode = context.getSourceCode();
|
@@ -48,7 +48,7 @@ function validateDocument({ context, schema = null, documentNode, rule, hasDidYo
|
|
48
48
|
}
|
49
49
|
catch (e) {
|
50
50
|
context.report({
|
51
|
-
loc:
|
51
|
+
loc: utils_js_1.REPORT_ON_FIRST_CHARACTER,
|
52
52
|
message: e.message,
|
53
53
|
});
|
54
54
|
}
|
@@ -74,7 +74,7 @@ const getMissingFragments = (node) => {
|
|
74
74
|
const handleMissingFragments = ({ ruleId, context, node }) => {
|
75
75
|
const missingFragments = getMissingFragments(node);
|
76
76
|
if (missingFragments.length > 0) {
|
77
|
-
const siblings = (0,
|
77
|
+
const siblings = (0, utils_js_1.requireSiblingsOperations)(ruleId, context);
|
78
78
|
const fragmentsToAdd = [];
|
79
79
|
for (const fragmentName of missingFragments) {
|
80
80
|
const [foundFragment] = siblings.getFragment(fragmentName).map(source => source.document);
|
@@ -124,13 +124,13 @@ const validationToRule = ({ ruleId, ruleName, getDocumentNode, schema = [], hasD
|
|
124
124
|
},
|
125
125
|
create(context) {
|
126
126
|
if (!ruleFn) {
|
127
|
-
|
127
|
+
utils_js_1.logger.warn(`Rule "${ruleId}" depends on a GraphQL validation rule "${ruleName}" but it's not available in the "graphql" version you are using. Skipping…`);
|
128
128
|
return {};
|
129
129
|
}
|
130
130
|
return {
|
131
131
|
Document(node) {
|
132
132
|
const schema = docs.requiresSchema
|
133
|
-
? (0,
|
133
|
+
? (0, utils_js_1.requireGraphQLSchemaFromContext)(ruleId, context)
|
134
134
|
: null;
|
135
135
|
const documentNode = getDocumentNode
|
136
136
|
? getDocumentNode({ ruleId, context, node: node.rawNode() })
|
@@ -203,7 +203,7 @@ exports.GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
203
203
|
additionalProperties: false,
|
204
204
|
required: ['ignoreClientDirectives'],
|
205
205
|
properties: {
|
206
|
-
ignoreClientDirectives:
|
206
|
+
ignoreClientDirectives: utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
207
207
|
},
|
208
208
|
},
|
209
209
|
},
|
@@ -320,7 +320,7 @@ exports.GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule({
|
|
320
320
|
ruleId: 'no-unused-fragments',
|
321
321
|
ruleName: 'NoUnusedFragments',
|
322
322
|
getDocumentNode: ({ ruleId, context, node }) => {
|
323
|
-
const siblings = (0,
|
323
|
+
const siblings = (0, utils_js_1.requireSiblingsOperations)(ruleId, context);
|
324
324
|
const FilePathToDocumentsMap = [
|
325
325
|
...siblings.getOperations(),
|
326
326
|
...siblings.getFragments(),
|
package/cjs/rules/index.js
CHANGED
@@ -4,71 +4,71 @@
|
|
4
4
|
*/
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.rules = void 0;
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const
|
23
|
-
const
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const
|
27
|
-
const
|
28
|
-
const
|
29
|
-
const
|
30
|
-
const
|
31
|
-
const
|
32
|
-
const
|
33
|
-
const
|
34
|
-
const
|
35
|
-
const
|
36
|
-
const
|
37
|
-
const
|
38
|
-
const
|
39
|
-
const
|
7
|
+
const graphql_js_validation_js_1 = require("./graphql-js-validation.js");
|
8
|
+
const alphabetize_js_1 = require("./alphabetize.js");
|
9
|
+
const description_style_js_1 = require("./description-style.js");
|
10
|
+
const input_name_js_1 = require("./input-name.js");
|
11
|
+
const lone_executable_definition_js_1 = require("./lone-executable-definition.js");
|
12
|
+
const match_document_filename_js_1 = require("./match-document-filename.js");
|
13
|
+
const naming_convention_js_1 = require("./naming-convention.js");
|
14
|
+
const no_anonymous_operations_js_1 = require("./no-anonymous-operations.js");
|
15
|
+
const no_case_insensitive_enum_values_duplicates_js_1 = require("./no-case-insensitive-enum-values-duplicates.js");
|
16
|
+
const no_deprecated_js_1 = require("./no-deprecated.js");
|
17
|
+
const no_duplicate_fields_js_1 = require("./no-duplicate-fields.js");
|
18
|
+
const no_hashtag_description_js_1 = require("./no-hashtag-description.js");
|
19
|
+
const no_one_place_fragments_js_1 = require("./no-one-place-fragments.js");
|
20
|
+
const no_root_type_js_1 = require("./no-root-type.js");
|
21
|
+
const no_scalar_result_type_on_mutation_js_1 = require("./no-scalar-result-type-on-mutation.js");
|
22
|
+
const no_typename_prefix_js_1 = require("./no-typename-prefix.js");
|
23
|
+
const no_unreachable_types_js_1 = require("./no-unreachable-types.js");
|
24
|
+
const no_unused_fields_js_1 = require("./no-unused-fields.js");
|
25
|
+
const relay_arguments_js_1 = require("./relay-arguments.js");
|
26
|
+
const relay_connection_types_js_1 = require("./relay-connection-types.js");
|
27
|
+
const relay_edge_types_js_1 = require("./relay-edge-types.js");
|
28
|
+
const relay_page_info_js_1 = require("./relay-page-info.js");
|
29
|
+
const require_deprecation_date_js_1 = require("./require-deprecation-date.js");
|
30
|
+
const require_deprecation_reason_js_1 = require("./require-deprecation-reason.js");
|
31
|
+
const require_description_js_1 = require("./require-description.js");
|
32
|
+
const require_field_of_type_query_in_mutation_result_js_1 = require("./require-field-of-type-query-in-mutation-result.js");
|
33
|
+
const require_id_when_available_js_1 = require("./require-id-when-available.js");
|
34
|
+
const require_nullable_fields_with_oneof_js_1 = require("./require-nullable-fields-with-oneof.js");
|
35
|
+
const require_type_pattern_with_oneof_js_1 = require("./require-type-pattern-with-oneof.js");
|
36
|
+
const selection_set_depth_js_1 = require("./selection-set-depth.js");
|
37
|
+
const strict_id_in_types_js_1 = require("./strict-id-in-types.js");
|
38
|
+
const unique_fragment_name_js_1 = require("./unique-fragment-name.js");
|
39
|
+
const unique_operation_name_js_1 = require("./unique-operation-name.js");
|
40
40
|
exports.rules = {
|
41
|
-
...
|
42
|
-
alphabetize:
|
43
|
-
'description-style':
|
44
|
-
'input-name':
|
45
|
-
'lone-executable-definition':
|
46
|
-
'match-document-filename':
|
47
|
-
'naming-convention':
|
48
|
-
'no-anonymous-operations':
|
49
|
-
'no-case-insensitive-enum-values-duplicates':
|
50
|
-
'no-deprecated':
|
51
|
-
'no-duplicate-fields':
|
52
|
-
'no-hashtag-description':
|
53
|
-
'no-one-place-fragments':
|
54
|
-
'no-root-type':
|
55
|
-
'no-scalar-result-type-on-mutation':
|
56
|
-
'no-typename-prefix':
|
57
|
-
'no-unreachable-types':
|
58
|
-
'no-unused-fields':
|
59
|
-
'relay-arguments':
|
60
|
-
'relay-connection-types':
|
61
|
-
'relay-edge-types':
|
62
|
-
'relay-page-info':
|
63
|
-
'require-deprecation-date':
|
64
|
-
'require-deprecation-reason':
|
65
|
-
'require-description':
|
66
|
-
'require-field-of-type-query-in-mutation-result':
|
67
|
-
'require-id-when-available':
|
68
|
-
'require-nullable-fields-with-oneof':
|
69
|
-
'require-type-pattern-with-oneof':
|
70
|
-
'selection-set-depth':
|
71
|
-
'strict-id-in-types':
|
72
|
-
'unique-fragment-name':
|
73
|
-
'unique-operation-name':
|
41
|
+
...graphql_js_validation_js_1.GRAPHQL_JS_VALIDATIONS,
|
42
|
+
alphabetize: alphabetize_js_1.rule,
|
43
|
+
'description-style': description_style_js_1.rule,
|
44
|
+
'input-name': input_name_js_1.rule,
|
45
|
+
'lone-executable-definition': lone_executable_definition_js_1.rule,
|
46
|
+
'match-document-filename': match_document_filename_js_1.rule,
|
47
|
+
'naming-convention': naming_convention_js_1.rule,
|
48
|
+
'no-anonymous-operations': no_anonymous_operations_js_1.rule,
|
49
|
+
'no-case-insensitive-enum-values-duplicates': no_case_insensitive_enum_values_duplicates_js_1.rule,
|
50
|
+
'no-deprecated': no_deprecated_js_1.rule,
|
51
|
+
'no-duplicate-fields': no_duplicate_fields_js_1.rule,
|
52
|
+
'no-hashtag-description': no_hashtag_description_js_1.rule,
|
53
|
+
'no-one-place-fragments': no_one_place_fragments_js_1.rule,
|
54
|
+
'no-root-type': no_root_type_js_1.rule,
|
55
|
+
'no-scalar-result-type-on-mutation': no_scalar_result_type_on_mutation_js_1.rule,
|
56
|
+
'no-typename-prefix': no_typename_prefix_js_1.rule,
|
57
|
+
'no-unreachable-types': no_unreachable_types_js_1.rule,
|
58
|
+
'no-unused-fields': no_unused_fields_js_1.rule,
|
59
|
+
'relay-arguments': relay_arguments_js_1.rule,
|
60
|
+
'relay-connection-types': relay_connection_types_js_1.rule,
|
61
|
+
'relay-edge-types': relay_edge_types_js_1.rule,
|
62
|
+
'relay-page-info': relay_page_info_js_1.rule,
|
63
|
+
'require-deprecation-date': require_deprecation_date_js_1.rule,
|
64
|
+
'require-deprecation-reason': require_deprecation_reason_js_1.rule,
|
65
|
+
'require-description': require_description_js_1.rule,
|
66
|
+
'require-field-of-type-query-in-mutation-result': require_field_of_type_query_in_mutation_result_js_1.rule,
|
67
|
+
'require-id-when-available': require_id_when_available_js_1.rule,
|
68
|
+
'require-nullable-fields-with-oneof': require_nullable_fields_with_oneof_js_1.rule,
|
69
|
+
'require-type-pattern-with-oneof': require_type_pattern_with_oneof_js_1.rule,
|
70
|
+
'selection-set-depth': selection_set_depth_js_1.rule,
|
71
|
+
'strict-id-in-types': strict_id_in_types_js_1.rule,
|
72
|
+
'unique-fragment-name': unique_fragment_name_js_1.rule,
|
73
|
+
'unique-operation-name': unique_operation_name_js_1.rule,
|
74
74
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.rule = void 0;
|
4
|
-
const
|
4
|
+
const utils_js_1 = require("../utils.js");
|
5
5
|
const RULE_ID = 'lone-executable-definition';
|
6
6
|
const definitionTypes = ['fragment', 'query', 'mutation', 'subscription'];
|
7
7
|
const schema = {
|
@@ -13,7 +13,7 @@ const schema = {
|
|
13
13
|
additionalProperties: false,
|
14
14
|
properties: {
|
15
15
|
ignore: {
|
16
|
-
...
|
16
|
+
...utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
17
17
|
maxItems: 3,
|
18
18
|
items: {
|
19
19
|
enum: definitionTypes,
|
@@ -71,13 +71,13 @@ exports.rule = {
|
|
71
71
|
'Program:exit'() {
|
72
72
|
var _a, _b;
|
73
73
|
for (const { node, type } of definitions.slice(1) /* ignore first definition */) {
|
74
|
-
let name = (0,
|
74
|
+
let name = (0, utils_js_1.pascalCase)(type);
|
75
75
|
const definitionName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
|
76
76
|
if (definitionName) {
|
77
77
|
name += ` "${definitionName}"`;
|
78
78
|
}
|
79
79
|
context.report({
|
80
|
-
loc: ((_b = node.name) === null || _b === void 0 ? void 0 : _b.loc) || (0,
|
80
|
+
loc: ((_b = node.name) === null || _b === void 0 ? void 0 : _b.loc) || (0, utils_js_1.getLocation)(node.loc.start, type),
|
81
81
|
messageId: RULE_ID,
|
82
82
|
data: { name },
|
83
83
|
});
|
@@ -4,7 +4,7 @@ exports.rule = void 0;
|
|
4
4
|
const path_1 = require("path");
|
5
5
|
const fs_1 = require("fs");
|
6
6
|
const graphql_1 = require("graphql");
|
7
|
-
const
|
7
|
+
const utils_js_1 = require("../utils.js");
|
8
8
|
const MATCH_EXTENSION = 'MATCH_EXTENSION';
|
9
9
|
const MATCH_STYLE = 'MATCH_STYLE';
|
10
10
|
const CASE_STYLES = [
|
@@ -181,7 +181,7 @@ exports.rule = {
|
|
181
181
|
var _a;
|
182
182
|
if (options.fileExtension && options.fileExtension !== fileExtension) {
|
183
183
|
context.report({
|
184
|
-
loc:
|
184
|
+
loc: utils_js_1.REPORT_ON_FIRST_CHARACTER,
|
185
185
|
messageId: MATCH_EXTENSION,
|
186
186
|
data: {
|
187
187
|
fileExtension,
|
@@ -212,7 +212,7 @@ exports.rule = {
|
|
212
212
|
let expectedFilename = option.prefix || '';
|
213
213
|
if (option.style) {
|
214
214
|
expectedFilename +=
|
215
|
-
option.style === 'matchDocumentStyle' ? docName : (0,
|
215
|
+
option.style === 'matchDocumentStyle' ? docName : (0, utils_js_1.convertCase)(option.style, docName);
|
216
216
|
}
|
217
217
|
else {
|
218
218
|
expectedFilename += filename;
|
@@ -221,7 +221,7 @@ exports.rule = {
|
|
221
221
|
const filenameWithExtension = filename + expectedExtension;
|
222
222
|
if (expectedFilename !== filenameWithExtension) {
|
223
223
|
context.report({
|
224
|
-
loc:
|
224
|
+
loc: utils_js_1.REPORT_ON_FIRST_CHARACTER,
|
225
225
|
messageId: MATCH_STYLE,
|
226
226
|
data: {
|
227
227
|
expectedFilename,
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.rule = void 0;
|
4
4
|
const graphql_1 = require("graphql");
|
5
|
-
const
|
5
|
+
const utils_js_1 = require("../utils.js");
|
6
6
|
const KindToDisplayName = {
|
7
7
|
// types
|
8
8
|
[graphql_1.Kind.OBJECT_TYPE_DEFINITION]: 'Type',
|
@@ -46,8 +46,8 @@ const schema = {
|
|
46
46
|
style: { enum: ALLOWED_STYLES },
|
47
47
|
prefix: { type: 'string' },
|
48
48
|
suffix: { type: 'string' },
|
49
|
-
forbiddenPrefixes:
|
50
|
-
forbiddenSuffixes:
|
49
|
+
forbiddenPrefixes: utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
50
|
+
forbiddenSuffixes: utils_js_1.ARRAY_DEFAULT_OPTIONS,
|
51
51
|
ignorePattern: {
|
52
52
|
type: 'string',
|
53
53
|
description: 'Option to skip validation of some words, e.g. acronyms',
|
@@ -63,7 +63,7 @@ const schema = {
|
|
63
63
|
properties: {
|
64
64
|
types: {
|
65
65
|
...schemaOption,
|
66
|
-
description: `Includes:\n${
|
66
|
+
description: `Includes:\n${utils_js_1.TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
|
67
67
|
},
|
68
68
|
...Object.fromEntries(ALLOWED_KINDS.map(kind => [
|
69
69
|
kind,
|
@@ -285,7 +285,7 @@ exports.rule = {
|
|
285
285
|
if (!caseRegex.test(name)) {
|
286
286
|
return {
|
287
287
|
errorMessage: `be in ${style} format`,
|
288
|
-
renameToName: (0,
|
288
|
+
renameToName: (0, utils_js_1.convertCase)(style, name),
|
289
289
|
};
|
290
290
|
}
|
291
291
|
}
|
@@ -301,7 +301,7 @@ exports.rule = {
|
|
301
301
|
if (!allowTrailingUnderscore) {
|
302
302
|
listeners['Name[value=/_$/]:matches([parent.kind!=Field], [parent.kind=Field][parent.alias])'] = checkUnderscore(false);
|
303
303
|
}
|
304
|
-
const selectors = new Set([types &&
|
304
|
+
const selectors = new Set([types && utils_js_1.TYPES_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
|
305
305
|
for (const selector of selectors) {
|
306
306
|
listeners[selector] = checkNode(selector);
|
307
307
|
}
|