@graphql-eslint/eslint-plugin 3.11.2-alpha-20220926143611-7437e15 → 3.11.2-alpha-20220926144959-f269795
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +14 -17
- package/index.mjs +14 -17
- package/package.json +1 -1
package/index.js
CHANGED
@@ -26,7 +26,7 @@ let graphQLConfig;
|
|
26
26
|
function loadOnDiskGraphQLConfig(filePath) {
|
27
27
|
return graphqlConfig.loadConfigSync({
|
28
28
|
// load config relative to the file being linted
|
29
|
-
rootDir: path.dirname(filePath),
|
29
|
+
rootDir: filePath ? path.dirname(filePath) : undefined,
|
30
30
|
throwOnEmpty: false,
|
31
31
|
throwOnMissing: false,
|
32
32
|
extensions: [addCodeFileLoaderExtension],
|
@@ -66,25 +66,22 @@ const addCodeFileLoaderExtension = api => {
|
|
66
66
|
return { name: 'graphql-eslint-loaders' };
|
67
67
|
};
|
68
68
|
|
69
|
-
let RELEVANT_KEYWORDS;
|
70
|
-
let graphQLTagPluckOptions;
|
71
69
|
const blocksMap = new Map();
|
70
|
+
let onDiskConfig;
|
72
71
|
const processor = {
|
73
72
|
supportsAutofix: true,
|
74
73
|
preprocess(code, filePath) {
|
75
|
-
var _a, _b
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
...
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
];
|
87
|
-
}
|
74
|
+
var _a, _b;
|
75
|
+
onDiskConfig || (onDiskConfig = loadOnDiskGraphQLConfig(filePath));
|
76
|
+
const graphQLTagPluckOptions = (_b = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath)) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.graphqlTagPluck;
|
77
|
+
const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = graphQLTagPluckOptions || {};
|
78
|
+
const RELEVANT_KEYWORDS = [
|
79
|
+
...new Set([
|
80
|
+
...modules.map(({ identifier }) => identifier),
|
81
|
+
...utils.asArray(globalGqlIdentifierName),
|
82
|
+
gqlMagicComment,
|
83
|
+
].filter(Boolean)),
|
84
|
+
];
|
88
85
|
if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
|
89
86
|
return [code];
|
90
87
|
}
|
@@ -106,7 +103,7 @@ const processor = {
|
|
106
103
|
blocksMap.set(filePath, blocks);
|
107
104
|
return [...blocks, code /* source code must be provided and be last */];
|
108
105
|
}
|
109
|
-
catch (
|
106
|
+
catch (_c) {
|
110
107
|
// in case of parsing error return code as is
|
111
108
|
return [code];
|
112
109
|
}
|
package/index.mjs
CHANGED
@@ -20,7 +20,7 @@ let graphQLConfig;
|
|
20
20
|
function loadOnDiskGraphQLConfig(filePath) {
|
21
21
|
return loadConfigSync({
|
22
22
|
// load config relative to the file being linted
|
23
|
-
rootDir: dirname(filePath),
|
23
|
+
rootDir: filePath ? dirname(filePath) : undefined,
|
24
24
|
throwOnEmpty: false,
|
25
25
|
throwOnMissing: false,
|
26
26
|
extensions: [addCodeFileLoaderExtension],
|
@@ -60,25 +60,22 @@ const addCodeFileLoaderExtension = api => {
|
|
60
60
|
return { name: 'graphql-eslint-loaders' };
|
61
61
|
};
|
62
62
|
|
63
|
-
let RELEVANT_KEYWORDS;
|
64
|
-
let graphQLTagPluckOptions;
|
65
63
|
const blocksMap = new Map();
|
64
|
+
let onDiskConfig;
|
66
65
|
const processor = {
|
67
66
|
supportsAutofix: true,
|
68
67
|
preprocess(code, filePath) {
|
69
|
-
var _a, _b
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
...
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
];
|
81
|
-
}
|
68
|
+
var _a, _b;
|
69
|
+
onDiskConfig || (onDiskConfig = loadOnDiskGraphQLConfig(filePath));
|
70
|
+
const graphQLTagPluckOptions = (_b = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath)) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.graphqlTagPluck;
|
71
|
+
const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = graphQLTagPluckOptions || {};
|
72
|
+
const RELEVANT_KEYWORDS = [
|
73
|
+
...new Set([
|
74
|
+
...modules.map(({ identifier }) => identifier),
|
75
|
+
...asArray(globalGqlIdentifierName),
|
76
|
+
gqlMagicComment,
|
77
|
+
].filter(Boolean)),
|
78
|
+
];
|
82
79
|
if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
|
83
80
|
return [code];
|
84
81
|
}
|
@@ -100,7 +97,7 @@ const processor = {
|
|
100
97
|
blocksMap.set(filePath, blocks);
|
101
98
|
return [...blocks, code /* source code must be provided and be last */];
|
102
99
|
}
|
103
|
-
catch (
|
100
|
+
catch (_c) {
|
104
101
|
// in case of parsing error return code as is
|
105
102
|
return [code];
|
106
103
|
}
|
package/package.json
CHANGED