fake-tag
A fake template literal tag to trick linters and formatters into action. Interpolations and escapes are tested.
This hack will be redundant once comment tags are supported by tools such as Prettier:
`
{
foo
}
`
Install
Install with npm:
npm install fake-tag
Usage
Import and use the tag with the required name:
import gql from 'fake-tag'
const typeDefs = gql`
"A foo."
type Foo {
"The \`Foo\` ID."
id: ID!
}
`
Why not String.raw
?
It doesn’t unescape characters. For the usage example, if you console.log(typeDefs)
before and after replacing the import withconst gql = String.raw
you will see the difference in the type description markdown:
"A foo."
type Foo {
- "The `Foo` ID."
+ "The \`Foo\` ID."
id: ID!
}