Skip to content

Commit a57d4f5

Browse files
authored
fix(naming-convention): fix issues with numeric values (#246)
1 parent 174a66f commit a57d4f5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.changeset/swift-hairs-jam.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
fix(naming-convention): fix issues with numeric values

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { GraphQLESLintRule } from '../types';
44
const formats = {
55
camelCase: /^[a-z][^_]*$/g,
66
PascalCase: /^[A-Z][^_]*$/g,
7-
snake_case: /^[a-z_]*$/g,
8-
UPPER_CASE: /^[A-Z_]*$/g,
7+
snake_case: /^[a-z_][a-z0-9_]*$/g,
8+
UPPER_CASE: /^[A-Z_][A-Z0-9_]*$/g,
99
};
1010

1111
const acceptedStyles: ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE'] = [

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

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ ruleTester.runGraphQLTests('naming-convention', rule, {
3636
code: 'type B { test: String }',
3737
options: [{ ObjectTypeDefinition: 'PascalCase' }],
3838
},
39+
{
40+
code: 'type my_test_6_t { test: String }',
41+
options: [{ ObjectTypeDefinition: 'snake_case' }],
42+
},
43+
{
44+
code: 'type MY_TEST_6_T { test: String }',
45+
options: [{ ObjectTypeDefinition: 'UPPER_CASE' }],
46+
},
3947
{
4048
code: 'type B { test: String }',
4149
options: [{ leadingUnderscore: 'forbid', trailingUnderscore: 'forbid' }],

0 commit comments

Comments
 (0)