@graphql-eslint/eslint-plugin 3.12.0-alpha-20221009002505-ace0694 → 3.12.0-alpha-20221009195322-d8a697f

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +18 -19
  2. package/index.mjs +18 -19
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -78,33 +78,32 @@ const codeFileLoaderExtension = (pluckConfig) => api => {
78
78
 
79
79
  const blocksMap = new Map();
80
80
  let onDiskConfig;
81
- let pluckConfig;
82
- let RELEVANT_KEYWORDS;
81
+ let onDiskConfigLoaded = false;
83
82
  const processor = {
84
83
  supportsAutofix: true,
85
84
  preprocess(code, filePath) {
86
- if (!pluckConfig) {
85
+ var _a;
86
+ if (!onDiskConfigLoaded) {
87
87
  onDiskConfig = loadOnDiskGraphQLConfig(filePath);
88
- const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = (onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath).extensions.pluckConfig) || {};
89
- pluckConfig = {
90
- skipIndent: true,
91
- modules,
92
- globalGqlIdentifierName,
93
- gqlMagicComment,
94
- };
95
- RELEVANT_KEYWORDS = [
96
- ...new Set([
97
- ...modules.map(({ identifier }) => identifier),
98
- ...utils.asArray(globalGqlIdentifierName),
99
- gqlMagicComment,
100
- ].filter(Boolean)),
101
- ];
88
+ onDiskConfigLoaded = true;
102
89
  }
90
+ const pluckConfig = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath).extensions) === null || _a === void 0 ? void 0 : _a.pluckConfig;
91
+ const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = pluckConfig || {};
92
+ const RELEVANT_KEYWORDS = [
93
+ ...new Set([
94
+ ...modules.map(({ identifier }) => identifier),
95
+ ...utils.asArray(globalGqlIdentifierName),
96
+ gqlMagicComment,
97
+ ].filter(Boolean)),
98
+ ];
103
99
  if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
104
100
  return [code];
105
101
  }
106
102
  try {
107
- const sources = graphqlTagPluck.gqlPluckFromCodeStringSync(filePath, code, pluckConfig);
103
+ const sources = graphqlTagPluck.gqlPluckFromCodeStringSync(filePath, code, {
104
+ skipIndent: true,
105
+ ...pluckConfig,
106
+ });
108
107
  const isSvelte = filePath.endsWith('.svelte');
109
108
  const blocks = sources.map(item => ({
110
109
  filename: 'document.graphql',
@@ -116,7 +115,7 @@ const processor = {
116
115
  blocksMap.set(filePath, blocks);
117
116
  return [...blocks, code /* source code must be provided and be last */];
118
117
  }
119
- catch (_a) {
118
+ catch (_b) {
120
119
  // in case of parsing error return code as is
121
120
  return [code];
122
121
  }
package/index.mjs CHANGED
@@ -72,33 +72,32 @@ const codeFileLoaderExtension = (pluckConfig) => api => {
72
72
 
73
73
  const blocksMap = new Map();
74
74
  let onDiskConfig;
75
- let pluckConfig;
76
- let RELEVANT_KEYWORDS;
75
+ let onDiskConfigLoaded = false;
77
76
  const processor = {
78
77
  supportsAutofix: true,
79
78
  preprocess(code, filePath) {
80
- if (!pluckConfig) {
79
+ var _a;
80
+ if (!onDiskConfigLoaded) {
81
81
  onDiskConfig = loadOnDiskGraphQLConfig(filePath);
82
- const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = (onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath).extensions.pluckConfig) || {};
83
- pluckConfig = {
84
- skipIndent: true,
85
- modules,
86
- globalGqlIdentifierName,
87
- gqlMagicComment,
88
- };
89
- RELEVANT_KEYWORDS = [
90
- ...new Set([
91
- ...modules.map(({ identifier }) => identifier),
92
- ...asArray(globalGqlIdentifierName),
93
- gqlMagicComment,
94
- ].filter(Boolean)),
95
- ];
82
+ onDiskConfigLoaded = true;
96
83
  }
84
+ const pluckConfig = (_a = onDiskConfig === null || onDiskConfig === void 0 ? void 0 : onDiskConfig.getProjectForFile(filePath).extensions) === null || _a === void 0 ? void 0 : _a.pluckConfig;
85
+ const { modules = [], globalGqlIdentifierName = ['gql', 'graphql'], gqlMagicComment = 'GraphQL', } = pluckConfig || {};
86
+ const RELEVANT_KEYWORDS = [
87
+ ...new Set([
88
+ ...modules.map(({ identifier }) => identifier),
89
+ ...asArray(globalGqlIdentifierName),
90
+ gqlMagicComment,
91
+ ].filter(Boolean)),
92
+ ];
97
93
  if (RELEVANT_KEYWORDS.every(keyword => !code.includes(keyword))) {
98
94
  return [code];
99
95
  }
100
96
  try {
101
- const sources = gqlPluckFromCodeStringSync(filePath, code, pluckConfig);
97
+ const sources = gqlPluckFromCodeStringSync(filePath, code, {
98
+ skipIndent: true,
99
+ ...pluckConfig,
100
+ });
102
101
  const isSvelte = filePath.endsWith('.svelte');
103
102
  const blocks = sources.map(item => ({
104
103
  filename: 'document.graphql',
@@ -110,7 +109,7 @@ const processor = {
110
109
  blocksMap.set(filePath, blocks);
111
110
  return [...blocks, code /* source code must be provided and be last */];
112
111
  }
113
- catch (_a) {
112
+ catch (_b) {
114
113
  // in case of parsing error return code as is
115
114
  return [code];
116
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.12.0-alpha-20221009002505-ace0694",
3
+ "version": "3.12.0-alpha-20221009195322-d8a697f",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -14,7 +14,7 @@
14
14
  "chalk": "^4.1.2",
15
15
  "debug": "^4.3.4",
16
16
  "fast-glob": "^3.2.12",
17
- "graphql-config": "^4.3.5",
17
+ "graphql-config": "^4.3.6",
18
18
  "graphql-depth-limit": "^1.1.0",
19
19
  "lodash.lowercase": "^4.3.0"
20
20
  },