@graphql-eslint/eslint-plugin 2.3.0-alpha-f7157af.0 → 2.4.0-alpha-b91589b.0

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 CHANGED
@@ -46,7 +46,7 @@ npm install --save-dev @graphql-eslint/eslint-plugin
46
46
 
47
47
  ### Configuration
48
48
 
49
- To get started, create an override configuration for your ESLint, while applying it to to `.graphql` files (do that even if you are declaring your operations in code files):
49
+ To get started, create an override configuration for your ESLint, while applying it to `.graphql` files (do that even if you are declaring your operations in code files):
50
50
 
51
51
  ```json
52
52
  {
@@ -38,7 +38,7 @@ const rule: GraphQLESLintRule = {
38
38
  So what happens here?
39
39
 
40
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. You rule is being loaded by ESLint, and executes just like any other ESLint rule.
41
+ 1. Your rule is being loaded by ESLint, and executes just like any other ESLint rule.
42
42
  1. Our custom rule asks ESLint to run our function for every `OperationDefinition` found.
43
43
  1. If the `OperationDefinition` node doesn't have a valid `name` - we report an error to ESLint.
44
44
 
@@ -49,7 +49,7 @@ You can scan the `packages/plugin/src/rules` directory in this repo for referenc
49
49
  ## Accessing original GraphQL AST nodes
50
50
 
51
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 from the AST nodes of GraphQL (you can read more about that in [graphql-eslint parser documentation](./parser.md)).
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
53
 
54
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
55
 
@@ -1,7 +1,6 @@
1
1
  import { GraphQLESTreeNode } from './estree-ast';
2
2
  import { ASTNode, TypeInfo } from 'graphql';
3
- import { Comment } from 'estree';
4
3
  export declare function convertToESTree<T extends ASTNode>(node: T, typeInfo?: TypeInfo): {
5
- rootTree: GraphQLESTreeNode<T>;
6
- comments: Comment[];
4
+ rootTree: GraphQLESTreeNode<T, false>;
5
+ comments: import("estree").Comment[];
7
6
  };
package/index.js CHANGED
@@ -790,6 +790,7 @@ const rule$1 = {
790
790
  messages: {
791
791
  [AVOID_DUPLICATE_FIELDS]: `{{ type }} "{{ fieldName }}" defined multiple times.`,
792
792
  },
793
+ schema: [],
793
794
  },
794
795
  create(context) {
795
796
  return {
@@ -960,6 +961,7 @@ const rule$3 = {
960
961
  },
961
962
  ],
962
963
  },
964
+ schema: [],
963
965
  },
964
966
  create(context) {
965
967
  const schema = requireGraphQLSchemaFromContext('avoid-scalar-result-type-on-mutation', context);
@@ -1015,6 +1017,7 @@ const rule$4 = {
1015
1017
  messages: {
1016
1018
  [AVOID_TYPENAME_PREFIX]: `Field "{{ fieldName }}" starts with the name of the parent type "{{ typeName }}"`,
1017
1019
  },
1020
+ schema: [],
1018
1021
  },
1019
1022
  create(context) {
1020
1023
  return {
@@ -1728,6 +1731,7 @@ const rule$9 = {
1728
1731
  messages: {
1729
1732
  [NO_ANONYMOUS_OPERATIONS]: `Anonymous GraphQL operations are forbidden. Please make sure to name your {{ operation }}!`,
1730
1733
  },
1734
+ schema: [],
1731
1735
  },
1732
1736
  create(context) {
1733
1737
  return {
@@ -1791,6 +1795,7 @@ const rule$a = {
1791
1795
  messages: {
1792
1796
  [ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
1793
1797
  },
1798
+ schema: [],
1794
1799
  },
1795
1800
  create(context) {
1796
1801
  return {
@@ -1885,6 +1890,7 @@ const rule$b = {
1885
1890
  messages: {
1886
1891
  [NO_DEPRECATED]: `This {{ type }} is marked as deprecated in your GraphQL schema {{ reason }}`,
1887
1892
  },
1893
+ schema: [],
1888
1894
  },
1889
1895
  create(context) {
1890
1896
  return {
@@ -1892,7 +1898,7 @@ const rule$b = {
1892
1898
  requireGraphQLSchemaFromContext('no-deprecated', context);
1893
1899
  const typeInfo = node.typeInfo();
1894
1900
  if (typeInfo && typeInfo.enumValue) {
1895
- if (typeInfo.enumValue.isDeprecated) {
1901
+ if (typeInfo.enumValue.deprecationReason) {
1896
1902
  context.report({
1897
1903
  loc: node.loc,
1898
1904
  messageId: NO_DEPRECATED,
@@ -1908,7 +1914,7 @@ const rule$b = {
1908
1914
  requireGraphQLSchemaFromContext('no-deprecated', context);
1909
1915
  const typeInfo = node.typeInfo();
1910
1916
  if (typeInfo && typeInfo.fieldDef) {
1911
- if (typeInfo.fieldDef.isDeprecated) {
1917
+ if (typeInfo.fieldDef.deprecationReason) {
1912
1918
  context.report({
1913
1919
  loc: node.loc,
1914
1920
  messageId: NO_DEPRECATED,
@@ -1971,6 +1977,7 @@ const rule$c = {
1971
1977
  ],
1972
1978
  },
1973
1979
  type: 'suggestion',
1980
+ schema: [],
1974
1981
  },
1975
1982
  create(context) {
1976
1983
  return {
@@ -2031,6 +2038,7 @@ const rule$d = {
2031
2038
  messages: {
2032
2039
  [NO_OPERATION_NAME_SUFFIX]: `Unnecessary "{{ invalidSuffix }}" suffix in your operation name!`,
2033
2040
  },
2041
+ schema: [],
2034
2042
  },
2035
2043
  create(context) {
2036
2044
  return {
@@ -2096,6 +2104,7 @@ const rule$e = {
2096
2104
  },
2097
2105
  fixable: 'code',
2098
2106
  type: 'suggestion',
2107
+ schema: [],
2099
2108
  },
2100
2109
  create(context) {
2101
2110
  const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
@@ -2187,6 +2196,7 @@ const rule$f = {
2187
2196
  },
2188
2197
  fixable: 'code',
2189
2198
  type: 'suggestion',
2199
+ schema: [],
2190
2200
  },
2191
2201
  create(context) {
2192
2202
  const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
@@ -2452,6 +2462,7 @@ const rule$h = {
2452
2462
  ],
2453
2463
  },
2454
2464
  type: 'suggestion',
2465
+ schema: [],
2455
2466
  },
2456
2467
  create(context) {
2457
2468
  return {
@@ -2516,7 +2527,7 @@ const rule$i = {
2516
2527
  examples: [
2517
2528
  {
2518
2529
  title: 'Incorrect',
2519
- usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }],
2530
+ usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
2520
2531
  code: /* GraphQL */ `
