@graphql-eslint/eslint-plugin 3.19.2 → 3.19.3

Sign up to get free protection for your applications and to get access to all the features.
package/cjs/parser.js CHANGED
@@ -13,6 +13,7 @@ const utils_js_1 = require("./utils.js");
13
13
  const debug = (0, debug_1.default)('graphql-eslint:parser');
14
14
  debug('cwd %o', utils_js_1.CWD);
15
15
  function parseForESLint(code, options) {
16
+ var _a, _b;
16
17
  try {
17
18
  const { filePath } = options;
18
19
  // TODO: remove in graphql-eslint v4
@@ -64,10 +65,13 @@ function parseForESLint(code, options) {
64
65
  // In case of GraphQL parser error, we report it to ESLint as a parser error that matches the requirements
65
66
  // of ESLint. This will make sure to display it correctly in IDEs and lint results.
66
67
  if (error instanceof graphql_1.GraphQLError) {
68
+ const location = (_a = error.locations) === null || _a === void 0 ? void 0 : _a[0];
67
69
  const eslintError = {
68
- index: error.positions[0],
69
- lineNumber: error.locations[0].line,
70
- column: error.locations[0].column - 1,
70
+ index: (_b = error.positions) === null || _b === void 0 ? void 0 : _b[0],
71
+ ...(location && {
72
+ lineNumber: location.line,
73
+ column: location.column - 1,
74
+ }),
71
75
  message: error.message,
72
76
  };
73
77
  throw eslintError;
package/esm/parser.js CHANGED
@@ -9,6 +9,7 @@ import { CWD, VIRTUAL_DOCUMENT_REGEX } from './utils.js';
9
9
  const debug = debugFactory('graphql-eslint:parser');
10
10
  debug('cwd %o', CWD);
11
11
  export function parseForESLint(code, options) {
12
+ var _a, _b;
12
13
  try {
13
14
  const { filePath } = options;
14
15
  // TODO: remove in graphql-eslint v4
@@ -60,10 +61,13 @@ export function parseForESLint(code, options) {
60
61
  // In case of GraphQL parser error, we report it to ESLint as a parser error that matches the requirements
61
62
  // of ESLint. This will make sure to display it correctly in IDEs and lint results.
62
63
  if (error instanceof GraphQLError) {
64
+ const location = (_a = error.locations) === null || _a === void 0 ? void 0 : _a[0];
63
65
  const eslintError = {
64
- index: error.positions[0],
65
- lineNumber: error.locations[0].line,
66
- column: error.locations[0].column - 1,
66
+ index: (_b = error.positions) === null || _b === void 0 ? void 0 : _b[0],
67
+ ...(location && {
68
+ lineNumber: location.line,
69
+ column: location.column - 1,
70
+ }),
67
71
  message: error.message,
68
72
  };
69
73
  throw eslintError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-eslint/eslint-plugin",
3
- "version": "3.19.2",
3
+ "version": "3.19.3",
4
4
  "description": "GraphQL plugin for ESLint",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {