-
Notifications
You must be signed in to change notification settings - Fork 111
122 lines (122 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
diff --git a/esm/estree-converter/utils.js b/esm/estree-converter/utils.js
index f57ab7f17cfc19de13cc969ee32bf44d4f6c361f..6db8f13220171ba109b131db6d5ba5bf7249e87a 100644
--- a/esm/estree-converter/utils.js
+++ b/esm/estree-converter/utils.js
@@ -1,11 +1,12 @@
-import { createRequire } from 'module';
-const require = createRequire(import.meta.url);
+// import { createRequire } from 'module';
+// const require = createRequire(import.meta.url);
import "../chunk-BMTV3EA2.js";
import {
isListType,
isNonNullType,
Source,
- TokenKind
+ TokenKind,
+ Lexer
} from "graphql";
import { valueFromASTUntyped } from "graphql/utilities/valueFromASTUntyped.js";
const valueFromNode = (...args) => {
@@ -41,15 +42,7 @@ function convertToken(token, type) {
};
}
function getLexer(source) {
- const gqlLanguage = require("graphql/language");
- if (gqlLanguage == null ? void 0 : gqlLanguage.createLexer) {
- return gqlLanguage.createLexer(source, {});
- }
- const { Lexer: LexerCls } = require("graphql");
- if (LexerCls && typeof LexerCls === "function") {
- return new LexerCls(source);
- }
- throw new Error("Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!");
+ return new Lexer(source)
}
function extractTokens(filePath, code) {
const source = new Source(code, filePath);
diff --git a/esm/index.js b/esm/index.js
index c70680ab5ef5a04c71db529015e879f91aedf2cf..402b56f8d4b0109d58411e6a5c002b8f69fc40d6 100644
--- a/esm/index.js
+++ b/esm/index.js
@@ -2,7 +2,7 @@ import "./chunk-BMTV3EA2.js";
import { processor } from "./processor.js";
import { parseForESLint } from "./parser.js";
import { rules } from "./rules/index.js";
-export * from "./testkit.js";
+// export * from "./testkit.js";
export * from "./types.js";
import { requireGraphQLSchemaFromContext, requireSiblingsOperations } from "./utils.js";
const processors = { graphql: processor };
diff --git a/esm/parser.js b/esm/parser.js
index 8dc131164b22e24c227d2296d16899a6abb4f692..b1870bc8472fe52e045eaa85b15fe0cac0f8c383 100644
--- a/esm/parser.js
+++ b/esm/parser.js
@@ -3,10 +3,10 @@ import { parseGraphQLSDL } from "@graphql-tools/utils";
import debugFactory from "debug";
import { buildSchema, GraphQLError } from "graphql";
import { convertToESTree, extractComments, extractTokens } from "./estree-converter/index.js";
-import { loadGraphQLConfig } from "./graphql-config.js";
+// import { loadGraphQLConfig } from "./graphql-config.js";
import { getSchema } from "./schema.js";
import { getSiblings } from "./siblings.js";
-import { CWD, VIRTUAL_DOCUMENT_REGEX } from "./utils.js";
+import { CWD, /*VIRTUAL_DOCUMENT_REGEX*/ } from "./utils.js";
const debug = debugFactory("graphql-eslint:parser");
debug("cwd %o", CWD);
function parseForESLint(code, options) {
@@ -18,9 +18,9 @@ function parseForESLint(code, options) {
...options.graphQLParserOptions,
noLocation: false
});
- const gqlConfig = loadGraphQLConfig(options);
- const realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, "");
- const project = gqlConfig.getProjectForFile(realFilepath);
+ // const gqlConfig = loadGraphQLConfig(options);
+ // const realFilepath = filePath.replace(VIRTUAL_DOCUMENT_REGEX, "");
+ let project;
let schema = null;
try {
schema = project ? getSchema(project, options.schemaOptions) : typeof options.schema === "string" ? buildSchema(options.schema) : null;
diff --git a/esm/rules/graphql-js-validation.js b/esm/rules/graphql-js-validation.js
index d952cee1e10976459e7c5836b86ba6540c45fdb6..d314997bfd26477c7d823cad397eb5d65d147806 100644
--- a/esm/rules/graphql-js-validation.js
+++ b/esm/rules/graphql-js-validation.js
@@ -1,5 +1,6 @@
-import { createRequire } from 'module';
-const require = createRequire(import.meta.url);
+// import { createRequire } from 'module';
+// const require = createRequire(import.meta.url);
+import * as allGraphQLJSRules from 'graphql/validation/index.js'
import "../chunk-BMTV3EA2.js";
import {
Kind,
@@ -112,16 +113,18 @@ const validationToRule = ({
schema = [],
hasDidYouMeanSuggestions
}, docs) => {
- let ruleFn = null;
- try {
- ruleFn = require(`graphql/validation/rules/${ruleName}Rule`)[`${ruleName}Rule`];
- } catch {
- try {
- ruleFn = require(`graphql/validation/rules/${ruleName}`)[`${ruleName}Rule`];
- } catch {
- ruleFn = require("graphql/validation")[`${ruleName}Rule`];
- }
- }
+ // let ruleFn = null;
+ // try {
+ // ruleFn = require(`graphql/validation/rules/${ruleName}Rule`)[`${ruleName}Rule`];
+ // } catch {
+ // try {
+ // ruleFn = require(`graphql/validation/rules/${ruleName}`)[`${ruleName}Rule`];
+ // } catch {
+ // ruleFn = require("graphql/validation")[`${ruleName}Rule`];
+ // }
+ // }
+ let ruleFn = allGraphQLJSRules[`${ruleName}Rule`];
+
return {
[ruleId]: {
meta: {