1+ diff --git a/cjs/documents.js b/cjs/documents.js
2+ index f418f624fec59761e9537d7e0acc43a0bebb843e..0cda9fb8be4888d5a8d8c38a0b82f84b5745edb8 100644
3+ --- a/cjs/documents.js
4+ +++ b/cjs/documents.js
5+ @@ -44,7 +44,7 @@ const handleVirtualPath = (documents) => {
6+ if ([".gql", ".graphql"].some((extension) => location.endsWith(extension))) {
7+ return source;
8+ }
9+ - filepathMap[location] ??= -1;
10+ + filepathMap[location] = filepathMap[location] != null ? filepathMap[location] : -1;
11+ const index = filepathMap[location] += 1;
12+ return {
13+ ...source,
14+ diff --git a/cjs/parser.js b/cjs/parser.js
15+ index 269ecb5e2107d08ac185af6175d921de38fac476..4b9d5a698b515feaf6107f73dbdc14186d507354 100644
16+ --- a/cjs/parser.js
17+ +++ b/cjs/parser.js
18+ @@ -44,7 +44,7 @@ debug("cwd %o", import_utils2.CWD);
19+ function parseForESLint(code, options) {
20+ try {
21+ const { filePath } = options;
22+ - options.documents ||= options.operations;
23+ + options.documents = options.documents || options.operations;
24+ const { document } = (0, import_utils.parseGraphQLSDL)(filePath, code, {
25+ ...options.graphQLParserOptions,
26+ noLocation: false
27+ diff --git a/cjs/rules/graphql-js-validation.js b/cjs/rules/graphql-js-validation.js
28+ index 9130aae0f12847ce0d9cd69c7dae673d80f75de4..168cdf270ba1dfc39e8f5002b76b5242b154f1c5 100644
29+ --- a/cjs/rules/graphql-js-validation.js
30+ +++ b/cjs/rules/graphql-js-validation.js
31+ @@ -49,7 +49,7 @@ function validateDocument({
32+ };
33+ if (token) {
34+ loc = // if cursor on `@` symbol than use next node
35+ - token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
36+ + token.type === "@" ? sourceCode.getNodeByRangeIndex(token.range[1] + 1).loc : token.loc;
37+ }
38+ const didYouMeanContent = error.message.match(/Did you mean (?<content>.*)\?$/)?.groups.content;
39+ const matches = didYouMeanContent ? [...didYouMeanContent.matchAll(/"(?<name>[^"]*)"/g)] : [];
40+ @@ -407,7 +407,7 @@ const GRAPHQL_JS_VALIDATIONS = Object.assign(
41+ ...siblings.getOperations(),
42+ ...siblings.getFragments()
43+ ].reduce((map, { filePath, document }) => {
44+ - map[filePath] ??= [];
45+ + map[filePath] = map[filePath] != null ? map[filePath] : [];
46+ map[filePath].push(document);
47+ return map;
48+ }, /* @__PURE__ */ Object.create(null));
49+ diff --git a/cjs/rules/no-one-place-fragments.js b/cjs/rules/no-one-place-fragments.js
50+ index 0f4e2c34a00d4267eef2cf0f6e6e2d5369e4a11f..adbee674fbda8710acad8690dc7c637d8e6f1956 100644
51+ --- a/cjs/rules/no-one-place-fragments.js
52+ +++ b/cjs/rules/no-one-place-fragments.js
53+ @@ -87,7 +87,7 @@ const rule = {
54+ (0, import_graphql.visit)(document, {
55+ FragmentSpread({ name }) {
56+ const spreadName = name.value;
57+ - usedFragmentsMap[spreadName] ||= [];
58+ + usedFragmentsMap[spreadName] = usedFragmentsMap[spreadName] || [];
59+ usedFragmentsMap[spreadName].push(relativeFilePath);
60+ }
61+ });
62+ diff --git a/cjs/rules/no-unused-fields.js b/cjs/rules/no-unused-fields.js
63+ index dab854e13820dcf4037cc51729354e67fbb3bf90..1f1b1ddd52119bea302e4998bff6a5a316ca0a3d 100644
64+ --- a/cjs/rules/no-unused-fields.js
65+ +++ b/cjs/rules/no-unused-fields.js
66+ @@ -39,7 +39,7 @@ function getUsedFields(schema, operations) {
67+ }
68+ const parentTypeName = typeInfo.getParentType().name;
69+ const fieldName = node.name.value;
70+ - usedFields[parentTypeName] ??= /* @__PURE__ */ new Set();
71+ + usedFields[parentTypeName] = usedFields[parentTypeName] != null ? usedFields[parentTypeName] : /* @__PURE__ */ new Set();
72+ usedFields[parentTypeName].add(fieldName);
73+ }
74+ });
0 commit comments