2521
2532
  type someTypeName {
2522
2533
  name: String
@@ -2525,7 +2536,7 @@ const rule$i = {
2525
2536
  },
2526
2537
  {
2527
2538
  title: 'Correct',
2528
- usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }],
2539
+ usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
2529
2540
  code: /* GraphQL */ `
2530
2541
  """
2531
2542
  Some type description
@@ -2610,6 +2621,7 @@ const rule$j = {
2610
2621
  },
2611
2622
  ],
2612
2623
  },
2624
+ schema: [],
2613
2625
  },
2614
2626
  create(context) {
2615
2627
  const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
@@ -3229,6 +3241,7 @@ const rule$n = {
3229
3241
  messages: {
3230
3242
  [UNIQUE_FRAGMENT_NAME]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
3231
3243
  },
3244
+ schema: [],
3232
3245
  },
3233
3246
  create(context) {
3234
3247
  return {
@@ -3291,6 +3304,7 @@ const rule$o = {
3291
3304
  messages: {
3292
3305
  [UNIQUE_OPERATION_NAME]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
3293
3306
  },
3307
+ schema: [],
3294
3308
  },
3295
3309
  create(context) {
3296
3310
  return {
package/index.mjs CHANGED
@@ -784,6 +784,7 @@ const rule$1 = {
784
784
  messages: {
785
785
  [AVOID_DUPLICATE_FIELDS]: `{{ type }} "{{ fieldName }}" defined multiple times.`,
786
786
  },
787
+ schema: [],
787
788
  },
788
789
  create(context) {
789
790
  return {
@@ -954,6 +955,7 @@ const rule$3 = {
954
955
  },
955
956
  ],
956
957
  },
958
+ schema: [],
957
959
  },
958
960
  create(context) {
959
961
  const schema = requireGraphQLSchemaFromContext('avoid-scalar-result-type-on-mutation', context);
@@ -1009,6 +1011,7 @@ const rule$4 = {
1009
1011
  messages: {
1010
1012
  [AVOID_TYPENAME_PREFIX]: `Field "{{ fieldName }}" starts with the name of the parent type "{{ typeName }}"`,
1011
1013
  },
1014
+ schema: [],
1012
1015
  },
1013
1016
  create(context) {
1014
1017
  return {
@@ -1722,6 +1725,7 @@ const rule$9 = {
1722
1725
  messages: {
1723
1726
  [NO_ANONYMOUS_OPERATIONS]: `Anonymous GraphQL operations are forbidden. Please make sure to name your {{ operation }}!`,
1724
1727
  },
1728
+ schema: [],
1725
1729
  },
1726
1730
  create(context) {
1727
1731
  return {
@@ -1785,6 +1789,7 @@ const rule$a = {
1785
1789
  messages: {
1786
1790
  [ERROR_MESSAGE_ID]: `Case-insensitive enum values duplicates are not allowed! Found: "{{ found }}"`,
1787
1791
  },
1792
+ schema: [],
1788
1793
  },
1789
1794
  create(context) {
1790
1795
  return {
@@ -1879,6 +1884,7 @@ const rule$b = {
1879
1884
  messages: {
1880
1885
  [NO_DEPRECATED]: `This {{ type }} is marked as deprecated in your GraphQL schema {{ reason }}`,
1881
1886
  },
1887
+ schema: [],
1882
1888
  },
1883
1889
  create(context) {
1884
1890
  return {
@@ -1886,7 +1892,7 @@ const rule$b = {
1886
1892
  requireGraphQLSchemaFromContext('no-deprecated', context);
1887
1893
  const typeInfo = node.typeInfo();
1888
1894
  if (typeInfo && typeInfo.enumValue) {
1889
- if (typeInfo.enumValue.isDeprecated) {
1895
+ if (typeInfo.enumValue.deprecationReason) {
1890
1896
  context.report({
1891
1897
  loc: node.loc,
1892
1898
  messageId: NO_DEPRECATED,
@@ -1902,7 +1908,7 @@ const rule$b = {
1902
1908
  requireGraphQLSchemaFromContext('no-deprecated', context);
1903
1909
  const typeInfo = node.typeInfo();
1904
1910
  if (typeInfo && typeInfo.fieldDef) {
1905
- if (typeInfo.fieldDef.isDeprecated) {
1911
+ if (typeInfo.fieldDef.deprecationReason) {
1906
1912
  context.report({
1907
1913
  loc: node.loc,
1908
1914
  messageId: NO_DEPRECATED,
@@ -1965,6 +1971,7 @@ const rule$c = {
1965
1971
  ],
1966
1972
  },
1967
1973
  type: 'suggestion',
1974
+ schema: [],
1968
1975
  },
1969
1976
  create(context) {
1970
1977
  return {
@@ -2025,6 +2032,7 @@ const rule$d = {
2025
2032
  messages: {
2026
2033
  [NO_OPERATION_NAME_SUFFIX]: `Unnecessary "{{ invalidSuffix }}" suffix in your operation name!`,
2027
2034
  },
2035
+ schema: [],
2028
2036
  },
2029
2037
  create(context) {
2030
2038
  return {
@@ -2090,6 +2098,7 @@ const rule$e = {
2090
2098
  },
2091
2099
  fixable: 'code',
2092
2100
  type: 'suggestion',
2101
+ schema: [],
2093
2102
  },
2094
2103
  create(context) {
2095
2104
  const reachableTypes = requireReachableTypesFromContext(RULE_NAME, context);
@@ -2181,6 +2190,7 @@ const rule$f = {
2181
2190
  },
2182
2191
  fixable: 'code',
2183
2192
  type: 'suggestion',
2193
+ schema: [],
2184
2194
  },
2185
2195
  create(context) {
2186
2196
  const usedFields = requireUsedFieldsFromContext(RULE_NAME$1, context);
@@ -2446,6 +2456,7 @@ const rule$h = {
2446
2456
  ],
2447
2457
  },
2448
2458
  type: 'suggestion',
2459
+ schema: [],
2449
2460
  },
2450
2461
  create(context) {
2451
2462
  return {
@@ -2510,7 +2521,7 @@ const rule$i = {
2510
2521
  examples: [
2511
2522
  {
2512
2523
  title: 'Incorrect',
2513
- usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }],
2524
+ usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
2514
2525
  code: /* GraphQL */ `
2515
2526
  type someTypeName {
2516
2527
  name: String
@@ -2519,7 +2530,7 @@ const rule$i = {
2519
2530
  },
2520
2531
  {
2521
2532
  title: 'Correct',
2522
- usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }],
2533
+ usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
2523
2534
  code: /* GraphQL */ `
2524
2535
  """
2525
2536
  Some type description
@@ -2604,6 +2615,7 @@ const rule$j = {
2604
2615
  },
2605
2616
  ],
2606
2617
  },
2618
+ schema: [],
2607
2619
  },
2608
2620
  create(context) {
2609
2621
  const schema = requireGraphQLSchemaFromContext(RULE_NAME$2, context);
@@ -3223,6 +3235,7 @@ const rule$n = {
3223
3235
  messages: {
3224
3236
  [UNIQUE_FRAGMENT_NAME]: 'Fragment named "{{ documentName }}" already defined in:\n{{ summary }}',
3225
3237
  },
3238
+ schema: [],
3226
3239
  },
3227
3240
  create(context) {
3228
3241
  return {
@@ -3285,6 +3298,7 @@ const rule$o = {
3285
3298
  messages: {
3286
3299
  [UNIQUE_OPERATION_NAME]: 'Operation named "{{ documentName }}" already defined in:\n{{ summary }}',
3287
3300
  },
3301
+ schema: [],
3288
3302
  },
3289
3303
  create(context) {
3290
3304
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "2.3.0-alpha-f7157af.0",
3
+ "version": "2.4.0-alpha-b91589b.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"