Skip to content

Commit 3cf1841

Browse files
author
Dimitri POSTOLOV
authored
fix(docs): some graphql-eslint rules are named differently than graphql-js rules (#726)
1 parent dd7a612 commit 3cf1841

10 files changed

+20
-22
lines changed

docs/rules/fragments-on-composite-type.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ Fragments use a type condition to determine if they apply, since fragments can o
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypeRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FragmentsOnCompositeTypeRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/FragmentsOnCompositeTypesRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.ts)

docs/rules/one-field-subscriptions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ A GraphQL subscription is valid only if it contains a single root field.
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/OneFieldSubscriptionsRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/OneFieldSubscriptionsRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/SingleFieldSubscriptionsRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/SingleFieldSubscriptionsRule-test.ts)

docs/rules/possible-fragment-spread.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ A fragment spread is only valid if the type condition could ever possibly be tru
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleFragmentSpreadRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleFragmentSpreadsRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleFragmentSpreadsRule-test.ts)

docs/rules/possible-type-extension.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ A type extension is only valid if the type is defined and has the same kind.
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleTypeExtensionRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/PossibleTypeExtensionsRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/PossibleTypeExtensionsRule-test.ts)

docs/rules/unique-directive-names-per-location.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ A GraphQL document is only valid if all non-repeatable directives at a given loc
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectiveNamesPerLocationRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueDirectiveNamesPerLocationRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/UniqueDirectivesPerLocationRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.ts)

docs/rules/value-literals-of-correct-type.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ A GraphQL document is only valid if all value literals are of the type expected
1313
1414
## Resources
1515

16-
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValueLiteralsOfCorrectTypeRule.ts)
17-
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ValueLiteralsOfCorrectTypeRule-test.ts)
16+
- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ValuesOfCorrectTypeRule.ts)
17+
- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts)

packages/plugin/src/rules/graphql-js-validation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const validationToRule = (
7070
meta: {
7171
docs: {
7272
...docs,
73+
graphQLJSRuleName: ruleName,
7374
category: 'Validation',
7475
recommended: true,
7576
requiresSchema,

packages/plugin/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type RuleDocsInfo<T> = Rule.RuleMetaData & {
5959
usage?: T;
6060
}[];
6161
optionsForConfig?: T;
62+
graphQLJSRuleName?: string
6263
};
6364
};
6465

packages/plugin/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export enum CaseStyle {
164164
kebabCase = 'kebab-case',
165165
}
166166

167-
export const pascalCase = (str: string): string =>
167+
const pascalCase = (str: string): string =>
168168
lowerCase(str)
169169
.split(' ')
170170
.map(word => word.charAt(0).toUpperCase() + word.slice(1))

scripts/generate-docs.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import dedent from 'dedent';
44
import md from 'json-schema-to-markdown';
55
import { format } from 'prettier';
66
import { rules } from '../packages/plugin/src';
7-
import { pascalCase } from '../packages/plugin/src/utils';
8-
import { GRAPHQL_JS_VALIDATIONS } from '../packages/plugin/src/rules/graphql-js-validation';
97

108
const BR = '';
119
const DOCS_PATH = resolve(process.cwd(), 'docs');
@@ -63,7 +61,7 @@ function generateDocs(): void {
6361
);
6462
}
6563

66-
const { requiresSchema = false, requiresSiblings = false } = docs;
64+
const { requiresSchema = false, requiresSiblings = false, graphQLJSRuleName } = docs;
6765

6866
blocks.push(
6967
`- Category: \`${docs.category}\``,
@@ -111,13 +109,11 @@ function generateDocs(): void {
111109
}
112110

113111
blocks.push(BR, '## Resources', BR);
114-
const isGraphQLJSRule = ruleName in GRAPHQL_JS_VALIDATIONS;
115112

116-
if (isGraphQLJSRule) {
117-
const graphQLJSRuleName = `${pascalCase(ruleName)}Rule`;
113+
if (graphQLJSRuleName) {
118114
blocks.push(
119-
`- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${graphQLJSRuleName}.ts)`,
120-
`- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/${graphQLJSRuleName}-test.ts)`
115+
`- [Rule source](https://github.com/graphql/graphql-js/blob/main/src/validation/rules/${graphQLJSRuleName}Rule.ts)`,
116+
`- [Test source](https://github.com/graphql/graphql-js/tree/main/src/validation/__tests__/${graphQLJSRuleName}Rule-test.ts)`
121117
);
122118
} else {
123119
blocks.push(`- [Rule source](../../packages/plugin/src/rules/${ruleName}.ts)`);
@@ -145,7 +141,7 @@ function generateDocs(): void {
145141
return [
146142
link,
147143
docs.description.split('\n')[0],
148-
ruleName in GRAPHQL_JS_VALIDATIONS ? Icon.GRAPHQL_JS : Icon.GRAPHQL_ESLINT,
144+
docs.graphQLJSRuleName ? Icon.GRAPHQL_JS : Icon.GRAPHQL_ESLINT,
149145
fixable ? Icon.FIXABLE : '',
150146
docs.recommended ? Icon.RECOMMENDED : '',
151147
];

0 commit comments

Comments
 (0)