@graphql-eslint/eslint-plugin 3.7.0-alpha-a9b0ecf.0 → 3.8.0-alpha-998ffa8.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/docs/README.md CHANGED
@@ -44,7 +44,7 @@ Name            &nbs
44
44
  [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][]|🔮
45
45
  [require-deprecation-date](rules/require-deprecation-date.md)|Require deletion date on `@deprecated` directive. Suggest removing deprecated things after deprecated date.|![all][]|🚀
46
46
  [require-deprecation-reason](rules/require-deprecation-reason.md)|Require all deprecation directives to specify a reason.|![recommended][]|🚀
47
- [require-description](rules/require-description.md)|Enforce descriptions in your type definitions.|![recommended][]|🚀
47
+ [require-description](rules/require-description.md)|Enforce descriptions in type definitions and operations.|![recommended][]|🚀
48
48
  [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][]|🚀
49
49
  [require-id-when-available](rules/require-id-when-available.md)|Enforce selecting specific fields when they are available on the GraphQL type.|![recommended][]|🚀
50
50
  [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][]|🔮
@@ -131,7 +131,7 @@ The schema defines the following additional types:
131
131
 
132
132
  ## `asString` (enum)
133
133
 
134
- One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`
134
+ One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`, `kebab-case`, `documentStyle`
135
135
 
136
136
  ## `asObject` (object)
137
137
 
@@ -146,6 +146,7 @@ This element must be one of the following enum values:
146
146
  - `snake_case`
147
147
  - `UPPER_CASE`
148
148
  - `kebab-case`
149
+ - `documentStyle`
149
150
 
150
151
  ### `suffix` (string)
151
152
 
