@graphql-eslint/eslint-plugin 3.11.2-alpha-20220926143611-7437e15 → 3.11.2-alpha-20220926145433-4bedc51
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +12 -15
- package/index.mjs +12 -15
- 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
74
|
var _a, _b, _c;
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
...
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
];
|
87
|
-
}
|
75
|
+
onDiskConfig || (onDiskConfig = loadOnDiskGraphQLConfig(filePath));
|
76
|
+
const graphQLTagPluckOptions = (_c = (_b = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile) === null || _a === void 0 ? void 0 : _a.call(onDiskConfig, filePath)) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.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
|
}
|
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
68
|
var _a, _b, _c;
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
...
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
];
|
81
|
-
}
|
69
|
+
onDiskConfig || (onDiskConfig = loadOnDiskGraphQLConfig(filePath));
|
70
|
+
const graphQLTagPluckOptions = (_c = (_b = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile) === null || _a === void 0 ? void 0 : _a.call(onDiskConfig, filePath)) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.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
|
}
|
package/package.json
CHANGED