@graphql-eslint/eslint-plugin 4.0.0-alpha.8 → 4.0.0-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
package/cjs/documents.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-UIAXBAMD.js');
2
- var _nodepath = require('node:path');
2
+ var _nodepath = require('node:path'); var _nodepath2 = _interopRequireDefault(_nodepath);
3
3
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
4
4
  var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
5
5
  var _cachejs = require('./cache.js');
@@ -8,12 +8,17 @@ const debug = _debug2.default.call(void 0, "graphql-eslint:operations"), operati
8
8
  return documents.map((source) => {
9
9
  const location = source.location;
10
10
  if ([".gql", ".graphql"].some((extension) => location.endsWith(extension)))
11
- return source;
11
+ return {
12
+ ...source,
13
+ // When using glob pattern e.g. `**/*.gql` location contains always forward slashes even on
14
+ // Windows
15
+ location: _nodepath2.default.resolve(location)
16
+ };
12
17
  filepathMap[location] ??= -1;
13
18
  const index = filepathMap[location] += 1;
14
19
  return {
15
20
  ...source,
16
- location: _nodepath.resolve.call(void 0, location, `${index}_document.graphql`)
21
+ location: _nodepath2.default.resolve(location, `${index}_document.graphql`)
17
22
  };
18
23
  });
19
24
  }, getDocuments = exports.getDocuments = (project) => {
package/cjs/meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UIAXBAMD.js');
2
- const version = "4.0.0-alpha.8";
2
+ const version = "4.0.0-alpha.9";
3
3
 
4
4
 
5
5
  exports.version = version;
@@ -85,7 +85,7 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
85
85
  ).test(comment.value)) continue;
