Skip to content

Commit 9a40163

Browse files
committed
Fix issues with avoid-operation-name-prefix and error with caseSensitive
1 parent 63dc00a commit 9a40163

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/dry-tigers-roll.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 issues with `avoid-operation-name-prefix` and error with caseSensitive

packages/plugin/src/rules/avoid-operation-name-prefix.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { GraphQLESLintRule, GraphQLESlintRuleContext } from '../types';
22
import { GraphQLESTreeNode } from '../estree-parser/estree-ast';
33
import { OperationDefinitionNode, FragmentDefinitionNode } from 'graphql';
44

5-
type AvoidOperationNamePrefixConfig = [
5+
export type AvoidOperationNamePrefixConfig = [
66
{
77
keywords: string[];
88
caseSensitive?: boolean;
@@ -15,10 +15,12 @@ function verifyRule(
1515
context: GraphQLESlintRuleContext<AvoidOperationNamePrefixConfig>,
1616
node: GraphQLESTreeNode<OperationDefinitionNode> | GraphQLESTreeNode<FragmentDefinitionNode>
1717
) {
18-
const caseSensitive = context.options[0].caseSensitive;
18+
const config = context.options[0] || { keywords: [], caseSensitive: false };
19+
const caseSensitive = config.caseSensitive;
20+
const keywords = config.keywords || [];
1921

2022
if (node && node.name && node.name.value !== '') {
21-
for (const keyword of context.options[0].keywords) {
23+
for (const keyword of keywords) {
2224
const testKeyword = caseSensitive ? keyword : keyword.toLowerCase();
2325
const testName = caseSensitive ? node.name.value : node.name.value.toLowerCase();
2426

0 commit comments

Comments
 (0)