Skip to content

Commit 174a66f

Browse files
[naming-convention] Update property schema to accept objects. Add prefix and suffix option (#201)
Co-authored-by: Dotan Simha <[email protected]>
1 parent 5e1bbe6 commit 174a66f

File tree

7 files changed

+301
-118
lines changed

7 files changed

+301
-118
lines changed

.changeset/fuzzy-mice-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': minor
3+
---
4+
5+
[naming-convention] Allow each definition to take either a strng or object. Object can take the following keys: style (naming style), prefix (value must have prefix) and suffix (value must have suffix)

docs/rules/naming-convention.md

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,104 +37,82 @@ The schema defines an array with all elements of the type `object`.
3737

3838
The array object has the following properties:
3939

40-
#### `FieldDefinition` (string, enum)
40+
#### `FieldDefinition`
4141

42-
This element must be one of the following enum values:
42+
The object must be one of the following types:
4343

44-
* `camelCase`
45-
* `PascalCase`
46-
* `snake_case`
47-
* `UPPER_CASE`
44+
* `asString`
45+
* `asObject`
4846

49-
#### `InputObjectTypeDefinition` (string, enum)
47+
#### `InputObjectTypeDefinition`
5048

51-
This element must be one of the following enum values:
49+
The object must be one of the following types:
5250

53-
* `camelCase`
54-
* `PascalCase`
55-
* `snake_case`
56-
* `UPPER_CASE`
51+
* `asString`
52+
* `asObject`
5753

58-
#### `EnumValueDefinition` (string, enum)
54+
#### `EnumValueDefinition`
5955

60-
This element must be one of the following enum values:
56+
The object must be one of the following types:
6157

62-
* `camelCase`
63-
* `PascalCase`
64-
* `snake_case`
65-
* `UPPER_CASE`
58+
* `asString`
59+
* `asObject`
6660

67-
#### `InputValueDefinition` (string, enum)
61+
#### `InputValueDefinition`
6862

69-
This element must be one of the following enum values:
63+
The object must be one of the following types:
7064

71-
* `camelCase`
72-
* `PascalCase`
73-
* `snake_case`
74-
* `UPPER_CASE`
65+
* `asString`
66+
* `asObject`
7567

76-
#### `ObjectTypeDefinition` (string, enum)
68+
#### `ObjectTypeDefinition`
7769

78-
This element must be one of the following enum values:
70+
The object must be one of the following types:
7971

80-
* `camelCase`
81-
* `PascalCase`
82-
* `snake_case`
83-
* `UPPER_CASE`
72+
* `asString`
73+
* `asObject`
8474

85-
#### `InterfaceTypeDefinition` (string, enum)
75+
#### `InterfaceTypeDefinition`
8676

87-
This element must be one of the following enum values:
77+
The object must be one of the following types:
8878

89-
* `camelCase`
90-
* `PascalCase`
91-
* `snake_case`
92-
* `UPPER_CASE`
79+
* `asString`
80+
* `asObject`
9381

94-
#### `EnumTypeDefinition` (string, enum)
82+
#### `EnumTypeDefinition`
9583

96-
This element must be one of the following enum values:
84+
The object must be one of the following types:
9785

98-
* `camelCase`
99-
* `PascalCase`
100-
* `snake_case`
101-
* `UPPER_CASE`
86+
* `asString`
87+
* `asObject`
10288

103-
#### `UnionTypeDefinition` (string, enum)
89+
#### `UnionTypeDefinition`
10490

105-
This element must be one of the following enum values:
91+
The object must be one of the following types:
10692

107-
* `camelCase`
108-
* `PascalCase`
109-
* `snake_case`
110-
* `UPPER_CASE`
93+
* `asString`
94+
* `asObject`
11195

112-
#### `ScalarTypeDefinition` (string, enum)
96+
#### `ScalarTypeDefinition`
11397

114-
This element must be one of the following enum values:
98+
The object must be one of the following types:
11599

116-
* `camelCase`
117-
* `PascalCase`
118-
* `snake_case`
119-
* `UPPER_CASE`
100+
* `asString`
101+
* `asObject`
120102

121-
#### `OperationDefinition` (string, enum)
103+
#### `OperationDefinition`
122104

123-
This element must be one of the following enum values:
105+
The object must be one of the following types:
124106

125-
* `camelCase`
126-
* `PascalCase`
127-
* `snake_case`
128-
* `UPPER_CASE`
107+
* `asString`
108+
* `asObject`
129109

130-
#### `FragmentDefinition` (string, enum)
110+
#### `FragmentDefinition`
131111

132-
This element must be one of the following enum values:
112+
The object must be one of the following types:
133113

134-
* `camelCase`
135-
* `PascalCase`
136-
* `snake_case`
137-
* `UPPER_CASE`
114+
* `asString`
115+
* `asObject`
138116

139117
#### `leadingUnderscore` (string, enum)
140118

@@ -152,4 +130,31 @@ This element must be one of the following enum values:
152130
* `allow`
153131
* `forbid`
154132

155-
Default: `"forbid"`
133+
Default: `"forbid"`
134+
135+
---
136+
137+
# Sub Schemas
138+
139+
The schema defines the following additional types:
140+
141+
## `asString` (string)
142+
143+
One of: `camelCase`, `PascalCase`, `snake_case`, `UPPER_CASE`
144+
145+
## `asObject` (object)
146+
147+
Properties of the `asObject` object:
148+
149+
### `style` (string, enum)
150+
151+
This element must be one of the following enum values:
152+
153+
* `camelCase`
154+
* `PascalCase`
155+
* `snake_case`
156+
* `UPPER_CASE`
157+
158+
### `prefix` (string)
159+
160+
### `suffix` (string)

docs/rules/require-description.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,20 @@ type someTypeName {
3737

3838
## Config Schema
3939

40-
The schema defines the following properties:
40+
### (array)
41+
42+
The schema defines an array with all elements of the type `object`.
43+
44+
The array object has the following properties:
45+
46+
#### `on` (array)
47+
48+
The object is an array with all elements of the type `string`.
49+
50+
Additional restrictions:
51+
52+
* Minimum items: `1`
53+
54+
Additional restrictions:
55+
56+
* Minimum items: `1`

docs/rules/require-id-when-available.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,12 @@ query user {
5050

5151
## Config Schema
5252

53-
The schema defines the following properties:
53+
### (array)
54+
55+
The schema defines an array with all elements of the type `object`.
56+
57+
The array object has the following properties:
58+
59+
#### `fieldName` (string)
60+
61+
Default: `"id"`

0 commit comments

Comments
 (0)