86
86
  const extractedImportPath = _optionalChain([comment, 'access', _ => _.value, 'access', _2 => _2.match, 'call', _3 => _3(/(["'])((?:\1|.)*?)\1/), 'optionalAccess', _4 => _4[2]]);
87
87
  if (!extractedImportPath) continue;
88
- const importPath = _nodepath2.default.join(_nodepath2.default.dirname(filePath), extractedImportPath);
88
+ const importPath = _nodepath2.default.join(filePath, "..", extractedImportPath);
89
89
  if (fragmentsFromSiblings.some(
90
90
  (source) => source.filePath === importPath
91
91
  )) return;
@@ -93,7 +93,12 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
93
93
  if (fragmentsFromSiblings.some(
94
94
  (source) => source.filePath === filePath
95
95
  )) return;
96
- const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) => _nodepath2.default.relative(_nodepath2.default.dirname(filePath), o.filePath)) : ["CHANGE_ME.graphql"];
96
+ const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map(
97
+ (o) => (
98
+ // Use always forward slash for suggested import path
99
+ _utilsjs.slash.call(void 0, _nodepath2.default.relative(_nodepath2.default.dirname(filePath), o.filePath))
100
+ )
101
+ ) : ["CHANGE_ME.graphql"];
97
102
  context.report({
98
103
  node,
99
104
  messageId: RULE_ID,
package/cjs/utils.js CHANGED
@@ -29,7 +29,7 @@ const chalk = {
29
29
  // eslint-disable-next-line no-console
30
30
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
31
31
  )
32
- }, slash = exports.slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = exports.VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = exports.CWD = process.cwd(), getTypeName = exports.getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = exports.TYPES_KINDS = [
32
+ }, slash = exports.slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = exports.VIRTUAL_DOCUMENT_REGEX = /[/\\]\d+_document.graphql$/, CWD = exports.CWD = process.cwd(), getTypeName = exports.getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = exports.TYPES_KINDS = [
33
33
  _graphql.Kind.OBJECT_TYPE_DEFINITION,
34
34
  _graphql.Kind.INTERFACE_TYPE_DEFINITION,
35
35
  _graphql.Kind.ENUM_TYPE_DEFINITION,
package/esm/documents.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-UIAXBAMD.js";
2
- import { resolve } from "node:path";
2
+ import path from "node:path";
3
3
  import debugFactory from "debug";
4
4
  import fg from "fast-glob";
5
5
  import { ModuleCache } from "./cache.js";
@@ -8,12 +8,17 @@ const debug = debugFactory("graphql-eslint:operations"), operationsCache = new M
8
8
  return documents.map((source) => {
9
9
  const location = source.location;
10
10
  if ([".gql", ".graphql"].some((extension) => location.endsWith(extension)))
11
- return source;
11
+ return {
12
+ ...source,
13
+ // When using glob pattern e.g. `**/*.gql` location contains always forward slashes even on
14
+ // Windows
15
+ location: path.resolve(location)
16
+ };
12
17
  filepathMap[location] ??= -1;
13
18
  const index = filepathMap[location] += 1;
14
19
  return {
15
20
  ...source,
16
- location: resolve(location, `${index}_document.graphql`)
21
+ location: path.resolve(location, `${index}_document.graphql`)
17
22
  };
18
23
  });
19
24
  }, getDocuments = (project) => {
package/esm/meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-UIAXBAMD.js";
2
- const version = "4.0.0-alpha.8";
2
+ const version = "4.0.0-alpha.9";
3
3
  export {
4
4
  version
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import "../../chunk-UIAXBAMD.js";
2
2
  import path from "node:path";
3
- import { requireSiblingsOperations } from "../../utils.js";
3
+ import { requireSiblingsOperations, slash } from "../../utils.js";
4
4
  const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expression", rule = {
5
5
  meta: {
6
6
  type: "suggestion",
@@ -85,7 +85,7 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
85
85
  ).test(comment.value)) continue;
86
86
  const extractedImportPath = comment.value.match(/(["'])((?:\1|.)*?)\1/)?.[2];
87
87
  if (!extractedImportPath) continue;
88
- const importPath = path.join(path.dirname(filePath), extractedImportPath);
88
+ const importPath = path.join(filePath, "..", extractedImportPath);
89
89
  if (fragmentsFromSiblings.some(
90
90
  (source) => source.filePath === importPath
91
91
  )) return;
@@ -93,7 +93,12 @@ const RULE_ID = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
93
93
  if (fragmentsFromSiblings.some(
94
94
  (source) => source.filePath === filePath
95
95
  )) return;
96
- const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) => path.relative(path.dirname(filePath), o.filePath)) : ["CHANGE_ME.graphql"];
96
+ const suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map(
97
+ (o) => (
98
+ // Use always forward slash for suggested import path
99
+ slash(path.relative(path.dirname(filePath), o.filePath))
100
+ )
101
+ ) : ["CHANGE_ME.graphql"];
97
102
  context.report({
98
103
  node,
99
104
  messageId: RULE_ID,
package/esm/utils.js CHANGED
@@ -29,7 +29,7 @@ const chalk = {
29
29
  // eslint-disable-next-line no-console
30
30
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
31
31
  )
32
- }, slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
32
+ }, slash = (path) => path.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
33
33
  Kind.OBJECT_TYPE_DEFINITION,
34
34
  Kind.INTERFACE_TYPE_DEFINITION,
35
35
  Kind.ENUM_TYPE_DEFINITION,
package/index.browser.js CHANGED
@@ -427,7 +427,7 @@ var chalk = {
427
427
  // eslint-disable-next-line no-console
428
428
  console.warn(chalk.yellow("warning"), "[graphql-eslint]", ...args)
429
429
  )
430
- }, slash = (path2) => path2.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[\/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
430
+ }, slash = (path2) => path2.replaceAll("\\", "/"), VIRTUAL_DOCUMENT_REGEX = /[/\\]\d+_document.graphql$/, CWD = process.cwd(), getTypeName = (node) => "type" in node ? getTypeName(node.type) : "name" in node && node.name ? node.name.value : "", TYPES_KINDS = [
431
431
  Kind2.OBJECT_TYPE_DEFINITION,
432
432
  Kind2.INTERFACE_TYPE_DEFINITION,
433
433
  Kind2.ENUM_TYPE_DEFINITION,
@@ -4387,7 +4387,7 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
4387
4387
  ).test(comment.value)) continue;
4388
4388
  let extractedImportPath = comment.value.match(/(["'])((?:\1|.)*?)\1/)?.[2];
4389
4389
  if (!extractedImportPath) continue;
4390
- let importPath = path.join(path.dirname(filePath), extractedImportPath);
4390
+ let importPath = path.join(filePath, "..", extractedImportPath);
4391
4391
  if (fragmentsFromSiblings.some(
4392
4392
  (source) => source.filePath === importPath
4393
4393
  )) return;
@@ -4395,7 +4395,12 @@ var RULE_ID16 = "require-import-fragment", SUGGESTION_ID = "add-import-expressio
4395
4395
  if (fragmentsFromSiblings.some(
4396
4396
  (source) => source.filePath === filePath
4397
4397
  )) return;
4398
- let suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map((o) => path.relative(path.dirname(filePath), o.filePath)) : ["CHANGE_ME.graphql"];
4398
+ let suggestedFilePaths = fragmentsFromSiblings.length ? fragmentsFromSiblings.map(
4399
+ (o) => (
4400
+ // Use always forward slash for suggested import path
4401
+ slash(path.relative(path.dirname(filePath), o.filePath))
4402
+ )
4403
+ ) : ["CHANGE_ME.graphql"];
4399
4404
  context.report({
4400
4405
  node,
4401
4406
  messageId: RULE_ID16,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "4.0.0-alpha.8",
3
+ "version": "4.0.0-alpha.9",
4
4
  "type": "module",
5
5
  "description": "GraphQL plugin for ESLint",
6
6
  "repository": "https://github.com/B2o5T/graphql-eslint",