@graphql-eslint/eslint-plugin 4.0.0-alpha.0 → 4.0.0-alpha.10
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 +1 -1
- package/{esm/cache.d.mts → cjs/cache.d.cts} +1 -1
- package/cjs/cache.js +8 -36
- package/cjs/chunk-UIAXBAMD.js +8 -0
- package/cjs/configs/index.d.cts +24 -0
- package/cjs/configs/index.js +35 -38
- package/cjs/configs/operations-all.js +33 -26
- package/cjs/configs/operations-recommended.js +59 -52
- package/cjs/configs/schema-all.js +29 -22
- package/cjs/configs/schema-recommended.js +73 -66
- package/cjs/configs/schema-relay.js +17 -10
- package/cjs/documents.js +18 -38
- package/{esm/estree-converter/converter.d.mts → cjs/estree-converter/converter.d.cts} +1 -1
- package/cjs/estree-converter/converter.js +16 -30
- package/cjs/estree-converter/index.d.cts +8 -0
- package/cjs/estree-converter/index.js +3 -23
- package/{esm/estree-converter/types.d.mts → cjs/estree-converter/types.d.cts} +1 -1
- package/cjs/estree-converter/types.js +1 -14
- package/{esm/estree-converter/utils.d.mts → cjs/estree-converter/utils.d.cts} +3 -3
- package/cjs/estree-converter/utils.js +22 -40
- package/{esm/graphql-config.d.mts → cjs/graphql-config.d.cts} +3 -3
- package/cjs/graphql-config.js +16 -42
- package/cjs/index.d.cts +184 -0
- package/cjs/index.js +24 -41
- package/cjs/meta.d.cts +3 -0
- package/cjs/meta.js +5 -0
- package/cjs/package.json +1 -0
- package/{esm/parser.d.mts → cjs/parser.d.cts} +12 -5
- package/cjs/parser.js +35 -46
- package/{esm/processor.d.mts → cjs/processor.d.cts} +5 -1
- package/cjs/processor.js +25 -34
- package/cjs/rules/{alphabetize.d.ts → alphabetize/index.d.cts} +6 -6
- package/cjs/rules/{alphabetize.js → alphabetize/index.js} +69 -77
- package/{esm/rules/description-style.d.mts → cjs/rules/description-style/index.d.cts} +5 -5
- package/cjs/rules/{description-style.js → description-style/index.js} +7 -27
- package/{esm/rules/graphql-js-validation.d.mts → cjs/rules/graphql-js-validation.d.cts} +4 -4
- package/cjs/rules/graphql-js-validation.js +93 -70
- package/{esm/rules/index.d.mts → cjs/rules/index.d.cts} +11 -12
- package/cjs/rules/index.js +74 -60
- package/cjs/rules/{input-name.d.ts → input-name/index.d.cts} +8 -6
- package/cjs/rules/{input-name.js → input-name/index.js} +10 -28
- package/cjs/rules/{lone-executable-definition.d.ts → lone-executable-definition/index.d.cts} +5 -5
- package/cjs/rules/{lone-executable-definition.js → lone-executable-definition/index.js} +13 -32
- package/cjs/rules/{match-document-filename.d.ts → match-document-filename/index.d.cts} +6 -6
- package/cjs/rules/{match-document-filename.js → match-document-filename/index.js} +21 -35
- package/{esm/rules/naming-convention.d.mts → cjs/rules/naming-convention/index.d.cts} +8 -6
- package/cjs/rules/{naming-convention.js → naming-convention/index.js} +41 -54
- package/cjs/rules/no-anonymous-operations/index.d.cts +13 -0
- package/cjs/rules/{no-anonymous-operations.js → no-anonymous-operations/index.js} +9 -28
- package/{esm/rules/no-deprecated.d.mts → cjs/rules/no-deprecated/index.d.cts} +4 -4
- package/cjs/rules/{no-deprecated.js → no-deprecated/index.js} +11 -30
- package/cjs/rules/no-duplicate-fields/index.d.cts +13 -0
- package/cjs/rules/{no-duplicate-fields.js → no-duplicate-fields/index.js} +8 -28
- package/cjs/rules/{no-hashtag-description.d.ts → no-hashtag-description/index.d.cts} +4 -4
- package/cjs/rules/{no-hashtag-description.js → no-hashtag-description/index.js} +11 -31
- package/cjs/rules/no-one-place-fragments/index.d.cts +13 -0
- package/cjs/rules/{no-one-place-fragments.js → no-one-place-fragments/index.js} +11 -29
- package/cjs/rules/{no-root-type.d.ts → no-root-type/index.d.cts} +5 -5
- package/cjs/rules/{no-root-type.js → no-root-type/index.js} +9 -29
- package/cjs/rules/no-scalar-result-type-on-mutation/index.d.cts +13 -0
- package/cjs/rules/no-scalar-result-type-on-mutation/index.js +69 -0
- package/cjs/rules/no-typename-prefix/index.d.cts +13 -0
- package/cjs/rules/{no-typename-prefix.js → no-typename-prefix/index.js} +5 -25
- package/cjs/rules/no-unreachable-types/index.d.cts +13 -0
- package/cjs/rules/no-unreachable-types/index.js +155 -0
- package/cjs/rules/no-unused-fields/index.d.cts +13 -0
- package/cjs/rules/{no-unused-fields.js → no-unused-fields/index.js} +16 -34
- package/{esm/rules/relay-arguments.d.mts → cjs/rules/relay-arguments/index.d.cts} +5 -5
- package/cjs/rules/{relay-arguments.js → relay-arguments/index.js} +11 -30
- package/{esm/rules/relay-connection-types.d.mts → cjs/rules/relay-connection-types/index.d.cts} +4 -4
- package/cjs/rules/{relay-connection-types.js → relay-connection-types/index.js} +19 -40
- package/cjs/rules/{relay-edge-types.d.ts → relay-edge-types/index.d.cts} +8 -6
- package/cjs/rules/{relay-edge-types.js → relay-edge-types/index.js} +31 -44
- package/cjs/rules/relay-page-info/index.d.cts +13 -0
- package/cjs/rules/{relay-page-info.js → relay-page-info/index.js} +13 -31
- package/{esm/rules/require-deprecation-date.d.mts → cjs/rules/require-deprecation-date/index.d.cts} +5 -5
- package/cjs/rules/{require-deprecation-date.js → require-deprecation-date/index.js} +13 -32
- package/cjs/rules/require-deprecation-reason/index.d.cts +13 -0
- package/cjs/rules/require-deprecation-reason/index.js +66 -0
- package/{esm/rules/require-description.d.mts → cjs/rules/require-description/index.d.cts} +5 -5
- package/cjs/rules/{require-description.js → require-description/index.js} +30 -44
- package/cjs/rules/require-field-of-type-query-in-mutation-result/index.d.cts +13 -0
- package/cjs/rules/{require-field-of-type-query-in-mutation-result.js → require-field-of-type-query-in-mutation-result/index.js} +10 -29
- package/cjs/rules/require-import-fragment/index.d.cts +13 -0
- package/cjs/rules/{require-import-fragment.js → require-import-fragment/index.js} +20 -46
- package/cjs/rules/require-nullable-fields-with-oneof/index.d.cts +13 -0
- package/cjs/rules/require-nullable-fields-with-oneof/index.js +62 -0
- package/cjs/rules/require-nullable-result-in-root/index.d.cts +13 -0
- package/cjs/rules/{require-nullable-result-in-root.js → require-nullable-result-in-root/index.js} +12 -31
- package/{esm/rules/require-selections.d.mts → cjs/rules/require-selections/index.d.cts} +5 -5
- package/cjs/rules/{require-selections.js → require-selections/index.js} +47 -45
- package/cjs/rules/require-type-pattern-with-oneof/index.d.cts +13 -0
- package/cjs/rules/require-type-pattern-with-oneof/index.js +63 -0
- package/{esm/rules/selection-set-depth.d.mts → cjs/rules/selection-set-depth/index.d.cts} +5 -5
- package/cjs/rules/{selection-set-depth.js → selection-set-depth/index.js} +16 -42
- package/cjs/rules/{strict-id-in-types.d.ts → strict-id-in-types/index.d.cts} +8 -6
- package/cjs/rules/{strict-id-in-types.js → strict-id-in-types/index.js} +26 -39
- package/cjs/rules/unique-enum-value-names/index.d.cts +13 -0
- package/cjs/rules/{unique-enum-value-names.js → unique-enum-value-names/index.js} +10 -29
- package/{esm/rules/unique-fragment-name.d.mts → cjs/rules/unique-fragment-name/index.d.cts} +4 -4
- package/cjs/rules/unique-fragment-name/index.js +87 -0
- package/cjs/rules/unique-operation-name/index.d.cts +13 -0
- package/cjs/rules/{unique-operation-name.js → unique-operation-name/index.js} +7 -27
- package/{esm/schema.d.mts → cjs/schema.d.cts} +3 -3
- package/cjs/schema.js +11 -36
- package/{esm/siblings.d.mts → cjs/siblings.d.cts} +2 -2
- package/cjs/siblings.js +17 -33
- package/{esm/types.d.mts → cjs/types.d.cts} +5 -4
- package/cjs/types.js +1 -14
- package/{esm/utils.d.mts → cjs/utils.d.cts} +6 -6
- package/cjs/utils.js +94 -115
- package/{cjs → esm}/cache.d.ts +1 -1
- package/esm/cache.js +1 -1
- package/esm/configs/index.d.ts +24 -0
- package/esm/configs/index.js +23 -2
- package/esm/configs/operations-all.js +2 -2
- package/esm/configs/operations-recommended.js +1 -1
- package/esm/configs/schema-all.js +1 -1
- package/esm/configs/schema-recommended.js +1 -1
- package/esm/configs/schema-relay.js +1 -1
- package/esm/documents.js +9 -4
- package/esm/estree-converter/converter.js +1 -1
- package/{cjs → esm}/estree-converter/index.d.ts +2 -2
- package/{cjs → esm}/estree-converter/types.d.ts +1 -1
- package/{cjs → esm}/estree-converter/utils.d.ts +3 -3
- package/esm/estree-converter/utils.js +1 -1
- package/esm/graphql-config.js +3 -3
- package/esm/index.d.ts +184 -0
- package/esm/index.js +11 -5
- package/esm/meta.d.ts +3 -0
- package/esm/meta.js +5 -0
- package/{cjs → esm}/parser.d.ts +10 -3
- package/esm/parser.js +13 -4
- package/{cjs → esm}/processor.d.ts +5 -1
- package/esm/processor.js +6 -1
- package/esm/rules/{alphabetize.d.mts → alphabetize/index.d.ts} +6 -6
- package/esm/rules/{alphabetize.js → alphabetize/index.js} +26 -10
- package/{cjs/rules/description-style.d.ts → esm/rules/description-style/index.d.ts} +5 -5
- package/esm/rules/{description-style.js → description-style/index.js} +2 -2
- package/esm/rules/graphql-js-validation.js +1 -1
- package/{cjs → esm}/rules/index.d.ts +9 -10
- package/esm/rules/index.js +35 -35
- package/esm/rules/{input-name.d.mts → input-name/index.d.ts} +8 -6
- package/esm/rules/{input-name.js → input-name/index.js} +1 -1
- package/esm/rules/{lone-executable-definition.d.mts → lone-executable-definition/index.d.ts} +5 -5
- package/esm/rules/{lone-executable-definition.js → lone-executable-definition/index.js} +2 -2
- package/esm/rules/{match-document-filename.d.mts → match-document-filename/index.d.ts} +6 -6
- package/esm/rules/{match-document-filename.js → match-document-filename/index.js} +4 -4
- package/{cjs/rules/naming-convention.d.ts → esm/rules/naming-convention/index.d.ts} +8 -6
- package/esm/rules/{naming-convention.js → naming-convention/index.js} +2 -2
- package/{cjs/rules/no-one-place-fragments.d.ts → esm/rules/no-anonymous-operations/index.d.ts} +4 -4
- package/esm/rules/{no-anonymous-operations.js → no-anonymous-operations/index.js} +2 -2
- package/{cjs/rules/no-deprecated.d.ts → esm/rules/no-deprecated/index.d.ts} +4 -4
- package/esm/rules/{no-deprecated.js → no-deprecated/index.js} +2 -2
- package/{cjs/rules/no-scalar-result-type-on-mutation.d.ts → esm/rules/no-duplicate-fields/index.d.ts} +4 -4
- package/esm/rules/{no-duplicate-fields.js → no-duplicate-fields/index.js} +1 -1
- package/esm/rules/{no-hashtag-description.d.mts → no-hashtag-description/index.d.ts} +4 -4
- package/esm/rules/{no-hashtag-description.js → no-hashtag-description/index.js} +2 -2
- package/{cjs/rules/no-anonymous-operations.d.ts → esm/rules/no-one-place-fragments/index.d.ts} +4 -4
- package/esm/rules/{no-one-place-fragments.js → no-one-place-fragments/index.js} +2 -2
- package/esm/rules/{no-root-type.d.mts → no-root-type/index.d.ts} +5 -5
- package/esm/rules/{no-root-type.js → no-root-type/index.js} +2 -2
- package/{cjs/rules/no-duplicate-fields.d.ts → esm/rules/no-scalar-result-type-on-mutation/index.d.ts} +4 -4
- package/esm/rules/{no-scalar-result-type-on-mutation.js → no-scalar-result-type-on-mutation/index.js} +2 -2
- package/esm/rules/no-typename-prefix/index.d.ts +13 -0
- package/esm/rules/{no-typename-prefix.js → no-typename-prefix/index.js} +1 -1
- package/esm/rules/no-unreachable-types/index.d.ts +13 -0
- package/esm/rules/{no-unreachable-types.js → no-unreachable-types/index.js} +9 -10
- package/esm/rules/no-unused-fields/index.d.ts +13 -0
- package/esm/rules/{no-unused-fields.js → no-unused-fields/index.js} +8 -7
- package/{cjs/rules/relay-arguments.d.ts → esm/rules/relay-arguments/index.d.ts} +5 -5
- package/esm/rules/{relay-arguments.js → relay-arguments/index.js} +2 -2
- package/{cjs/rules/relay-connection-types.d.ts → esm/rules/relay-connection-types/index.d.ts} +4 -4
- package/esm/rules/{relay-connection-types.js → relay-connection-types/index.js} +1 -1
- package/esm/rules/{relay-edge-types.d.mts → relay-edge-types/index.d.ts} +8 -6
- package/esm/rules/{relay-edge-types.js → relay-edge-types/index.js} +4 -4
- package/esm/rules/relay-page-info/index.d.ts +13 -0
- package/esm/rules/{relay-page-info.js → relay-page-info/index.js} +4 -4
- package/{cjs/rules/require-deprecation-date.d.ts → esm/rules/require-deprecation-date/index.d.ts} +5 -5
- package/esm/rules/{require-deprecation-date.js → require-deprecation-date/index.js} +3 -3
- package/esm/rules/require-deprecation-reason/index.d.ts +13 -0
- package/esm/rules/{require-deprecation-reason.js → require-deprecation-reason/index.js} +3 -3
- package/{cjs/rules/require-description.d.ts → esm/rules/require-description/index.d.ts} +5 -5
- package/esm/rules/{require-description.js → require-description/index.js} +3 -3
- package/esm/rules/require-field-of-type-query-in-mutation-result/index.d.ts +13 -0
- package/esm/rules/{require-field-of-type-query-in-mutation-result.js → require-field-of-type-query-in-mutation-result/index.js} +2 -2
- package/esm/rules/require-import-fragment/index.d.ts +13 -0
- package/esm/rules/{require-import-fragment.js → require-import-fragment/index.js} +13 -12
- package/esm/rules/require-nullable-fields-with-oneof/index.d.ts +13 -0
- package/esm/rules/{require-nullable-fields-with-oneof.js → require-nullable-fields-with-oneof/index.js} +2 -2
- package/esm/rules/require-nullable-result-in-root/index.d.ts +13 -0
- package/esm/rules/{require-nullable-result-in-root.js → require-nullable-result-in-root/index.js} +2 -2
- package/{cjs/rules/require-selections.d.ts → esm/rules/require-selections/index.d.ts} +5 -5
- package/esm/rules/{require-selections.js → require-selections/index.js} +14 -8
- package/esm/rules/require-type-pattern-with-oneof/index.d.ts +13 -0
- package/esm/rules/{require-type-pattern-with-oneof.js → require-type-pattern-with-oneof/index.js} +2 -2
- package/{cjs/rules/selection-set-depth.d.ts → esm/rules/selection-set-depth/index.d.ts} +5 -5
- package/esm/rules/{selection-set-depth.js → selection-set-depth/index.js} +3 -3
- package/esm/rules/{strict-id-in-types.d.mts → strict-id-in-types/index.d.ts} +8 -6
- package/esm/rules/{strict-id-in-types.js → strict-id-in-types/index.js} +2 -2
- package/esm/rules/unique-enum-value-names/index.d.ts +13 -0
- package/esm/rules/{unique-enum-value-names.js → unique-enum-value-names/index.js} +2 -2
- package/{cjs/rules/unique-fragment-name.d.ts → esm/rules/unique-fragment-name/index.d.ts} +4 -4
- package/esm/rules/{unique-fragment-name.js → unique-fragment-name/index.js} +3 -3
- package/esm/rules/unique-operation-name/index.d.ts +13 -0
- package/esm/rules/{unique-operation-name.js → unique-operation-name/index.js} +2 -2
- package/esm/schema.js +1 -1
- package/{cjs → esm}/siblings.d.ts +2 -2
- package/esm/siblings.js +1 -1
- package/{cjs → esm}/types.d.ts +4 -3
- package/{cjs → esm}/utils.d.ts +4 -4
- package/esm/utils.js +40 -17
- package/{index.browser.mjs → index.browser.js} +846 -790
- package/package.json +9 -13
- package/cjs/configs/index.d.ts +0 -174
- package/cjs/flat-configs.d.ts +0 -307
- package/cjs/flat-configs.js +0 -55
- package/cjs/index.d.ts +0 -27
- package/cjs/rules/no-scalar-result-type-on-mutation.js +0 -88
- package/cjs/rules/no-typename-prefix.d.ts +0 -13
- package/cjs/rules/no-unreachable-types.d.ts +0 -13
- package/cjs/rules/no-unreachable-types.js +0 -177
- package/cjs/rules/no-unused-fields.d.ts +0 -13
- package/cjs/rules/relay-page-info.d.ts +0 -13
- package/cjs/rules/require-deprecation-reason.d.ts +0 -13
- package/cjs/rules/require-deprecation-reason.js +0 -85
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -13
- package/cjs/rules/require-import-fragment.d.ts +0 -13
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +0 -13
- package/cjs/rules/require-nullable-fields-with-oneof.js +0 -81
- package/cjs/rules/require-nullable-result-in-root.d.ts +0 -13
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +0 -13
- package/cjs/rules/require-type-pattern-with-oneof.js +0 -83
- package/cjs/rules/unique-enum-value-names.d.ts +0 -13
- package/cjs/rules/unique-fragment-name.js +0 -106
- package/cjs/rules/unique-operation-name.d.ts +0 -13
- package/esm/configs/index.d.mts +0 -174
- package/esm/estree-converter/index.d.mts +0 -8
- package/esm/flat-configs.d.mts +0 -307
- package/esm/flat-configs.js +0 -36
- package/esm/index.d.mts +0 -27
- package/esm/package.json +0 -1
- package/esm/rules/no-anonymous-operations.d.mts +0 -13
- package/esm/rules/no-duplicate-fields.d.mts +0 -13
- package/esm/rules/no-one-place-fragments.d.mts +0 -13
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +0 -13
- package/esm/rules/no-typename-prefix.d.mts +0 -13
- package/esm/rules/no-unreachable-types.d.mts +0 -13
- package/esm/rules/no-unused-fields.d.mts +0 -13
- package/esm/rules/relay-page-info.d.mts +0 -13
- package/esm/rules/require-deprecation-reason.d.mts +0 -13
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +0 -13
- package/esm/rules/require-import-fragment.d.mts +0 -13
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +0 -13
- package/esm/rules/require-nullable-result-in-root.d.mts +0 -13
- package/esm/rules/require-type-pattern-with-oneof.d.mts +0 -13
- package/esm/rules/unique-enum-value-names.d.mts +0 -13
- package/esm/rules/unique-operation-name.d.mts +0 -13
- package/cjs/configs/{operations-all.d.ts → operations-all.d.cts} +0 -0
- package/cjs/configs/{operations-recommended.d.ts → operations-recommended.d.cts} +0 -0
- package/cjs/configs/{schema-all.d.ts → schema-all.d.cts} +0 -0
- package/cjs/configs/{schema-recommended.d.ts → schema-recommended.d.cts} +0 -0
- package/cjs/configs/{schema-relay.d.ts → schema-relay.d.cts} +0 -0
- package/{esm/documents.d.mts → cjs/documents.d.cts} +1 -1
- package/esm/{chunk-U3TKCM4X.js → chunk-UIAXBAMD.js} +0 -0
- package/esm/configs/{operations-all.d.mts → operations-all.d.ts} +0 -0
- package/esm/configs/{operations-recommended.d.mts → operations-recommended.d.ts} +0 -0
- package/esm/configs/{schema-all.d.mts → schema-all.d.ts} +0 -0
- package/esm/configs/{schema-recommended.d.mts → schema-recommended.d.ts} +0 -0
- package/esm/configs/{schema-relay.d.mts → schema-relay.d.ts} +0 -0
- package/{cjs → esm}/documents.d.ts +1 -1
- package/{cjs → esm}/estree-converter/converter.d.ts +0 -0
- package/{cjs → esm}/graphql-config.d.ts +1 -1
- package/{cjs → esm}/rules/graphql-js-validation.d.ts +2 -2
- package/{cjs → esm}/schema.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(src_exports);
|
|
27
|
-
var import_processor = require("./processor.js"), import_parser = require("./parser.js"), import_rules = require("./rules/index.js");
|
|
28
|
-
__reExport(src_exports, require("./types.js"), module.exports);
|
|
29
|
-
var import_utils = require("./utils.js"), import_configs = require("./configs/index.js"), import_flat_configs = require("./flat-configs.js");
|
|
30
|
-
const processors = { graphql: import_processor.processor };
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
configs,
|
|
34
|
-
flatConfigs,
|
|
35
|
-
parseForESLint,
|
|
36
|
-
processors,
|
|
37
|
-
requireGraphQLSchemaFromContext,
|
|
38
|
-
requireSiblingsOperations,
|
|
39
|
-
rules,
|
|
40
|
-
...require("./types.js")
|
|
41
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }require('./chunk-UIAXBAMD.js');
|
|
2
|
+
var _indexjs = require('./configs/index.js');
|
|
3
|
+
var _parserjs = require('./parser.js');
|
|
4
|
+
var _processorjs = require('./processor.js');
|
|
5
|
+
var _indexjs3 = require('./rules/index.js');
|
|
6
|
+
var _typesjs = require('./types.js'); _createStarExport(_typesjs);
|
|
7
|
+
var _utilsjs = require('./utils.js');
|
|
8
|
+
const processors = { graphql: _processorjs.processor };
|
|
9
|
+
var src_default = {
|
|
10
|
+
parser: _parserjs.parser,
|
|
11
|
+
processor: _processorjs.processor,
|
|
12
|
+
rules: _indexjs3.rules,
|
|
13
|
+
configs: _indexjs.configs
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.configs = _indexjs.configs; exports.default = src_default; exports.parseForESLint = _parserjs.parseForESLint; exports.parser = _parserjs.parser; exports.processors = processors; exports.requireGraphQLSchemaFromContext = _utilsjs.requireGraphQLSchemaFromContext; exports.requireSiblingsOperations = _utilsjs.requireSiblingsOperations; exports.rules = _indexjs3.rules;
|
package/cjs/meta.d.cts
ADDED
package/cjs/meta.js
ADDED
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { ParserOptions, GraphQLESLintParseResult } from './types.
|
|
1
|
+
import { ParserOptions, GraphQLESLintParseResult } from './types.cjs';
|
|
2
2
|
import 'eslint';
|
|
3
3
|
import 'estree';
|
|
4
4
|
import 'graphql';
|
|
5
|
+
import 'graphql-config';
|
|
5
6
|
import 'json-schema-to-ts';
|
|
6
|
-
import './
|
|
7
|
+
import './estree-converter/types.cjs';
|
|
8
|
+
import './siblings.cjs';
|
|
7
9
|
import '@graphql-tools/utils';
|
|
8
|
-
import './estree-converter/types.mjs';
|
|
9
|
-
import 'graphql-config';
|
|
10
10
|
|
|
11
11
|
declare function parseForESLint(code: string, options: ParserOptions): GraphQLESLintParseResult;
|
|
12
|
+
declare const parser: {
|
|
13
|
+
parseForESLint: typeof parseForESLint;
|
|
14
|
+
meta: {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
12
19
|
|
|
13
|
-
export { parseForESLint };
|
|
20
|
+
export { parseForESLint, parser };
|
package/cjs/parser.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var parser_exports = {};
|
|
25
|
-
__export(parser_exports, {
|
|
26
|
-
parseForESLint: () => parseForESLint
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(parser_exports);
|
|
29
|
-
var import_utils = require("@graphql-tools/utils"), import_debug = __toESM(require("debug")), import_graphql = require("graphql"), import_estree_converter = require("./estree-converter/index.js"), import_graphql_config = require("./graphql-config.js"), import_schema = require("./schema.js"), import_siblings = require("./siblings.js"), import_utils2 = require("./utils.js"), import_documents = require("./documents.js");
|
|
30
|
-
const debug = (0, import_debug.default)("graphql-eslint:parser");
|
|
31
|
-
debug("cwd %o", import_utils2.CWD);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-UIAXBAMD.js');
|
|
2
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
3
|
+
var _graphql = require('graphql');
|
|
4
|
+
var _utils = require('@graphql-tools/utils');
|
|
5
|
+
var _documentsjs = require('./documents.js');
|
|
6
|
+
var _indexjs = require('./estree-converter/index.js');
|
|
7
|
+
var _graphqlconfigjs = require('./graphql-config.js');
|
|
8
|
+
var _metajs = require('./meta.js');
|
|
9
|
+
var _schemajs = require('./schema.js');
|
|
10
|
+
var _siblingsjs = require('./siblings.js');
|
|
11
|
+
var _utilsjs = require('./utils.js');
|
|
12
|
+
const debug = _debug2.default.call(void 0, "graphql-eslint:parser");
|
|
13
|
+
debug("cwd %o", _utilsjs.CWD);
|
|
32
14
|
const LEGACY_PARSER_OPTIONS_KEYS = [
|
|
33
15
|
"schema",
|
|
34
16
|
"documents",
|
|
@@ -48,26 +30,26 @@ function parseForESLint(code, options) {
|
|
|
48
30
|
`\`parserOptions.${key}\` was removed in graphql-eslint@4. Use physical graphql-config for setting schema and documents or \`parserOptions.graphQLConfig\` for programmatic usage.`
|
|
49
31
|
);
|
|
50
32
|
try {
|
|
51
|
-
const { filePath } = options, { document } = (0,
|
|
33
|
+
const { filePath } = options, { document } = _utils.parseGraphQLSDL.call(void 0, filePath, code, { noLocation: !1 });
|
|
52
34
|
let project, schema, documents;
|
|
53
35
|
{
|
|
54
|
-
const gqlConfig = (0,
|
|
55
|
-
project = gqlConfig.getProjectForFile(realFilepath), documents = (0,
|
|
36
|
+
const gqlConfig = _graphqlconfigjs.loadGraphQLConfig.call(void 0, options), realFilepath = filePath.replace(_utilsjs.VIRTUAL_DOCUMENT_REGEX, "");
|
|
37
|
+
project = gqlConfig.getProjectForFile(realFilepath), documents = _documentsjs.getDocuments.call(void 0, project);
|
|
56
38
|
}
|
|
57
39
|
try {
|
|
58
|
-
schema = (0,
|
|
40
|
+
schema = _schemajs.getSchema.call(void 0, project);
|
|
59
41
|
} catch (error) {
|
|
60
42
|
throw error instanceof Error && (error.message = `Error while loading schema: ${error.message}`), error;
|
|
61
43
|
}
|
|
62
|
-
const rootTree = (0,
|
|
44
|
+
const rootTree = _indexjs.convertToESTree.call(void 0, document, schema);
|
|
63
45
|
return {
|
|
64
46
|
services: {
|
|
65
47
|
schema,
|
|
66
|
-
siblingOperations: (0,
|
|
48
|
+
siblingOperations: _siblingsjs.getSiblings.call(void 0, documents)
|
|
67
49
|
},
|
|
68
50
|
ast: {
|
|
69
|
-
comments: (0,
|
|
70
|
-
tokens: (0,
|
|
51
|
+
comments: _indexjs.extractComments.call(void 0, document.loc),
|
|
52
|
+
tokens: _indexjs.extractTokens.call(void 0, filePath, code),
|
|
71
53
|
loc: rootTree.loc,
|
|
72
54
|
range: rootTree.range,
|
|
73
55
|
type: "Program",
|
|
@@ -76,10 +58,10 @@ function parseForESLint(code, options) {
|
|
|
76
58
|
}
|
|
77
59
|
};
|
|
78
60
|
} catch (error) {
|
|
79
|
-
if (error instanceof Error && (error.message = `[graphql-eslint] ${error.message}`), error instanceof
|
|
80
|
-
const location = error.locations
|
|
61
|
+
if (error instanceof Error && (error.message = `[graphql-eslint] ${error.message}`), error instanceof _graphql.GraphQLError) {
|
|
62
|
+
const location = _optionalChain([error, 'access', _ => _.locations, 'optionalAccess', _2 => _2[0]]);
|
|
81
63
|
throw {
|
|
82
|
-
index: error.positions
|
|
64
|
+
index: _optionalChain([error, 'access', _3 => _3.positions, 'optionalAccess', _4 => _4[0]]),
|
|
83
65
|
...location && {
|
|
84
66
|
lineNumber: location.line,
|
|
85
67
|
column: location.column - 1
|
|
@@ -90,7 +72,14 @@ function parseForESLint(code, options) {
|
|
|
90
72
|
throw error;
|
|
91
73
|
}
|
|
92
74
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
const parser = {
|
|
76
|
+
parseForESLint,
|
|
77
|
+
meta: {
|
|
78
|
+
name: "@graphql-eslint/parser",
|
|
79
|
+
version: _metajs.version
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
exports.parseForESLint = parseForESLint; exports.parser = parser;
|
|
@@ -5,9 +5,13 @@ type Block = Linter.ProcessorFile & {
|
|
|
5
5
|
offset: number;
|
|
6
6
|
};
|
|
7
7
|
declare const processor: {
|
|
8
|
+
meta: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string | undefined;
|
|
11
|
+
};
|
|
8
12
|
supportsAutofix: true;
|
|
9
13
|
preprocess(code: string, filePath: string): (string | Block)[];
|
|
10
14
|
postprocess(messages: Linter.LintMessage[][], filePath: string): Linter.LintMessage[];
|
|
11
15
|
};
|
|
12
16
|
|
|
13
|
-
export { Block, processor };
|
|
17
|
+
export { type Block, processor };
|
package/cjs/processor.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 processor_exports = {};
|
|
17
|
-
__export(processor_exports, {
|
|
18
|
-
processor: () => processor
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(processor_exports);
|
|
21
|
-
var import_node_path = require("node:path"), import_graphql_tag_pluck = require("@graphql-tools/graphql-tag-pluck"), import_utils = require("@graphql-tools/utils"), import_graphql_config2 = require("./graphql-config.js"), import_utils2 = 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; }require('./chunk-UIAXBAMD.js');
|
|
2
|
+
var _nodepath = require('node:path');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _graphqltagpluck = require('@graphql-tools/graphql-tag-pluck');
|
|
6
|
+
var _utils = require('@graphql-tools/utils');
|
|
7
|
+
var _graphqlconfigjs = require('./graphql-config.js');
|
|
8
|
+
var _metajs = require('./meta.js');
|
|
9
|
+
var _utilsjs = require('./utils.js');
|
|
22
10
|
const blocksMap = /* @__PURE__ */ new Map();
|
|
23
11
|
let onDiskConfig, onDiskConfigLoaded = !1;
|
|
24
|
-
const RELEVANT_KEYWORDS = ["gql", "graphql", "GraphQL"], processor = {
|
|
12
|
+
const RELEVANT_KEYWORDS = ["gql", "graphql", "GraphQL"], processor = exports.processor = {
|
|
13
|
+
meta: {
|
|
14
|
+
name: "@graphql-eslint/processor",
|
|
15
|
+
version: _metajs.version
|
|
16
|
+
},
|
|
25
17
|
supportsAutofix: !0,
|
|
26
18
|
preprocess(code, filePath) {
|
|
27
|
-
onDiskConfigLoaded || (onDiskConfig = (0,
|
|
19
|
+
onDiskConfigLoaded || (onDiskConfig = _graphqlconfigjs.loadOnDiskGraphQLConfig.call(void 0, filePath), onDiskConfigLoaded = !0);
|
|
28
20
|
let keywords = RELEVANT_KEYWORDS;
|
|
29
|
-
const pluckConfig = onDiskConfig
|
|
21
|
+
const pluckConfig = _optionalChain([onDiskConfig, 'optionalAccess', _ => _.getProjectForFile, 'call', _2 => _2(filePath), 'access', _3 => _3.extensions, 'access', _4 => _4.pluckConfig]);
|
|
30
22
|
if (pluckConfig) {
|
|
31
23
|
const {
|
|
32
24
|
modules = [],
|
|
@@ -37,16 +29,16 @@ const RELEVANT_KEYWORDS = ["gql", "graphql", "GraphQL"], processor = {
|
|
|
37
29
|
...new Set(
|
|
38
30
|
[
|
|
39
31
|
...modules.map(({ identifier }) => identifier),
|
|
40
|
-
...(0,
|
|
32
|
+
..._utils.asArray.call(void 0, globalGqlIdentifierName),
|
|
41
33
|
gqlMagicComment
|
|
42
|
-
].filter(
|
|
34
|
+
].filter(_utilsjs.truthy)
|
|
43
35
|
)
|
|
44
36
|
];
|
|
45
37
|
}
|
|
46
38
|
if (keywords.every((keyword) => !code.includes(keyword)))
|
|
47
39
|
return [code];
|
|
48
40
|
try {
|
|
49
|
-
const blocks = (0,
|
|
41
|
+
const blocks = _graphqltagpluck.gqlPluckFromCodeStringSync.call(void 0, filePath, code, {
|
|
50
42
|
skipIndent: !0,
|
|
51
43
|
...pluckConfig
|
|
52
44
|
}).map((item) => ({
|
|
@@ -62,8 +54,8 @@ const RELEVANT_KEYWORDS = ["gql", "graphql", "GraphQL"], processor = {
|
|
|
62
54
|
/* source code must be provided and be last */
|
|
63
55
|
];
|
|
64
56
|
} catch (error) {
|
|
65
|
-
return error instanceof Error && (error.message = `[graphql-eslint] Error while preprocessing "${(0,
|
|
66
|
-
|
|
57
|
+
return error instanceof Error && (error.message = `[graphql-eslint] Error while preprocessing "${_nodepath.relative.call(void 0,
|
|
58
|
+
_utilsjs.CWD,
|
|
67
59
|
filePath
|
|
68
60
|
)}" file
|
|
69
61
|
|
|
@@ -76,7 +68,7 @@ ${error.message}`), console.error(error), [code];
|
|
|
76
68
|
const { lineOffset, offset } = blocks[i];
|
|
77
69
|
for (const message of messages[i] || []) {
|
|
78
70
|
if (/\.(vue|svelte)$/.test(filePath)) {
|
|
79
|
-
delete message.endLine, delete message.endColumn, delete message.fix, delete message.suggestions, Object.assign(message,
|
|
71
|
+
delete message.endLine, delete message.endColumn, delete message.fix, delete message.suggestions, Object.assign(message, _utilsjs.REPORT_ON_FIRST_CHARACTER);
|
|
80
72
|
continue;
|
|
81
73
|
}
|
|
82
74
|
message.line += lineOffset, typeof message.endLine == "number" && (message.endLine += lineOffset), message.fix && (message.fix.range[0] += offset, message.fix.range[1] += offset);
|
|
@@ -89,7 +81,6 @@ ${error.message}`), console.error(error), [code];
|
|
|
89
81
|
return messages.flat().sort((a, b) => a.line - b.line || a.column - b.column);
|
|
90
82
|
}
|
|
91
83
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
exports.processor = processor;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FromSchema } from 'json-schema-to-ts';
|
|
2
|
-
import { GraphQLESLintRule } from '
|
|
2
|
+
import { GraphQLESLintRule } from '../../types.cjs';
|
|
3
3
|
import 'eslint';
|
|
4
4
|
import 'estree';
|
|
5
5
|
import 'graphql';
|
|
6
|
-
import '../siblings.js';
|
|
7
|
-
import '@graphql-tools/utils';
|
|
8
|
-
import '../estree-converter/types.js';
|
|
9
6
|
import 'graphql-config';
|
|
7
|
+
import '../../estree-converter/types.cjs';
|
|
8
|
+
import '../../siblings.cjs';
|
|
9
|
+
import '@graphql-tools/utils';
|
|
10
10
|
|
|
11
11
|
declare const schema: {
|
|
12
12
|
readonly type: "array";
|
|
@@ -58,7 +58,7 @@ declare const schema: {
|
|
|
58
58
|
};
|
|
59
59
|
readonly groups: {
|
|
60
60
|
readonly minItems: 2;
|
|
61
|
-
readonly description:
|
|
61
|
+
readonly description: string;
|
|
62
62
|
readonly type: "array";
|
|
63
63
|
readonly uniqueItems: true;
|
|
64
64
|
readonly items: {
|
|
@@ -71,4 +71,4 @@ declare const schema: {
|
|
|
71
71
|
type RuleOptions = FromSchema<typeof schema>;
|
|
72
72
|
declare const rule: GraphQLESLintRule<RuleOptions>;
|
|
73
73
|
|
|
74
|
-
export { RuleOptions, rule };
|
|
74
|
+
export { type RuleOptions, rule };
|
|
@@ -1,44 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var alphabetize_exports = {};
|
|
25
|
-
__export(alphabetize_exports, {
|
|
26
|
-
rule: () => rule
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(alphabetize_exports);
|
|
29
|
-
var import_graphql = require("graphql"), import_lodash = __toESM(require("lodash.lowercase")), import_utils = require("../utils.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../../chunk-UIAXBAMD.js');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _graphql = require('graphql');
|
|
5
|
+
var _lodashlowercase = require('lodash.lowercase'); var _lodashlowercase2 = _interopRequireDefault(_lodashlowercase);
|
|
6
|
+
var _utilsjs = require('../../utils.js');
|
|
30
7
|
const RULE_ID = "alphabetize", fieldsEnum = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
_graphql.Kind.OBJECT_TYPE_DEFINITION,
|
|
9
|
+
_graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
|
10
|
+
_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION
|
|
34
11
|
], selectionsEnum = [
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
_graphql.Kind.OPERATION_DEFINITION,
|
|
13
|
+
_graphql.Kind.FRAGMENT_DEFINITION
|
|
37
14
|
], argumentsEnum = [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
_graphql.Kind.FIELD_DEFINITION,
|
|
16
|
+
_graphql.Kind.FIELD,
|
|
17
|
+
_graphql.Kind.DIRECTIVE_DEFINITION,
|
|
18
|
+
_graphql.Kind.DIRECTIVE
|
|
42
19
|
], schema = {
|
|
43
20
|
type: "array",
|
|
44
21
|
minItems: 1,
|
|
@@ -49,7 +26,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
49
26
|
minProperties: 1,
|
|
50
27
|
properties: {
|
|
51
28
|
fields: {
|
|
52
|
-
...
|
|
29
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
|
53
30
|
items: {
|
|
54
31
|
enum: fieldsEnum
|
|
55
32
|
},
|
|
@@ -60,7 +37,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
60
37
|
description: "Values of `enum`."
|
|
61
38
|
},
|
|
62
39
|
selections: {
|
|
63
|
-
...
|
|
40
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
|
64
41
|
items: {
|
|
65
42
|
enum: selectionsEnum
|
|
66
43
|
},
|
|
@@ -71,7 +48,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
71
48
|
description: "Variables of operations `query`, `mutation` and `subscription`."
|
|
72
49
|
},
|
|
73
50
|
arguments: {
|
|
74
|
-
...
|
|
51
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
|
75
52
|
items: {
|
|
76
53
|
enum: argumentsEnum
|
|
77
54
|
},
|
|
@@ -82,13 +59,20 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
82
59
|
description: "Definitions \u2013 `type`, `interface`, `enum`, `scalar`, `input`, `union` and `directive`."
|
|
83
60
|
},
|
|
84
61
|
groups: {
|
|
85
|
-
...
|
|
62
|
+
..._utilsjs.ARRAY_DEFAULT_OPTIONS,
|
|
86
63
|
minItems: 2,
|
|
87
|
-
description:
|
|
64
|
+
description: [
|
|
65
|
+
"Order group. Example: `['...', 'id', '*', '{']` where:",
|
|
66
|
+
"- `...` stands for fragment spreads",
|
|
67
|
+
"- `id` stands for field with name `id`",
|
|
68
|
+
"- `*` stands for everything else",
|
|
69
|
+
"- `{` stands for fields `selection set`"
|
|
70
|
+
].join(`
|
|
71
|
+
`)
|
|
88
72
|
}
|
|
89
73
|
}
|
|
90
74
|
}
|
|
91
|
-
}, rule = {
|
|
75
|
+
}, rule = exports.rule = {
|
|
92
76
|
meta: {
|
|
93
77
|
type: "suggestion",
|
|
94
78
|
fixable: "code",
|
|
@@ -99,7 +83,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
99
83
|
examples: [
|
|
100
84
|
{
|
|
101
85
|
title: "Incorrect",
|
|
102
|
-
usage: [{ fields: [
|
|
86
|
+
usage: [{ fields: [_graphql.Kind.OBJECT_TYPE_DEFINITION] }],
|
|
103
87
|
code: (
|
|
104
88
|
/* GraphQL */
|
|
105
89
|
`
|
|
@@ -114,7 +98,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
114
98
|
},
|
|
115
99
|
{
|
|
116
100
|
title: "Correct",
|
|
117
|
-
usage: [{ fields: [
|
|
101
|
+
usage: [{ fields: [_graphql.Kind.OBJECT_TYPE_DEFINITION] }],
|
|
118
102
|
code: (
|
|
119
103
|
/* GraphQL */
|
|
120
104
|
`
|
|
@@ -159,7 +143,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
159
143
|
},
|
|
160
144
|
{
|
|
161
145
|
title: "Incorrect",
|
|
162
|
-
usage: [{ selections: [
|
|
146
|
+
usage: [{ selections: [_graphql.Kind.OPERATION_DEFINITION] }],
|
|
163
147
|
code: (
|
|
164
148
|
/* GraphQL */
|
|
165
149
|
`
|
|
@@ -175,7 +159,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
175
159
|
},
|
|
176
160
|
{
|
|
177
161
|
title: "Correct",
|
|
178
|
-
usage: [{ selections: [
|
|
162
|
+
usage: [{ selections: [_graphql.Kind.OPERATION_DEFINITION] }],
|
|
179
163
|
code: (
|
|
180
164
|
/* GraphQL */
|
|
181
165
|
`
|
|
@@ -205,8 +189,8 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
205
189
|
definitions: !0,
|
|
206
190
|
selections: selectionsEnum,
|
|
207
191
|
variables: !0,
|
|
208
|
-
arguments: [
|
|
209
|
-
groups: ["
|
|
192
|
+
arguments: [_graphql.Kind.FIELD, _graphql.Kind.DIRECTIVE],
|
|
193
|
+
groups: ["...", "id", "*", "{"]
|
|
210
194
|
}
|
|
211
195
|
]
|
|
212
196
|
}
|
|
@@ -238,26 +222,24 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
238
222
|
return filteredComments;
|
|
239
223
|
}
|
|
240
224
|
function getRangeWithComments(node) {
|
|
241
|
-
node.kind ===
|
|
225
|
+
node.kind === _graphql.Kind.VARIABLE && (node = node.parent);
|
|
242
226
|
const [firstBeforeComment] = getBeforeComments(node), [firstAfterComment] = sourceCode.getCommentsAfter(node), from = firstBeforeComment || node, to = firstAfterComment && isNodeAndCommentOnSameLine(node, firstAfterComment) ? firstAfterComment : node;
|
|
243
227
|
return [from.range[0], to.range[1]];
|
|
244
228
|
}
|
|
245
229
|
function checkNodes(nodes = []) {
|
|
246
230
|
for (let i = 1; i < nodes.length; i += 1) {
|
|
247
|
-
const currNode = nodes[i], currName =
|
|
231
|
+
const currNode = nodes[i], currName = getName(currNode);
|
|
248
232
|
if (!currName)
|
|
249
233
|
continue;
|
|
250
|
-
const prevNode = nodes[i - 1], prevName =
|
|
234
|
+
const prevNode = nodes[i - 1], prevName = getName(prevNode);
|
|
251
235
|
if (prevName) {
|
|
252
236
|
const compareResult = prevName.localeCompare(currName), { groups } = opts;
|
|
253
237
|
let shouldSortByGroup = !1;
|
|
254
|
-
if (groups
|
|
238
|
+
if (_optionalChain([groups, 'optionalAccess', _ => _.length])) {
|
|
255
239
|
if (!groups.includes("*"))
|
|
256
240
|
throw new Error("`groups` option should contain `*` string.");
|
|
257
|
-
|
|
258
|
-
indexForPrev
|
|
259
|
-
let indexForCurr = groups.indexOf(currName);
|
|
260
|
-
if (indexForCurr === -1 && (indexForCurr = groups.indexOf("*")), shouldSortByGroup = indexForPrev - indexForCurr > 0, indexForPrev < indexForCurr)
|
|
241
|
+
const indexForPrev = getIndex({ node: prevNode, groups }), indexForCurr = getIndex({ node: currNode, groups });
|
|
242
|
+
if (shouldSortByGroup = indexForPrev - indexForCurr > 0, indexForPrev < indexForCurr)
|
|
261
243
|
continue;
|
|
262
244
|
}
|
|
263
245
|
if (!shouldSortByGroup && !(compareResult === 1) && (!(compareResult === 0) || !prevNode.kind.endsWith("Extension") || currNode.kind.endsWith("Extension")))
|
|
@@ -268,8 +250,8 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
268
250
|
node: "alias" in currNode && currNode.alias || currNode.name,
|
|
269
251
|
messageId: RULE_ID,
|
|
270
252
|
data: {
|
|
271
|
-
currNode: (0,
|
|
272
|
-
prevNode: prevName ? (0,
|
|
253
|
+
currNode: _utilsjs.displayNodeName.call(void 0, currNode),
|
|
254
|
+
prevNode: prevName ? _utilsjs.displayNodeName.call(void 0, prevNode) : _lodashlowercase2.default.call(void 0, prevNode.kind)
|
|
273
255
|
},
|
|
274
256
|
*fix(fixer) {
|
|
275
257
|
const prevRange = getRangeWithComments(prevNode), currRange = getRangeWithComments(currNode);
|
|
@@ -284,24 +266,24 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
284
266
|
});
|
|
285
267
|
}
|
|
286
268
|
}
|
|
287
|
-
const opts = context.options[0], fields = new Set(opts.fields
|
|
288
|
-
fields.has(
|
|
289
|
-
|
|
290
|
-
|
|
269
|
+
const opts = context.options[0], fields = new Set(_nullishCoalesce(opts.fields, () => ( []))), listeners = {}, fieldsSelector = [
|
|
270
|
+
fields.has(_graphql.Kind.OBJECT_TYPE_DEFINITION) && [
|
|
271
|
+
_graphql.Kind.OBJECT_TYPE_DEFINITION,
|
|
272
|
+
_graphql.Kind.OBJECT_TYPE_EXTENSION
|
|
291
273
|
],
|
|
292
|
-
fields.has(
|
|
293
|
-
|
|
294
|
-
|
|
274
|
+
fields.has(_graphql.Kind.INTERFACE_TYPE_DEFINITION) && [
|
|
275
|
+
_graphql.Kind.INTERFACE_TYPE_DEFINITION,
|
|
276
|
+
_graphql.Kind.INTERFACE_TYPE_EXTENSION
|
|
295
277
|
],
|
|
296
|
-
fields.has(
|
|
297
|
-
|
|
298
|
-
|
|
278
|
+
fields.has(_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION) && [
|
|
279
|
+
_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
280
|
+
_graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION
|
|
299
281
|
]
|
|
300
|
-
].filter(
|
|
282
|
+
].filter(_utilsjs.truthy).flat().join(","), selectionsSelector = _optionalChain([opts, 'access', _2 => _2.selections, 'optionalAccess', _3 => _3.join, 'call', _4 => _4(",")]), argumentsSelector = _optionalChain([opts, 'access', _5 => _5.arguments, 'optionalAccess', _6 => _6.join, 'call', _7 => _7(",")]);
|
|
301
283
|
if (fieldsSelector && (listeners[fieldsSelector] = (node) => {
|
|
302
284
|
checkNodes(node.fields);
|
|
303
285
|
}), opts.values) {
|
|
304
|
-
const enumValuesSelector = [
|
|
286
|
+
const enumValuesSelector = [_graphql.Kind.ENUM_TYPE_DEFINITION, _graphql.Kind.ENUM_TYPE_EXTENSION].join(",");
|
|
305
287
|
listeners[enumValuesSelector] = (node) => {
|
|
306
288
|
checkNodes(node.values);
|
|
307
289
|
};
|
|
@@ -309,7 +291,7 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
309
291
|
return selectionsSelector && (listeners[`:matches(${selectionsSelector}) SelectionSet`] = (node) => {
|
|
310
292
|
checkNodes(node.selections);
|
|
311
293
|
}), opts.variables && (listeners.OperationDefinition = (node) => {
|
|
312
|
-
checkNodes(node.variableDefinitions
|
|
294
|
+
checkNodes(_optionalChain([node, 'access', _8 => _8.variableDefinitions, 'optionalAccess', _9 => _9.map, 'call', _10 => _10((varDef) => varDef.variable)]));
|
|
313
295
|
}), argumentsSelector && (listeners[argumentsSelector] = (node) => {
|
|
314
296
|
checkNodes(node.arguments);
|
|
315
297
|
}), opts.definitions && (listeners.Document = (node) => {
|
|
@@ -317,7 +299,17 @@ const RULE_ID = "alphabetize", fieldsEnum = [
|
|
|
317
299
|
}), listeners;
|
|
318
300
|
}
|
|
319
301
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
})
|
|
302
|
+
function getIndex({
|
|
303
|
+
node,
|
|
304
|
+
groups
|
|
305
|
+
}) {
|
|
306
|
+
let index = groups.indexOf(getName(node));
|
|
307
|
+
return index === -1 && "selectionSet" in node && node.selectionSet && (index = groups.indexOf("{")), index === -1 && node.kind === _graphql.Kind.FRAGMENT_SPREAD && (index = groups.indexOf("...")), index === -1 && (index = groups.indexOf("*")), index;
|
|
308
|
+
}
|
|
309
|
+
function getName(node) {
|
|
310
|
+
return "alias" in node && _optionalChain([node, 'access', _11 => _11.alias, 'optionalAccess', _12 => _12.value]) || //
|
|
311
|
+
"name" in node && _optionalChain([node, 'access', _13 => _13.name, 'optionalAccess', _14 => _14.value]) || "";
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
exports.rule = rule;
|