Add prettier

This commit is contained in:
Alex Dima 2020-09-02 17:44:31 +02:00
parent 1ca4a3a0aa
commit 3efc637414
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
156 changed files with 51562 additions and 37461 deletions

View file

@ -9,80 +9,87 @@ import { testTokenization } from '../test/testRunner';
testTokenization('graphql', [
// Keywords
[{
line: 'scalar Date',
tokens: [
{ startIndex: 0, type: 'keyword.gql' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'type.identifier.gql' },
]
}],
[
{
line: 'scalar Date',
tokens: [
{ startIndex: 0, type: 'keyword.gql' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'type.identifier.gql' }
]
}
],
// Root schema definition
[{
line: 'schema { query: Query, mutation: Mutation subscription: Subscription }',
tokens: [
{ startIndex: 0, type: "keyword.gql" },
{ startIndex: 6, type: "" },
{ startIndex: 7, type: "delimiter.curly.gql" },
{ startIndex: 8, type: "" },
{ startIndex: 9, type: "keyword.gql" }, // this should be identifier
{ startIndex: 14, type: "operator.gql" },
{ startIndex: 15, type: "" },
{ startIndex: 16, type: "type.identifier.gql" },
{ startIndex: 21, type: "delimiter.gql" },
{ startIndex: 22, type: "" },
{ startIndex: 23, type: "keyword.gql" }, // this should be identifier
{ startIndex: 31, type: "operator.gql" },
{ startIndex: 32, type: "" },
{ startIndex: 33, type: "type.identifier.gql" },
{ startIndex: 41, type: "" },
{ startIndex: 42, type: "keyword.gql" }, // this should be identifier
{ startIndex: 54, type: "operator.gql" },
{ startIndex: 55, type: "" },
{ startIndex: 56, type: "type.identifier.gql" },
{ startIndex: 68, type: "" },
{ startIndex: 69, type: "delimiter.curly.gql" },
]
}],
[
{
line:
'schema { query: Query, mutation: Mutation subscription: Subscription }',
tokens: [
{ startIndex: 0, type: 'keyword.gql' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'delimiter.curly.gql' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.gql' }, // this should be identifier
{ startIndex: 14, type: 'operator.gql' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'type.identifier.gql' },
{ startIndex: 21, type: 'delimiter.gql' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'keyword.gql' }, // this should be identifier
{ startIndex: 31, type: 'operator.gql' },
{ startIndex: 32, type: '' },
{ startIndex: 33, type: 'type.identifier.gql' },
{ startIndex: 41, type: '' },
{ startIndex: 42, type: 'keyword.gql' }, // this should be identifier
{ startIndex: 54, type: 'operator.gql' },
{ startIndex: 55, type: '' },
{ startIndex: 56, type: 'type.identifier.gql' },
{ startIndex: 68, type: '' },
{ startIndex: 69, type: 'delimiter.curly.gql' }
]
}
],
[{
line: `query testQuery($intValue:Int=3){value(arg:{string:"string" int:$intValue}){field1 field2}}`,
tokens: [
{ startIndex: 0, type: "keyword.gql" }, // 'query'
{ startIndex: 5, type: "" }, // ' '
{ startIndex: 6, type: "key.identifier.gql" }, // 'testQuery'
{ startIndex: 15, type: "delimiter.parenthesis.gql" }, // '('
{ startIndex: 16, type: "argument.identifier.gql" }, // '$intValue'
{ startIndex: 25, type: "operator.gql" }, // ':'
{ startIndex: 26, type: "keyword.gql" }, // 'Int'
{ startIndex: 29, type: "operator.gql" }, // '='
{ startIndex: 30, type: "number.gql" }, // '3'
{ startIndex: 31, type: "delimiter.parenthesis.gql" }, // ')'
{ startIndex: 32, type: "delimiter.curly.gql" }, // '{'
{ startIndex: 33, type: "key.identifier.gql" }, // 'value'
{ startIndex: 38, type: "delimiter.parenthesis.gql" }, // '('
{ startIndex: 39, type: "key.identifier.gql" }, // 'arg'
{ startIndex: 42, type: "operator.gql" }, // ':'
{ startIndex: 43, type: "delimiter.curly.gql" }, // '{'
{ startIndex: 44, type: "key.identifier.gql" }, // 'string'
{ startIndex: 50, type: "operator.gql" }, // ':'
{ startIndex: 51, type: "string.quote.gql" }, // '"'
{ startIndex: 52, type: "string.gql" }, // 'string'
{ startIndex: 58, type: "string.quote.gql" }, // '"'
{ startIndex: 59, type: "" }, // ' '
{ startIndex: 60, type: "key.identifier.gql" }, // 'int'
{ startIndex: 63, type: "operator.gql" }, // ':'
{ startIndex: 64, type: "argument.identifier.gql" }, // '$intValue'
{ startIndex: 73, type: "delimiter.curly.gql" }, // '}'
{ startIndex: 74, type: "delimiter.parenthesis.gql" }, // ')'
{ startIndex: 75, type: "delimiter.curly.gql" }, // '{'
{ startIndex: 76, type: "key.identifier.gql" }, // 'field1'
{ startIndex: 82, type: "" }, // ' '
{ startIndex: 83, type: "key.identifier.gql" }, // 'field2'
{ startIndex: 89, type: "delimiter.curly.gql" }, // '}}'
],
}],
[
{
line: `query testQuery($intValue:Int=3){value(arg:{string:"string" int:$intValue}){field1 field2}}`,
tokens: [
{ startIndex: 0, type: 'keyword.gql' }, // 'query'
{ startIndex: 5, type: '' }, // ' '
{ startIndex: 6, type: 'key.identifier.gql' }, // 'testQuery'
{ startIndex: 15, type: 'delimiter.parenthesis.gql' }, // '('
{ startIndex: 16, type: 'argument.identifier.gql' }, // '$intValue'
{ startIndex: 25, type: 'operator.gql' }, // ':'
{ startIndex: 26, type: 'keyword.gql' }, // 'Int'
{ startIndex: 29, type: 'operator.gql' }, // '='
{ startIndex: 30, type: 'number.gql' }, // '3'
{ startIndex: 31, type: 'delimiter.parenthesis.gql' }, // ')'
{ startIndex: 32, type: 'delimiter.curly.gql' }, // '{'
{ startIndex: 33, type: 'key.identifier.gql' }, // 'value'
{ startIndex: 38, type: 'delimiter.parenthesis.gql' }, // '('
{ startIndex: 39, type: 'key.identifier.gql' }, // 'arg'
{ startIndex: 42, type: 'operator.gql' }, // ':'
{ startIndex: 43, type: 'delimiter.curly.gql' }, // '{'
{ startIndex: 44, type: 'key.identifier.gql' }, // 'string'
{ startIndex: 50, type: 'operator.gql' }, // ':'
{ startIndex: 51, type: 'string.quote.gql' }, // '"'
{ startIndex: 52, type: 'string.gql' }, // 'string'
{ startIndex: 58, type: 'string.quote.gql' }, // '"'
{ startIndex: 59, type: '' }, // ' '
{ startIndex: 60, type: 'key.identifier.gql' }, // 'int'
{ startIndex: 63, type: 'operator.gql' }, // ':'
{ startIndex: 64, type: 'argument.identifier.gql' }, // '$intValue'
{ startIndex: 73, type: 'delimiter.curly.gql' }, // '}'
{ startIndex: 74, type: 'delimiter.parenthesis.gql' }, // ')'
{ startIndex: 75, type: 'delimiter.curly.gql' }, // '{'
{ startIndex: 76, type: 'key.identifier.gql' }, // 'field1'
{ startIndex: 82, type: '' }, // ' '
{ startIndex: 83, type: 'key.identifier.gql' }, // 'field2'
{ startIndex: 89, type: 'delimiter.curly.gql' } // '}}'
]
}
],
// More complex test:
// """
@ -95,49 +102,40 @@ testTokenization('graphql', [
[
{
line: '"""',
tokens: [
{ startIndex: 0, type: "string.gql" }
],
tokens: [{ startIndex: 0, type: 'string.gql' }]
},
{
line: 'This is MarkDown',
tokens: [
{ startIndex: 0, type: "" }
],
tokens: [{ startIndex: 0, type: '' }]
},
{
line: '"""',
tokens: [
{ startIndex: 0, type: "string.gql" }
],
tokens: [{ startIndex: 0, type: 'string.gql' }]
},
{
line: 'interface Node {',
tokens: [
{ startIndex: 0, type: "keyword.gql" },
{ startIndex: 9, type: "" },
{ startIndex: 10, type: "type.identifier.gql" },
{ startIndex: 14, type: "" },
{ startIndex: 15, type: "delimiter.curly.gql" },
],
{ startIndex: 0, type: 'keyword.gql' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'type.identifier.gql' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.curly.gql' }
]
},
{
line: ' id: ID!',
tokens: [
{ startIndex: 0, type: "" },
{ startIndex: 2, type: "key.identifier.gql" },
{ startIndex: 4, type: "operator.gql" },
{ startIndex: 5, type: "" },
{ startIndex: 6, type: "keyword.gql" },
{ startIndex: 8, type: "operator.gql" },
],
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'key.identifier.gql' },
{ startIndex: 4, type: 'operator.gql' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'keyword.gql' },
{ startIndex: 8, type: 'operator.gql' }
]
},
{
line: '}',
tokens: [
{ startIndex: 0, type: "delimiter.curly.gql", },
],
},
tokens: [{ startIndex: 0, type: 'delimiter.curly.gql' }]
}
]
]);