@graphql-eslint/eslint-plugin 3.11.2-alpha-20220926143611-7437e15 → 3.11.2-alpha-20220926145433-4bedc51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +12 -15
  2. package/index.mjs +12 -15
  3. 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
- if (!RELEVANT_KEYWORDS) {
77
- graphQLTagPluckOptions =
78
- (_c = (_b = (_a = loadOnDiskGraphQLConfig(filePath)) === null || _a === void 0 ? void 0 : _a.getDefault()) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.graphqlTagPluck;
79
- const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = graphQLTagPluckOptions || {};
80
- RELEVANT_KEYWORDS = [
81
- ...new Set([
82
- ...modules.map(({ identifier }) => identifier),
83
- ...utils.asArray(globalGqlIdentifierName),
84
- gqlMagicComment,
85
- ].filter(Boolean)),
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
- if (!RELEVANT_KEYWORDS) {
71
- graphQLTagPluckOptions =
72
- (_c = (_b = (_a = loadOnDiskGraphQLConfig(filePath)) === null || _a === void 0 ? void 0 : _a.getDefault()) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.graphqlTagPluck;
73
- const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = graphQLTagPluckOptions || {};
74
- RELEVANT_KEYWORDS = [
75
- ...new Set([
76
- ...modules.map(({ identifier }) => identifier),
77
- ...asArray(globalGqlIdentifierName),
78
- gqlMagicComment,
79
- ].filter(Boolean)),
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.11.2-alpha-20220926143611-7437e15",
3
+ "version": "3.11.2-alpha-20220926145433-4bedc51",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {