@graphql-eslint/eslint-plugin 4.0.0-alpha-20220821140530-e968cfc → 4.0.0-alpha-20230810155929-e89edf7
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +14 -252
- package/cjs/cache.d.ts +12 -0
- package/cjs/cache.js +53 -0
- package/cjs/configs/index.d.ts +174 -0
- package/cjs/configs/index.js +40 -0
- package/cjs/configs/operations-all.d.ts +23 -0
- package/cjs/configs/operations-all.js +28 -0
- package/cjs/configs/operations-recommended.d.ts +54 -0
- package/{configs/operations-recommended.json → cjs/configs/operations-recommended.js} +19 -15
- package/cjs/configs/schema-all.d.ts +24 -0
- package/cjs/configs/schema-all.js +24 -0
- package/cjs/configs/schema-recommended.d.ts +67 -0
- package/cjs/configs/schema-recommended.js +68 -0
- package/cjs/configs/schema-relay.d.ts +12 -0
- package/{configs/relay.json → cjs/configs/schema-relay.js} +6 -4
- package/cjs/documents.d.ts +6 -0
- package/cjs/documents.js +66 -0
- package/cjs/estree-converter/converter.d.ts +8 -0
- package/cjs/estree-converter/converter.js +70 -0
- package/cjs/estree-converter/index.d.ts +8 -0
- package/cjs/estree-converter/index.js +23 -0
- package/cjs/estree-converter/types.d.ts +42 -0
- package/cjs/estree-converter/types.js +14 -0
- package/cjs/estree-converter/utils.d.ts +17 -0
- package/cjs/estree-converter/utils.js +105 -0
- package/cjs/flat-configs.d.ts +307 -0
- package/cjs/flat-configs.js +55 -0
- package/cjs/graphql-config.d.ts +14 -0
- package/cjs/graphql-config.js +65 -0
- package/cjs/index.d.ts +28 -0
- package/cjs/index.js +41 -0
- package/cjs/parser.d.ts +13 -0
- package/cjs/parser.js +96 -0
- package/cjs/processor.d.ts +13 -0
- package/cjs/processor.js +95 -0
- package/cjs/rules/alphabetize.d.ts +74 -0
- package/cjs/rules/alphabetize.js +323 -0
- package/cjs/rules/description-style.d.ts +29 -0
- package/cjs/rules/description-style.js +102 -0
- package/cjs/rules/graphql-js-validation.d.ts +13 -0
- package/cjs/rules/graphql-js-validation.js +595 -0
- package/cjs/rules/index.d.ts +127 -0
- package/cjs/rules/index.js +62 -0
- package/cjs/rules/input-name.d.ts +44 -0
- package/cjs/rules/input-name.js +154 -0
- package/cjs/rules/lone-executable-definition.d.ts +35 -0
- package/cjs/rules/lone-executable-definition.js +105 -0
- package/cjs/rules/match-document-filename.d.ts +81 -0
- package/cjs/rules/match-document-filename.js +251 -0
- package/cjs/rules/naming-convention.d.ts +108 -0
- package/cjs/rules/naming-convention.js +416 -0
- package/cjs/rules/no-anonymous-operations.d.ts +13 -0
- package/cjs/rules/no-anonymous-operations.js +91 -0
- package/cjs/rules/no-deprecated.d.ts +13 -0
- package/cjs/rules/no-deprecated.js +143 -0
- package/cjs/rules/no-duplicate-fields.d.ts +13 -0
- package/cjs/rules/no-duplicate-fields.js +136 -0
- package/cjs/rules/no-hashtag-description.d.ts +14 -0
- package/cjs/rules/no-hashtag-description.js +127 -0
- package/cjs/rules/no-one-place-fragments.d.ts +13 -0
- package/cjs/rules/no-one-place-fragments.js +101 -0
- package/cjs/rules/no-root-type.d.ts +34 -0
- package/cjs/rules/no-root-type.js +103 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.d.ts +13 -0
- package/cjs/rules/no-scalar-result-type-on-mutation.js +88 -0
- package/cjs/rules/no-typename-prefix.d.ts +13 -0
- package/cjs/rules/no-typename-prefix.js +91 -0
- package/cjs/rules/no-unreachable-types.d.ts +13 -0
- package/cjs/rules/no-unreachable-types.js +177 -0
- package/cjs/rules/no-unused-fields.d.ts +13 -0
- package/cjs/rules/no-unused-fields.js +132 -0
- package/cjs/rules/relay-arguments.d.ts +30 -0
- package/cjs/rules/relay-arguments.js +126 -0
- package/cjs/rules/relay-connection-types.d.ts +14 -0
- package/cjs/rules/relay-connection-types.js +111 -0
- package/cjs/rules/relay-edge-types.d.ts +40 -0
- package/cjs/rules/relay-edge-types.js +161 -0
- package/cjs/rules/relay-page-info.d.ts +13 -0
- package/cjs/rules/relay-page-info.js +98 -0
- package/cjs/rules/require-deprecation-date.d.ts +27 -0
- package/cjs/rules/require-deprecation-date.js +148 -0
- package/cjs/rules/require-deprecation-reason.d.ts +13 -0
- package/cjs/rules/require-deprecation-reason.js +85 -0
- package/cjs/rules/require-description.d.ts +24 -0
- package/cjs/rules/require-description.js +179 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.d.ts +13 -0
- package/cjs/rules/require-field-of-type-query-in-mutation-result.js +87 -0
- package/cjs/rules/require-import-fragment.d.ts +13 -0
- package/cjs/rules/require-import-fragment.js +148 -0
- package/cjs/rules/require-nullable-fields-with-oneof.d.ts +13 -0
- package/cjs/rules/require-nullable-fields-with-oneof.js +81 -0
- package/cjs/rules/require-nullable-result-in-root.d.ts +13 -0
- package/cjs/rules/require-nullable-result-in-root.js +99 -0
- package/cjs/rules/require-selections.d.ts +45 -0
- package/cjs/rules/require-selections.js +198 -0
- package/cjs/rules/require-type-pattern-with-oneof.d.ts +13 -0
- package/cjs/rules/require-type-pattern-with-oneof.js +83 -0
- package/cjs/rules/selection-set-depth.d.ts +37 -0
- package/cjs/rules/selection-set-depth.js +159 -0
- package/cjs/rules/strict-id-in-types.d.ts +66 -0
- package/cjs/rules/strict-id-in-types.js +168 -0
- package/cjs/rules/unique-enum-value-names.d.ts +13 -0
- package/cjs/rules/unique-enum-value-names.js +91 -0
- package/cjs/rules/unique-fragment-name.d.ts +14 -0
- package/cjs/rules/unique-fragment-name.js +106 -0
- package/cjs/rules/unique-operation-name.d.ts +13 -0
- package/cjs/rules/unique-operation-name.js +93 -0
- package/cjs/schema.d.ts +13 -0
- package/cjs/schema.js +52 -0
- package/{sibling-operations.d.ts → cjs/siblings.d.ts} +9 -6
- package/cjs/siblings.js +96 -0
- package/cjs/types.d.ts +75 -0
- package/cjs/types.js +14 -0
- package/cjs/utils.d.ts +45 -0
- package/cjs/utils.js +188 -0
- package/esm/cache.d.mts +12 -0
- package/esm/cache.js +25 -0
- package/esm/chunk-U3TKCM4X.js +8 -0
- package/esm/configs/index.d.mts +174 -0
- package/esm/configs/index.js +16 -0
- package/esm/configs/operations-all.d.mts +23 -0
- package/esm/configs/operations-all.js +35 -0
- package/esm/configs/operations-recommended.d.mts +54 -0
- package/esm/configs/operations-recommended.js +61 -0
- package/esm/configs/schema-all.d.mts +24 -0
- package/esm/configs/schema-all.js +31 -0
- package/esm/configs/schema-recommended.d.mts +67 -0
- package/esm/configs/schema-recommended.js +75 -0
- package/esm/configs/schema-relay.d.mts +12 -0
- package/esm/configs/schema-relay.js +18 -0
- package/esm/documents.d.mts +6 -0
- package/esm/documents.js +41 -0
- package/esm/estree-converter/converter.d.mts +8 -0
- package/esm/estree-converter/converter.js +56 -0
- package/esm/estree-converter/index.d.mts +8 -0
- package/esm/estree-converter/index.js +3 -0
- package/esm/estree-converter/types.d.mts +42 -0
- package/esm/estree-converter/types.js +0 -0
- package/esm/estree-converter/utils.d.mts +17 -0
- package/esm/estree-converter/utils.js +87 -0
- package/esm/flat-configs.d.mts +307 -0
- package/esm/flat-configs.js +36 -0
- package/esm/graphql-config.d.mts +14 -0
- package/esm/graphql-config.js +39 -0
- package/esm/index.d.mts +28 -0
- package/esm/index.js +18 -0
- package/esm/package.json +1 -0
- package/esm/parser.d.mts +13 -0
- package/esm/parser.js +76 -0
- package/esm/processor.d.mts +13 -0
- package/esm/processor.js +81 -0
- package/esm/rules/alphabetize.d.mts +74 -0
- package/esm/rules/alphabetize.js +299 -0
- package/esm/rules/description-style.d.mts +29 -0
- package/esm/rules/description-style.js +82 -0
- package/esm/rules/graphql-js-validation.d.mts +13 -0
- package/esm/rules/graphql-js-validation.js +618 -0
- package/esm/rules/index.d.mts +127 -0
- package/esm/rules/index.js +76 -0
- package/esm/rules/input-name.d.mts +44 -0
- package/esm/rules/input-name.js +136 -0
- package/esm/rules/lone-executable-definition.d.mts +35 -0
- package/esm/rules/lone-executable-definition.js +86 -0
- package/esm/rules/match-document-filename.d.mts +81 -0
- package/esm/rules/match-document-filename.js +237 -0
- package/esm/rules/naming-convention.d.mts +108 -0
- package/esm/rules/naming-convention.js +403 -0
- package/esm/rules/no-anonymous-operations.d.mts +13 -0
- package/esm/rules/no-anonymous-operations.js +72 -0
- package/esm/rules/no-deprecated.d.mts +13 -0
- package/esm/rules/no-deprecated.js +124 -0
- package/esm/rules/no-duplicate-fields.d.mts +13 -0
- package/esm/rules/no-duplicate-fields.js +116 -0
- package/esm/rules/no-hashtag-description.d.mts +14 -0
- package/esm/rules/no-hashtag-description.js +107 -0
- package/esm/rules/no-one-place-fragments.d.mts +13 -0
- package/esm/rules/no-one-place-fragments.js +83 -0
- package/esm/rules/no-root-type.d.mts +34 -0
- package/esm/rules/no-root-type.js +83 -0
- package/esm/rules/no-scalar-result-type-on-mutation.d.mts +13 -0
- package/esm/rules/no-scalar-result-type-on-mutation.js +69 -0
- package/esm/rules/no-typename-prefix.d.mts +13 -0
- package/esm/rules/no-typename-prefix.js +71 -0
- package/esm/rules/no-unreachable-types.d.mts +13 -0
- package/esm/rules/no-unreachable-types.js +156 -0
- package/esm/rules/no-unused-fields.d.mts +13 -0
- package/esm/rules/no-unused-fields.js +113 -0
- package/esm/rules/relay-arguments.d.mts +30 -0
- package/esm/rules/relay-arguments.js +107 -0
- package/esm/rules/relay-connection-types.d.mts +14 -0
- package/esm/rules/relay-connection-types.js +90 -0
- package/esm/rules/relay-edge-types.d.mts +40 -0
- package/esm/rules/relay-edge-types.js +148 -0
- package/esm/rules/relay-page-info.d.mts +13 -0
- package/esm/rules/relay-page-info.js +80 -0
- package/esm/rules/require-deprecation-date.d.mts +27 -0
- package/esm/rules/require-deprecation-date.js +129 -0
- package/esm/rules/require-deprecation-reason.d.mts +13 -0
- package/esm/rules/require-deprecation-reason.js +66 -0
- package/esm/rules/require-description.d.mts +24 -0
- package/esm/rules/require-description.js +165 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.d.mts +13 -0
- package/esm/rules/require-field-of-type-query-in-mutation-result.js +68 -0
- package/esm/rules/require-import-fragment.d.mts +13 -0
- package/esm/rules/require-import-fragment.js +121 -0
- package/esm/rules/require-nullable-fields-with-oneof.d.mts +13 -0
- package/esm/rules/require-nullable-fields-with-oneof.js +62 -0
- package/esm/rules/require-nullable-result-in-root.d.mts +13 -0
- package/esm/rules/require-nullable-result-in-root.js +80 -0
- package/esm/rules/require-selections.d.mts +45 -0
- package/esm/rules/require-selections.js +194 -0
- package/esm/rules/require-type-pattern-with-oneof.d.mts +13 -0
- package/esm/rules/require-type-pattern-with-oneof.js +63 -0
- package/esm/rules/selection-set-depth.d.mts +37 -0
- package/esm/rules/selection-set-depth.js +133 -0
- package/esm/rules/strict-id-in-types.d.mts +66 -0
- package/esm/rules/strict-id-in-types.js +155 -0
- package/esm/rules/unique-enum-value-names.d.mts +13 -0
- package/esm/rules/unique-enum-value-names.js +72 -0
- package/esm/rules/unique-fragment-name.d.mts +14 -0
- package/esm/rules/unique-fragment-name.js +87 -0
- package/esm/rules/unique-operation-name.d.mts +13 -0
- package/esm/rules/unique-operation-name.js +73 -0
- package/esm/schema.d.mts +13 -0
- package/esm/schema.js +27 -0
- package/esm/siblings.d.mts +24 -0
- package/esm/siblings.js +80 -0
- package/esm/types.d.mts +75 -0
- package/esm/types.js +0 -0
- package/esm/utils.d.mts +45 -0
- package/esm/utils.js +144 -0
- package/index.browser.mjs +5323 -0
- package/package.json +43 -35
- package/configs/base.json +0 -4
- package/configs/operations-all.json +0 -24
- package/configs/schema-all.json +0 -26
- package/configs/schema-recommended.json +0 -49
- package/docs/README.md +0 -75
- package/docs/custom-rules.md +0 -148
- package/docs/deprecated-rules.md +0 -21
- package/docs/parser-options.md +0 -85
- package/docs/parser.md +0 -49
- package/docs/rules/alphabetize.md +0 -178
- package/docs/rules/description-style.md +0 -54
- package/docs/rules/executable-definitions.md +0 -17
- package/docs/rules/fields-on-correct-type.md +0 -17
- package/docs/rules/fragments-on-composite-type.md +0 -17
- package/docs/rules/input-name.md +0 -76
- package/docs/rules/known-argument-names.md +0 -17
- package/docs/rules/known-directives.md +0 -44
- package/docs/rules/known-fragment-names.md +0 -69
- package/docs/rules/known-type-names.md +0 -17
- package/docs/rules/lone-anonymous-operation.md +0 -17
- package/docs/rules/lone-schema-definition.md +0 -17
- package/docs/rules/match-document-filename.md +0 -156
- package/docs/rules/naming-convention.md +0 -300
- package/docs/rules/no-anonymous-operations.md +0 -39
- package/docs/rules/no-case-insensitive-enum-values-duplicates.md +0 -43
- package/docs/rules/no-deprecated.md +0 -85
- package/docs/rules/no-duplicate-fields.md +0 -65
- package/docs/rules/no-fragment-cycles.md +0 -17
- package/docs/rules/no-hashtag-description.md +0 -59
- package/docs/rules/no-root-type.md +0 -53
- package/docs/rules/no-scalar-result-type-on-mutation.md +0 -37
- package/docs/rules/no-typename-prefix.md +0 -39
- package/docs/rules/no-undefined-variables.md +0 -17
- package/docs/rules/no-unreachable-types.md +0 -49
- package/docs/rules/no-unused-fields.md +0 -62
- package/docs/rules/no-unused-fragments.md +0 -17
- package/docs/rules/no-unused-variables.md +0 -17
- package/docs/rules/one-field-subscriptions.md +0 -17
- package/docs/rules/overlapping-fields-can-be-merged.md +0 -17
- package/docs/rules/possible-fragment-spread.md +0 -17
- package/docs/rules/possible-type-extension.md +0 -15
- package/docs/rules/provided-required-arguments.md +0 -17
- package/docs/rules/relay-arguments.md +0 -57
- package/docs/rules/relay-connection-types.md +0 -42
- package/docs/rules/relay-edge-types.md +0 -56
- package/docs/rules/relay-page-info.md +0 -32
- package/docs/rules/require-deprecation-date.md +0 -56
- package/docs/rules/require-deprecation-reason.md +0 -47
- package/docs/rules/require-description.md +0 -115
- package/docs/rules/require-field-of-type-query-in-mutation-result.md +0 -47
- package/docs/rules/require-id-when-available.md +0 -88
- package/docs/rules/scalar-leafs.md +0 -17
- package/docs/rules/selection-set-depth.md +0 -76
- package/docs/rules/strict-id-in-types.md +0 -130
- package/docs/rules/unique-argument-names.md +0 -17
- package/docs/rules/unique-directive-names-per-location.md +0 -17
- package/docs/rules/unique-directive-names.md +0 -17
- package/docs/rules/unique-enum-value-names.md +0 -15
- package/docs/rules/unique-field-definition-names.md +0 -17
- package/docs/rules/unique-fragment-name.md +0 -51
- package/docs/rules/unique-input-field-names.md +0 -17
- package/docs/rules/unique-operation-name.md +0 -55
- package/docs/rules/unique-operation-types.md +0 -17
- package/docs/rules/unique-type-names.md +0 -17
- package/docs/rules/unique-variable-names.md +0 -17
- package/docs/rules/value-literals-of-correct-type.md +0 -17
- package/docs/rules/variables-are-input-types.md +0 -17
- package/docs/rules/variables-in-allowed-position.md +0 -17
- package/estree-converter/converter.d.ts +0 -3
- package/estree-converter/index.d.ts +0 -3
- package/estree-converter/types.d.ts +0 -40
- package/estree-converter/utils.d.ts +0 -13
- package/graphql-config.d.ts +0 -3
- package/index.d.ts +0 -16
- package/index.js +0 -4653
- package/index.mjs +0 -4641
- package/parser.d.ts +0 -2
- package/processor.d.ts +0 -7
- package/rules/alphabetize.d.ts +0 -16
- package/rules/description-style.d.ts +0 -6
- package/rules/graphql-js-validation.d.ts +0 -2
- package/rules/index.d.ts +0 -41
- package/rules/input-name.d.ts +0 -9
- package/rules/match-document-filename.d.ts +0 -18
- package/rules/naming-convention.d.ts +0 -37
- package/rules/no-anonymous-operations.d.ts +0 -3
- package/rules/no-case-insensitive-enum-values-duplicates.d.ts +0 -3
- package/rules/no-deprecated.d.ts +0 -3
- package/rules/no-duplicate-fields.d.ts +0 -3
- package/rules/no-hashtag-description.d.ts +0 -3
- package/rules/no-root-type.d.ts +0 -7
- package/rules/no-scalar-result-type-on-mutation.d.ts +0 -3
- package/rules/no-typename-prefix.d.ts +0 -3
- package/rules/no-unreachable-types.d.ts +0 -3
- package/rules/no-unused-fields.d.ts +0 -3
- package/rules/relay-arguments.d.ts +0 -6
- package/rules/relay-connection-types.d.ts +0 -5
- package/rules/relay-edge-types.d.ts +0 -8
- package/rules/relay-page-info.d.ts +0 -3
- package/rules/require-deprecation-date.d.ts +0 -5
- package/rules/require-deprecation-reason.d.ts +0 -3
- package/rules/require-description.d.ts +0 -11
- package/rules/require-field-of-type-query-in-mutation-result.d.ts +0 -3
- package/rules/require-id-when-available.d.ts +0 -6
- package/rules/selection-set-depth.d.ts +0 -7
- package/rules/strict-id-in-types.d.ts +0 -11
- package/rules/unique-fragment-name.d.ts +0 -6
- package/rules/unique-operation-name.d.ts +0 -3
- package/schema.d.ts +0 -3
- package/testkit.d.ts +0 -27
- package/types.d.ts +0 -79
- package/utils.d.ts +0 -39
package/package.json
CHANGED
@@ -1,47 +1,55 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "4.0.0-alpha-
|
3
|
+
"version": "4.0.0-alpha-20230810155929-e89edf7",
|
4
4
|
"description": "GraphQL plugin for ESLint",
|
5
|
-
"
|
6
|
-
"
|
7
|
-
|
5
|
+
"repository": "https://github.com/B2o5T/graphql-eslint",
|
6
|
+
"author": "Dotan Simha <dotansimha@gmail.com>",
|
7
|
+
"license": "MIT",
|
8
|
+
"engines": {
|
9
|
+
"node": ">=18"
|
8
10
|
},
|
9
|
-
"
|
10
|
-
|
11
|
-
"
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
"main": "cjs/index.js",
|
12
|
+
"exports": {
|
13
|
+
"./package.json": "./package.json",
|
14
|
+
".": {
|
15
|
+
"browser": "./index.browser.mjs",
|
16
|
+
"require": {
|
17
|
+
"types": "./cjs/index.d.ts",
|
18
|
+
"default": "./cjs/index.js"
|
19
|
+
},
|
20
|
+
"import": {
|
21
|
+
"types": "./esm/index.d.mts",
|
22
|
+
"default": "./esm/index.js"
|
23
|
+
},
|
24
|
+
"default": {
|
25
|
+
"types": "./esm/index.d.mts",
|
26
|
+
"default": "./esm/index.js"
|
27
|
+
}
|
28
|
+
}
|
20
29
|
},
|
21
|
-
"repository": "https://github.com/B2o5T/graphql-eslint",
|
22
30
|
"keywords": [
|
23
31
|
"eslint",
|
24
32
|
"eslintplugin",
|
25
33
|
"eslint-plugin",
|
26
34
|
"graphql"
|
27
35
|
],
|
28
|
-
"
|
29
|
-
|
30
|
-
|
31
|
-
"module": "index.mjs",
|
32
|
-
"typings": "index.d.ts",
|
33
|
-
"typescript": {
|
34
|
-
"definition": "index.d.ts"
|
36
|
+
"peerDependencies": {
|
37
|
+
"eslint": ">=8.44.0",
|
38
|
+
"graphql": "^16"
|
35
39
|
},
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
"dependencies": {
|
41
|
+
"@graphql-tools/code-file-loader": "^7.3.6",
|
42
|
+
"@graphql-tools/graphql-tag-pluck": "^7.3.6",
|
43
|
+
"@graphql-tools/utils": "^9.0.0",
|
44
|
+
"debug": "^4.3.4",
|
45
|
+
"fast-glob": "^3.2.12",
|
46
|
+
"graphql-config": "^4.5.0",
|
47
|
+
"graphql-depth-limit": "^1.1.0",
|
48
|
+
"lodash.lowercase": "^4.3.0"
|
49
|
+
},
|
50
|
+
"publishConfig": {
|
51
|
+
"directory": "dist",
|
52
|
+
"access": "public"
|
53
|
+
},
|
54
|
+
"sideEffects": false
|
55
|
+
}
|
package/configs/base.json
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": ["./base.json", "./operations-recommended.json"],
|
3
|
-
"rules": {
|
4
|
-
"@graphql-eslint/alphabetize": [
|
5
|
-
"error",
|
6
|
-
{
|
7
|
-
"selections": ["OperationDefinition", "FragmentDefinition"],
|
8
|
-
"variables": ["OperationDefinition"],
|
9
|
-
"arguments": ["Field", "Directive"]
|
10
|
-
}
|
11
|
-
],
|
12
|
-
"@graphql-eslint/match-document-filename": [
|
13
|
-
"error",
|
14
|
-
{
|
15
|
-
"query": "kebab-case",
|
16
|
-
"mutation": "kebab-case",
|
17
|
-
"subscription": "kebab-case",
|
18
|
-
"fragment": "kebab-case"
|
19
|
-
}
|
20
|
-
],
|
21
|
-
"@graphql-eslint/unique-fragment-name": "error",
|
22
|
-
"@graphql-eslint/unique-operation-name": "error"
|
23
|
-
}
|
24
|
-
}
|
package/configs/schema-all.json
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": ["./base.json", "./schema-recommended.json"],
|
3
|
-
"rules": {
|
4
|
-
"@graphql-eslint/alphabetize": [
|
5
|
-
"error",
|
6
|
-
{
|
7
|
-
"fields": [
|
8
|
-
"ObjectTypeDefinition",
|
9
|
-
"InterfaceTypeDefinition",
|
10
|
-
"InputObjectTypeDefinition"
|
11
|
-
],
|
12
|
-
"values": ["EnumTypeDefinition"],
|
13
|
-
"arguments": [
|
14
|
-
"FieldDefinition",
|
15
|
-
"Field",
|
16
|
-
"DirectiveDefinition",
|
17
|
-
"Directive"
|
18
|
-
]
|
19
|
-
}
|
20
|
-
],
|
21
|
-
"@graphql-eslint/input-name": "error",
|
22
|
-
"@graphql-eslint/no-scalar-result-type-on-mutation": "error",
|
23
|
-
"@graphql-eslint/require-deprecation-date": "error",
|
24
|
-
"@graphql-eslint/require-field-of-type-query-in-mutation-result": "error"
|
25
|
-
}
|
26
|
-
}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": "./base.json",
|
3
|
-
"rules": {
|
4
|
-
"@graphql-eslint/description-style": "error",
|
5
|
-
"@graphql-eslint/known-argument-names": "error",
|
6
|
-
"@graphql-eslint/known-directives": "error",
|
7
|
-
"@graphql-eslint/known-type-names": "error",
|
8
|
-
"@graphql-eslint/lone-schema-definition": "error",
|
9
|
-
"@graphql-eslint/naming-convention": [
|
10
|
-
"error",
|
11
|
-
{
|
12
|
-
"types": "PascalCase",
|
13
|
-
"FieldDefinition": "camelCase",
|
14
|
-
"InputValueDefinition": "camelCase",
|
15
|
-
"Argument": "camelCase",
|
16
|
-
"DirectiveDefinition": "camelCase",
|
17
|
-
"EnumValueDefinition": "UPPER_CASE",
|
18
|
-
"FieldDefinition[parent.name.value=Query]": {
|
19
|
-
"forbiddenPrefixes": ["query", "get"],
|
20
|
-
"forbiddenSuffixes": ["Query"]
|
21
|
-
},
|
22
|
-
"FieldDefinition[parent.name.value=Mutation]": {
|
23
|
-
"forbiddenPrefixes": ["mutation"],
|
24
|
-
"forbiddenSuffixes": ["Mutation"]
|
25
|
-
},
|
26
|
-
"FieldDefinition[parent.name.value=Subscription]": {
|
27
|
-
"forbiddenPrefixes": ["subscription"],
|
28
|
-
"forbiddenSuffixes": ["Subscription"]
|
29
|
-
}
|
30
|
-
}
|
31
|
-
],
|
32
|
-
"@graphql-eslint/no-case-insensitive-enum-values-duplicates": "error",
|
33
|
-
"@graphql-eslint/no-hashtag-description": "error",
|
34
|
-
"@graphql-eslint/no-typename-prefix": "error",
|
35
|
-
"@graphql-eslint/no-unreachable-types": "error",
|
36
|
-
"@graphql-eslint/provided-required-arguments": "error",
|
37
|
-
"@graphql-eslint/require-deprecation-reason": "error",
|
38
|
-
"@graphql-eslint/require-description": [
|
39
|
-
"error",
|
40
|
-
{ "types": true, "DirectiveDefinition": true }
|
41
|
-
],
|
42
|
-
"@graphql-eslint/strict-id-in-types": "error",
|
43
|
-
"@graphql-eslint/unique-directive-names": "error",
|
44
|
-
"@graphql-eslint/unique-directive-names-per-location": "error",
|
45
|
-
"@graphql-eslint/unique-field-definition-names": "error",
|
46
|
-
"@graphql-eslint/unique-operation-types": "error",
|
47
|
-
"@graphql-eslint/unique-type-names": "error"
|
48
|
-
}
|
49
|
-
}
|
package/docs/README.md
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
## Available Rules
|
2
|
-
|
3
|
-
Each rule has emojis denoting:
|
4
|
-
|
5
|
-
- 🚀 `graphql-eslint` rule
|
6
|
-
- 🔮 `graphql-js` rule
|
7
|
-
- 🔧 if some problems reported by the rule are automatically fixable by the `--fix` [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) option
|
8
|
-
- 💡 if some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
|
9
|
-
|
10
|
-
<!-- 🚨 IMPORTANT! Do not manually modify this table. Run: `yarn generate:docs` -->
|
11
|
-
<!-- prettier-ignore-start -->
|
12
|
-
Name |Description| Config |🚀 / 🔮|🔧 / 💡
|
13
|
-
-|-|:-:|:-:|:-:
|
14
|
-
[alphabetize](rules/alphabetize.md)|Enforce arrange in alphabetical order for type fields, enum values, input object fields, operation selections and more.|![all][]|🚀|🔧
|
15
|
-
[description-style](rules/description-style.md)|Require all comments to follow the same style (either block or inline).|![recommended][]|🚀|💡
|
16
|
-
[executable-definitions](rules/executable-definitions.md)|A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.|![recommended][]|🔮|
|
17
|
-
[fields-on-correct-type](rules/fields-on-correct-type.md)|A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as `__typename`.|![recommended][]|🔮|
|
18
|
-
[fragments-on-composite-type](rules/fragments-on-composite-type.md)|Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.|![recommended][]|🔮|
|
19
|
-
[input-name](rules/input-name.md)|Require mutation argument to be always called "input" and input type to be called Mutation name + "Input".|![all][]|🚀|💡
|
20
|
-
[known-argument-names](rules/known-argument-names.md)|A GraphQL field is only valid if all supplied arguments are defined by that field.|![recommended][]|🔮|
|
21
|
-
[known-directives](rules/known-directives.md)|A GraphQL document is only valid if all `@directive`s are known by the schema and legally positioned.|![recommended][]|🔮|
|
22
|
-
[known-fragment-names](rules/known-fragment-names.md)|A GraphQL document is only valid if all `...Fragment` fragment spreads refer to fragments defined in the same document.|![recommended][]|🔮|
|
23
|
-
[known-type-names](rules/known-type-names.md)|A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.|![recommended][]|🔮|
|
24
|
-
[lone-anonymous-operation](rules/lone-anonymous-operation.md)|A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.|![recommended][]|🔮|
|
25
|
-
[lone-schema-definition](rules/lone-schema-definition.md)|A GraphQL document is only valid if it contains only one schema definition.|![recommended][]|🔮|
|
26
|
-
[match-document-filename](rules/match-document-filename.md)|This rule allows you to enforce that the file name should match the operation name.|![all][]|🚀|
|
27
|
-
[naming-convention](rules/naming-convention.md)|Require names to follow specified conventions.|![recommended][]|🚀|💡
|
28
|
-
[no-anonymous-operations](rules/no-anonymous-operations.md)|Require name for your GraphQL operations. This is useful since most GraphQL client libraries are using the operation name for caching purposes.|![recommended][]|🚀|💡
|
29
|
-
[no-case-insensitive-enum-values-duplicates](rules/no-case-insensitive-enum-values-duplicates.md)|Disallow case-insensitive enum values duplicates.|![recommended][]|🚀|💡
|
30
|
-
[no-deprecated](rules/no-deprecated.md)|Enforce that deprecated fields or enum values are not in use by operations.|![recommended][]|🚀|💡
|
31
|
-
[no-duplicate-fields](rules/no-duplicate-fields.md)|Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.|![recommended][]|🚀|💡
|
32
|
-
[no-fragment-cycles](rules/no-fragment-cycles.md)|A GraphQL fragment is only valid when it does not have cycles in fragments usage.|![recommended][]|🔮|
|
33
|
-
[no-hashtag-description](rules/no-hashtag-description.md)|Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.|![recommended][]|🚀|💡
|
34
|
-
[no-root-type](rules/no-root-type.md)|Disallow using root types `mutation` and/or `subscription`.||🚀|💡
|
35
|
-
[no-scalar-result-type-on-mutation](rules/no-scalar-result-type-on-mutation.md)|Avoid scalar result type on mutation type to make sure to return a valid state.|![all][]|🚀|💡
|
36
|
-
[no-typename-prefix](rules/no-typename-prefix.md)|Enforces users to avoid using the type name in a field name while defining your schema.|![recommended][]|🚀|💡
|
37
|
-
[no-undefined-variables](rules/no-undefined-variables.md)|A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.|![recommended][]|🔮|
|
38
|
-
[no-unreachable-types](rules/no-unreachable-types.md)|Requires all types to be reachable at some level by root level fields.|![recommended][]|🚀|💡
|
39
|
-
[no-unused-fields](rules/no-unused-fields.md)|Requires all fields to be used at some level by siblings operations.||🚀|💡
|
40
|
-
[no-unused-fragments](rules/no-unused-fragments.md)|A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.|![recommended][]|🔮|
|
41
|
-
[no-unused-variables](rules/no-unused-variables.md)|A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.|![recommended][]|🔮|
|
42
|
-
[one-field-subscriptions](rules/one-field-subscriptions.md)|A GraphQL subscription is valid only if it contains a single root field.|![recommended][]|🔮|
|
43
|
-
[overlapping-fields-can-be-merged](rules/overlapping-fields-can-be-merged.md)|A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.|![recommended][]|🔮|
|
44
|
-
[possible-fragment-spread](rules/possible-fragment-spread.md)|A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.|![recommended][]|🔮|
|
45
|
-
[possible-type-extension](rules/possible-type-extension.md)|A type extension is only valid if the type is defined and has the same kind.||🔮|
|
46
|
-
[provided-required-arguments](rules/provided-required-arguments.md)|A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.|![recommended][]|🔮|
|
47
|
-
[relay-arguments](rules/relay-arguments.md)|Set of rules to follow Relay specification for Arguments.||🚀|
|
48
|
-
[relay-connection-types](rules/relay-connection-types.md)|Set of rules to follow Relay specification for Connection types.||🚀|
|
49
|
-
[relay-edge-types](rules/relay-edge-types.md)|Set of rules to follow Relay specification for Edge types.||🚀|
|
50
|
-
[relay-page-info](rules/relay-page-info.md)|Set of rules to follow Relay specification for `PageInfo` object.||🚀|
|
51
|
-
[require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|![all][]|🚀|💡
|
52
|
-
[require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|![recommended][]|🚀|
|
53
|
-
[require-description](rules/require-description.md)|Enforce descriptions in type definitions and operations.|![recommended][]|🚀|
|
54
|
-
[require-field-of-type-query-in-mutation-result](rules/require-field-of-type-query-in-mutation-result.md)|Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.|![all][]|🚀|
|
55
|
-
[require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|![recommended][]|🚀|💡
|
56
|
-
[scalar-leafs](rules/scalar-leafs.md)|A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.|![recommended][]|🔮|
|
57
|
-
[selection-set-depth](rules/selection-set-depth.md)|Limit the complexity of the GraphQL operations solely by their depth. Based on [graphql-depth-limit](https://npmjs.com/package/graphql-depth-limit).|![recommended][]|🚀|💡
|
58
|
-
[strict-id-in-types](rules/strict-id-in-types.md)|Requires output types to have one unique identifier unless they do not have a logical one. Exceptions can be used to ignore output types that do not have unique identifiers.|![recommended][]|🚀|
|
59
|
-
[unique-argument-names](rules/unique-argument-names.md)|A GraphQL field or directive is only valid if all supplied arguments are uniquely named.|![recommended][]|🔮|
|
60
|
-
[unique-directive-names](rules/unique-directive-names.md)|A GraphQL document is only valid if all defined directives have unique names.|![recommended][]|🔮|
|
61
|
-
[unique-directive-names-per-location](rules/unique-directive-names-per-location.md)|A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.|![recommended][]|🔮|
|
62
|
-
[unique-enum-value-names](rules/unique-enum-value-names.md)|A GraphQL enum type is only valid if all its values are uniquely named.||🔮|
|
63
|
-
[unique-field-definition-names](rules/unique-field-definition-names.md)|A GraphQL complex type is only valid if all its fields are uniquely named.|![recommended][]|🔮|
|
64
|
-
[unique-fragment-name](rules/unique-fragment-name.md)|Enforce unique fragment names across your project.|![all][]|🚀|
|
65
|
-
[unique-input-field-names](rules/unique-input-field-names.md)|A GraphQL input object value is only valid if all supplied fields are uniquely named.|![recommended][]|🔮|
|
66
|
-
[unique-operation-name](rules/unique-operation-name.md)|Enforce unique operation names across your project.|![all][]|🚀|
|
67
|
-
[unique-operation-types](rules/unique-operation-types.md)|A GraphQL document is only valid if it has only one type per operation.|![recommended][]|🔮|
|
68
|
-
[unique-type-names](rules/unique-type-names.md)|A GraphQL document is only valid if all defined types have unique names.|![recommended][]|🔮|
|
69
|
-
[unique-variable-names](rules/unique-variable-names.md)|A GraphQL operation is only valid if all its variables are uniquely named.|![recommended][]|🔮|
|
70
|
-
[value-literals-of-correct-type](rules/value-literals-of-correct-type.md)|A GraphQL document is only valid if all value literals are of the type expected at their position.|![recommended][]|🔮|
|
71
|
-
[variables-are-input-types](rules/variables-are-input-types.md)|A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).|![recommended][]|🔮|
|
72
|
-
[variables-in-allowed-position](rules/variables-in-allowed-position.md)|Variables passed to field arguments conform to type.|![recommended][]|🔮|
|
73
|
-
<!-- prettier-ignore-end -->
|
74
|
-
[recommended]: https://img.shields.io/badge/-recommended-green.svg
|
75
|
-
[all]: https://img.shields.io/badge/-all-blue.svg
|
package/docs/custom-rules.md
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
# Writing Custom Rules
|
2
|
-
|
3
|
-
To get started with your own rules, start by understanding how [ESLint custom rules works](https://eslint.org/docs/developer-guide/working-with-rules).
|
4
|
-
|
5
|
-
`graphql-eslint` converts the [GraphQL AST](https://graphql.org/graphql-js/language) into [ESTree structure](https://github.com/estree/estree), so it allows you to easily travel the GraphQL AST tree easily.
|
6
|
-
|
7
|
-
You can visit any GraphQL AST node in your custom rules, and report this as error. You don't need to have special handlers for code-files, since `graphql-eslint` extracts usages of `gql` and magic `/* GraphQL */` comments automatically, and runs it through the parser, and eventually it knows to adjust errors location to fit in your code files original location.
|
8
|
-
|
9
|
-
## Getting Started
|
10
|
-
|
11
|
-
Start by creating a [simple ESLint rule file](https://eslint.org/docs/developer-guide/working-with-rules), and choose the AST nodes you wish to visit. It can either be a [simple AST node `Kind`](https://github.com/graphql/graphql-js/blob/master/src/language/kinds.d.ts) or a complex [ESLint selector](https://eslint.org/docs/developer-guide/selectors) that allows you to travel and filter AST nodes.
|
12
|
-
|
13
|
-
We recommend you to read the [graphql-eslint parser documentation](parser.md) before getting started, to understand the differences between the AST structures.
|
14
|
-
|
15
|
-
The `graphql-eslint` comes with a TypeScript wrapper for ESLint rules, and provides a testkit to simplify testing process with GraphQL schemas, so you can use that by importing `GraphQLESLintRule` type. But if you wish to use JavaScript - that's fine :)
|
16
|
-
|
17
|
-
Here's an example for a simple rule that reports on anonymous GraphQL operations:
|
18
|
-
|
19
|
-
```ts
|
20
|
-
import { GraphQLESLintRule } from '@graphql-eslint/eslint-plugin'
|
21
|
-
|
22
|
-
const rule: GraphQLESLintRule = {
|
23
|
-
create(context) {
|
24
|
-
return {
|
25
|
-
OperationDefinition(node) {
|
26
|
-
if (!node.name || !node.name.value) {
|
27
|
-
context.report({
|
28
|
-
node,
|
29
|
-
message: 'Oops, name is required!'
|
30
|
-
})
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
```
|
37
|
-
|
38
|
-
So what happens here?
|
39
|
-
|
40
|
-
1. `@graphql-eslint/eslint-plugin` handles the parsing process for your GraphQL content. It will load the GraphQL files (either from code files or from `.graphql` files with SDL), parse it using GraphQL parser, converts it to ESTree structure and let ESLint do the rest.
|
41
|
-
1. Your rule is being loaded by ESLint, and executes just like any other ESLint rule.
|
42
|
-
1. Our custom rule asks ESLint to run our function for every `OperationDefinition` found.
|
43
|
-
1. If the `OperationDefinition` node doesn't have a valid `name` - we report an error to ESLint.
|
44
|
-
|
45
|
-
#### More Examples
|
46
|
-
|
47
|
-
You can scan the `packages/plugin/src/rules` directory in this repo for references for implementing rules. It coverts most of the use-cases and concepts of rules.
|
48
|
-
|
49
|
-
## Accessing original GraphQL AST nodes
|
50
|
-
|
51
|
-
Since our parser converts GraphQL AST to ESTree structure, there are some minor differences in the structure of the objects.
|
52
|
-
If you are using TypeScript, and you typed your rule with `GraphQLESLintRule` - you'll see that each `node` is a bit different from the AST nodes of GraphQL (you can read more about that in [graphql-eslint parser documentation](parser.md)).
|
53
|
-
|
54
|
-
If you need access to the original GraphQL AST `node`, you can use `.rawNode()` method on each node you get from the AST structure of ESLint.
|
55
|
-
|
56
|
-
This is useful if you wish to use other GraphQL tools that works with the original GraphQL AST objects.
|
57
|
-
|
58
|
-
Here's an example for using original `graphql-js` validate method to validate `OperationDefinition`:
|
59
|
-
|
60
|
-
```ts
|
61
|
-
import { validate } from 'graphql'
|
62
|
-
import { requireGraphQLSchemaFromContext } from '@graphql-eslint/eslint-plugin'
|
63
|
-
|
64
|
-
export const rule = {
|
65
|
-
create(context) {
|
66
|
-
return {
|
67
|
-
OperationDefinition(node) {
|
68
|
-
const schema = requireGraphQLSchemaFromContext(context)
|
69
|
-
|
70
|
-
validate(context, schema, {
|
71
|
-
kind: Kind.DOCUMENT,
|
72
|
-
definitions: [node.rawNode()]
|
73
|
-
})
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}
|
78
|
-
```
|
79
|
-
|
80
|
-
## `TypeInfo` / `GraphQLSchema`
|
81
|
-
|
82
|
-
If you provide GraphQL schema in your ESLint configuration, it will get loaded automatically, and become available in your rules in two ways:
|
83
|
-
|
84
|
-
1. You'll be able to access the loaded `GraphQLSchema` object.
|
85
|
-
2. In every visited node, you'll be able to use `.typeInfo()` method to get an object with complete type information on your visited node (see [TypeInfo documentation](https://graphql.org/graphql-js/utilities/#typeinfo)).
|
86
|
-
|
87
|
-
#### Getting `GraphQLSchema`
|
88
|
-
|
89
|
-
To mark your ESLint rules as a rule that needs access to GraphQL schema, start by running `requireGraphQLSchemaFromContext` from the plugin package, it will make sure to return a schema, or throw an error for the user about the missing schema.
|
90
|
-
|
91
|
-
```ts
|
92
|
-
const schema = requireGraphQLSchemaFromContext(context)
|
93
|
-
```
|
94
|
-
|
95
|
-
#### Accessing TypeInfo
|
96
|
-
|
97
|
-
If schema is provided and loaded successfully, the `typeInfo` will be available to use. Otherwise - it will be `undefined`.
|
98
|
-
If your plugin requires `typeInfo` in order to operate and run, make sure to call `requireGraphQLSchemaFromContext` - it will validate that the schema is loaded.
|
99
|
-
|
100
|
-
`typeInfo` is provided on every node, based on the type of that node, for example, to access the `GraphQLOutputType` while you are visiting a `SelectionSet` node, you can do:
|
101
|
-
|
102
|
-
```ts
|
103
|
-
import { requireGraphQLSchemaFromContext } from '@graphql-eslint/eslint-plugin'
|
104
|
-
|
105
|
-
export const rule = {
|
106
|
-
create(context) {
|
107
|
-
requireGraphQLSchemaFromContext('your-rule-name', context)
|
108
|
-
|
109
|
-
return {
|
110
|
-
SelectionSet(node) {
|
111
|
-
const typeInfo = node.typeInfo()
|
112
|
-
if (typeInfo.gqlType) {
|
113
|
-
console.log(`The GraphQLOutputType is: ${typeInfo.gqlType}`)
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
}
|
119
|
-
```
|
120
|
-
|
121
|
-
The structure of the return value of `.typeInfo()` is [defined here](https://github.com/B2o5T/graphql-eslint/blob/master/packages/plugin/src/estree-converter/converter.ts#L32-L40). So based on the `node` you are using, you'll get a different values on `.typeInfo()` result.
|
122
|
-
|
123
|
-
## Testing your rules
|
124
|
-
|
125
|
-
To test your rules, you can either use the wrapped `GraphQLRuleTester` from this library, or use the built-it [`RuleTester`](https://eslint.org/docs/developer-guide/working-with-rules#rule-unit-tests) of ESLint.
|
126
|
-
|
127
|
-
The wrapped `GraphQLRuleTester` provides built-in configured parser, and a schema loader, if you need to test your rule with a loaded schema.
|
128
|
-
|
129
|
-
```ts
|
130
|
-
import { GraphQLRuleTester } from '@graphql-eslint/eslint-plugin'
|
131
|
-
import { rule } from './my-rule'
|
132
|
-
|
133
|
-
const ruleTester = new GraphQLRuleTester()
|
134
|
-
|
135
|
-
ruleTester.runGraphQLTests('my-rule', rule, {
|
136
|
-
valid: [
|
137
|
-
{
|
138
|
-
code: 'query something { foo }'
|
139
|
-
}
|
140
|
-
],
|
141
|
-
invalid: [
|
142
|
-
{
|
143
|
-
code: 'query invalid { foo }',
|
144
|
-
errors: [{ message: 'Your error message.' }],
|
145
|
-
}
|
146
|
-
]
|
147
|
-
})
|
148
|
-
```
|
package/docs/deprecated-rules.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Deprecated Rules
|
2
|
-
|
3
|
-
## avoid-duplicate-fields
|
4
|
-
|
5
|
-
This rule was renamed to [`no-duplicate-fields`](rules/no-duplicate-fields.md).
|
6
|
-
|
7
|
-
## avoid-scalar-result-type-on-mutation
|
8
|
-
|
9
|
-
This rule was renamed to [`no-scalar-result-type-on-mutation`](rules/no-scalar-result-type-on-mutation.md).
|
10
|
-
|
11
|
-
## avoid-typename-prefix
|
12
|
-
|
13
|
-
This rule was renamed to [`no-typename-prefix`](rules/no-typename-prefix.md).
|
14
|
-
|
15
|
-
## avoid-operation-name-prefix
|
16
|
-
|
17
|
-
This rule was removed because the same things can be validated using [`naming-convention`](rules/naming-convention.md).
|
18
|
-
|
19
|
-
## no-operation-name-suffix
|
20
|
-
|
21
|
-
This rule was removed because the same things can be validated using [`naming-convention`](rules/naming-convention.md).
|
package/docs/parser-options.md
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
## Parser Options
|
2
|
-
|
3
|
-
### `graphQLParserOptions`
|
4
|
-
|
5
|
-
With this configuration, you can specify custom configurations for GraphQL's `parse` method. By default, `graphql-eslint` parser just adds `noLocation: false` to make sure all parsed AST has `location` set, since we need this for tokenizing and for converting the GraphQL AST into ESTree.
|
6
|
-
|
7
|
-
You can find the [complete set of options for this object here](https://github.com/graphql/graphql-js/blob/6e48d16f92b9a6df8638b1486354c6be2537033b/src/language/parser.ts#L73)
|
8
|
-
|
9
|
-
### `skipGraphQLConfig`
|
10
|
-
|
11
|
-
If you are using [`graphql-config`](https://graphql-config.com) in your project, the parser will automatically use that to load your default GraphQL schema.
|
12
|
-
|
13
|
-
You can disable this behaviour using `skipGraphQLConfig: true` in the `parserOptions`:
|
14
|
-
|
15
|
-
```json
|
16
|
-
"parserOptions": {
|
17
|
-
"skipGraphQLConfig": true
|
18
|
-
}
|
19
|
-
```
|
20
|
-
|
21
|
-
### `schema`
|
22
|
-
|
23
|
-
You can specify `parserOptions.schema` to load your GraphQL schema. The parser uses `graphql-tools` and it's loaders, that means you can either specify a URL, a path to a local `.json` (introspection) file, or a path to a local `.graphql` file(s). You can also use Glob expressions to load multiple files.
|
24
|
-
|
25
|
-
Here are a few examples for a valid setup:
|
26
|
-
|
27
|
-
```json
|
28
|
-
"parserOptions": {
|
29
|
-
"schema": "./schema.graphql"
|
30
|
-
}
|
31
|
-
```
|
32
|
-
|
33
|
-
```json
|
34
|
-
"parserOptions": {
|
35
|
-
"schema": "./schema.json"
|
36
|
-
}
|
37
|
-
```
|
38
|
-
|
39
|
-
```json
|
40
|
-
"parserOptions": {
|
41
|
-
"schema": "http://my-server/graphql"
|
42
|
-
}
|
43
|
-
```
|
44
|
-
|
45
|
-
```json
|
46
|
-
"parserOptions": {
|
47
|
-
"schema": "./src/**/*.graphql"
|
48
|
-
}
|
49
|
-
```
|
50
|
-
|
51
|
-
```json
|
52
|
-
"parserOptions": {
|
53
|
-
"schema": [
|
54
|
-
"src/schema-a.graphql",
|
55
|
-
"src/schema-b.graphql",
|
56
|
-
"src/schema-c.graphql"
|
57
|
-
]
|
58
|
-
}
|
59
|
-
```
|
60
|
-
|
61
|
-
### `schemaOptions`
|
62
|
-
|
63
|
-
If you wish to send additional configuration for the `graphql-tools` loaders that loads your schema, you can specify `schemaOptions` object:
|
64
|
-
|
65
|
-
```json
|
66
|
-
"parserOptions": {
|
67
|
-
"schema": "http://my-server/graphql",
|
68
|
-
"schemaOptions": {
|
69
|
-
"headers": {
|
70
|
-
"Authorization": "Bearer MY_TOKEN"
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
```
|
75
|
-
|
76
|
-
```json
|
77
|
-
"parserOptions": {
|
78
|
-
"schema": "./src/**/*.graphql",
|
79
|
-
"schemaOptions": {
|
80
|
-
"assumeValid": true
|
81
|
-
}
|
82
|
-
}
|
83
|
-
```
|
84
|
-
|
85
|
-
> The configuration here is flexible, and will be sent to `graphql-tools` and it's loaders. So depends on the schema source, the options may vary. [You can read more about these loaders and their configuration here](https://graphql-tools.com/docs/api/interfaces/loaders_graphql_file_src.GraphQLFileLoaderOptions#properties).
|
package/docs/parser.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
## GraphQL-ESLint Parser
|
2
|
-
|
3
|
-
The `graphql-eslint` parser is works in the following way:
|
4
|
-
|
5
|
-
1. Loads all relevant GraphQL code using ESLint core (either from `.graphql` files, or using [ESLint `processor`](https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins) to find in code-files).
|
6
|
-
1. Is uses `graphql-js` (and `graphql-tools`) to parse the found string into a `DocumentNode`.
|
7
|
-
1. Extracts all comments (marked as `# ...`) from the parsed AST, and provides to ESLint as directives hints.
|
8
|
-
1. If `graphql-config` is used, or `schema` field is provided, the schema is being loaded and provided to the rules using `parserServices`.
|
9
|
-
1. Converts the `DocumentNode` to ESTree structure (and enrich the nodes with `typeInfo`, if schema is loaded).
|
10
|
-
|
11
|
-
### ESTree Conversion
|
12
|
-
|
13
|
-
The GraphQL AST structure is very similar to ESTree structure, but there are a few differences that the `parser` does.
|
14
|
-
|
15
|
-
Here's a list of changes that the parser performs, in order to make the GraphQL AST compatible with ESTree:
|
16
|
-
|
17
|
-
---
|
18
|
-
|
19
|
-
**Problem**: GraphQL uses `kind` field to define the kind of the AST node, while ESTree uses `type`.
|
20
|
-
|
21
|
-
**Solution**: The parser adds `type` field on each node, and just copies the value from `kind` field.
|
22
|
-
|
23
|
-
---
|
24
|
-
|
25
|
-
**Problem**: Some GraphQL AST nodes are using `type` field (which conflicts with the ESTree kind).
|
26
|
-
|
27
|
-
**Solution**: AST nodes that has `type` field are being transformed, and the `type` field changes to `gqlType`.
|
28
|
-
|
29
|
-
---
|
30
|
-
|
31
|
-
**Problem**: GraphQL AST structure allows circular JSON links (while ESTree might fail on `Maximum call stack exceeded`).
|
32
|
-
|
33
|
-
**Solution**: The parser removes circular JSONs (specifically around GraphQL `Location` and the `Lexer`)
|
34
|
-
|
35
|
-
---
|
36
|
-
|
37
|
-
**Problem**: GraphQL uses `location` field to store the AST locations, while ESTree also uses it in a different structure.
|
38
|
-
|
39
|
-
**Solution**: The parser creates a new `location` field that is compatible with ESTree.
|
40
|
-
|
41
|
-
### Loading GraphQL Schema
|
42
|
-
|
43
|
-
If you are using [`graphql-config`](https://graphql-config.com) in your project, the parser will automatically use that to load your default GraphQL schema (you can disable this behaviour using `skipGraphQLConfig: true` in the `parserOptions`).
|
44
|
-
|
45
|
-
If you are not using `graphql-config`, you can specify `parserOptions.schema` to load your GraphQL schema. The parser uses `graphql-tools` and it's loaders, that means you can either specify a URL, a path to a local `.json` (introspection) file, or a path to a local `.graphql` file(s). You can also use Glob expressions to load multiple files.
|
46
|
-
|
47
|
-
[You can find more detail on the `parserOptions` config here](parser-options.md)
|
48
|
-
|
49
|
-
Providing the schema will make sure that rules that needs it will be able to access it, and it enriches every converted AST node with `typeInfo`.
|