Skip to content

Instantly share code, notes, and snippets.

@RB-Lab
Last active April 18, 2017 16:45
Show Gist options
  • Save RB-Lab/cc33715d19de6d6da55b0c08d5c88aa8 to your computer and use it in GitHub Desktop.
Save RB-Lab/cc33715d19de6d6da55b0c08d5c88aa8 to your computer and use it in GitHub Desktop.
Live templates for InteliJ Idea JavaScript files (you can copy them and paste into according templates "folder")

unit-tests

<template name="dsc" value="describe('$text$', () =&gt; {&#10;    $end$&#10;});" description="describe for tests suites" toReformat="false" toShortenFQNames="true">
  <variable name="text" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

<template name="it" value="it('should $text$', () =&gt; {&#10;    $end$&#10;});" description="it - test case in BDD style" toReformat="false" toShortenFQNames="true">
  <variable name="text" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

eslint stuff

<template name="es-dev-dep" value="/* eslint import/no-extraneous-dependencies: [&quot;error&quot;, {&quot;devDependencies&quot;: true}] */" description="eslint: allow to use devDependencies" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

<template name="es-mocha" value="/* eslint env: mocha */" description="eslint: set environment to mocha" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

<template name="esdl" value="// eslint-disable-line $end$" description="eslint-disable-line" toReformat="false" toShortenFQNames="true">
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

<template name="esd" value="/* eslint-disable $rule$ */$end$" description="eslint-disable" toReformat="false" toShortenFQNames="true">
  <variable name="rule" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

imports and require

<template name="im" value="import $name$ from '$module$';$end$" description="es2015 import" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="module" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
    <option name="JSX_HTML" value="true" />
  </context>
</template>

<template name="ir" value="import React, {Component} from 'react';$end$" description="import React &amp; Component" toReformat="false" toShortenFQNames="true">
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
  </context>
</template>

<template name="req" value="const $name$ = require('$module$');&#10;$end$" description="require" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="module" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="JS_STATEMENT" value="true" />
    <option name="JS_EXPRESSION" value="true" />
  </context>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment