diff --git a/extensions/javascript/package.json b/extensions/javascript/package.json index 5e7a91f2bc3..10e0aa8d3ff 100644 --- a/extensions/javascript/package.json +++ b/extensions/javascript/package.json @@ -58,6 +58,10 @@ { "language": "javascript", "path": "./snippets/javascript.json" + }, + { + "language": "javascriptreact", + "path": "./snippets/javascriptreact.json" } ], "jsonValidation": [ diff --git a/extensions/javascript/snippets/javascriptreact.json b/extensions/javascript/snippets/javascriptreact.json new file mode 100644 index 00000000000..6892d470314 --- /dev/null +++ b/extensions/javascript/snippets/javascriptreact.json @@ -0,0 +1,141 @@ +{ + "define module": { + "prefix": "define", + "body": [ + "define([", + "\t'require',", + "\t'${dependency}'", + "], function(require, ${factory}) {", + "\t'use strict';", + "\t$0", + "});" + ], + "description": "define module" + }, + "For Loop": { + "prefix": "for", + "body": [ + "for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {", + "\tvar ${element} = ${array}[${index}];", + "\t$0", + "}" + ], + "description": "For Loop" + }, + "For-Each Loop": { + "prefix": "foreach", + "body": [ + "${array}.forEach(function(${element}) {", + "\t$0", + "}, this);" + ], + "description": "For-Each Loop" + }, + "For-In Loop": { + "prefix": "forin", + "body": [ + "for (var ${key} in ${object}) {", + "\tif (${object}.hasOwnProperty(${key})) {", + "\t\tvar ${element} = ${object}[${key}];", + "\t\t$0", + "\t}", + "}" + ], + "description": "For-In Loop" + }, + "Function Statement": { + "prefix": "function", + "body": [ + "function ${name}(${params}) {", + "\t$0", + "}" + ], + "description": "Function Statement" + }, + "If Statement": { + "prefix": "if", + "body": [ + "if (${condition}) {", + "\t$0", + "}" + ], + "description": "If Statement" + }, + "If-Else Statement": { + "prefix": "ifelse", + "body": [ + "if (${condition}) {", + "\t$0", + "} else {", + "\t", + "}" + ], + "description": "If-Else Statement" + }, + "New Statement": { + "prefix": "new", + "body": [ + "var ${name} = new ${type}(${arguments});$0" + ], + "description": "New Statement" + }, + "Switch Statement": { + "prefix": "switch", + "body": [ + "switch (${key}) {", + "\tcase ${value}:", + "\t\t$0", + "\t\tbreak;", + "", + "\tdefault:", + "\t\tbreak;", + "}" + ], + "description": "Switch Statement" + }, + "While Statement": { + "prefix": "while", + "body": [ + "while (${condition}) {", + "\t$0", + "}" + ], + "description": "While Statement" + }, + "Do-While Statement": { + "prefix": "dowhile", + "body": [ + "do {", + "\t$0", + "} while (${condition});" + ], + "description": "Do-While Statement" + }, + "Try-Catch Statement":{ + "prefix": "trycatch", + "body": [ + "try {", + "\t$0", + "} catch (${error}) {", + "\t", + "}" + ], + "description": "Try-Catch Statement" + }, + "Set Timeout Function": { + "prefix": "settimeout", + "body": [ + "setTimeout(function() {", + "\t$0", + "}, ${timeout});" + ], + "description": "Set Timeout Function" + }, + "Relative Reference to another File": { + "prefix": "reference", + "body": [ + "/// $0" + ], + "description": "Relative Reference to another File" + } +}