@graphql-eslint/eslint-plugin 3.0.0-alpha-4613dfe.0 → 3.0.1-alpha-8123ea2.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
@@ -180,17 +180,27 @@ You can find a list of [ESLint directives here](https://eslint.org/docs/2.13.1/u
180
180
 
181
181
  You can find a complete list of [all available rules here](docs/README.md).
182
182
 
183
+ ## Deprecated Rules
184
+
185
+ See [docs/deprecated-rules.md](docs/deprecated-rules.md).
186
+
183
187
  ## Available Configs
184
188
 
185
189
  <!-- prettier-ignore-start -->
186
190
  |Name|Description|
187
191
  |:-:|-|
188
- |[`schema-recommended`](packages/plugin/src/configs/schema-recommended.ts)|enables all recommended rules|
189
- |[`operations-recommended`](packages/plugin/src/configs/operations-recommended.ts) |enables all recommended rules|
190
- |[`schema-all`](packages/plugin/src/configs/schema-all.ts)|enables all rules, except for those that require `parserOptions.operations` option)|
191
- |[`operations-all`](packages/plugin/src/configs/operations-all.ts)|enables all rules|
192
+ |[`schema-recommended`](packages/plugin/src/configs/schema-recommended.ts)|enables recommended rules for schema (SDL) development|
193
+ |[`schema-all`](packages/plugin/src/configs/schema-all.ts)|enables all rules for schema (SDL) development, except for those that require `parserOptions.operations` option|
194
+ |[`operations-recommended`](packages/plugin/src/configs/operations-recommended.ts) |enables recommended rules for consuming GraphQL (operations) development|
195
+ |[`operations-all`](packages/plugin/src/configs/operations-all.ts)|enables all rules for consuming GraphQL (operations) development|
192
196
  <!-- prettier-ignore-end -->
193
197
 
198
+ > If you are in a project that develops the GraphQL schema, you'll need `schema` rules.
199
+
200
+ > If you are in a project that develops GraphQL operations (query/mutation/subscription), you'll need `operations` rules.
201
+
202
+ > If you are in a monorepo project, you probably need both sets of rules.
203
+
194
204
  ## Config usage
195
205
 
196
206
  For example, to enable the `schema-recommended` config, enable it in your `.eslintrc` file with the `extends` option:
