1.1.0 • Published 4 years ago

dynamic-snippets-generator v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Dynamic Snippets generator

Snippet parser for VSCode extention. Inspired by emmet abbreviation syntax.

This parser uses the emmet-like syntax for parsing the most frequently used JavaScript construction. For example this line:

i>request>axios

will be parsed into appropriate VSCode snippet line:

import ${1:request} from '${2:axios}';

Below you will find the list of all possible abbreviations

Abbreviations

AbbreviationVSCode snippetDescription
ES6 import
i>nameimport ${1:name} from '${2:name}';ES6 import
i>defaultExport>nameimport ${1:defaultExport} from '${2:name}';ES6 import with a different default export name
i:a,b>nameimport { ${1:a}, ${2:b} } from '${3:name}';ES6 import with multiple exports
i*alias>nameimport * as ${1:alias} from '${2:name}';ES6 import with a namespace
ES6 export
e>nameexport const ${1:name} = $2Exporting individual variables
ed>nameexport default ${1:name};Default export
CommonJS module require
r>nameconst ${1:name} = require('${2:name}');Module require
r>defaultExport>nameconst ${1:defaultExport} = require('${2:name}');Module require with a different default export name
r:a,b>nameconst { ${1:a}, ${2:b} } = require('${3:name}');Module require with property destructuring
CommonJS module export
me>namemodule.exports = ${1:name};Default module export
Function declaration
f>namefunction ${1:name}() {$2}Without parameters
f>name:a,bfunction ${1:name}(${2:a}, ${3:b}) {$4}With parameters
f>name:a,b:function ${1:name}({ ${2:a}, ${3:b} }) {$4}With one destructured object property
Arrow function expression
name=>const ${1:name} = () => {$2};Without parameters
name:a,b=>const ${1:name} = (${2:a}, ${3:b}) => {$4};With parameters
name:a,b:=>const ${1:name} = ({ ${2:a}, ${3:b} }) => {$4};With one destructured object property

Usage

import generateSnippet from 'dynamic-snippets-generator';

generateSnippet('i>example'); // "import ${1:example} from '${2:example}';"