This is a small collection of useful JavaScript snippets for VS Code.
Shortcut | Command |
---|---|
cl |
console.log('foo: ', foo) |
clog |
console.log(foo) |
cljson |
console.log(JSON.stringify(foo, null, 2)) |
clobj |
console.log({ foo }) |
cleslint |
// eslint-disable-next-line no-console \n console.log('$1: ', $1) |
Shortcut | Command |
---|---|
esdisable |
/* eslint-disable @typescript-eslint/no-unused-vars */ |
esdisablenextline |
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ |
Shortcut | Command |
---|---|
imp |
import defaultExport from 'module' |
impn |
import { namedExport } from 'module' |
Shortcut | Command |
---|---|
testfile |
Unit test boilerplate |
testdescribe |
describe('', () => {}) |
testspec |
it('', () => {}) |
testassert |
expect(variable).toEqual(result) |
Shortcut | Command |
---|---|
react-typescript |
React component boilerplate |
reactnative-typescript |
React Native component boilerplate |
useEffectHook |
React useEffect hook boilerplate |
This extension can be installed through the VS Code Marketplace:
https://marketplace.visualstudio.com/items?itemName=ezrafree.js-snippets
For development, you can also install manually through git:
cd ~/.vscode/extensions
git clone git@github.com:ezrafree/vscode-javascript-snippets.git ezrafree.js-snippets
You may want to disable keywords in your configuration to make accessing snippets easier:
{
"[javascript]": {
"editor.suggest.showKeywords": false
},
"[javascriptreact]": {
"editor.suggest.showKeywords": false
},
"[typescript]": {
"editor.suggest.showKeywords": false
},
"[typescriptreact]": {
"editor.suggest.showKeywords": false
}
}
Learn more about configuring snippets in the VS Code IntelliSense documentation.
There are no known issues at this time, please reach out if you discover anything.