@@ -13,7 +13,10 @@ export declare const configs: {
13
13
  '@graphql-eslint/lone-schema-definition': string;
14
14
  '@graphql-eslint/naming-convention': (string | {
15
15
  types: string;
16
- fields: string;
16
+ FieldDefinition: string;
17
+ InputValueDefinition: string;
18
+ Argument: string;
19
+ DirectiveDefinition: string;
17
20
  EnumValueDefinition: string;
18
21
  'FieldDefinition[parent.name.value=Query]': {
19
22
  forbiddenPrefixes: string[];
@@ -32,7 +35,6 @@ export declare const configs: {
32
35
  '@graphql-eslint/no-hashtag-description': string;
33
36
  '@graphql-eslint/no-typename-prefix': string;
34
37
  '@graphql-eslint/no-unreachable-types': string;
35
- '@graphql-eslint/possible-type-extension': string;
36
38
  '@graphql-eslint/provided-required-arguments': string;
37
39
  '@graphql-eslint/require-deprecation-reason': string;
38
40
  '@graphql-eslint/require-description': (string | {
@@ -60,6 +62,7 @@ export declare const configs: {
60
62
  '@graphql-eslint/no-root-type': string;
61
63
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
62
64
  '@graphql-eslint/no-unused-fields': string;
65
+ '@graphql-eslint/possible-type-extension': string;
63
66
  '@graphql-eslint/require-deprecation-date': string;
64
67
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
65
68
  };
@@ -76,7 +79,6 @@ export declare const configs: {
76
79
  '@graphql-eslint/known-type-names': string;
77
80
  '@graphql-eslint/lone-anonymous-operation': string;
78
81
  '@graphql-eslint/naming-convention': (string | {
79
- Argument: string;
80
82
  VariableDefinition: string;
81
83
  OperationDefinition: {
82
84
  style: string;
@@ -10,7 +10,6 @@ declare const _default: {
10
10
  '@graphql-eslint/known-type-names': string;
11
11
  '@graphql-eslint/lone-anonymous-operation': string;
12
12
  '@graphql-eslint/naming-convention': (string | {
13
- Argument: string;
14
13
  VariableDefinition: string;
15
14
  OperationDefinition: {
16
15
  style: string;
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  '@graphql-eslint/no-root-type': string;
11
11
  '@graphql-eslint/no-scalar-result-type-on-mutation': string;
12
12
  '@graphql-eslint/no-unused-fields': string;
13
+ '@graphql-eslint/possible-type-extension': string;
13
14
  '@graphql-eslint/require-deprecation-date': string;
14
15
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': string;
15
16
  };
@@ -8,7 +8,10 @@ declare const _default: {
8
8
  '@graphql-eslint/lone-schema-definition': string;
9
9
  '@graphql-eslint/naming-convention': (string | {
10
10
  types: string;
11
- fields: string;
11
+ FieldDefinition: string;
12
+ InputValueDefinition: string;
13
+ Argument: string;
14
+ DirectiveDefinition: string;
12
15
  EnumValueDefinition: string;
13
16
  'FieldDefinition[parent.name.value=Query]': {
14
17
  forbiddenPrefixes: string[];
@@ -27,7 +30,6 @@ declare const _default: {
27
30
  '@graphql-eslint/no-hashtag-description': string;
28
31
  '@graphql-eslint/no-typename-prefix': string;
29
32
  '@graphql-eslint/no-unreachable-types': string;
30
- '@graphql-eslint/possible-type-extension': string;
31
33
  '@graphql-eslint/provided-required-arguments': string;
32
34
  '@graphql-eslint/require-deprecation-reason': string;
33
35
  '@graphql-eslint/require-description': (string | {
package/docs/README.md CHANGED
@@ -42,7 +42,7 @@ Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
42
42
  [one-field-subscriptions](rules/one-field-subscriptions.md)|A GraphQL subscription is valid only if it contains a single root field.|🔮||✅
43
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.|🔮||✅
44
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.|🔮||✅
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.|🔮||✅
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
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.|🔮||✅
47
47
  [require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|🚀||
48
48
  [require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|🚀||✅
@@ -14,7 +14,7 @@ Require names to follow specified conventions.
14
14
  ### Incorrect
15
15
 
16
16
  ```graphql
17
- # eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', fields: 'camelCase' }]
17
+ # eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
18
18
 
19
19
  type user {
20
20
  first_name: String!
@@ -44,7 +44,7 @@ type Query {
44
44
  ### Correct
45
45
 
46
46
  ```graphql
47
- # eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', fields: 'camelCase' }]
47
+ # eslint @graphql-eslint/naming-convention: ['error', { types: 'PascalCase', FieldDefinition: 'camelCase' }]
48
48
 
49
49
  type User {
50
50
  firstName: String
@@ -97,20 +97,6 @@ The object must be one of the following types:
97
97
  * `asString`
98
98
  * `asObject`
99
99
 
100
- ### `fields`
101
-
102
- Includes:
103
-
104
- - `FieldDefinition`
105
- - `InputValueDefinition`
106
- - `Argument`
107
- - `DirectiveDefinition`
108
-
109
- The object must be one of the following types:
110
-
111
- * `asString`
112
- * `asObject`
113
-
114
100
  ### `Argument`
115
101
 
116
102
  Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#Argument).
@@ -1,7 +1,5 @@
1
1
  # `possible-type-extension`
2
2
 
3
- ✅ The `"extends": "plugin:@graphql-eslint/schema-recommended"` property in a configuration file enables this rule.
4
-
5
3
  - Category: `Schema`
6
4
  - Rule name: `@graphql-eslint/possible-type-extension`
7
5
  - Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
package/index.js CHANGED
@@ -38,7 +38,10 @@ const schemaRecommendedConfig = {
38
38
  'error',
39
39
  {
40
40
  types: 'PascalCase',
41
- fields: 'camelCase',
41
+ FieldDefinition: 'camelCase',
42
+ InputValueDefinition: 'camelCase',
43
+ Argument: 'camelCase',
44
+ DirectiveDefinition: 'camelCase',
42
45
  EnumValueDefinition: 'UPPER_CASE',
43
46
  'FieldDefinition[parent.name.value=Query]': {
44
47
  forbiddenPrefixes: ['query', 'get'],
@@ -58,7 +61,6 @@ const schemaRecommendedConfig = {
58
61
  '@graphql-eslint/no-hashtag-description': 'error',
59
62
  '@graphql-eslint/no-typename-prefix': 'error',
60
63
  '@graphql-eslint/no-unreachable-types': 'error',
61
- '@graphql-eslint/possible-type-extension': 'error',
62
64
  '@graphql-eslint/provided-required-arguments': 'error',
63
65
  '@graphql-eslint/require-deprecation-reason': 'error',
64
66
  '@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
@@ -90,6 +92,7 @@ const schemaAllConfig = {
90
92
  '@graphql-eslint/no-root-type': 'off',
91
93
  '@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
92
94
  '@graphql-eslint/no-unused-fields': 'off',
95
+ '@graphql-eslint/possible-type-extension': 'off',
93
96
  '@graphql-eslint/require-deprecation-date': 'error',
94
97
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
95
98
  },
@@ -112,7 +115,6 @@ const operationsRecommendedConfig = {
112
115
  '@graphql-eslint/naming-convention': [
113
116
  'error',
114
117
  {
115
- Argument: 'camelCase',
116
118
  VariableDefinition: 'camelCase',
117
119
  OperationDefinition: {
118
120
  style: 'PascalCase',
@@ -385,9 +387,9 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
385
387
  [name]: {
386
388
  meta: {
387
389
  docs: {
390
+ recommended: true,
388
391
  ...docs,
389
392
  graphQLJSRuleName: ruleName,
390
- recommended: true,
391
393
  requiresSchema,
392
394
  url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${name}.md`,
393
395
  description: `${docs.description}\n\n> This rule is a wrapper around a \`graphql-js\` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${ruleName}Rule.ts).`,
@@ -563,6 +565,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
563
565
  category: 'Schema',
564
566
  description: `A type extension is only valid if the type is defined and has the same kind.`,
565
567
  requiresSchema: false,
568
+ recommended: false, // TODO: enable after https://github.com/dotansimha/graphql-eslint/issues/787 will be fixed
566
569
  }), validationToRule('provided-required-arguments', 'ProvidedRequiredArguments', {
567
570
  category: ['Schema', 'Operations'],
568
571
  description: `A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.`,
@@ -1248,7 +1251,6 @@ const rule$3 = {
1248
1251
  },
1249
1252
  };
1250
1253
 
1251
- const FIELDS_KINDS = [graphql.Kind.FIELD_DEFINITION, graphql.Kind.INPUT_VALUE_DEFINITION, graphql.Kind.ARGUMENT, graphql.Kind.DIRECTIVE_DEFINITION];
1252
1254
  const KindToDisplayName = {
1253
1255
  // types
1254
1256
  [graphql.Kind.OBJECT_TYPE_DEFINITION]: 'Type',
@@ -1290,7 +1292,7 @@ const rule$4 = {
1290
1292
  examples: [
1291
1293
  {
1292
1294
  title: 'Incorrect',
1293
- usage: [{ types: 'PascalCase', fields: 'camelCase' }],
1295
+ usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
1294
1296
  code: /* GraphQL */ `
1295
1297
  type user {
1296
1298
  first_name: String!
@@ -1317,7 +1319,7 @@ const rule$4 = {
1317
1319
  },
1318
1320
  {
1319
1321
  title: 'Correct',
1320
- usage: [{ types: 'PascalCase', fields: 'camelCase' }],
1322
+ usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
1321
1323
  code: /* GraphQL */ `
1322
1324
  type User {
1323
1325
  firstName: String
@@ -1347,7 +1349,10 @@ const rule$4 = {
1347
1349
  schema: [
1348
1350
  {
1349
1351
  types: 'PascalCase',
1350
- fields: 'camelCase',
1352
+ FieldDefinition: 'camelCase',
1353
+ InputValueDefinition: 'camelCase',
1354
+ Argument: 'camelCase',
1355
+ DirectiveDefinition: 'camelCase',
1351
1356
  EnumValueDefinition: 'UPPER_CASE',
1352
1357
  'FieldDefinition[parent.name.value=Query]': {
1353
1358
  forbiddenPrefixes: ['query', 'get'],
@@ -1365,7 +1370,6 @@ const rule$4 = {
1365
1370
  ],
1366
1371
  operations: [
1367
1372
  {
1368
- Argument: 'camelCase',
1369
1373
  VariableDefinition: 'camelCase',
1370
1374
  OperationDefinition: {
1371
1375
  style: 'PascalCase',
@@ -1419,10 +1423,6 @@ const rule$4 = {
1419
1423
  ...schemaOption$1,
1420
1424
  description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1421
1425
  },
1422
- fields: {
1423
- ...schemaOption$1,
1424
- description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1425
- },
1426
1426
  ...Object.fromEntries(ALLOWED_KINDS.map(kind => [
1427
1427
  kind,
1428
1428
  {
@@ -1454,12 +1454,9 @@ const rule$4 = {
1454
1454
  },
1455
1455
  create(context) {
1456
1456
  const options = context.options[0] || {};
1457
- const { allowLeadingUnderscore, allowTrailingUnderscore, types, fields, ...restOptions } = options;
1457
+ const { allowLeadingUnderscore, allowTrailingUnderscore, types, ...restOptions } = options;
1458
1458
  function normalisePropertyOption(kind) {
1459
- let style = options[kind];
1460
- if (!style) {
1461
- style = TYPES_KINDS.includes(kind) ? types : fields;
1462
- }
1459
+ const style = restOptions[kind] || types;
1463
1460
  return typeof style === 'object' ? style : { style };
1464
1461
  }
1465
1462
  const checkNode = (selector) => (node) => {
@@ -1522,7 +1519,7 @@ const rule$4 = {
1522
1519
  if (!allowTrailingUnderscore) {
1523
1520
  listeners['Name[value=/_$/]:matches([parent.kind!=Field], [parent.kind=Field][parent.alias])'] = checkUnderscore;
1524
1521
  }
1525
- const selectors = new Set([types && TYPES_KINDS, fields && FIELDS_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
1522
+ const selectors = new Set([types && TYPES_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
1526
1523
  for (const selector of selectors) {
1527
1524
  listeners[selector] = checkNode(selector);
1528
1525
  }
@@ -2044,13 +2041,11 @@ const rule$b = {
2044
2041
  }
2045
2042
  const selector = [
2046
2043
  `:matches(${graphql.Kind.OBJECT_TYPE_DEFINITION}, ${graphql.Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
2047
- '>',
2048
- graphql.Kind.FIELD_DEFINITION,
2049
- graphql.Kind.NAMED_TYPE,
2044
+ `> ${graphql.Kind.FIELD_DEFINITION} > .gqlType ${graphql.Kind.NAME}`,
2050
2045
  ].join(' ');
2051
2046
  return {
2052
2047
  [selector](node) {
2053
- const typeName = node.name.value;
2048
+ const typeName = node.value;
2054
2049
  const graphQLType = schema.getType(typeName);
2055
2050
  if (graphql.isScalarType(graphQLType)) {
2056
2051
  context.report({
package/index.mjs CHANGED
@@ -32,7 +32,10 @@ const schemaRecommendedConfig = {
32
32
  'error',
33
33
  {
34
34
  types: 'PascalCase',
35
- fields: 'camelCase',
35
+ FieldDefinition: 'camelCase',
36
+ InputValueDefinition: 'camelCase',
37
+ Argument: 'camelCase',
38
+ DirectiveDefinition: 'camelCase',
36
39
  EnumValueDefinition: 'UPPER_CASE',
37
40
  'FieldDefinition[parent.name.value=Query]': {
38
41
  forbiddenPrefixes: ['query', 'get'],
@@ -52,7 +55,6 @@ const schemaRecommendedConfig = {
52
55
  '@graphql-eslint/no-hashtag-description': 'error',
53
56
  '@graphql-eslint/no-typename-prefix': 'error',
54
57
  '@graphql-eslint/no-unreachable-types': 'error',
55
- '@graphql-eslint/possible-type-extension': 'error',
56
58
  '@graphql-eslint/provided-required-arguments': 'error',
57
59
  '@graphql-eslint/require-deprecation-reason': 'error',
58
60
  '@graphql-eslint/require-description': ['error', { types: true, DirectiveDefinition: true }],
@@ -84,6 +86,7 @@ const schemaAllConfig = {
84
86
  '@graphql-eslint/no-root-type': 'off',
85
87
  '@graphql-eslint/no-scalar-result-type-on-mutation': 'error',
86
88
  '@graphql-eslint/no-unused-fields': 'off',
89
+ '@graphql-eslint/possible-type-extension': 'off',
87
90
  '@graphql-eslint/require-deprecation-date': 'error',
88
91
  '@graphql-eslint/require-field-of-type-query-in-mutation-result': 'error',
89
92
  },
@@ -106,7 +109,6 @@ const operationsRecommendedConfig = {
106
109
  '@graphql-eslint/naming-convention': [
107
110
  'error',
108
111
  {
109
- Argument: 'camelCase',
110
112
  VariableDefinition: 'camelCase',
111
113
  OperationDefinition: {
112
114
  style: 'PascalCase',
@@ -379,9 +381,9 @@ const validationToRule = (name, ruleName, docs, getDocumentNode) => {
379
381
  [name]: {
380
382
  meta: {
381
383
  docs: {
384
+ recommended: true,
382
385
  ...docs,
383
386
  graphQLJSRuleName: ruleName,
384
- recommended: true,
385
387
  requiresSchema,
386
388
  url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${name}.md`,
387
389
  description: `${docs.description}\n\n> This rule is a wrapper around a \`graphql-js\` validation function. [You can find its source code here](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${ruleName}Rule.ts).`,
@@ -557,6 +559,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign({}, validationToRule('executable-de
557
559
  category: 'Schema',
558
560
  description: `A type extension is only valid if the type is defined and has the same kind.`,
559
561
  requiresSchema: false,
562
+ recommended: false, // TODO: enable after https://github.com/dotansimha/graphql-eslint/issues/787 will be fixed
560
563
  }), validationToRule('provided-required-arguments', 'ProvidedRequiredArguments', {
561
564
  category: ['Schema', 'Operations'],
562
565
  description: `A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.`,
@@ -1242,7 +1245,6 @@ const rule$3 = {
1242
1245
  },
1243
1246
  };
1244
1247
 
1245
- const FIELDS_KINDS = [Kind.FIELD_DEFINITION, Kind.INPUT_VALUE_DEFINITION, Kind.ARGUMENT, Kind.DIRECTIVE_DEFINITION];
1246
1248
  const KindToDisplayName = {
1247
1249
  // types
1248
1250
  [Kind.OBJECT_TYPE_DEFINITION]: 'Type',
@@ -1284,7 +1286,7 @@ const rule$4 = {
1284
1286
  examples: [
1285
1287
  {
1286
1288
  title: 'Incorrect',
1287
- usage: [{ types: 'PascalCase', fields: 'camelCase' }],
1289
+ usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
1288
1290
  code: /* GraphQL */ `
1289
1291
  type user {
1290
1292
  first_name: String!
@@ -1311,7 +1313,7 @@ const rule$4 = {
1311
1313
  },
1312
1314
  {
1313
1315
  title: 'Correct',
1314
- usage: [{ types: 'PascalCase', fields: 'camelCase' }],
1316
+ usage: [{ types: 'PascalCase', FieldDefinition: 'camelCase' }],
1315
1317
  code: /* GraphQL */ `
1316
1318
  type User {
1317
1319
  firstName: String
@@ -1341,7 +1343,10 @@ const rule$4 = {
1341
1343
  schema: [
1342
1344
  {
1343
1345
  types: 'PascalCase',
1344
- fields: 'camelCase',
1346
+ FieldDefinition: 'camelCase',
1347
+ InputValueDefinition: 'camelCase',
1348
+ Argument: 'camelCase',
1349
+ DirectiveDefinition: 'camelCase',
1345
1350
  EnumValueDefinition: 'UPPER_CASE',
1346
1351
  'FieldDefinition[parent.name.value=Query]': {
1347
1352
  forbiddenPrefixes: ['query', 'get'],
@@ -1359,7 +1364,6 @@ const rule$4 = {
1359
1364
  ],
1360
1365
  operations: [
1361
1366
  {
1362
- Argument: 'camelCase',
1363
1367
  VariableDefinition: 'camelCase',
1364
1368
  OperationDefinition: {
1365
1369
  style: 'PascalCase',
@@ -1413,10 +1417,6 @@ const rule$4 = {
1413
1417
  ...schemaOption$1,
1414
1418
  description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1415
1419
  },
1416
- fields: {
1417
- ...schemaOption$1,
1418
- description: `Includes:\n\n${FIELDS_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
1419
- },
1420
1420
  ...Object.fromEntries(ALLOWED_KINDS.map(kind => [
1421
1421
  kind,
1422
1422
  {
@@ -1448,12 +1448,9 @@ const rule$4 = {
1448
1448
  },
1449
1449
  create(context) {
1450
1450
  const options = context.options[0] || {};
1451
- const { allowLeadingUnderscore, allowTrailingUnderscore, types, fields, ...restOptions } = options;
1451
+ const { allowLeadingUnderscore, allowTrailingUnderscore, types, ...restOptions } = options;
1452
1452
  function normalisePropertyOption(kind) {
1453
- let style = options[kind];
1454
- if (!style) {
1455
- style = TYPES_KINDS.includes(kind) ? types : fields;
1456
- }
1453
+ const style = restOptions[kind] || types;
1457
1454
  return typeof style === 'object' ? style : { style };
1458
1455
  }
1459
1456
  const checkNode = (selector) => (node) => {
@@ -1516,7 +1513,7 @@ const rule$4 = {
1516
1513
  if (!allowTrailingUnderscore) {
1517
1514
  listeners['Name[value=/_$/]:matches([parent.kind!=Field], [parent.kind=Field][parent.alias])'] = checkUnderscore;
1518
1515
  }
1519
- const selectors = new Set([types && TYPES_KINDS, fields && FIELDS_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
1516
+ const selectors = new Set([types && TYPES_KINDS, Object.keys(restOptions)].flat().filter(Boolean));
1520
1517
  for (const selector of selectors) {
1521
1518
  listeners[selector] = checkNode(selector);
1522
1519
  }
@@ -2038,13 +2035,11 @@ const rule$b = {
2038
2035
  }
2039
2036
  const selector = [
2040
2037
  `:matches(${Kind.OBJECT_TYPE_DEFINITION}, ${Kind.OBJECT_TYPE_EXTENSION})[name.value=${mutationType.name}]`,
2041
- '>',
2042
- Kind.FIELD_DEFINITION,
2043
- Kind.NAMED_TYPE,
2038
+ `> ${Kind.FIELD_DEFINITION} > .gqlType ${Kind.NAME}`,
2044
2039
  ].join(' ');
2045
2040
  return {
2046
2041
  [selector](node) {
2047
- const typeName = node.name.value;
2042
+ const typeName = node.value;
2048
2043
  const graphQLType = schema.getType(typeName);
2049
2044
  if (isScalarType(graphQLType)) {
2050
2045
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.0.0-alpha-4613dfe.0",
3
+ "version": "3.0.1-alpha-8123ea2.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
@@ -44,13 +44,6 @@ export declare const rules: {
44
44
  forbiddenPrefixes?: string[];
45
45
  forbiddenSuffixes?: string[];
46
46
  };
47
- fields?: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
48
- style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
49
- suffix?: string;
50
- prefix?: string;
51
- forbiddenPrefixes?: string[];
52
- forbiddenSuffixes?: string[];
53
- };
54
47
  } & {
55
48
  [x: `OperationDefinition${string}`]: ("PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case") | {
56
49
  style?: "PascalCase" | "camelCase" | "UPPER_CASE" | "snake_case";
@@ -29,7 +29,6 @@ declare type NamingConventionRuleConfig = {
29
29
  allowLeadingUnderscore?: boolean;
30
30
  allowTrailingUnderscore?: boolean;
31
31
  types?: Options;
32
- fields?: Options;
33
32
  } & {
34
33
  [key in `${AllowedKind}${string}`]?: Options;
35
34
  };