@@ -7,7 +7,7 @@
7
7
  - Requires GraphQL Schema: `false` [â„šī¸](../../README.md#extended-linting-rules-with-graphql-schema)
8
8
  - Requires GraphQL Operations: `false` [â„šī¸](../../README.md#extended-linting-rules-with-siblings-operations)
9
9
 
10
- Enforce descriptions in your type definitions.
10
+ Enforce descriptions in type definitions and operations.
11
11
 
12
12
  ## Usage Examples
13
13
 
@@ -42,9 +42,9 @@ type someTypeName {
42
42
  ```graphql
43
43
  # eslint @graphql-eslint/require-description: ['error', { OperationDefinition: true }]
44
44
 
45
- # Enforce description on operations
46
- query {
47
- foo
45
+ # Create a new user
46
+ mutation createUser {
47
+ # ...
48
48
  }
49
49
  ```
50
50
 
@@ -99,6 +99,8 @@ Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October
99
99
 
100
100
  Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#OperationDefinition).
101
101
 
102
+ > You must use only comment syntax `#` and not description syntax `"""` or `"`.
103
+
102
104
  ### `ScalarTypeDefinition` (boolean)
103
105
 
104
106
  Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#ScalarTypeDefinition).
package/index.js CHANGED
@@ -1098,7 +1098,7 @@ const rule$2 = {
1098
1098
  const MATCH_EXTENSION = 'MATCH_EXTENSION';
1099
1099
  const MATCH_STYLE = 'MATCH_STYLE';
1100
1100
  const ACCEPTED_EXTENSIONS = ['.gql', '.graphql'];
1101
- const CASE_STYLES = ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE', 'kebab-case'];
1101
+ const CASE_STYLES = ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE', 'kebab-case', 'documentStyle'];
1102
1102
  const schemaOption = {
1103
1103
  oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
1104
1104
  };
@@ -1272,7 +1272,14 @@ const rule$3 = {
1272
1272
  option = { style: option };
1273
1273
  }
1274
1274
  const expectedExtension = options.fileExtension || fileExtension;
1275
- const expectedFilename = (option.style ? convertCase(option.style, docName) : filename) + (option.suffix || '') + expectedExtension;
1275
+ let expectedFilename;
1276
+ if (option.style) {
1277
+ expectedFilename = option.style === 'documentStyle' ? docName : convertCase(option.style, docName);
1278
+ }
1279
+ else {
1280
+ expectedFilename = filename;
1281
+ }
1282
+ expectedFilename += (option.suffix || '') + expectedExtension;
1276
1283
  const filenameWithExtension = filename + expectedExtension;
1277
1284
  if (expectedFilename !== filenameWithExtension) {
1278
1285
  context.report({
@@ -2638,7 +2645,7 @@ const rule$h = {
2638
2645
  meta: {
2639
2646
  docs: {
2640
2647
  category: 'Schema',
2641
- description: 'Enforce descriptions in your type definitions.',
2648
+ description: 'Enforce descriptions in type definitions and operations.',
2642
2649
  url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
2643
2650
  examples: [
2644
2651
  {
@@ -2669,9 +2676,9 @@ const rule$h = {
2669
2676
  title: 'Correct',
2670
2677
  usage: [{ OperationDefinition: true }],
2671
2678
  code: /* GraphQL */ `
2672
- # Enforce description on operations
2673
- query {
2674
- foo
2679
+ # Create a new user
2680
+ mutation createUser {
2681
+ # ...
2675
2682
  }
2676
2683
  `,
2677
2684
  },
@@ -2701,13 +2708,13 @@ const rule$h = {
2701
2708
  type: 'boolean',
2702
2709
  description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
2703
2710
  },
2704
- ...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => [
2705
- kind,
2706
- {
2707
- type: 'boolean',
2708
- description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
2709
- },
2710
- ])),
2711
+ ...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
2712
+ let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
2713
+ if (kind === graphql.Kind.OPERATION_DEFINITION) {
2714
+ description += '\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
2715
+ }
2716
+ return [kind, { type: 'boolean', description }];
2717
+ })),
2711
2718
  },
2712
2719
  },
2713
2720
  },
@@ -3775,6 +3782,8 @@ function loadGraphQLConfig(options) {
3775
3782
  const onDiskConfig = options.skipGraphQLConfig
3776
3783
  ? null
3777
3784
  : graphqlConfig.loadConfigSync({
3785
+ // load config relative to the file being linted
3786
+ rootDir: options.filePath ? path.dirname(options.filePath) : undefined,
3778
3787
  throwOnEmpty: false,
3779
3788
  throwOnMissing: false,
3780
3789
  extensions: [addCodeFileLoaderExtension],
package/index.mjs CHANGED
@@ -1092,7 +1092,7 @@ const rule$2 = {
1092
1092
  const MATCH_EXTENSION = 'MATCH_EXTENSION';
1093
1093
  const MATCH_STYLE = 'MATCH_STYLE';
1094
1094
  const ACCEPTED_EXTENSIONS = ['.gql', '.graphql'];
1095
- const CASE_STYLES = ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE', 'kebab-case'];
1095
+ const CASE_STYLES = ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE', 'kebab-case', 'documentStyle'];
1096
1096
  const schemaOption = {
1097
1097
  oneOf: [{ $ref: '#/definitions/asString' }, { $ref: '#/definitions/asObject' }],
1098
1098
  };
@@ -1266,7 +1266,14 @@ const rule$3 = {
1266
1266
  option = { style: option };
1267
1267
  }
1268
1268
  const expectedExtension = options.fileExtension || fileExtension;
1269
- const expectedFilename = (option.style ? convertCase(option.style, docName) : filename) + (option.suffix || '') + expectedExtension;
1269
+ let expectedFilename;
1270
+ if (option.style) {
1271
+ expectedFilename = option.style === 'documentStyle' ? docName : convertCase(option.style, docName);
1272
+ }
1273
+ else {
1274
+ expectedFilename = filename;
1275
+ }
1276
+ expectedFilename += (option.suffix || '') + expectedExtension;
1270
1277
  const filenameWithExtension = filename + expectedExtension;
1271
1278
  if (expectedFilename !== filenameWithExtension) {
1272
1279
  context.report({
@@ -2632,7 +2639,7 @@ const rule$h = {
2632
2639
  meta: {
2633
2640
  docs: {
2634
2641
  category: 'Schema',
2635
- description: 'Enforce descriptions in your type definitions.',
2642
+ description: 'Enforce descriptions in type definitions and operations.',
2636
2643
  url: `https://github.com/dotansimha/graphql-eslint/blob/master/docs/rules/${RULE_ID$2}.md`,
2637
2644
  examples: [
2638
2645
  {
@@ -2663,9 +2670,9 @@ const rule$h = {
2663
2670
  title: 'Correct',
2664
2671
  usage: [{ OperationDefinition: true }],
2665
2672
  code: /* GraphQL */ `
2666
- # Enforce description on operations
2667
- query {
2668
- foo
2673
+ # Create a new user
2674
+ mutation createUser {
2675
+ # ...
2669
2676
  }
2670
2677
  `,
2671
2678
  },
@@ -2695,13 +2702,13 @@ const rule$h = {
2695
2702
  type: 'boolean',
2696
2703
  description: `Includes:\n\n${TYPES_KINDS.map(kind => `- \`${kind}\``).join('\n')}`,
2697
2704
  },
2698
- ...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => [
2699
- kind,
2700
- {
2701
- type: 'boolean',
2702
- description: `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`,
2703
- },
2704
- ])),
2705
+ ...Object.fromEntries([...ALLOWED_KINDS$1].sort().map(kind => {
2706
+ let description = `Read more about this kind on [spec.graphql.org](https://spec.graphql.org/October2021/#${kind}).`;
2707
+ if (kind === Kind.OPERATION_DEFINITION) {
2708
+ description += '\n\n> You must use only comment syntax `#` and not description syntax `"""` or `"`.';
2709
+ }
2710
+ return [kind, { type: 'boolean', description }];
2711
+ })),
2705
2712
  },
2706
2713
  },
2707
2714
  },
@@ -3769,6 +3776,8 @@ function loadGraphQLConfig(options) {
3769
3776
  const onDiskConfig = options.skipGraphQLConfig
3770
3777
  ? null
3771
3778
  : loadConfigSync({
3779
+ // load config relative to the file being linted
3780
+ rootDir: options.filePath ? dirname(options.filePath) : undefined,
3772
3781
  throwOnEmpty: false,
3773
3782
  throwOnMissing: false,
3774
3783
  extensions: [addCodeFileLoaderExtension],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.7.0-alpha-a9b0ecf.0",
3
+ "version": "3.8.0-alpha-998ffa8.0",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -1,5 +1,6 @@
1
- import { CaseStyle } from '../utils';
1
+ import { CaseStyle as _CaseStyle } from '../utils';
2
2
  import { GraphQLESLintRule } from '../types';
3
+ declare type CaseStyle = _CaseStyle | 'documentStyle';
3
4
  declare const ACCEPTED_EXTENSIONS: ['.gql', '.graphql'];
4
5
  declare type PropertySchema = {
5
6
  style?: CaseStyle;