Skip to content

Commit 241936a

Browse files
authored
update docs before stable release and rename requireSiblingsOperations to requireGraphQLOperations, rename requireGraphQLSchemaFromContext to requireGraphQLSchema (#2768)
* more * more * more * more * more * more * more * more * more * more * more * prettier * fix lint * rm * rmm * more * more
1 parent 88a6391 commit 241936a

File tree

28 files changed

+152
-163
lines changed

28 files changed

+152
-163
lines changed

.changeset/sour-peaches-prove.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': major
3+
---
4+
5+
- rename `requireSiblingsOperations` to `requireGraphQLOperations`
6+
- rename `requireGraphQLSchemaFromContext` to `requireGraphQLSchema`

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ module.exports = {
123123
files: ['website/**/*.mdx/**'],
124124
rules: {
125125
'import/no-default-export': 'off',
126+
'no-dupe-keys': 'off', // Usage examples contains duplicate keys
126127
},
127128
},
128129
],

packages/plugin/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export * from './types.js';
77
export type { IGraphQLConfig } from 'graphql-config';
88
export type { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck';
99

10-
export { requireGraphQLSchemaFromContext, requireSiblingsOperations } from './utils.js';
10+
export { requireGraphQLSchema, requireGraphQLOperations } from './utils.js';
1111

1212
export const processors = { graphql: processor };
1313

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import { GraphQLESLintRule, GraphQLESLintRuleContext, RuleDocsInfo } from '../ty
5151
import {
5252
ARRAY_DEFAULT_OPTIONS,
5353
REPORT_ON_FIRST_CHARACTER,
54-
requireGraphQLSchemaFromContext,
55-
requireSiblingsOperations,
54+
requireGraphQLOperations,
55+
requireGraphQLSchema,
5656
} from '../utils.js';
5757

5858
type GraphQLJSRule = ValidationRule | SDLValidationRule;
@@ -161,7 +161,7 @@ type GetDocumentNode = (props: {
161161
const handleMissingFragments: GetDocumentNode = ({ ruleId, context, node }) => {
162162
const missingFragments = getMissingFragments(node);
163163
if (missingFragments.length > 0) {
164-
const siblings = requireSiblingsOperations(ruleId, context);
164+
const siblings = requireGraphQLOperations(ruleId, context);
165165
const fragmentsToAdd: FragmentDefinitionNode[] = [];
166166

167167
for (const fragmentName of missingFragments) {
@@ -218,9 +218,7 @@ const validationToRule = (
218218
create(context) {
219219
return {
220220
Document(node) {
221-
const schema = docs.requiresSchema
222-
? requireGraphQLSchemaFromContext(ruleId, context)
223-
: null;
221+
const schema = docs.requiresSchema ? requireGraphQLSchema(ruleId, context) : null;
224222

225223
const documentNode = getDocumentNode
226224
? getDocumentNode({ ruleId, context, node: node.rawNode() })
@@ -473,7 +471,7 @@ export const GRAPHQL_JS_VALIDATIONS: Record<string, GraphQLESLintRule> = Object.
473471
ruleId: 'no-unused-fragments',
474472
rule: NoUnusedFragmentsRule,
475473
getDocumentNode: ({ ruleId, context, node }) => {
476-
const siblings = requireSiblingsOperations(ruleId, context);
474+
const siblings = requireGraphQLOperations(ruleId, context);
477475
const FilePathToDocumentsMap = [
478476
...siblings.getOperations(),
479477
...siblings.getFragments(),

packages/plugin/src/rules/no-deprecated/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ArgumentNode, EnumValueNode, FieldNode, ObjectFieldNode } from 'graphql';
22
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
33
import { GraphQLESLintRule } from '../../types.js';
4-
import { displayNodeName, requireGraphQLSchemaFromContext } from '../../utils.js';
4+
import { displayNodeName, requireGraphQLSchema } from '../../utils.js';
55

66
const RULE_ID = 'no-deprecated';
77

@@ -84,7 +84,7 @@ export const rule: GraphQLESLintRule<[], true> = {
8484
schema: [],
8585
},
8686
create(context) {
87-
requireGraphQLSchemaFromContext(RULE_ID, context);
87+
requireGraphQLSchema(RULE_ID, context);
8888

8989
function report(
9090
node: GraphQLESTreeNode<EnumValueNode | FieldNode | ArgumentNode | ObjectFieldNode, true>,

packages/plugin/src/rules/no-one-place-fragments/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { relative } from 'node:path';
22
import { NameNode, visit } from 'graphql';
33
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
44
import { GraphQLESLintRule } from '../../types.js';
5-
import { CWD, requireSiblingsOperations } from '../../utils.js';
5+
import { CWD, requireGraphQLOperations } from '../../utils.js';
66

77
const RULE_ID = 'no-one-place-fragments';
88

@@ -54,7 +54,7 @@ export const rule: GraphQLESLintRule = {
5454
schema: [],
5555
},
5656
create(context) {
57-
const operations = requireSiblingsOperations(RULE_ID, context);
57+
const operations = requireGraphQLOperations(RULE_ID, context);
5858
const allDocuments = [...operations.getOperations(), ...operations.getFragments()];
5959

6060
const usedFragmentsMap: Record<string, string[]> = Object.create(null);

packages/plugin/src/rules/no-root-type/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NameNode } from 'graphql';
22
import { FromSchema } from 'json-schema-to-ts';
33
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
44
import { GraphQLESLintRule } from '../../types.js';
5-
import { ARRAY_DEFAULT_OPTIONS, requireGraphQLSchemaFromContext, truthy } from '../../utils.js';
5+
import { ARRAY_DEFAULT_OPTIONS, requireGraphQLSchema, truthy } from '../../utils.js';
66

77
const schema = {
88
type: 'array',
@@ -59,7 +59,7 @@ export const rule: GraphQLESLintRule<RuleOptions> = {
5959
schema,
6060
},
6161
create(context) {
62-
const schema = requireGraphQLSchemaFromContext('no-root-type', context);
62+
const schema = requireGraphQLSchema('no-root-type', context);
6363
const disallow = new Set(context.options[0].disallow);
6464

6565
const rootTypeNames = [

packages/plugin/src/rules/no-scalar-result-type-on-mutation/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { isScalarType, Kind, NameNode } from 'graphql';
22
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
33
import { GraphQLESLintRule } from '../../types.js';
4-
import { getNodeName, requireGraphQLSchemaFromContext } from '../../utils.js';
4+
import { getNodeName, requireGraphQLSchema } from '../../utils.js';
55

66
const RULE_ID = 'no-scalar-result-type-on-mutation';
77

@@ -37,7 +37,7 @@ export const rule: GraphQLESLintRule = {
3737
schema: [],
3838
},
3939
create(context) {
40-
const schema = requireGraphQLSchemaFromContext(RULE_ID, context);
40+
const schema = requireGraphQLSchema(RULE_ID, context);
4141
const mutationType = schema.getMutationType();
4242
if (!mutationType) {
4343
return {};

packages/plugin/src/rules/no-unreachable-types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import lowerCase from 'lodash.lowercase';
1414
import { ModuleCache } from '../../cache.js';
1515
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
1616
import { GraphQLESLintRule } from '../../types.js';
17-
import { getTypeName, requireGraphQLSchemaFromContext } from '../../utils.js';
17+
import { getTypeName, requireGraphQLSchema } from '../../utils.js';
1818

1919
const RULE_ID = 'no-unreachable-types';
2020

@@ -156,7 +156,7 @@ export const rule: GraphQLESLintRule = {
156156
hasSuggestions: true,
157157
},
158158
create(context) {
159-
const schema = requireGraphQLSchemaFromContext(RULE_ID, context);
159+
const schema = requireGraphQLSchema(RULE_ID, context);
160160
const reachableTypes = getReachableTypes(schema);
161161

162162
return {

packages/plugin/src/rules/no-unused-fields/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FromSchema } from 'json-schema-to-ts';
44
import { ModuleCache } from '../../cache.js';
55
import { SiblingOperations } from '../../siblings.js';
66
import { GraphQLESLintRule, GraphQLESTreeNode } from '../../types.js';
7-
import { requireGraphQLSchemaFromContext, requireSiblingsOperations } from '../../utils.js';
7+
import { requireGraphQLOperations, requireGraphQLSchema } from '../../utils.js';
88

99
const RULE_ID = 'no-unused-fields';
1010

@@ -214,8 +214,8 @@ export const rule: GraphQLESLintRule<RuleOptions> = {
214214
hasSuggestions: true,
215215
},
216216
create(context) {
217-
const schema = requireGraphQLSchemaFromContext(RULE_ID, context);
218-
const siblingsOperations = requireSiblingsOperations(RULE_ID, context);
217+
const schema = requireGraphQLSchema(RULE_ID, context);
218+
const siblingsOperations = requireGraphQLOperations(RULE_ID, context);
219219
const usedFields = getUsedFields(schema, siblingsOperations);
220220
const { ignoredFieldSelectors } = context.options[0] || {};
221221
const selector = (ignoredFieldSelectors || []).reduce(

0 commit comments

Comments
 (0)