Skip to content

Commit 1d85025

Browse files
Dimitri POSTOLOVdimitridotansimha
authored
fix: allow anonymous operations for naming-convention rule (#436)
* fix: allow anonymous operations for naming-convention rule * added changeset Co-authored-by: dimitri <[email protected]> Co-authored-by: Dotan Simha <[email protected]>
1 parent 45acfde commit 1d85025

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/fuzzy-dolphins-attack.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': patch
3+
---
4+
5+
fix: allow anonymous operations for naming-convention rule

packages/plugin/src/rules/naming-convention.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ const rule: GraphQLESLintRule<NamingConventionRuleConfig> = {
330330
OperationDefinition: node => {
331331
if (options.OperationDefinition) {
332332
const property = normalisePropertyOption(options.OperationDefinition);
333-
checkNode(node.name, property, 'Operation');
333+
if (node.name) {
334+
checkNode(node.name, property, 'Operation');
335+
}
334336
}
335337
},
336338
FragmentDefinition: node => {

packages/plugin/tests/naming-convention.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ ruleTester.runGraphQLTests('naming-convention', rule, {
113113
},
114114
],
115115
},
116+
{
117+
code: 'query { foo }',
118+
options: [{ OperationDefinition: { style: 'PascalCase' } }],
119+
},
116120
],
117121
invalid: [
118122
{

0 commit comments

Comments
 (0)