|
| 1 | +{ |
| 2 | + "Print to console": { |
| 3 | + "prefix": "u-ci", |
| 4 | + "body": [ |
| 5 | + "console.info('$1');" |
| 6 | + ], |
| 7 | + "description": "Log output to console" |
| 8 | + }, |
| 9 | + "Class Constructor": { |
| 10 | + "prefix": "u-ctor", |
| 11 | + "body": [ |
| 12 | + "constructor(props) {", |
| 13 | + "\tsuper(props);", |
| 14 | + "\t$0", |
| 15 | + "}" |
| 16 | + ], |
| 17 | + "description": "Class constructor" |
| 18 | + }, |
| 19 | + "Import Statement": { |
| 20 | + "prefix": "u-impt", |
| 21 | + "body": [ |
| 22 | + "import $2 from '$1';$0" |
| 23 | + ], |
| 24 | + "description": "Import module" |
| 25 | + }, |
| 26 | + "Stateless component": { |
| 27 | + "prefix": "u-rfc", |
| 28 | + "body": [ |
| 29 | + "import React from 'react';", |
| 30 | + "import PropTypes from 'prop-types';", |
| 31 | + "import styles from './$1.scss';", |
| 32 | + "", |
| 33 | + "export default function $1({ $2 }) {", |
| 34 | + "\treturn (", |
| 35 | + "\t\t$0", |
| 36 | + "\t);", |
| 37 | + "}", |
| 38 | + "", |
| 39 | + "$1.propTypes = {", |
| 40 | + "\t$2: PropTypes.$3.isRequired", |
| 41 | + "};" |
| 42 | + ], |
| 43 | + "description": "Stateless component" |
| 44 | + }, |
| 45 | + "Stateful component": { |
| 46 | + "prefix": "u-rcc", |
| 47 | + "body": [ |
| 48 | + "import React from 'react';", |
| 49 | + "import PropTypes from 'prop-types';", |
| 50 | + "import styles from './$1.scss';", |
| 51 | + "", |
| 52 | + "export default class $1 extends React.Component {", |
| 53 | + "\trender() {", |
| 54 | + "\t\t$0", |
| 55 | + "\t}", |
| 56 | + "}", |
| 57 | + "", |
| 58 | + "$1.propTypes = {", |
| 59 | + "", |
| 60 | + "};" |
| 61 | + ], |
| 62 | + "description": "Stateful component" |
| 63 | + }, |
| 64 | + "Test": { |
| 65 | + "prefix": "u-it", |
| 66 | + "body": [ |
| 67 | + "it('$1', () => {", |
| 68 | + "\tconst wrapper = shallow(<$2 />);", |
| 69 | + "\texpect(wrapper.$0).toBeTruthy();", |
| 70 | + "});" |
| 71 | + ], |
| 72 | + "description": "New unit test" |
| 73 | + }, |
| 74 | + "Test Suite": { |
| 75 | + "prefix": "u-desc", |
| 76 | + "body": [ |
| 77 | + "describe('$1', () => {", |
| 78 | + "\t$0", |
| 79 | + "});" |
| 80 | + ], |
| 81 | + "description": "New test suite" |
| 82 | + }, |
| 83 | + "Test Suite File": { |
| 84 | + "prefix": "u-suite", |
| 85 | + "body": [ |
| 86 | + "import React from 'react';", |
| 87 | + "import $1 from './$1';", |
| 88 | + "import renderer from 'react-test-renderer';", |
| 89 | + "import { shallow } from 'enzyme';", |
| 90 | + "", |
| 91 | + "describe('$1', () => {", |
| 92 | + "\tit('should render', () => {", |
| 93 | + "\t\tconst wrapper = shallow(<$1 />);", |
| 94 | + "\t\texpect(wrapper.find('div').node).toBeTruthy();", |
| 95 | + "\t});", |
| 96 | + "});" |
| 97 | + ], |
| 98 | + "description": "Jest Test Suite" |
| 99 | + }, |
| 100 | + "PropTypes": { |
| 101 | + "prefix": "u-pt", |
| 102 | + "body": [ |
| 103 | + "$1: PropTypes.$2.isRequired" |
| 104 | + ], |
| 105 | + "description": "React PropType" |
| 106 | + }, |
| 107 | + "PropTypes.String": { |
| 108 | + "prefix": "u-pts", |
| 109 | + "body": [ |
| 110 | + "$1: PropTypes.string.isRequired$2" |
| 111 | + ], |
| 112 | + "description": "React PropType String" |
| 113 | + }, |
| 114 | + "PropTypes.Number": { |
| 115 | + "prefix": "u-ptn", |
| 116 | + "body": [ |
| 117 | + "$1: PropTypes.number.isRequired$2" |
| 118 | + ], |
| 119 | + "description": "React PropType Number" |
| 120 | + }, |
| 121 | + "PropTypes.Bool": { |
| 122 | + "prefix": "u-ptb", |
| 123 | + "body": [ |
| 124 | + "$1: PropTypes.bool.isRequired$2" |
| 125 | + ], |
| 126 | + "description": "React PropType Bool" |
| 127 | + }, |
| 128 | + "PropTypes.Func": { |
| 129 | + "prefix": "u-ptf", |
| 130 | + "body": [ |
| 131 | + "$1: PropTypes.func.isRequired$2" |
| 132 | + ], |
| 133 | + "description": "React PropType Func" |
| 134 | + }, |
| 135 | + "PropTypes.Array": { |
| 136 | + "prefix": "u-pta", |
| 137 | + "body": [ |
| 138 | + "$1: PropTypes.array.isRequired$2" |
| 139 | + ], |
| 140 | + "description": "React PropType Array" |
| 141 | + }, |
| 142 | + "PropTypes.Object": { |
| 143 | + "prefix": "u-pto", |
| 144 | + "body": [ |
| 145 | + "$1: PropTypes.object.isRequired$2" |
| 146 | + ], |
| 147 | + "description": "React PropType Object" |
| 148 | + }, |
| 149 | + "PropTypes.Symbol": { |
| 150 | + "prefix": "u-ptsymbol", |
| 151 | + "body": [ |
| 152 | + "$1: PropTypes.symbol.isRequired$2" |
| 153 | + ], |
| 154 | + "description": "React PropType Symbol" |
| 155 | + }, |
| 156 | + "PropTypes.Element": { |
| 157 | + "prefix": "u-pte", |
| 158 | + "body": [ |
| 159 | + "$1: PropTypes.element.isRequired$2" |
| 160 | + ], |
| 161 | + "description": "React PropType Element" |
| 162 | + }, |
| 163 | + "PropTypes.Node": { |
| 164 | + "prefix": "u-ptnode", |
| 165 | + "body": [ |
| 166 | + "$1: PropTypes.node.isRequired$2" |
| 167 | + ], |
| 168 | + "description": "React PropType Node" |
| 169 | + }, |
| 170 | + "PropTypes.InstanceOf": { |
| 171 | + "prefix": "u-ptinstanceof", |
| 172 | + "body": [ |
| 173 | + "$1: PropTypes.instanceOf($2)$3" |
| 174 | + ], |
| 175 | + "description": "React PropType InstanceOf" |
| 176 | + }, |
| 177 | + "PropTypes.OneOf": { |
| 178 | + "prefix": "u-ptoneof", |
| 179 | + "body": [ |
| 180 | + "$1: PropTypes.oneOf([$2])$3" |
| 181 | + ], |
| 182 | + "description": "React PropType OneOf" |
| 183 | + }, |
| 184 | + "PropTypes.OneOfType": { |
| 185 | + "prefix": "u-ptoneoftype", |
| 186 | + "body": [ |
| 187 | + "$1: PropTypes.oneOfType([PropTypes.$2])$3" |
| 188 | + ], |
| 189 | + "description": "React PropType OneOfType" |
| 190 | + }, |
| 191 | + "PropTypes.ArrayOf": { |
| 192 | + "prefix": "u-ptarrayof", |
| 193 | + "body": [ |
| 194 | + "$1: PropTypes.arrayOf(PropTypes.$2).isRequired$3" |
| 195 | + ], |
| 196 | + "description": "React PropType ArrayOf" |
| 197 | + }, |
| 198 | + "PropTypes.ObjectOf": { |
| 199 | + "prefix": "u-ptobjectof", |
| 200 | + "body": [ |
| 201 | + "$1: PropTypes.objectOf(PropTypes.$2).isRequired$3" |
| 202 | + ], |
| 203 | + "description": "React PropType Object" |
| 204 | + }, |
| 205 | + "PropTypes.Shape": { |
| 206 | + "prefix": "u-ptshape", |
| 207 | + "body": [ |
| 208 | + "$1: PropTypes.shape({$2}).isRequired$3" |
| 209 | + ], |
| 210 | + "description": "React PropType Shape" |
| 211 | + }, |
| 212 | + "PropTypes.Any": { |
| 213 | + "prefix": "u-ptany", |
| 214 | + "body": [ |
| 215 | + "$1: PropTypes.any.isRequired$2" |
| 216 | + ], |
| 217 | + "description": "React PropType Any" |
| 218 | + }, |
| 219 | + "PropTypes.CustomProp": { |
| 220 | + "prefix": "u-ptcustom", |
| 221 | + "body": [ |
| 222 | + "function (props, propName, componentName) {", |
| 223 | + "\tif (!/$1/.test(props[propName])) {", |
| 224 | + "\t\treturn new Error(`Invalid prop '${propName}' supplied to '${componentName}'. Validation $2`);", |
| 225 | + "\t}", |
| 226 | + "}" |
| 227 | + ], |
| 228 | + "description": "React PropType Any" |
| 229 | + }, |
| 230 | + "PropTypes.CustomArrayProp": { |
| 231 | + "prefix": "u-ptcustomarrayof", |
| 232 | + "body": [ |
| 233 | + "PropTypes.arrayOf(function (propValue, key, componentName, location, propFullName) {", |
| 234 | + "\tif (!/$1/.test(propValue[key])) {", |
| 235 | + "\t\treturn new Error(`Invalid prop '${propFullName}' supplied to '${componentName}'. Validation $2`);", |
| 236 | + "\t}", |
| 237 | + "})" |
| 238 | + ], |
| 239 | + "description": "React PropType Any" |
| 240 | + }, |
| 241 | + "Redux actions": { |
| 242 | + "prefix": "u-actions", |
| 243 | + "body": [ |
| 244 | + "import { call, put, takeLatest } from 'redux-saga/effects';", |
| 245 | + "", |
| 246 | + "export const $1 = '$1';", |
| 247 | + "export const $2 = () => ({", |
| 248 | + "\ttype: $1", |
| 249 | + "});", |
| 250 | + "", |
| 251 | + "export default function* watch$3() {", |
| 252 | + "\tyield takeLatest($1, $4);", |
| 253 | + "}" |
| 254 | + ], |
| 255 | + "description": "Redux actions" |
| 256 | + }, |
| 257 | + "Redux action": { |
| 258 | + "prefix": "u-action", |
| 259 | + "body": [ |
| 260 | + "export const $1 = '$1';", |
| 261 | + "export const $2 = () => ({", |
| 262 | + "\ttype: $1", |
| 263 | + "});" |
| 264 | + ], |
| 265 | + "description": "Redux action" |
| 266 | + } |
| 267 | +} |
0 commit comments