Last active
March 18, 2020 17:23
-
-
Save joao-fontenele/356f7f2bf64532550454a4c0667b8da2 to your computer and use it in GitHub Desktop.
vs code snippets for js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
"Eslint disable": { | |
"prefix": "esd", | |
"description": "Directive to disable eslint", | |
"body": "// eslint-disable${1:-next}-line ${2:max-len}" | |
}, | |
"Tests block": { | |
"prefix": "tst", | |
"description": "Creates a common test block", | |
"body": [ | |
"${1:describe}('$2', function() {", | |
" $3", | |
"});" | |
] | |
}, | |
"Test hooks blocks": { | |
"prefix": "hook", | |
"description": "Creates common test hooks", | |
"body": [ | |
"beforeEach(function() {", | |
" $1", | |
"});", | |
"", | |
"afterEach(function() {", | |
"});", | |
] | |
}, | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1', $1);" | |
], | |
"description": "Log output to console" | |
}, | |
"Pretty print an object": { | |
"prefix": "ppo", | |
"body": "console.log('$1', JSON.stringify($1, null, ' '));" | |
}, | |
"componentWillMount": { | |
"prefix": "cwm", | |
"description": "React Lifecycle method", | |
"body": [ | |
"componentWillMount() {${1}}" | |
] | |
}, | |
"componentWillUnmount": { | |
"prefix": "cwu", | |
"description": "React Lifecycle method", | |
"body": [ | |
"componentWillUnmount() {${1}}" | |
] | |
}, | |
"componentDidMount": { | |
"prefix": "cdm", | |
"description": "React Lifecycle method", | |
"body": [ | |
"componentDidMount() {${1}}" | |
] | |
}, | |
"componentWillReceiveProps": { | |
"prefix": "cwrp", | |
"description": "React Lifecycle method", | |
"body": [ | |
"componentWillReceiveProps(nextProps) {${1}}" | |
] | |
}, | |
"React component initialization": { | |
"prefix": "component", | |
"description": "Initializes a react component", | |
"body": [ | |
"import React from 'react';", | |
"import PropTypes from 'prop-types';", | |
"import {connect} from 'react-redux';", | |
"", | |
"class ${1:Component} extends React.Component {", | |
" constructor (props) {", | |
" super(props);", | |
" }", | |
"", | |
" render () {", | |
" return (", | |
" <div className=\"\">", | |
" ${2:{this.props.message}}", | |
" </div>", | |
" );", | |
" }", | |
"}", | |
"", | |
"${1:Component}.propTypes = {", | |
" message: PropTypes.string.isRequired,", | |
"};", | |
"", | |
"${1:Component}.defaultProps = {", | |
" message: 'Hello World!',", | |
"};", | |
"", | |
"function mapStateToProps (state, ownProps) {", | |
" return {", | |
" };", | |
"}", | |
"", | |
"export default connect(mapStateToProps)(${1:Component});" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
menu in vs code:
File > Preferences > User Snippets
then type
javascript
for js snippets