@graphql-eslint/eslint-plugin 3.0.0-alpha-069461d.0 → 3.0.0-alpha-0a66b90.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/configs/all.d.ts CHANGED
@@ -21,7 +21,12 @@ export declare const allConfig: {
21
21
  '@graphql-eslint/no-unreachable-types': string;
22
22
  '@graphql-eslint/no-unused-fields': string;
23
23
  '@graphql-eslint/require-deprecation-date': string;
24
- '@graphql-eslint/require-description': string;
24
+ '@graphql-eslint/require-description': (string | {
25
+ types: boolean;
26
+ overrides: {
27
+ DirectiveDefinition: boolean;
28
+ };
29
+ })[];
25
30
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
26
31
  '@graphql-eslint/require-id-when-available': string;
27
32
  '@graphql-eslint/selection-set-depth': string;
@@ -22,7 +22,12 @@ export declare const configs: {
22
22
  '@graphql-eslint/no-unreachable-types': string;
23
23
  '@graphql-eslint/no-unused-fields': string;
24
24
  '@graphql-eslint/require-deprecation-date': string;
25
- '@graphql-eslint/require-description': string;
25
+ '@graphql-eslint/require-description': (string | {
26
+ types: boolean;
27
+ overrides: {
28
+ DirectiveDefinition: boolean;
29
+ };
30
+ })[];
26
31
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
27
32
  '@graphql-eslint/require-id-when-available': string;
28
33
  '@graphql-eslint/selection-set-depth': string;
@@ -39,12 +39,12 @@ The schema defines the following properties:
39
39
 
40
40
  Includes:
41
41
 
42
- - `ObjectTypeDefinition`
43
- - `InterfaceTypeDefinition`
44
- - `EnumTypeDefinition`
45
- - `ScalarTypeDefinition`
46
- - `InputObjectTypeDefinition`
47
- - `UnionTypeDefinition`
42
+ - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
43
+ - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
44
+ - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
45
+ - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
46
+ - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
47
+ - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
48
48
 
49
49
  The object must be one of the following types:
50
50
 
@@ -55,11 +55,11 @@ The object must be one of the following types:
55
55
 
56
56
  Includes:
57
57
 
58
- - `FieldDefinition`
59
- - `InputValueDefinition`
60
- - `VariableDefinition`
61
- - `Argument`
62
- - `DirectiveDefinition`
58
+ - [FieldDefinition](https://spec.graphql.org/October2021/#FieldDefinition)
59
+ - [InputValueDefinition](https://spec.graphql.org/October2021/#InputValueDefinition)
60
+ - [VariableDefinition](https://spec.graphql.org/October2021/#VariableDefinition)
61
+ - [Argument](https://spec.graphql.org/October2021/#Argument)
62
+ - [DirectiveDefinition](https://spec.graphql.org/October2021/#DirectiveDefinition)
63
63
 
64
64
  The object must be one of the following types:
65
65
 
@@ -78,20 +78,20 @@ Default: `false`
78
78
 
79
79
  May contain the following `ASTNode` names:
80
80
 
81
- - `Argument`
82
- - `DirectiveDefinition`
83
- - `EnumTypeDefinition`
84
- - `EnumValueDefinition`
85
- - `FieldDefinition`
86
- - `FragmentDefinition`
87
- - `InputObjectTypeDefinition`
88
- - `InputValueDefinition`
89
- - `InterfaceTypeDefinition`
90
- - `ObjectTypeDefinition`
91
- - `OperationDefinition`
92
- - `ScalarTypeDefinition`
93
- - `UnionTypeDefinition`
94
- - `VariableDefinition`
81
+ - [Argument](https://spec.graphql.org/October2021/#Argument)
82
+ - [DirectiveDefinition](https://spec.graphql.org/October2021/#DirectiveDefinition)
83
+ - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
84
+ - [EnumValueDefinition](https://spec.graphql.org/October2021/#EnumValueDefinition)
85
+ - [FieldDefinition](https://spec.graphql.org/October2021/#FieldDefinition)
86
+ - [FragmentDefinition](https://spec.graphql.org/October2021/#FragmentDefinition)
87
+ - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
88
+ - [InputValueDefinition](https://spec.graphql.org/October2021/#InputValueDefinition)
89
+ - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
90
+ - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
91
+ - [OperationDefinition](https://spec.graphql.org/October2021/#OperationDefinition)
92
+ - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
93
+ - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
94
+ - [VariableDefinition](https://spec.graphql.org/October2021/#VariableDefinition)
95
95
 
96
96
  > It's also possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with `ASTNode` name
97
97
  >
@@ -12,7 +12,7 @@ Enforce descriptions in your type definitions.
12
12
  ### Incorrect
13
13
 
14
14
  ```graphql
15
- # eslint @graphql-eslint/require-description: ['error', { on: ['ObjectTypeDefinition', 'FieldDefinition'] }]
15
+ # eslint @graphql-eslint/require-description: ['error', { types: true, overrides: { FieldDefinition: true } }]
16
16
 
17
17
  type someTypeName {
18
18
  name: String
@@ -22,7 +22,7 @@ type someTypeName {
22
22
  ### Correct
23
23
 
24
24
  ```graphql
25
- # eslint @graphql-eslint/require-description: ['error', { on: ['ObjectTypeDefinition', 'FieldDefinition'] }]
25
+ # eslint @graphql-eslint/require-description: ['error', { types: true, overrides: { FieldDefinition: true } }]
26
26
 
27
27
  """
28
28
  Some type description
@@ -39,13 +39,42 @@ type someTypeName {
39
39
 
40
40
  The schema defines the following properties:
41
41
 
42
- ### `on` (array)
42
+ ### `types` (boolean)
43
43
 
44
- The object is an array with all elements of the type `string`.
44
+ Includes:
45
45
 
46
- Additional restrictions:
46
+ - [ObjectTypeDefinition](https://spec.graphql.org/October2021/#ObjectTypeDefinition)
47
+ - [InterfaceTypeDefinition](https://spec.graphql.org/October2021/#InterfaceTypeDefinition)
48
+ - [EnumTypeDefinition](https://spec.graphql.org/October2021/#EnumTypeDefinition)
49
+ - [ScalarTypeDefinition](https://spec.graphql.org/October2021/#ScalarTypeDefinition)
50
+ - [InputObjectTypeDefinition](https://spec.graphql.org/October2021/#InputObjectTypeDefinition)
51
+ - [UnionTypeDefinition](https://spec.graphql.org/October2021/#UnionTypeDefinition)
47
52
 
48
- * Minimum items: `1`
53
+ ### `overrides` (object)
54
+
55
+ Configuration for precise `ASTNode`
56
+
57
+ Properties of the `overrides` object:
58
+
59
+ #### `ObjectTypeDefinition` (boolean)
60
+
61
+ #### `InterfaceTypeDefinition` (boolean)
62
+
63
+ #### `EnumTypeDefinition` (boolean)
64
+
65
+ #### `ScalarTypeDefinition` (boolean)
66
+
67
+ #### `InputObjectTypeDefinition` (boolean)
68
+
69
+ #### `UnionTypeDefinition` (boolean)
70
+
71
+ #### `FieldDefinition` (boolean)
72
+
73
+ #### `InputValueDefinition` (boolean)
74
+
75
+ #### `EnumValueDefinition` (boolean)
76
+
77
+ #### `DirectiveDefinition` (boolean)
49
78
 
50
79
  ## Resources
51
80
 
package/index.js CHANGED
@@ -122,7 +122,7 @@ const allConfig = {
122
122
  '@graphql-eslint/no-unreachable-types': 'error',
123
123
  '@graphql-eslint/no-unused-fields': 'error',
124
124
  '@graphql-eslint/require-deprecation-date': 'error',
125
- '@graphql-eslint/require-description': 'error',
125
+ '@graphql-eslint/require-description': ['error', { types: true, overrides: { DirectiveDefinition: true } }],
126
126
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
127
127
  '@graphql-eslint/require-id-when-available': 'error',
128
128
  '@graphql-eslint/selection-set-depth': 'error',
@@ -1595,11 +1595,11 @@ const rule$8 = {
1595
1595
  properties: {
1596
1596
  types: {
1597
1597
  ...schemaOption$1,
1598
- description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1598
+ description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
1599
1599
  },
1600
1600
  fields: {
1601
1601
  ...schemaOption$1,
1602
- description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1602
+ description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
1603
1603
  },
1604
1604
  allowLeadingUnderscore: {
1605
1605
  type: 'boolean',
@@ -1615,7 +1615,7 @@ const rule$8 = {
1615
1615
  description: [
1616
1616
  'May contain the following `ASTNode` names:',
1617
1617
  '',
1618
- ...ALLOWED_KINDS.map(kind => `- \`${kind}\``),
1618
+ ...ALLOWED_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`),
1619
1619
  '',
1620
1620
  "> It's also possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with `ASTNode` name",
1621
1621
  '>',
@@ -2588,41 +2588,23 @@ const rule$i = {
2588
2588
  };
2589
2589
 
2590
2590
  const REQUIRE_DESCRIPTION_ERROR = 'REQUIRE_DESCRIPTION_ERROR';
2591
- const DESCRIBABLE_NODES = [
2592
- graphql.Kind.SCHEMA_DEFINITION,
2593
- graphql.Kind.OBJECT_TYPE_DEFINITION,
2591
+ const ALLOWED_KINDS$1 = [
2592
+ ...TYPES_KINDS,
2594
2593
  graphql.Kind.FIELD_DEFINITION,
2595
2594
  graphql.Kind.INPUT_VALUE_DEFINITION,
2596
- graphql.Kind.INTERFACE_TYPE_DEFINITION,
2597
- graphql.Kind.UNION_TYPE_DEFINITION,
2598
- graphql.Kind.ENUM_TYPE_DEFINITION,
2599
2595
  graphql.Kind.ENUM_VALUE_DEFINITION,
2600
- graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
2601
2596
  graphql.Kind.DIRECTIVE_DEFINITION,
2602
2597
  ];
2603
- function verifyRule(context, node) {
2604
- if (node) {
2605
- if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
2606
- context.report({
2607
- loc: getLocation(('name' in node ? node.name : node).loc, 'name' in node ? node.name.value : 'schema'),
2608
- messageId: REQUIRE_DESCRIPTION_ERROR,
2609
- data: {
2610
- nodeType: node.kind,
2611
- },
2612
- });
2613
- }
2614
- }
2615
- }
2616
2598
  const rule$j = {
2617
2599
  meta: {
2618
2600
  docs: {
2619
2601
  category: 'Best Practices',
2620
- description: `Enforce descriptions in your type definitions.`,
2621
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/require-description.md`,
2602
+ description: 'Enforce descriptions in your type definitions.',
2603
+ url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/require-description.md',
2622
2604
  examples: [
2623
2605
  {
2624
2606
  title: 'Incorrect',
2625
- usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
2607
+ usage: [{ types: true, overrides: { FieldDefinition: true } }],
2626
2608
  code: /* GraphQL */ `
2627
2609
  type someTypeName {
2628
2610
  name: String
@@ -2631,7 +2613,7 @@ const rule$j = {
2631
2613
  },
2632
2614
  {
2633
2615
  title: 'Correct',
2634
- usage: [{ on: [graphql.Kind.OBJECT_TYPE_DEFINITION, graphql.Kind.FIELD_DEFINITION] }],
2616
+ usage: [{ types: true, overrides: { FieldDefinition: true } }],
2635
2617
  code: /* GraphQL */ `
2636
2618
  """
2637
2619
  Some type description
@@ -2645,35 +2627,69 @@ const rule$j = {
2645
2627
  `,
2646
2628
  },
2647
2629
  ],
2630
+ optionsForConfig: [
2631
+ {
2632
+ types: true,
2633
+ overrides: {
2634
+ [graphql.Kind.DIRECTIVE_DEFINITION]: true,
2635
+ },
2636
+ },
2637
+ ],
2648
2638
  },
2649
2639
  type: 'suggestion',
2650
2640
  messages: {
2651
- [REQUIRE_DESCRIPTION_ERROR]: `Description is required for nodes of type "{{ nodeType }}"`,
2641
+ [REQUIRE_DESCRIPTION_ERROR]: 'Description is required for nodes of type "{{ nodeType }}"',
2652
2642
  },
2653
2643
  schema: {
2654
2644
  type: 'array',
2655
- additionalItems: false,
2656
2645
  minItems: 1,
2657
2646
  maxItems: 1,
2658
2647
  items: {
2659
2648
  type: 'object',
2660
- require: ['on'],
2649
+ additionalProperties: false,
2650
+ minProperties: 1,
2661
2651
  properties: {
2662
- on: {
2663
- type: 'array',
2664
- minItems: 1,
2665
- additionalItems: false,
2666
- items: {
2667
- type: 'string',
2668
- enum: DESCRIBABLE_NODES,
2669
- },
2652
+ types: {
2653
+ type: 'boolean',
2654
+ description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
2655
+ },
2656
+ overrides: {
2657
+ type: 'object',
2658
+ description: 'Configuration for precise `ASTNode`',
2659
+ additionalProperties: false,
2660
+ properties: Object.fromEntries(ALLOWED_KINDS$1.map(kind => [kind, { type: 'boolean' }])),
2670
2661
  },
2671
2662
  },
2672
2663
  },
2673
2664
  },
2674
2665
  },
2675
2666
  create(context) {
2676
- return Object.fromEntries(context.options[0].on.map(optionKey => [optionKey, node => verifyRule(context, node)]));
2667
+ const { types, overrides = {} } = context.options[0];
2668
+ const kinds = new Set(types ? TYPES_KINDS : []);
2669
+ for (const [kind, isEnabled] of Object.entries(overrides)) {
2670
+ if (isEnabled) {
2671
+ kinds.add(kind);
2672
+ }
2673
+ else {
2674
+ kinds.delete(kind);
2675
+ }
2676
+ }
2677
+ const selector = [...kinds].join(',');
2678
+ return {
2679
+ [selector](node) {
2680
+ var _a;
2681
+ const description = ((_a = node.description) === null || _a === void 0 ? void 0 : _a.value) || '';
2682
+ if (description.trim().length === 0) {
2683
+ context.report({
2684
+ loc: getLocation(node.name.loc, node.name.value),
2685
+ messageId: REQUIRE_DESCRIPTION_ERROR,
2686
+ data: {
2687
+ nodeType: node.kind,
2688
+ },
2689
+ });
2690
+ }
2691
+ },
2692
+ };
2677
2693
  },
2678
2694
  };
2679
2695
 
package/index.mjs CHANGED
@@ -116,7 +116,7 @@ const allConfig = {
116
116
  '@graphql-eslint/no-unreachable-types': 'error',
117
117
  '@graphql-eslint/no-unused-fields': 'error',
118
118
  '@graphql-eslint/require-deprecation-date': 'error',
119
- '@graphql-eslint/require-description': 'error',
119
+ '@graphql-eslint/require-description': ['error', { types: true, overrides: { DirectiveDefinition: true } }],
120
120
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
121
121
  '@graphql-eslint/require-id-when-available': 'error',
122
122
  '@graphql-eslint/selection-set-depth': 'error',
@@ -1589,11 +1589,11 @@ const rule$8 = {
1589
1589
  properties: {
1590
1590
  types: {
1591
1591
  ...schemaOption$1,
1592
- description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1592
+ description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
1593
1593
  },
1594
1594
  fields: {
1595
1595
  ...schemaOption$1,
1596
- description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1596
+ description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
1597
1597
  },
1598
1598
  allowLeadingUnderscore: {
1599
1599
  type: 'boolean',
@@ -1609,7 +1609,7 @@ const rule$8 = {
1609
1609
  description: [
1610
1610
  'May contain the following `ASTNode` names:',
1611
1611
  '',
1612
- ...ALLOWED_KINDS.map(kind => `- \`${kind}\``),
1612
+ ...ALLOWED_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`),
1613
1613
  '',
1614
1614
  "> It's also possible to use a [`selector`](https://eslint.org/docs/developer-guide/selectors) that starts with `ASTNode` name",
1615
1615
  '>',
@@ -2582,41 +2582,23 @@ const rule$i = {
2582
2582
  };
2583
2583
 
2584
2584
  const REQUIRE_DESCRIPTION_ERROR = 'REQUIRE_DESCRIPTION_ERROR';
2585
- const DESCRIBABLE_NODES = [
2586
- Kind.SCHEMA_DEFINITION,
2587
- Kind.OBJECT_TYPE_DEFINITION,
2585
+ const ALLOWED_KINDS$1 = [
2586
+ ...TYPES_KINDS,
2588
2587
  Kind.FIELD_DEFINITION,
2589
2588
  Kind.INPUT_VALUE_DEFINITION,
2590
- Kind.INTERFACE_TYPE_DEFINITION,
2591
- Kind.UNION_TYPE_DEFINITION,
2592
- Kind.ENUM_TYPE_DEFINITION,
2593
2589
  Kind.ENUM_VALUE_DEFINITION,
2594
- Kind.INPUT_OBJECT_TYPE_DEFINITION,
2595
2590
  Kind.DIRECTIVE_DEFINITION,
2596
2591
  ];
2597
- function verifyRule(context, node) {
2598
- if (node) {
2599
- if (!node.description || !node.description.value || node.description.value.trim().length === 0) {
2600
- context.report({
2601
- loc: getLocation(('name' in node ? node.name : node).loc, 'name' in node ? node.name.value : 'schema'),
2602
- messageId: REQUIRE_DESCRIPTION_ERROR,
2603
- data: {
2604
- nodeType: node.kind,
2605
- },
2606
- });
2607
- }
2608
- }
2609
- }
2610
2592
  const rule$j = {
2611
2593
  meta: {
2612
2594
  docs: {
2613
2595
  category: 'Best Practices',
2614
- description: `Enforce descriptions in your type definitions.`,
2615
- url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/require-description.md`,
2596
+ description: 'Enforce descriptions in your type definitions.',
2597
+ url: 'https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/require-description.md',
2616
2598
  examples: [
2617
2599
  {
2618
2600
  title: 'Incorrect',
2619
- usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
2601
+ usage: [{ types: true, overrides: { FieldDefinition: true } }],
2620
2602
  code: /* GraphQL */ `
2621
2603
  type someTypeName {
2622
2604
  name: String
@@ -2625,7 +2607,7 @@ const rule$j = {
2625
2607
  },
2626
2608
  {
2627
2609
  title: 'Correct',
2628
- usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }],
2610
+ usage: [{ types: true, overrides: { FieldDefinition: true } }],
2629
2611
  code: /* GraphQL */ `
2630
2612
  """
2631
2613
  Some type description
@@ -2639,35 +2621,69 @@ const rule$j = {
2639
2621
  `,
2640
2622
  },
2641
2623
  ],
2624
+ optionsForConfig: [
2625
+ {
2626
+ types: true,
2627
+ overrides: {
2628
+ [Kind.DIRECTIVE_DEFINITION]: true,
2629
+ },
2630
+ },
2631
+ ],
2642
2632
  },
2643
2633
  type: 'suggestion',
2644
2634
  messages: {
2645
- [REQUIRE_DESCRIPTION_ERROR]: `Description is required for nodes of type "{{ nodeType }}"`,
2635
+ [REQUIRE_DESCRIPTION_ERROR]: 'Description is required for nodes of type "{{ nodeType }}"',
2646
2636
  },
2647
2637
  schema: {
2648
2638
  type: 'array',
2649
- additionalItems: false,
2650
2639
  minItems: 1,
2651
2640
  maxItems: 1,
2652
2641
  items: {
2653
2642
  type: 'object',
2654
- require: ['on'],
2643
+ additionalProperties: false,
2644
+ minProperties: 1,
2655
2645
  properties: {
2656
- on: {
2657
- type: 'array',
2658
- minItems: 1,
2659
- additionalItems: false,
2660
- items: {
2661
- type: 'string',
2662
- enum: DESCRIBABLE_NODES,
2663
- },
2646
+ types: {
2647
+ type: 'boolean',
2648
+ description: `Includes:\n\n${TYPES_KINDS.map(kind => `- [${kind}](https://spec.graphql.org/October2021/#${kind})`).join('\n')}`,
2649
+ },
2650
+ overrides: {
2651
+ type: 'object',
2652
+ description: 'Configuration for precise `ASTNode`',
2653
+ additionalProperties: false,
2654
+ properties: Object.fromEntries(ALLOWED_KINDS$1.map(kind => [kind, { type: 'boolean' }])),
2664
2655
  },
2665
2656
  },
2666
2657
  },
2667
2658
  },
2668
2659
  },
2669
2660
  create(context) {
2670
- return Object.fromEntries(context.options[0].on.map(optionKey => [optionKey, node => verifyRule(context, node)]));
2661
+ const { types, overrides = {} } = context.options[0];
2662
+ const kinds = new Set(types ? TYPES_KINDS : []);
2663
+ for (const [kind, isEnabled] of Object.entries(overrides)) {
2664
+ if (isEnabled) {
2665
+ kinds.add(kind);
2666
+ }
2667
+ else {
2668
+ kinds.delete(kind);
2669
+ }
2670
+ }
2671
+ const selector = [...kinds].join(',');
2672
+ return {
2673
+ [selector](node) {
2674
+ var _a;
2675
+ const description = ((_a = node.description) === null || _a === void 0 ? void 0 : _a.value) || '';
2676
+ if (description.trim().length === 0) {
2677
+ context.report({
2678
+ loc: getLocation(node.name.loc, node.name.value),
2679
+ messageId: REQUIRE_DESCRIPTION_ERROR,
2680
+ data: {
2681
+ nodeType: node.kind,
2682
+ },
2683
+ });
2684
+ }
2685
+ },
2686
+ };
2671
2687
  },
2672
2688
  };
2673
2689
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.0.0-alpha-069461d.0",
3
+ "version": "3.0.0-alpha-0a66b90.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 || ^16.0.0"
package/rules/index.d.ts CHANGED
@@ -171,7 +171,19 @@ export declare const rules: {
171
171
  }], false>;
172
172
  'require-deprecation-reason': import("..").GraphQLESLintRule<any[], false>;
173
173
  'require-description': import("..").GraphQLESLintRule<[{
174
- on: import("graphql").Kind[];
174
+ types?: boolean;
175
+ overrides?: {
176
+ ScalarTypeDefinition?: boolean;
177
+ ObjectTypeDefinition?: boolean;
178
+ FieldDefinition?: boolean;
179
+ InputValueDefinition?: boolean;
180
+ InterfaceTypeDefinition?: boolean;
181
+ UnionTypeDefinition?: boolean;
182
+ EnumTypeDefinition?: boolean;
183
+ EnumValueDefinition?: boolean;
184
+ InputObjectTypeDefinition?: boolean;
185
+ DirectiveDefinition?: boolean;
186
+ };
175
187
  }], false>;
176
188
  'require-field-of-type-query-in-mutation-result': import("..").GraphQLESLintRule<any[], false>;
177
189
  'require-id-when-available': import("..").GraphQLESLintRule<[{
@@ -1,8 +1,12 @@
1
- import { GraphQLESLintRule } from '../types';
2
1
  import { Kind } from 'graphql';
3
- declare const DESCRIBABLE_NODES: Kind[];
4
- declare type RequireDescriptionRuleConfig = [{
5
- on: typeof DESCRIBABLE_NODES;
6
- }];
7
- declare const rule: GraphQLESLintRule<RequireDescriptionRuleConfig>;
2
+ import { GraphQLESLintRule } from '../types';
3
+ declare const ALLOWED_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION, Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ENUM_VALUE_DEFINITION, Kind.DIRECTIVE_DEFINITION];
4
+ declare type AllowedKind = typeof ALLOWED_KINDS[number];
5
+ declare type RequireDescriptionRuleConfig = {
6
+ types?: boolean;
7
+ overrides?: {
8
+ [key in AllowedKind]?: boolean;
9
+ };
10
+ };
11
+ declare const rule: GraphQLESLintRule<[RequireDescriptionRuleConfig]>;
8
12
  export default rule;
package/utils.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare const normalizePath: (path: string) => string;
19
19
  export declare const getOnDiskFilepath: (filepath: string) => string;
20
20
  export declare const getTypeName: (node: any) => any;
21
21
  export declare const loaderCache: Record<string, LoaderSource[]>;
22
- export declare const TYPES_KINDS: Kind[];
22
+ export declare const TYPES_KINDS: readonly [Kind.OBJECT_TYPE_DEFINITION, Kind.INTERFACE_TYPE_DEFINITION, Kind.ENUM_TYPE_DEFINITION, Kind.SCALAR_TYPE_DEFINITION, Kind.INPUT_OBJECT_TYPE_DEFINITION, Kind.UNION_TYPE_DEFINITION];
23
23
  export declare enum CaseStyle {
24
24
  camelCase = "camelCase",
25
25
  pascalCase = "PascalCase",