Skip to content

Commit e6edc88

Browse files
committed
Added prefix to error thrown by the parser
1 parent 2df9134 commit e6edc88

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

.changeset/eleven-houses-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
Added prefix to error thrown by the parser

packages/plugin/src/parser.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ export function parse(code: string, options?: ParserOptions): Linter.ESLintParse
1212
return parseForESLint(code, options).ast;
1313
}
1414

15-
const addCodeFileLoaderExtension: GraphQLExtensionDeclaration = (api) => {
16-
schemaLoaders.forEach(loader => api.loaders.schema.register(loader))
17-
operationsLoaders.forEach(loader => api.loaders.documents.register(loader))
18-
return { name: 'graphql-eslint-loaders' }
19-
}
15+
const addCodeFileLoaderExtension: GraphQLExtensionDeclaration = api => {
16+
schemaLoaders.forEach(loader => api.loaders.schema.register(loader));
17+
operationsLoaders.forEach(loader => api.loaders.documents.register(loader));
18+
return { name: 'graphql-eslint-loaders' };
19+
};
2020

2121
export function parseForESLint(code: string, options?: ParserOptions): GraphQLESLintParseResult {
2222
const gqlConfig: GraphQLConfig | null = options?.skipGraphQLConfig
2323
? null
2424
: loadConfigSync({
2525
throwOnEmpty: false,
2626
throwOnMissing: false,
27-
extensions: [addCodeFileLoaderExtension]
27+
extensions: [addCodeFileLoaderExtension],
2828
});
2929

3030
const schema = getSchema(options, gqlConfig);
@@ -65,12 +65,14 @@ export function parseForESLint(code: string, options?: ParserOptions): GraphQLES
6565
index: e.positions[0],
6666
lineNumber: e.locations[0].line,
6767
column: e.locations[0].column,
68-
message: e.message,
68+
message: `[graphql-eslint]: ${e.message}`,
6969
};
7070

7171
throw eslintError;
7272
}
7373

74+
e.message = `[graphql-eslint]: ${e.message}`;
75+
7476
throw e;
7577
}
7678
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,6 +3234,11 @@ [email protected], graphql-config@^3.2.0:
32343234
string-env-interpolation "1.0.1"
32353235
tslib "^2.0.0"
32363236

3237+
graphql-tag@^2.11.0:
3238+
version "2.11.0"
3239+
resolved "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.11.0.tgz#1deb53a01c46a7eb401d6cb59dec86fa1cccbffd"
3240+
integrity sha512-VmsD5pJqWJnQZMUeRwrDhfgoyqcfwEkvtpANqcoUG8/tOLkwNgU9mzub/Mc78OJMhHjx7gfAMTxzdG43VGg3bA==
3241+
32373242
graphql-upload@^11.0.0:
32383243
version "11.0.0"
32393244
resolved "https://registry.yarnpkg.com/graphql-upload/-/graphql-upload-11.0.0.tgz#24b245ff18f353bab6715e8a055db9fd73035e10"

0 commit comments

Comments
 (0)