All Projects → jaydenseric → Fake Tag

jaydenseric / Fake Tag

A fake template literal tag to trick syntax highlighters, linters and formatters into action.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Fake Tag

Minimal Feedback
🗳 minimal-feedback is a blazingly fast and highly customizable component to get user feedback.
Stars: ✭ 78 (+254.55%)
Mutual labels:  featured, npm
Graphql Upload
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
Stars: ✭ 1,071 (+4768.18%)
Mutual labels:  featured, npm
Graphql Multipart Request Spec
A spec for GraphQL multipart form requests (file uploads).
Stars: ✭ 622 (+2727.27%)
Mutual labels:  featured
Npm Font Open Sans
npm package of Open Sans (incl. CSS/LESS/SCSS)
Stars: ✭ 6 (-72.73%)
Mutual labels:  npm
Npm Check Updates
Find newer versions of package dependencies than what your package.json allows
Stars: ✭ 6,617 (+29977.27%)
Mutual labels:  npm
Better Npm Run
🏃‍♂️ Better NPM scripts runner
Stars: ✭ 635 (+2786.36%)
Mutual labels:  npm
Eyeglass
NPM Modules for Sass
Stars: ✭ 741 (+3268.18%)
Mutual labels:  npm
New Bee
开源社区 vue + springBoot - 前后分离微服务的最佳实践
Stars: ✭ 619 (+2713.64%)
Mutual labels:  npm
Vscode Yarn
VSCode extension to manage yarn commands
Stars: ✭ 18 (-18.18%)
Mutual labels:  npm
Np
A better `npm publish`
Stars: ✭ 6,401 (+28995.45%)
Mutual labels:  npm
Showdown Htmlescape
Plugin for Showdown to prevent the use of arbitrary HTML and allow only the specific Markdown syntax.
Stars: ✭ 6 (-72.73%)
Mutual labels:  npm
Lerna
Splitting up large codebases into separate independently versioned packages is extremely useful for code sharing. However, making changes across many repositories is messy and difficult to track, and testing across repositories becomes complicated very quickly.
Stars: ✭ 31,079 (+141168.18%)
Mutual labels:  npm
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+2895.45%)
Mutual labels:  npm
Shrinkpack
Fast, resilient, reproducible builds with npm install.
Stars: ✭ 774 (+3418.18%)
Mutual labels:  npm
Simplestatemanager
A responsive state manager which allows you to run different javascript at different browser widths
Stars: ✭ 632 (+2772.73%)
Mutual labels:  npm
Declarativ
A declarative HTML rendering library that is definitely not JSX.
Stars: ✭ 16 (-27.27%)
Mutual labels:  npm
Django Drip
💧 Use Django admin to manage drip campaign emails using querysets on Django's User model.
Stars: ✭ 620 (+2718.18%)
Mutual labels:  featured
Vue Admin Webapp
this is a admin project
Stars: ✭ 673 (+2959.09%)
Mutual labels:  npm
Eslint Plugin Node
Additional ESLint's rules for Node.js
Stars: ✭ 740 (+3263.64%)
Mutual labels:  npm
Autodeploy
🚀 Autodeploy is a small and highly customizable CLI-Tool to automatically deploy your git repo and execute arbitrary commands/scripts after a specific git action (e.g. push, merge, ...)
Stars: ✭ 20 (-9.09%)
Mutual labels:  npm

fake-tag

npm version CI status

A fake template literal tag to trick syntax highlighters, linters and formatters into action. Interpolations and escapes are tested.

Setup

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!
  }
`

Names other than gql can be used for other use cases.

Why not comment tags?

A comment tag looks like this:

const QUERY = /* GraphQL */ `
  {
    foo
  }
`

They are far superior to a fake tag:

  • No dependency to manage.
  • No inconvenient imports.
  • No bundle size bloat.
  • No runtime overhead.

Unfortunately not all tools support them yet. prettier has since v1.13.0, but eslint-plugin-graphql at v3.1.0 still doesn’t.

Why not String.raw?

This may be temptingly simple:

const gql = String.raw
const QUERY = gql`
  {
    foo
  }
`

However, it doesn’t unescape characters. For the usage example, if you console.log(typeDefs) before and after replacing the import with const 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!
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].