Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[printError] Make location formatting IDE friendly #1949

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/error/__tests__/printError-test.js
Expand Up @@ -27,7 +27,7 @@ describe('printError', () => {
expect(printError(singleDigit)).to.equal(dedent`
Single digit line number with no padding

Test (9:1)
Test:9:1
9: *
^
`);
Expand All @@ -41,7 +41,7 @@ describe('printError', () => {
expect(printError(doubleDigit)).to.equal(dedent`
Left padded first line number

Test (9:1)
Test:9:1
9: *
^
10:
Expand Down Expand Up @@ -85,13 +85,13 @@ describe('printError', () => {
expect(printError(error)).to.equal(dedent`
Example error with two nodes

SourceA (2:10)
SourceA:2:10
1: type Foo {
2: field: String
^
3: }

SourceB (2:10)
SourceB:2:10
1: type Foo {
2: field: Int
^
Expand Down
2 changes: 1 addition & 1 deletion src/error/printError.js
Expand Up @@ -59,7 +59,7 @@ function highlightSourceAtLocation(

const lines = body.split(/\r\n|[\n\r]/g);
return (
`${source.name} (${lineNum}:${columnNum})\n` +
`${source.name}:${lineNum}:${columnNum}\n` +
printPrefixedLines([
// Lines specified like this: ["prefix", "string"],
[`${lineNum - 1}: `, lines[lineIndex - 1]],
Expand Down
6 changes: 3 additions & 3 deletions src/language/__tests__/lexer-test.js
Expand Up @@ -127,7 +127,7 @@ describe('Lexer', () => {
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".

GraphQL request (3:5)
GraphQL request:3:5
2:
3: ?
^
Expand All @@ -147,7 +147,7 @@ describe('Lexer', () => {
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".

foo.js (13:6)
foo.js:13:6
12:
13: ?
^
Expand All @@ -166,7 +166,7 @@ describe('Lexer', () => {
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".

foo.js (1:5)
foo.js:1:5
1: ?
^
`);
Expand Down
4 changes: 2 additions & 2 deletions src/language/__tests__/parser-test.js
Expand Up @@ -54,7 +54,7 @@ describe('Parser', () => {
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Expected Name, found <EOF>

GraphQL request (1:2)
GraphQL request:1:2
1: {
^
`);
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Parser', () => {
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Expected {, found <EOF>

MyQuery.graphql (1:6)
MyQuery.graphql:1:6
1: query
^
`);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/stripIgnoredCharacters-test.js
Expand Up @@ -165,7 +165,7 @@ describe('stripIgnoredCharacters', () => {
expectStripped('{ foo(arg: "\n"').toThrow(dedent`
Syntax Error: Unterminated string.

GraphQL request (1:13)
GraphQL request:1:13
1: { foo(arg: "
^
2: "
Expand Down