Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/swift-hairs-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

fix(naming-convention): fix issues with numeric values
4 changes: 2 additions & 2 deletions packages/plugin/src/rules/naming-convention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { GraphQLESLintRule } from '../types';
const formats = {
camelCase: /^[a-z][^_]*$/g,
PascalCase: /^[A-Z][^_]*$/g,
snake_case: /^[a-z_]*$/g,
UPPER_CASE: /^[A-Z_]*$/g,
snake_case: /^[a-z_][a-z0-9_]*$/g,
UPPER_CASE: /^[A-Z_][A-Z0-9_]*$/g,
};

const acceptedStyles: ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE'] = [
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin/tests/naming-convention.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ ruleTester.runGraphQLTests('naming-convention', rule, {
code: 'type B { test: String }',
options: [{ ObjectTypeDefinition: 'PascalCase' }],
},
{
code: 'type my_test_6_t { test: String }',
options: [{ ObjectTypeDefinition: 'snake_case' }],
},
{
code: 'type MY_TEST_6_T { test: String }',
options: [{ ObjectTypeDefinition: 'UPPER_CASE' }],
},
{
code: 'type B { test: String }',
options: [{ leadingUnderscore: 'forbid', trailingUnderscore: 'forbid' }],
Expand Down