diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..9b946fdf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.json] +indent_style = space +indent_size = 4 + +[*.lua] +indent_style = tab +indent_size = 4 + +[*.md] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/package.json b/package.json index 1c6c7167..c254ebec 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,10 @@ "language": "rails", "path": "./snippets/frameworks/rails.json" }, + { + "language": "rspec", + "path": "./snippets/ruby/rspec.json" + }, { "language": "rust", "path": "./snippets/rust/rust.json" @@ -584,10 +588,10 @@ "language": "loremipsum", "path": "./snippets/loremipsum.json" }, - { - "language": "cmake", - "path": "./snippets/cmake.json" - }, + { + "language": "cmake", + "path": "./snippets/cmake.json" + }, { "language": "zig", "path": "./snippets/zig.json" diff --git a/snippets/c/c.json b/snippets/c/c.json index b67b5d79..5028a840 100644 --- a/snippets/c/c.json +++ b/snippets/c/c.json @@ -274,67 +274,67 @@ }, "puts": { "prefix": "puts", - "body": ["puts(\"${1:This function doesn't need newline.}\")$0"], + "body": ["puts(\"${1:This function doesn't need newline.}\");$0"], "description": "puts() snippet" }, "fputs": { "prefix": "fputs", - "body": ["fputs(\"${2:This is a simpler printf.\\n}\", ${1:stdout})$0"], + "body": ["fputs(\"${2:This is a simpler printf.\\n}\", ${1:stdout});$0"], "description": "puts() snippet" }, "printf": { "prefix": "printf", - "body": ["printf(\"${1:%s}\\n\"$2)$0"], + "body": ["printf(\"${1:%s}\\n\"$2);$0"], "description": "printf() snippet" }, "fprintf": { "prefix": "fprintf", - "body": ["fprintf(${1:stderr}, \"${2:%s}\\n\"$3)$0"], + "body": ["fprintf(${1:stderr}, \"${2:%s}\\n\"$3);$0"], "description": "fprintf() snippet" }, "sprintf": { "prefix": "sprintf", - "body": ["sprintf(${1:buf}, \"${2:%s}\\n\"$3)$0"], + "body": ["sprintf(${1:buf}, \"${2:%s}\\n\"$3);$0"], "description": "sprintf() snippet" }, "snprintf": { "prefix": "snprintf", - "body": ["snprintf(${1:buf}, ${2:max}, \"${3:%s}\\n\"$3)$0"], + "body": ["snprintf(${1:buf}, ${2:max}, \"${3:%s}\\n\"$3);$0"], "description": "snprintf() snippet" }, "scanf": { "prefix": "scanf", - "body": ["scanf(\"${1:%d}\"$2)$0"], + "body": ["scanf(\"${1:%d}\"$2);$0"], "description": "scanf() snippet" }, "fscanf": { "prefix": "fscanf", - "body": ["fscanf(${1:stdin}, \"${2:%d}\"$3)$0"], + "body": ["fscanf(${1:stdin}, \"${2:%d}\"$3);$0"], "description": "fscanf() snippet" }, "sscanf": { "prefix": "sscanf", - "body": ["sscanf(${1:buf}, \"${2:%d}\"$3)$0"], + "body": ["sscanf(${1:buf}, \"${2:%d}\"$3);$0"], "description": "sscanf() snippet" }, "malloc": { "prefix": "malloc", - "body": ["malloc(sizeof(${1:int[69]})$2)$0"], + "body": ["malloc(sizeof(${1:int[69]})$2);$0"], "description": "malloc() snippet" }, "calloc": { "prefix": "calloc", - "body": ["calloc(${1:1}, sizeof(${2:int})$3)$0"], + "body": ["calloc(${1:1}, sizeof(${2:int})$3);$0"], "description": "calloc() snippet" }, "realloc": { "prefix": "realloc", - "body": ["realloc(${1:ptr}, sizeof(${2:int[69]})$3)$0"], + "body": ["realloc(${1:ptr}, sizeof(${2:int[69]})$3);$0"], "description": "realloc() snippet" }, "reallocarray": { "prefix": "reallocarray", - "body": ["reallocarray(${1:ptr}, ${2:69}, sizeof(${3:int})$4)$0"], + "body": ["reallocarray(${1:ptr}, ${2:69}, sizeof(${3:int})$4);$0"], "description": "reallocarray() snippet" }, "free": { diff --git a/snippets/cmake.json b/snippets/cmake.json index 5de528de..ef82a815 100644 --- a/snippets/cmake.json +++ b/snippets/cmake.json @@ -229,8 +229,8 @@ "Set c++ standard": { "prefix": "cxx", "body": [ - "set(CMAKE_CXX_STANDDARD ${1:14})", - "set(CMAKE_CXX_STANDDARD_REQUIRED ON)" + "set(CMAKE_CXX_STANDARD ${1:14})", + "set(CMAKE_CXX_STANDARD_REQUIRED ON)" ], "description": "Add the snippet to set c++ standard" }, diff --git a/snippets/cpp/cpp.json b/snippets/cpp/cpp.json index fc5d60e8..168f10d5 100644 --- a/snippets/cpp/cpp.json +++ b/snippets/cpp/cpp.json @@ -37,8 +37,8 @@ }, "while": { "prefix": "while", - "body": ["while ($1) {", "\t$2", "}"], - "description": "" + "body": ["while ($1) {", "\t$0", "}"], + "description": "'while' loop snippet" }, "foreach": { "prefix": "foreach", @@ -269,12 +269,12 @@ "#guard": { "prefix": "#guard", "body": [ - "#ifndef INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", - "#define INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", + "#ifndef INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", + "#define INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", "", "$0", "", - "#endif // INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_" + "#endif // INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_" ], "description": "header guard. format :\n\tINCLUDE____" }, diff --git a/snippets/csharp/csharp.json b/snippets/csharp/csharp.json index cfa210a4..119e30c0 100644 --- a/snippets/csharp/csharp.json +++ b/snippets/csharp/csharp.json @@ -52,10 +52,17 @@ "Console.WriteLine": { "prefix": "cw", "body": [ - "System.Console.WriteLine($0);" + "Console.WriteLine($0);" ], "description": "Console.WriteLine" }, + "Console.ReadLine": { + "prefix": "cr", + "body": [ + "Console.ReadLine($0);" + ], + "description": "Console.ReadLine" + }, "do...while loop": { "prefix": "do", "body": [ diff --git a/snippets/elixir.json b/snippets/elixir.json index d62cfc4b..7886f4a4 100644 --- a/snippets/elixir.json +++ b/snippets/elixir.json @@ -14,6 +14,16 @@ "body": ["defp ${1:name}() do", " $0", "end"], "description": "Define a private function" }, + "df": { + "prefix": "df", + "body": "def ${1:name}(), do: $0", + "description": "Define a one-liner function" + }, + "dfw": { + "prefix": "dfw", + "body": "def ${1:name}(${2:args}) when ${3:guard}, do: $0", + "description": "Define a one-liner function with when guard" + }, "IO.puts": { "prefix": "put", "body": "IO.puts($0)" diff --git a/snippets/erb.json b/snippets/erb.json index e7112ced..4d40d752 100644 --- a/snippets/erb.json +++ b/snippets/erb.json @@ -56,9 +56,19 @@ "body": ["<%= $1 %>"], "description": "render block pe" }, + "comment": { + "prefix": ["pc"], + "body": ["<%# $1 %>"], + "description": "erb print comment" + }, "exec": { "prefix": ["er", "%"], "body": ["<% $1 %>"], "description": "erb exec block" + }, + "link_to": { + "prefix": ["lt"], + "body": ["<%= link_to $1, $2 %>"], + "description": "link_to helper" } } diff --git a/snippets/global.json b/snippets/global.json index c7303eb9..3c238c0b 100644 --- a/snippets/global.json +++ b/snippets/global.json @@ -1,6 +1,6 @@ { "copyright": { - "prefix": "c)", + "prefix": "copyright", "body": [ "Copyright (c) ${CURRENT_YEAR} ${0:Author}. All Rights Reserved." ], diff --git a/snippets/go.json b/snippets/go.json index 5f1fb609..02209ae0 100644 --- a/snippets/go.json +++ b/snippets/go.json @@ -116,7 +116,7 @@ }, "if err != nil": { "prefix": "ir", - "body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}", + "body": "if err != nil {\n\treturn ${1:nil}, ${2:err}\n}", "description": "Snippet for if err != nil" }, "fmt.Println": { diff --git a/snippets/haskell.json b/snippets/haskell.json index 1bc33ece..62e89997 100644 --- a/snippets/haskell.json +++ b/snippets/haskell.json @@ -106,7 +106,7 @@ }, "lambda": { "prefix": ["\\", "lambda"], - "body": ["\\${1:x} -> ${2:undefined}$0"], + "body": ["\\\\${1:x} -> ${2:undefined}$0"], "description": "lambda function" }, "pragma": { diff --git a/snippets/html.json b/snippets/html.json index 839032a6..02456166 100644 --- a/snippets/html.json +++ b/snippets/html.json @@ -1,4 +1,22 @@ { + "!": { + "prefix": "!", + "body": [ + "", + "", + "", + "\t", + "\t", + "\t${5:Document}", + "", + "", + "\t${6}", + "", + "" + ], + "description": "HTML - Defines a template for a html5 document", + "scope": "text.html" + }, "doctype": { "prefix": "doctype", "body": ["", "$1"], @@ -309,12 +327,12 @@ "prefix": "html5", "body": [ "", - "", + "", "\t", "\t\t", "\t\t", "\t\t$2", - "\t\t", + "\t\t", "\t", "\t", "\t$0", diff --git a/snippets/javascript/javascript.json b/snippets/javascript/javascript.json index 0de4d787..5500ecc8 100644 --- a/snippets/javascript/javascript.json +++ b/snippets/javascript/javascript.json @@ -631,7 +631,7 @@ }, "If-Else Statement": { "prefix": "ifelse", - "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"], + "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], "description": "If-Else Statement" }, "New Statement": { diff --git a/snippets/javascript/react-es7.json b/snippets/javascript/react-es7.json index ee54f252..0bdb4a25 100644 --- a/snippets/javascript/react-es7.json +++ b/snippets/javascript/react-es7.json @@ -11,7 +11,7 @@ "prefix": "tsrcc", "description": "Creates a React component class with ES7 module system and TypeScript interfaces", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -31,7 +31,7 @@ "typescriptReactClassExportComponent": { "prefix": "tsrce", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -54,8 +54,7 @@ "typescriptReactFunctionalExportComponent": { "prefix": "tsrfce", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "function ${1:${TM_FILENAME_BASE}}({}: Props) {", @@ -71,8 +70,7 @@ "typescriptReactFunctionalComponent": { "prefix": "tsrfc", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "export default function ${1:${TM_FILENAME_BASE}}({}: Props) {", @@ -86,8 +84,7 @@ "typescriptReactArrowFunctionExportComponent": { "prefix": "tsrafce", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -103,8 +100,7 @@ "typescriptReactArrowFunctionComponent": { "prefix": "tsrafc", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -118,7 +114,7 @@ "typescriptReactClassPureComponent": { "prefix": "tsrpc", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "type Props = {}", "", @@ -135,7 +131,7 @@ "typescriptReactClassExportPureComponent": { "prefix": "tsrpce", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "type Props = {}", "", @@ -155,7 +151,7 @@ "prefix": "tsrcredux", "body": [ "import { connect } from 'react-redux'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -183,8 +179,7 @@ "prefix": "tsrnf", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -203,8 +198,7 @@ "prefix": "tsrnfs", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -224,8 +218,7 @@ "reactArrowFunctionComponent": { "prefix": "rafc", "body": [ - "import React from 'react'", - "", + "export const ${1:${TM_FILENAME_BASE}} = () => {", " return (", "
${1:first}
", @@ -238,7 +231,7 @@ "reactArrowFunctionComponentWithPropTypes": { "prefix": "rafcp", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "const ${1:${TM_FILENAME_BASE}} = props => {", @@ -256,8 +249,7 @@ "reactArrowFunctionExportComponent": { "prefix": "rafce", "body": [ - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", "
${1:first}
", @@ -271,7 +263,7 @@ "reactClassComponent": { "prefix": "rcc", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -288,7 +280,7 @@ "prefix": "rccp", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " static propTypes = {${2:second}: ${3:third}}", @@ -306,7 +298,7 @@ "reactClassComponentRedux": { "prefix": "rcredux", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import { connect } from 'react-redux'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", @@ -329,7 +321,7 @@ "prefix": "rcreduxp", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import { connect } from 'react-redux'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", @@ -355,7 +347,7 @@ "reactClassExportComponent": { "prefix": "rce", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -373,7 +365,7 @@ "prefix": "rcep", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " static propTypes = {}", @@ -392,7 +384,7 @@ "reactClassExportPureComponent": { "prefix": "rpce", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -409,7 +401,7 @@ "reactClassPureComponent": { "prefix": "rpc", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -426,7 +418,7 @@ "prefix": "rpcp", "body": [ "import PropTypes from 'prop-types'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " static propTypes = {}", @@ -444,7 +436,7 @@ "reactFunctionMemoComponent": { "prefix": "rmc", "body": [ - "import React, { memo } from 'react'", + "import { memo } from 'react'", "", "const ${1:${TM_FILENAME_BASE}} = memo(() => {", " return (", @@ -460,7 +452,7 @@ "prefix": "rmcp", "body": [ "import PropTypes from 'prop-types'", - "import React, { memo } from 'react'", + "import { memo } from 'react'", "", "const ${1:${TM_FILENAME_BASE}} = memo((props) => {", " return (", @@ -477,8 +469,7 @@ "reactFunctionalComponent": { "prefix": "rfc", "body": [ - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", "
${1:first}
", @@ -503,7 +494,7 @@ "reactFunctionalComponentRedux": { "prefix": "rfcredux", "body": [ - "import React from 'react'", + "import { connect } from 'react-redux'", "", "export const ${1:${TM_FILENAME_BASE}} = (props) => {", @@ -524,7 +515,7 @@ "prefix": "rfcreduxp", "body": [ "import PropTypes from 'prop-types'", - "import React from 'react'", + "import { connect } from 'react-redux'", "", "export const ${1:${TM_FILENAME_BASE}} = (props) => {", @@ -548,7 +539,7 @@ "reactFunctionalComponentWithPropTypes": { "prefix": "rfcp", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "function ${1:${TM_FILENAME_BASE}}(props) {", @@ -567,8 +558,7 @@ "reactFunctionalExportComponent": { "prefix": "rfce", "body": [ - "import React from 'react'", - "", + "function ${1:${TM_FILENAME_BASE}}() {", " return (", "
${1:first}
", @@ -775,36 +765,36 @@ }, "importReactWithComponent": { "prefix": "imrc", - "body": ["import React, { Component } from 'react'"] + "body": ["import { Component } from 'react'"] }, "importReactWithComponentAndPropTypes": { "prefix": "imrcp", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import PropTypes from 'prop-types'", "" ] }, "importReactWithMemo": { "prefix": "imrm", - "body": ["import React, { memo } from 'react'"] + "body": ["import { memo } from 'react'"] }, "importReactWithMemoAndPropTypes": { "prefix": "imrmp", "body": [ - "import React, { memo } from 'react'", + "import { memo } from 'react'", "import PropTypes from 'prop-types'", "" ] }, "importReactWithPureComponent": { "prefix": "imrpc", - "body": ["import React, { PureComponent } from 'react'"] + "body": ["import { PureComponent } from 'react'"] }, "importReactWithPureComponentAndPropTypes": { "prefix": "imrpcp", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "import PropTypes from 'prop-types'", "" ] @@ -990,7 +980,7 @@ "prefix": "rnc", "body": [ "import { Text, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1007,7 +997,7 @@ "prefix": "rnce", "body": [ "import { Text, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1026,7 +1016,7 @@ "prefix": "rncs", "body": [ "import { Text, StyleSheet, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1045,8 +1035,7 @@ "prefix": "rnf", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", " ", @@ -1060,8 +1049,7 @@ "prefix": "rnfs", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", " ", @@ -1077,8 +1065,7 @@ "prefix": "rnfe", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", " ", @@ -1094,8 +1081,7 @@ "prefix": "rnfes", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", " ", @@ -1117,7 +1103,7 @@ "prefix": "rnpc", "body": [ "import { Text, View } from 'react-native'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -1134,7 +1120,7 @@ "prefix": "rnpce", "body": [ "import { Text, View } from 'react-native'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -1243,7 +1229,7 @@ "setupReactComponentTestWithRedux": { "prefix": "srtest", "body": [ - "import React from 'react'", + "import renderer from 'react-test-renderer'", "import { Provider } from 'react-redux'", "", @@ -1269,7 +1255,7 @@ "prefix": "sntest", "body": [ "import 'react-native'", - "import React from 'react'", + "import renderer from 'react-test-renderer'", "", "import ${1:${TM_FILENAME_BASE}} from '../${1:${TM_FILENAME_BASE}}'", @@ -1288,7 +1274,7 @@ "prefix": "snrtest", "body": [ "import 'react-native'", - "import React from 'react'", + "import renderer from 'react-test-renderer'", "import { Provider } from 'react-redux'", "", @@ -1312,7 +1298,7 @@ "setupReactTest": { "prefix": "stest", "body": [ - "import React from 'react'", + "import renderer from 'react-test-renderer'", "", "import { ${1:${TM_FILENAME_BASE}} } from '../${1:${TM_FILENAME_BASE}}'", @@ -1532,7 +1518,7 @@ "hocComponentWithRedux": { "prefix": "hocredux", "body": [ - "import React from 'react'", + "import { connect } from 'react-redux'", "import PropTypes from 'prop-types'", "", @@ -1555,7 +1541,7 @@ "hocComponent": { "prefix": "hoc", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "export default (WrappedComponent) => {", diff --git a/snippets/javascript/react-native-ts.json b/snippets/javascript/react-native-ts.json index aaf0c311..4eae9c11 100644 --- a/snippets/javascript/react-native-ts.json +++ b/snippets/javascript/react-native-ts.json @@ -2,7 +2,7 @@ "statefulComponent": { "prefix": "rnc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -20,8 +20,7 @@ "statelessComponent": { "prefix": "rnsc", "body": [ - "import React from 'react';", - "", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -36,7 +35,7 @@ "componentFunctional": { "prefix": "rnfc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -53,7 +52,7 @@ "componentFunctionalTypescript": { "prefix": "rnfcc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", diff --git a/snippets/javascript/react-native.json b/snippets/javascript/react-native.json index 918183fb..ed2f3531 100644 --- a/snippets/javascript/react-native.json +++ b/snippets/javascript/react-native.json @@ -2,7 +2,7 @@ "statefulComponent": { "prefix": "rnc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -20,7 +20,7 @@ "statefulReduxComponent": { "prefix": "rnrc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -51,8 +51,7 @@ "statelessComponent": { "prefix": "rnsc", "body": [ - "import React from 'react';", - "", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -67,7 +66,7 @@ "componentFunctional": { "prefix": "rnfc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -84,7 +83,7 @@ "componentFunctionalTypescript": { "prefix": "rnfcc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", diff --git a/snippets/javascript/react-ts.json b/snippets/javascript/react-ts.json index ff02f6b1..372eb6d1 100644 --- a/snippets/javascript/react-ts.json +++ b/snippets/javascript/react-ts.json @@ -1,375 +1,375 @@ { - "destructuring of props": { - "prefix": "dp", - "body": ["const { ${1:name} } = this.props"] - }, - "destructuring of state": { - "prefix": "ds", - "body": ["const { ${1:name} } = this.state"] - }, - "reactClassCompoment": { - "prefix": "rcc", - "body": "import React, { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", - "description": "Creates a React component class" - }, - "reactJustClassCompoment": { - "prefix": "rcjc", - "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", - "description": "Creates a React component class" - }, - "reactClassCompomentPropTypes": { - "prefix": "rccp", - "body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes" - }, - "reactClassCompomentWithMethods": { - "prefix": "rcfc", - "body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes and all lifecycle methods" - }, - "reactFunctionComponent": { - "prefix": "rfc", - "body": "import React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props : {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component without PropTypes" - }, - "reactFunctionComponentWithEmotion": { - "prefix": "rfce", - "body": "import { css } from '@emotion/core'\nimport React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props: {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component with emotion import" - }, - "classConstructor": { - "prefix": "con", - "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props as arguments" - }, - "classConstructorContext": { - "prefix": "conc", - "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props and context as arguments" - }, - "componentWillMount": { - "prefix": "cwm", - "body": "\ncomponentWillMount () {\n\t$0\n}\n", - "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" - }, - "componentDidMount": { - "prefix": "cdm", - "body": "componentDidMount () {\n\t$0\n}\n", - "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." - }, - "componentWillReceiveProps": { - "prefix": "cwr", - "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", - "description": "Invoked when a component is receiving new props. This method is not called for the initial render." - }, - "componentGetDerivedStateFromProps": { - "prefix": "cgd", - "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", - "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." - }, - "shouldComponentUpdate": { - "prefix": "scu", - "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked before rendering when new props or state are being received. " - }, - "componentWillUpdate": { - "prefix": "cwup", - "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked immediately before rendering when new props or state are being received." - }, - "componentDidUpdate": { - "prefix": "cdup", - "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", - "description": "Invoked immediately after the component's updates are flushed to the DOM." - }, - "componentWillUnmount": { - "prefix": "cwun", - "body": "componentWillUnmount () {\n\t$0\n}\n", - "description": "Invoked immediately before a component is unmounted from the DOM." - }, - "componentRender": { - "prefix": "ren", - "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "When called, it should examine this.props and this.state and return a single child element." - }, - "componentSetStateObject": { - "prefix": "sst", - "body": "this.setState($0)", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentSetStateFunc": { - "prefix": "ssf", - "body": "this.setState((state, props) => { return { $0 }})\n", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentProps": { - "prefix": "tp", - "body": "this.props.$0", - "description": "Access component's props" - }, - "componentState": { - "prefix": "ts", - "body": "this.state.$0", - "description": "Access component's state" - }, - "propTypes": { - "prefix": "rpt", - "body": "$1.propTypes = {\n\t$2\n}", - "description": "Creates empty propTypes declaration" - }, - "propTypeArray": { - "prefix": "pta", - "body": "PropTypes.array,", - "description": "Array prop type" - }, - "propTypeArrayRequired": { - "prefix": "ptar", - "body": "PropTypes.array.isRequired,", - "description": "Array prop type required" - }, - "propTypeBool": { - "prefix": "ptb", - "body": "PropTypes.bool,", - "description": "Bool prop type" - }, - "propTypeBoolRequired": { - "prefix": "ptbr", - "body": "PropTypes.bool.isRequired,", - "description": "Bool prop type required" - }, - "propTypeFunc": { - "prefix": "ptf", - "body": "PropTypes.func,", - "description": "Func prop type" - }, - "propTypeFuncRequired": { - "prefix": "ptfr", - "body": "PropTypes.func.isRequired,", - "description": "Func prop type required" - }, - "propTypeNumber": { - "prefix": "ptn", - "body": "PropTypes.number,", - "description": "Number prop type" - }, - "propTypeNumberRequired": { - "prefix": "ptnr", - "body": "PropTypes.number.isRequired,", - "description": "Number prop type required" - }, - "propTypeObject": { - "prefix": "pto", - "body": "PropTypes.object,", - "description": "Object prop type" - }, - "propTypeObjectRequired": { - "prefix": "ptor", - "body": "PropTypes.object.isRequired,", - "description": "Object prop type required" - }, - "propTypeString": { - "prefix": "pts", - "body": "PropTypes.string,", - "description": "String prop type" - }, - "propTypeStringRequired": { - "prefix": "ptsr", - "body": "PropTypes.string.isRequired,", - "description": "String prop type required" - }, - "propTypeNode": { - "prefix": "ptnd", - "body": "PropTypes.node,", - "description": "Anything that can be rendered: numbers, strings, elements or an array" - }, - "propTypeNodeRequired": { - "prefix": "ptndr", - "body": "PropTypes.node.isRequired,", - "description": "Anything that can be rendered: numbers, strings, elements or an array required" - }, - "propTypeElement": { - "prefix": "ptel", - "body": "PropTypes.element,", - "description": "React element prop type" - }, - "propTypeElementRequired": { - "prefix": "ptelr", - "body": "PropTypes.element.isRequired,", - "description": "React element prop type required" - }, - "propTypeInstanceOf": { - "prefix": "pti", - "body": "PropTypes.instanceOf($0),", - "description": "Is an instance of a class prop type" - }, - "propTypeInstanceOfRequired": { - "prefix": "ptir", - "body": "PropTypes.instanceOf($0).isRequired,", - "description": "Is an instance of a class prop type required" - }, - "propTypeEnum": { - "prefix": "pte", - "body": "PropTypes.oneOf(['$0']),", - "description": "Prop type limited to specific values by treating it as an enum" - }, - "propTypeEnumRequired": { - "prefix": "pter", - "body": "PropTypes.oneOf(['$0']).isRequired,", - "description": "Prop type limited to specific values by treating it as an enum required" - }, - "propTypeOneOfType": { - "prefix": "ptet", - "body": "PropTypes.oneOfType([\n\t$0\n]),", - "description": "An object that could be one of many types" - }, - "propTypeOneOfTypeRequired": { - "prefix": "ptetr", - "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", - "description": "An object that could be one of many types required" - }, - "propTypeArrayOf": { - "prefix": "ptao", - "body": "PropTypes.arrayOf($0),", - "description": "An array of a certain type" - }, - "propTypeArrayOfRequired": { - "prefix": "ptaor", - "body": "PropTypes.arrayOf($0).isRequired,", - "description": "An array of a certain type required" - }, - "propTypeObjectOf": { - "prefix": "ptoo", - "body": "PropTypes.objectOf($0),", - "description": "An object with property values of a certain type" - }, - "propTypeObjectOfRequired": { - "prefix": "ptoor", - "body": "PropTypes.objectOf($0).isRequired,", - "description": "An object with property values of a certain type required" - }, - "propTypeShape": { - "prefix": "ptsh", - "body": "PropTypes.shape({\n\t$0\n}),", - "description": "An object taking on a particular shape" - }, - "propTypeShapeRequired": { - "prefix": "ptshr", - "body": "PropTypes.shape({\n\t$0\n}).isRequired,", - "description": "An object taking on a particular shape required" - }, - "jsx element": { - "prefix": "j", - "body": "<${1:elementName}>\n\t$0\n", - "description": "an element" - }, - "jsx element self closed": { - "prefix": "jc", - "body": "<${1:elementName} />", - "description": "an element self closed" - }, - "jsx elements map": { - "prefix": "jm", - "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", - "description": "an element self closed" - }, - "jsx elements map with return": { - "prefix": "jmr", - "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", - "description": "an element self closed" - }, - "jsx element wrap selection": { - "prefix": "jsx wrap selection with element", - "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", - "description": "an element" - }, - "useState": { - "prefix": "us", - "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", - "description": "React useState() hook" - }, - "useEffect": { - "prefix": "ue", - "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], - "description": "React useEffect() hook" - }, - "useEffect with cleanup": { - "prefix": "uec", - "body": [ - "useEffect(() => {", - "\t$1", - "\n\treturn () => {", - "\t\t$2", - "\t}", - "}, [${3:dependencies}])$0" - ], - "description": "React useEffect() hook with a cleanup function" - }, - "createContext": { - "prefix": "cc", - "body": [ - "export const $1 = createContext<$2>(", - "\t(null as any) as $2", - ")" - ], - "description": "creates a react context" - }, - "useContext": { - "prefix": "uc", - "body": ["const $1 = useContext($2)$0"], - "description": "React useContext() hook" - }, - "useRef": { - "prefix": "ur", - "body": ["const ${1:elName}El = useRef(null)$0"], - "description": "React useRef() hook" - }, - "useCallback": { - "prefix": "ucb", - "body": [ - "const ${1:memoizedCallback} = useCallback(", - "\t() => {", - "\t\t${2:doSomething}(${3:a}, ${4:b})", - "\t},", - "\t[${5:a}, ${6:b}],", - ")$0" - ], - "description": "React useCallback() hook" - }, - "useMemo": { - "prefix": "ume", - "body": [ - "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" - ], - "description": "React useMemo() hook" - }, - "createReactHook": { - "prefix": "crh", - "body": [ "export const use$0 = () => {", "", "}" ], - "description": "Create React Hook" - }, - "createReactHookWithName": { - "prefix": "crhn", - "body": [ "export const ${TM_FILENAME_BASE} = () => {", "\t$0", "}"], - "description": "Create React Hook using File name" - }, - "describeBlock": { - "prefix": "desc", - "body": ["describe('$1', () => {", " $0", "})", ""], - "description": "Testing `describe` block" - }, - "testBlock": { - "prefix": "test", - "body": ["test('should $1', () => {", " $0", "})", ""], - "description": "Testing `test` block" - }, - "itBlock": { - "prefix": "tit", - "body": ["it('should $1', () => {", " $0", "})", ""], - "description": "Testing `it` block" - }, - "itAsyncBlock": { - "prefix": "tita", - "body": ["it('should $1', async () => {", " $0", "})", ""], - "description": "Testing async `it` block" - } + "destructuring of props": { + "prefix": "dp", + "body": ["const { ${1:name} } = this.props"] + }, + "destructuring of state": { + "prefix": "ds", + "body": ["const { ${1:name} } = this.state"] + }, + "reactClassComponent": { + "prefix": "rcc", + "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", + "description": "Creates a React component class" + }, + "reactJustClassComponent": { + "prefix": "rcjc", + "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", + "description": "Creates a React component class" + }, + "reactClassComponentPropTypes": { + "prefix": "rccp", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes" + }, + "reactClassComponentWithMethods": { + "prefix": "rcfc", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes and all lifecycle methods" + }, + "reactFunctionComponent": { + "prefix": "rfc", + "body": "export const ${TM_FILENAME_BASE} = (props : {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component without PropTypes" + }, + "reactFunctionComponentWithEmotion": { + "prefix": "rfce", + "body": "import { css } from '@emotion/core'\nexport const ${TM_FILENAME_BASE} = (props: {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component with emotion import" + }, + "classConstructor": { + "prefix": "con", + "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props as arguments" + }, + "classConstructorContext": { + "prefix": "conc", + "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props and context as arguments" + }, + "componentWillMount": { + "prefix": "cwm", + "body": "\ncomponentWillMount () {\n\t$0\n}\n", + "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" + }, + "componentDidMount": { + "prefix": "cdm", + "body": "componentDidMount () {\n\t$0\n}\n", + "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." + }, + "componentWillReceiveProps": { + "prefix": "cwr", + "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", + "description": "Invoked when a component is receiving new props. This method is not called for the initial render." + }, + "componentGetDerivedStateFromProps": { + "prefix": "cgd", + "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", + "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." + }, + "shouldComponentUpdate": { + "prefix": "scu", + "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked before rendering when new props or state are being received. " + }, + "componentWillUpdate": { + "prefix": "cwup", + "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked immediately before rendering when new props or state are being received." + }, + "componentDidUpdate": { + "prefix": "cdup", + "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", + "description": "Invoked immediately after the component's updates are flushed to the DOM." + }, + "componentWillUnmount": { + "prefix": "cwun", + "body": "componentWillUnmount () {\n\t$0\n}\n", + "description": "Invoked immediately before a component is unmounted from the DOM." + }, + "componentRender": { + "prefix": "ren", + "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "When called, it should examine this.props and this.state and return a single child element." + }, + "componentSetStateObject": { + "prefix": "sst", + "body": "this.setState($0)", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentSetStateFunc": { + "prefix": "ssf", + "body": "this.setState((state, props) => { return { $0 }})\n", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentProps": { + "prefix": "tp", + "body": "this.props.$0", + "description": "Access component's props" + }, + "componentState": { + "prefix": "ts", + "body": "this.state.$0", + "description": "Access component's state" + }, + "propTypes": { + "prefix": "rpt", + "body": "$1.propTypes = {\n\t$2\n}", + "description": "Creates empty propTypes declaration" + }, + "propTypeArray": { + "prefix": "pta", + "body": "PropTypes.array,", + "description": "Array prop type" + }, + "propTypeArrayRequired": { + "prefix": "ptar", + "body": "PropTypes.array.isRequired,", + "description": "Array prop type required" + }, + "propTypeBool": { + "prefix": "ptb", + "body": "PropTypes.bool,", + "description": "Bool prop type" + }, + "propTypeBoolRequired": { + "prefix": "ptbr", + "body": "PropTypes.bool.isRequired,", + "description": "Bool prop type required" + }, + "propTypeFunc": { + "prefix": "ptf", + "body": "PropTypes.func,", + "description": "Func prop type" + }, + "propTypeFuncRequired": { + "prefix": "ptfr", + "body": "PropTypes.func.isRequired,", + "description": "Func prop type required" + }, + "propTypeNumber": { + "prefix": "ptn", + "body": "PropTypes.number,", + "description": "Number prop type" + }, + "propTypeNumberRequired": { + "prefix": "ptnr", + "body": "PropTypes.number.isRequired,", + "description": "Number prop type required" + }, + "propTypeObject": { + "prefix": "pto", + "body": "PropTypes.object,", + "description": "Object prop type" + }, + "propTypeObjectRequired": { + "prefix": "ptor", + "body": "PropTypes.object.isRequired,", + "description": "Object prop type required" + }, + "propTypeString": { + "prefix": "pts", + "body": "PropTypes.string,", + "description": "String prop type" + }, + "propTypeStringRequired": { + "prefix": "ptsr", + "body": "PropTypes.string.isRequired,", + "description": "String prop type required" + }, + "propTypeNode": { + "prefix": "ptnd", + "body": "PropTypes.node,", + "description": "Anything that can be rendered: numbers, strings, elements or an array" + }, + "propTypeNodeRequired": { + "prefix": "ptndr", + "body": "PropTypes.node.isRequired,", + "description": "Anything that can be rendered: numbers, strings, elements or an array required" + }, + "propTypeElement": { + "prefix": "ptel", + "body": "PropTypes.element,", + "description": "React element prop type" + }, + "propTypeElementRequired": { + "prefix": "ptelr", + "body": "PropTypes.element.isRequired,", + "description": "React element prop type required" + }, + "propTypeInstanceOf": { + "prefix": "pti", + "body": "PropTypes.instanceOf($0),", + "description": "Is an instance of a class prop type" + }, + "propTypeInstanceOfRequired": { + "prefix": "ptir", + "body": "PropTypes.instanceOf($0).isRequired,", + "description": "Is an instance of a class prop type required" + }, + "propTypeEnum": { + "prefix": "pte", + "body": "PropTypes.oneOf(['$0']),", + "description": "Prop type limited to specific values by treating it as an enum" + }, + "propTypeEnumRequired": { + "prefix": "pter", + "body": "PropTypes.oneOf(['$0']).isRequired,", + "description": "Prop type limited to specific values by treating it as an enum required" + }, + "propTypeOneOfType": { + "prefix": "ptet", + "body": "PropTypes.oneOfType([\n\t$0\n]),", + "description": "An object that could be one of many types" + }, + "propTypeOneOfTypeRequired": { + "prefix": "ptetr", + "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", + "description": "An object that could be one of many types required" + }, + "propTypeArrayOf": { + "prefix": "ptao", + "body": "PropTypes.arrayOf($0),", + "description": "An array of a certain type" + }, + "propTypeArrayOfRequired": { + "prefix": "ptaor", + "body": "PropTypes.arrayOf($0).isRequired,", + "description": "An array of a certain type required" + }, + "propTypeObjectOf": { + "prefix": "ptoo", + "body": "PropTypes.objectOf($0),", + "description": "An object with property values of a certain type" + }, + "propTypeObjectOfRequired": { + "prefix": "ptoor", + "body": "PropTypes.objectOf($0).isRequired,", + "description": "An object with property values of a certain type required" + }, + "propTypeShape": { + "prefix": "ptsh", + "body": "PropTypes.shape({\n\t$0\n}),", + "description": "An object taking on a particular shape" + }, + "propTypeShapeRequired": { + "prefix": "ptshr", + "body": "PropTypes.shape({\n\t$0\n}).isRequired,", + "description": "An object taking on a particular shape required" + }, + "jsx element": { + "prefix": "j", + "body": "<${1:elementName}>\n\t$0\n", + "description": "an element" + }, + "jsx element self closed": { + "prefix": "jc", + "body": "<${1:elementName} />", + "description": "an element self closed" + }, + "jsx elements map": { + "prefix": "jm", + "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", + "description": "an element self closed" + }, + "jsx elements map with return": { + "prefix": "jmr", + "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", + "description": "an element self closed" + }, + "jsx element wrap selection": { + "prefix": "jsx wrap selection with element", + "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", + "description": "an element" + }, + "useState": { + "prefix": "us", + "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", + "description": "React useState() hook" + }, + "useEffect": { + "prefix": "ue", + "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], + "description": "React useEffect() hook" + }, + "useEffect with cleanup": { + "prefix": "uec", + "body": [ + "useEffect(() => {", + "\t$1", + "\n\treturn () => {", + "\t\t$2", + "\t}", + "}, [${3:dependencies}])$0" + ], + "description": "React useEffect() hook with a cleanup function" + }, + "createContext": { + "prefix": "cc", + "body": [ + "export const $1 = createContext<$2>(", + "\t(null as any) as $2", + ")" + ], + "description": "creates a react context" + }, + "useContext": { + "prefix": "uc", + "body": ["const $1 = useContext($2)$0"], + "description": "React useContext() hook" + }, + "useRef": { + "prefix": "ur", + "body": ["const ${1:elName}El = useRef(null)$0"], + "description": "React useRef() hook" + }, + "useCallback": { + "prefix": "ucb", + "body": [ + "const ${1:memoizedCallback} = useCallback(", + "\t() => {", + "\t\t${2:doSomething}(${3:a}, ${4:b})", + "\t},", + "\t[${5:a}, ${6:b}],", + ")$0" + ], + "description": "React useCallback() hook" + }, + "useMemo": { + "prefix": "ume", + "body": [ + "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" + ], + "description": "React useMemo() hook" + }, + "createReactHook": { + "prefix": "crh", + "body": ["export const use$0 = () => {", "", "}"], + "description": "Create React Hook" + }, + "createReactHookWithName": { + "prefix": "crhn", + "body": ["export const ${TM_FILENAME_BASE} = () => {", "\t$0", "}"], + "description": "Create React Hook using File name" + }, + "describeBlock": { + "prefix": "desc", + "body": ["describe('$1', () => {", " $0", "})", ""], + "description": "Testing `describe` block" + }, + "testBlock": { + "prefix": "test", + "body": ["test('should $1', () => {", " $0", "})", ""], + "description": "Testing `test` block" + }, + "itBlock": { + "prefix": "tit", + "body": ["it('should $1', () => {", " $0", "})", ""], + "description": "Testing `it` block" + }, + "itAsyncBlock": { + "prefix": "tita", + "body": ["it('should $1', async () => {", " $0", "})", ""], + "description": "Testing async `it` block" + } } diff --git a/snippets/javascript/react.json b/snippets/javascript/react.json index b51c5847..a41e83d9 100644 --- a/snippets/javascript/react.json +++ b/snippets/javascript/react.json @@ -1,370 +1,370 @@ { - "destructuring of props": { - "prefix": "dp", - "body": ["const { ${1:name} } = this.props"] - }, - "destructuring of state": { - "prefix": "ds", - "body": ["const { ${1:name} } = this.state"] - }, - "if falsy return null": { - "prefix": "ifr", - "body": "if (!${1:condition}) {\n\treturn null\n}" - }, - "reactClassCompoment": { - "prefix": "rcc", - "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", - "description": "Creates a React component class" - }, - "reactJustClassCompoment": { - "prefix": "rcjc", - "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", - "description": "Creates a React component class" - }, - "reactClassCompomentPropTypes": { - "prefix": "rccp", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes" - }, - "reactClassCompomentWithMethods": { - "prefix": "rcfc", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes and all lifecycle methods" - }, - "reactFunctionComponent": { - "prefix": "rfc", - "body": "\nconst ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${TM_FILENAME_BASE}", - "description": "Creates a React function component without PropTypes" - }, - "reactFunctionComponentWithCustomName": { - "prefix": "rfcn", - "body": "\nconst ${1:functionname} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${1:functionname}", - "description": "Creates a React function component with custom name" - }, - "reactFunctionComponentWithEmotion": { - "prefix": "rfce", - "body": "import { css } from '@emotion/core'\n\nexport const ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component with emotion" - }, - "reactStatelessProps": { - "prefix": "rfcp", - "body": "import { PropTypes } from 'react'\n\nconst ${TM_FILENAME_BASE} = props => {\n\treturn (\n\t\t
\n\t\t\t\n\t\t
\n\t)\n}\n\n${1}.propTypes = {\n\t$0\n}\n\nexport default ${1}", - "description": "Creates a React function component with PropTypes" - }, - "classConstructor": { - "prefix": "con", - "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props as arguments" - }, - "classConstructorContext": { - "prefix": "conc", - "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props and context as arguments" - }, - "componentWillMount": { - "prefix": "cwm", - "body": "\ncomponentWillMount () {\n\t$0\n}\n", - "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" - }, - "componentDidMount": { - "prefix": "cdm", - "body": "componentDidMount () {\n\t$0\n}\n", - "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." - }, - "componentWillReceiveProps": { - "prefix": "cwr", - "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", - "description": "Invoked when a component is receiving new props. This method is not called for the initial render." - }, - "componentGetDerivedStateFromProps": { - "prefix": "cgd", - "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", - "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." - }, - "shouldComponentUpdate": { - "prefix": "scu", - "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked before rendering when new props or state are being received. " - }, - "componentWillUpdate": { - "prefix": "cwup", - "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked immediately before rendering when new props or state are being received." - }, - "componentDidUpdate": { - "prefix": "cdup", - "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", - "description": "Invoked immediately after the component's updates are flushed to the DOM." - }, - "componentWillUnmount": { - "prefix": "cwun", - "body": "componentWillUnmount () {\n\t$0\n}\n", - "description": "Invoked immediately before a component is unmounted from the DOM." - }, - "componentRender": { - "prefix": "ren", - "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "When called, it should examine this.props and this.state and return a single child element." - }, - "componentSetStateObject": { - "prefix": "sst", - "body": "this.setState($0)", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentSetStateFunc": { - "prefix": "ssf", - "body": "this.setState((state, props) => { return { $0 }})\n", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentProps": { - "prefix": "tp", - "body": "this.props.$0", - "description": "Access component's props" - }, - "componentState": { - "prefix": "ts", - "body": "this.state.$0", - "description": "Access component's state" - }, - "propTypes": { - "prefix": "rpt", - "body": "$1.propTypes = {\n\t$2\n}", - "description": "Creates empty propTypes declaration" - }, - "propTypeArray": { - "prefix": "pta", - "body": "PropTypes.array,", - "description": "Array prop type" - }, - "propTypeArrayRequired": { - "prefix": "ptar", - "body": "PropTypes.array.isRequired,", - "description": "Array prop type required" - }, - "propTypeBool": { - "prefix": "ptb", - "body": "PropTypes.bool,", - "description": "Bool prop type" - }, - "propTypeBoolRequired": { - "prefix": "ptbr", - "body": "PropTypes.bool.isRequired,", - "description": "Bool prop type required" - }, - "propTypeFunc": { - "prefix": "ptf", - "body": "PropTypes.func,", - "description": "Func prop type" - }, - "propTypeFuncRequired": { - "prefix": "ptfr", - "body": "PropTypes.func.isRequired,", - "description": "Func prop type required" - }, - "propTypeNumber": { - "prefix": "ptn", - "body": "PropTypes.number,", - "description": "Number prop type" - }, - "propTypeNumberRequired": { - "prefix": "ptnr", - "body": "PropTypes.number.isRequired,", - "description": "Number prop type required" - }, - "propTypeObject": { - "prefix": "pto", - "body": "PropTypes.object,", - "description": "Object prop type" - }, - "propTypeObjectRequired": { - "prefix": "ptor", - "body": "PropTypes.object.isRequired,", - "description": "Object prop type required" - }, - "propTypeString": { - "prefix": "pts", - "body": "PropTypes.string,", - "description": "String prop type" - }, - "propTypeStringRequired": { - "prefix": "ptsr", - "body": "PropTypes.string.isRequired,", - "description": "String prop type required" - }, - "propTypeNode": { - "prefix": "ptnd", - "body": "PropTypes.node,", - "description": "Anything that can be rendered: numbers, strings, elements or an array" - }, - "propTypeNodeRequired": { - "prefix": "ptndr", - "body": "PropTypes.node.isRequired,", - "description": "Anything that can be rendered: numbers, strings, elements or an array required" - }, - "propTypeElement": { - "prefix": "ptel", - "body": "PropTypes.element,", - "description": "React element prop type" - }, - "propTypeElementRequired": { - "prefix": "ptelr", - "body": "PropTypes.element.isRequired,", - "description": "React element prop type required" - }, - "propTypeInstanceOf": { - "prefix": "pti", - "body": "PropTypes.instanceOf($0),", - "description": "Is an instance of a class prop type" - }, - "propTypeInstanceOfRequired": { - "prefix": "ptir", - "body": "PropTypes.instanceOf($0).isRequired,", - "description": "Is an instance of a class prop type required" - }, - "propTypeEnum": { - "prefix": "pte", - "body": "PropTypes.oneOf(['$0']),", - "description": "Prop type limited to specific values by treating it as an enum" - }, - "propTypeEnumRequired": { - "prefix": "pter", - "body": "PropTypes.oneOf(['$0']).isRequired,", - "description": "Prop type limited to specific values by treating it as an enum required" - }, - "propTypeOneOfType": { - "prefix": "ptet", - "body": "PropTypes.oneOfType([\n\t$0\n]),", - "description": "An object that could be one of many types" - }, - "propTypeOneOfTypeRequired": { - "prefix": "ptetr", - "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", - "description": "An object that could be one of many types required" - }, - "propTypeArrayOf": { - "prefix": "ptao", - "body": "PropTypes.arrayOf($0),", - "description": "An array of a certain type" - }, - "propTypeArrayOfRequired": { - "prefix": "ptaor", - "body": "PropTypes.arrayOf($0).isRequired,", - "description": "An array of a certain type required" - }, - "propTypeObjectOf": { - "prefix": "ptoo", - "body": "PropTypes.objectOf($0),", - "description": "An object with property values of a certain type" - }, - "propTypeObjectOfRequired": { - "prefix": "ptoor", - "body": "PropTypes.objectOf($0).isRequired,", - "description": "An object with property values of a certain type required" - }, - "propTypeShape": { - "prefix": "ptsh", - "body": "PropTypes.shape({\n\t$0\n}),", - "description": "An object taking on a particular shape" - }, - "propTypeShapeRequired": { - "prefix": "ptshr", - "body": "PropTypes.shape({\n\t$0\n}).isRequired,", - "description": "An object taking on a particular shape required" - }, - "jsx element": { - "prefix": "j", - "body": "<${1:elementName}>\n\t$0\n", - "description": "an element" - }, - "jsx element self closed": { - "prefix": "jc", - "body": "<${1:elementName} />", - "description": "an element self closed" - }, - "jsx elements map": { - "prefix": "jm", - "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", - "description": "an element self closed" - }, - "jsx elements map with return": { - "prefix": "jmr", - "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", - "description": "an element self closed" - }, - "jsx element wrap selection": { - "prefix": "jsx wrap selection with element", - "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", - "description": "an element" - }, - "useState": { - "prefix": "us", - "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", - "description": "React useState() hook" - }, - "useEffect": { - "prefix": "ue", - "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], - "description": "React useEffect() hook" - }, - "useEffect with return": { - "prefix": "uer", - "body": [ - "useEffect(() => {", - "\t$1", - "\n\treturn () => {", - "\t\t$2", - "\t}", - "}, [${3:dependencies}])$0" - ], - "description": "React useEffect() hook with return statement" - }, - "useContext": { - "prefix": "uc", - "body": ["const $1 = useContext($2)$0"], - "description": "React useContext() hook" - }, - "useRef": { - "prefix": "ur", - "body": ["const ${1:elName}El = useRef(null)$0"], - "description": "React useContext() hook" - }, - "useCallback": { - "prefix": "ucb", - "body": [ - "const ${1:memoizedCallback} = useCallback(", - "\t() => {", - "\t\t${2:doSomething}(${3:a}, ${4:b})", - "\t},", - "\t[${5:a}, ${6:b}],", - ")$0" - ], - "description": "React useCallback() hook" - }, - "useMemo": { - "prefix": "ume", - "body": [ - "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" - ], - "description": "React useMemo() hook" - }, - "describeBlock": { - "prefix": "desc", - "body": ["describe('$1', () => {", " $0", "})", ""], - "description": "Testing `describe` block" - }, - "testBlock": { - "prefix": "test", - "body": ["test('should $1', () => {", " $0", "})", ""], - "description": "Testing `test` block" - }, - "itBlock": { - "prefix": "tit", - "body": ["it('should $1', () => {", " $0", "})", ""], - "description": "Testing `it` block" - }, - "itAsyncBlock": { - "prefix": "tita", - "body": ["it('should $1', async () => {", " $0", "})", ""], - "description": "Testing async `it` block" - } + "destructuring of props": { + "prefix": "dp", + "body": ["const { ${1:name} } = this.props"] + }, + "destructuring of state": { + "prefix": "ds", + "body": ["const { ${1:name} } = this.state"] + }, + "if falsy return null": { + "prefix": "ifr", + "body": "if (!${1:condition}) {\n\treturn null\n}" + }, + "reactClassComponent": { + "prefix": "rcc", + "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", + "description": "Creates a React component class" + }, + "reactJustClassComponent": { + "prefix": "rcjc", + "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", + "description": "Creates a React component class" + }, + "reactClassComponentPropTypes": { + "prefix": "rccp", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes" + }, + "reactClassComponentWithMethods": { + "prefix": "rcfc", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes and all lifecycle methods" + }, + "reactFunctionComponent": { + "prefix": "rfc", + "body": "\nconst ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${TM_FILENAME_BASE}", + "description": "Creates a React function component without PropTypes" + }, + "reactFunctionComponentWithCustomName": { + "prefix": "rfcn", + "body": "\nconst ${1:functionname} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${1:functionname}", + "description": "Creates a React function component with custom name" + }, + "reactFunctionComponentWithEmotion": { + "prefix": "rfce", + "body": "import { css } from '@emotion/core'\n\nexport const ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component with emotion" + }, + "reactStatelessProps": { + "prefix": "rfcp", + "body": "import { PropTypes } from 'react'\n\nconst ${TM_FILENAME_BASE} = props => {\n\treturn (\n\t\t
\n\t\t\t\n\t\t
\n\t)\n}\n\n${1}.propTypes = {\n\t$0\n}\n\nexport default ${1}", + "description": "Creates a React function component with PropTypes" + }, + "classConstructor": { + "prefix": "con", + "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props as arguments" + }, + "classConstructorContext": { + "prefix": "conc", + "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props and context as arguments" + }, + "componentWillMount": { + "prefix": "cwm", + "body": "\ncomponentWillMount () {\n\t$0\n}\n", + "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" + }, + "componentDidMount": { + "prefix": "cdm", + "body": "componentDidMount () {\n\t$0\n}\n", + "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." + }, + "componentWillReceiveProps": { + "prefix": "cwr", + "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", + "description": "Invoked when a component is receiving new props. This method is not called for the initial render." + }, + "componentGetDerivedStateFromProps": { + "prefix": "cgd", + "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", + "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." + }, + "shouldComponentUpdate": { + "prefix": "scu", + "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked before rendering when new props or state are being received. " + }, + "componentWillUpdate": { + "prefix": "cwup", + "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked immediately before rendering when new props or state are being received." + }, + "componentDidUpdate": { + "prefix": "cdup", + "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", + "description": "Invoked immediately after the component's updates are flushed to the DOM." + }, + "componentWillUnmount": { + "prefix": "cwun", + "body": "componentWillUnmount () {\n\t$0\n}\n", + "description": "Invoked immediately before a component is unmounted from the DOM." + }, + "componentRender": { + "prefix": "ren", + "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "When called, it should examine this.props and this.state and return a single child element." + }, + "componentSetStateObject": { + "prefix": "sst", + "body": "this.setState($0)", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentSetStateFunc": { + "prefix": "ssf", + "body": "this.setState((state, props) => { return { $0 }})\n", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentProps": { + "prefix": "tp", + "body": "this.props.$0", + "description": "Access component's props" + }, + "componentState": { + "prefix": "ts", + "body": "this.state.$0", + "description": "Access component's state" + }, + "propTypes": { + "prefix": "rpt", + "body": "$1.propTypes = {\n\t$2\n}", + "description": "Creates empty propTypes declaration" + }, + "propTypeArray": { + "prefix": "pta", + "body": "PropTypes.array,", + "description": "Array prop type" + }, + "propTypeArrayRequired": { + "prefix": "ptar", + "body": "PropTypes.array.isRequired,", + "description": "Array prop type required" + }, + "propTypeBool": { + "prefix": "ptb", + "body": "PropTypes.bool,", + "description": "Bool prop type" + }, + "propTypeBoolRequired": { + "prefix": "ptbr", + "body": "PropTypes.bool.isRequired,", + "description": "Bool prop type required" + }, + "propTypeFunc": { + "prefix": "ptf", + "body": "PropTypes.func,", + "description": "Func prop type" + }, + "propTypeFuncRequired": { + "prefix": "ptfr", + "body": "PropTypes.func.isRequired,", + "description": "Func prop type required" + }, + "propTypeNumber": { + "prefix": "ptn", + "body": "PropTypes.number,", + "description": "Number prop type" + }, + "propTypeNumberRequired": { + "prefix": "ptnr", + "body": "PropTypes.number.isRequired,", + "description": "Number prop type required" + }, + "propTypeObject": { + "prefix": "pto", + "body": "PropTypes.object,", + "description": "Object prop type" + }, + "propTypeObjectRequired": { + "prefix": "ptor", + "body": "PropTypes.object.isRequired,", + "description": "Object prop type required" + }, + "propTypeString": { + "prefix": "pts", + "body": "PropTypes.string,", + "description": "String prop type" + }, + "propTypeStringRequired": { + "prefix": "ptsr", + "body": "PropTypes.string.isRequired,", + "description": "String prop type required" + }, + "propTypeNode": { + "prefix": "ptnd", + "body": "PropTypes.node,", + "description": "Anything that can be rendered: numbers, strings, elements or an array" + }, + "propTypeNodeRequired": { + "prefix": "ptndr", + "body": "PropTypes.node.isRequired,", + "description": "Anything that can be rendered: numbers, strings, elements or an array required" + }, + "propTypeElement": { + "prefix": "ptel", + "body": "PropTypes.element,", + "description": "React element prop type" + }, + "propTypeElementRequired": { + "prefix": "ptelr", + "body": "PropTypes.element.isRequired,", + "description": "React element prop type required" + }, + "propTypeInstanceOf": { + "prefix": "pti", + "body": "PropTypes.instanceOf($0),", + "description": "Is an instance of a class prop type" + }, + "propTypeInstanceOfRequired": { + "prefix": "ptir", + "body": "PropTypes.instanceOf($0).isRequired,", + "description": "Is an instance of a class prop type required" + }, + "propTypeEnum": { + "prefix": "pte", + "body": "PropTypes.oneOf(['$0']),", + "description": "Prop type limited to specific values by treating it as an enum" + }, + "propTypeEnumRequired": { + "prefix": "pter", + "body": "PropTypes.oneOf(['$0']).isRequired,", + "description": "Prop type limited to specific values by treating it as an enum required" + }, + "propTypeOneOfType": { + "prefix": "ptet", + "body": "PropTypes.oneOfType([\n\t$0\n]),", + "description": "An object that could be one of many types" + }, + "propTypeOneOfTypeRequired": { + "prefix": "ptetr", + "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", + "description": "An object that could be one of many types required" + }, + "propTypeArrayOf": { + "prefix": "ptao", + "body": "PropTypes.arrayOf($0),", + "description": "An array of a certain type" + }, + "propTypeArrayOfRequired": { + "prefix": "ptaor", + "body": "PropTypes.arrayOf($0).isRequired,", + "description": "An array of a certain type required" + }, + "propTypeObjectOf": { + "prefix": "ptoo", + "body": "PropTypes.objectOf($0),", + "description": "An object with property values of a certain type" + }, + "propTypeObjectOfRequired": { + "prefix": "ptoor", + "body": "PropTypes.objectOf($0).isRequired,", + "description": "An object with property values of a certain type required" + }, + "propTypeShape": { + "prefix": "ptsh", + "body": "PropTypes.shape({\n\t$0\n}),", + "description": "An object taking on a particular shape" + }, + "propTypeShapeRequired": { + "prefix": "ptshr", + "body": "PropTypes.shape({\n\t$0\n}).isRequired,", + "description": "An object taking on a particular shape required" + }, + "jsx element": { + "prefix": "j", + "body": "<${1:elementName}>\n\t$0\n", + "description": "an element" + }, + "jsx element self closed": { + "prefix": "jc", + "body": "<${1:elementName} />", + "description": "an element self closed" + }, + "jsx elements map": { + "prefix": "jm", + "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", + "description": "an element self closed" + }, + "jsx elements map with return": { + "prefix": "jmr", + "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", + "description": "an element self closed" + }, + "jsx element wrap selection": { + "prefix": "jsx wrap selection with element", + "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", + "description": "an element" + }, + "useState": { + "prefix": "us", + "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", + "description": "React useState() hook" + }, + "useEffect": { + "prefix": "ue", + "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], + "description": "React useEffect() hook" + }, + "useEffect with return": { + "prefix": "uer", + "body": [ + "useEffect(() => {", + "\t$1", + "\n\treturn () => {", + "\t\t$2", + "\t}", + "}, [${3:dependencies}])$0" + ], + "description": "React useEffect() hook with return statement" + }, + "useContext": { + "prefix": "uc", + "body": ["const $1 = useContext($2)$0"], + "description": "React useContext() hook" + }, + "useRef": { + "prefix": "ur", + "body": ["const ${1:elName}El = useRef(null)$0"], + "description": "React useContext() hook" + }, + "useCallback": { + "prefix": "ucb", + "body": [ + "const ${1:memoizedCallback} = useCallback(", + "\t() => {", + "\t\t${2:doSomething}(${3:a}, ${4:b})", + "\t},", + "\t[${5:a}, ${6:b}],", + ")$0" + ], + "description": "React useCallback() hook" + }, + "useMemo": { + "prefix": "ume", + "body": [ + "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" + ], + "description": "React useMemo() hook" + }, + "describeBlock": { + "prefix": "desc", + "body": ["describe('$1', () => {", " $0", "})", ""], + "description": "Testing `describe` block" + }, + "testBlock": { + "prefix": "test", + "body": ["test('should $1', () => {", " $0", "})", ""], + "description": "Testing `test` block" + }, + "itBlock": { + "prefix": "tit", + "body": ["it('should $1', () => {", " $0", "})", ""], + "description": "Testing `it` block" + }, + "itAsyncBlock": { + "prefix": "tita", + "body": ["it('should $1', async () => {", " $0", "})", ""], + "description": "Testing async `it` block" + } } diff --git a/snippets/javascript/typescript.json b/snippets/javascript/typescript.json index 665aeff2..29b447a8 100644 --- a/snippets/javascript/typescript.json +++ b/snippets/javascript/typescript.json @@ -165,7 +165,7 @@ }, "If-Else Statement": { "prefix": "ifelse", - "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"], + "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], "description": "If-Else Statement" }, "New Statement": { diff --git a/snippets/lua/lua.json b/snippets/lua/lua.json index 0da132f4..814a34ee 100644 --- a/snippets/lua/lua.json +++ b/snippets/lua/lua.json @@ -1,37 +1,35 @@ { "require": { "prefix": "req", - "body": ["require(\"${1:module}\")"], + "body": ["require(${1:module})"], "description": "Require module" }, "return": { "prefix": "rt", "body": ["return $0"], - "description": "return value" + "description": "Return value" }, "assigment": { "prefix": "ll", "body": ["local ${1:varName} = ${0:value}"], - "description": "create a variable" + "description": "Define a variable" }, "local": { "prefix": "l", "body": ["local ${0}"], - "description": "create a variable" + "description": "Declare a variable" }, "locreq": { "prefix": "lreq", - "body": ["local ${1:var} = require(\"${2:module}\")"], + "body": ["local ${1:module} = require(\"${2:$1}\")$0"], "description": "Require module as a variable" }, "class": { "prefix": "cl", "body": [ - "${1:className} = {}\n", + "${1:M} = {}\n", "$1.${2:new} = function($3)", - "\tlocal ${4:varName} = ${5:value}\n", - "\t${6: --code}\n", - "\treturn $4", + "\t${6}", "end" ], "description": "Create a class" @@ -46,32 +44,65 @@ }, "for": { "prefix": "for", - "body": ["for ${1:i}=${2:1},${3:10} do", "\t$0", "end"], - "description": "for loop range" + "body": ["for $1 do", "\t$0", "end"], + "description": "for statement" }, - "foreach": { - "prefix": "foreach", - "body": ["for i, ${1:x} in pairs(${2:table}) do", "\t$0", "end"] + "for-numeric": { + "prefix": "forn", + "body": ["for ${1:i} = ${2:1}, ${3:10} do", "\t$0", "end"], + "description": "for numeric range statement" + }, + "for-ipairs": { + "prefix": "fori", + "body": ["for ${1:i}, ${2:x} in ipairs(${3:t}) do", "\t$0", "end"], + "description": "for i, x in ipairs(t)" + }, + "for-pairs": { + "prefix": "forp", + "body": ["for ${1:k}, ${2:v} in pairs(${3:t}) do", "\t$0", "end"], + "description": "for k, v in pairs(t)" }, "forline": { "prefix": "forline", "body": [ - "f = io.open(${1:\"${2:filename}\"}, \"${3:r}\")\n", + "local f = io.open(${1:${2:filename}}, \"${3:r}\")\n", "while true do", "\tline = f:read()", "\tif line == nil then break end\n", - "\t${0:-- code}", + "\t${0}", "end" ], - "description": "read file line by line" + "description": "Read file line by line" }, "function": { "prefix": "fu", - "body": ["function ${1:name}($2)", "\t${0:-- code}", "end"] + "body": ["function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a function" }, - "inline-function": { + "assign-function": { "prefix": "f=", - "body": ["local ${1:name} = function($2)", "\t${0:-- code}", "end"] + "body": ["${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a variable" + }, + "local-function": { + "prefix": "lfu", + "body": ["local function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a local function" + }, + "local-assign-function": { + "prefix": "lf=", + "body": ["local ${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a local variable" + }, + "anonymous-function": { + "prefix": "f)", + "body": ["function($1)", "\t${0}", "end"], + "description": "Create an anonymous function" + }, + "member-function": { + "prefix": "f,", + "body": ["${1:name} = function($2)", "\t${0}", "end,"], + "description": "Assign a function to a table key" }, "print": { "prefix": "p", diff --git a/snippets/nix.json b/snippets/nix.json index 340f1bfe..8cb7cce2 100644 --- a/snippets/nix.json +++ b/snippets/nix.json @@ -93,5 +93,15 @@ "};" ], "description": "Nixpkgs' minimal meta attribute set" + }, + "with": { + "prefix": "with", + "body": ["with $1; $0;"], + "description": "with expression" + }, + "inherit": { + "prefix": "inherit", + "body": ["inherit $1;"], + "description": "inherit expression" } } diff --git a/snippets/norg.json b/snippets/norg.json index a5a32e54..bde52d68 100644 --- a/snippets/norg.json +++ b/snippets/norg.json @@ -1,280 +1,280 @@ { - "h1": { - "prefix": "h1", - "body": ["* $0"], - "description": "level 1 heading" - }, - "h2": { - "prefix": "h2", - "body": ["** $0"], - "description": "level 2 heading" - }, - "h3": { - "prefix": "h3", - "body": ["*** $0"], - "description": "level 3 heading" - }, - "h4": { - "prefix": "h4", - "body": ["**** $0"], - "description": "level 4 heading" - }, - "h5": { - "prefix": "h5", - "body": ["***** $0"], - "description": "level 5 heading" - }, - "h6": { - "prefix": "h6", - "body": ["****** $0"], - "description": "level 6 heading" - }, + "h1": { + "prefix": "h1", + "body": ["* $0"], + "description": "level 1 heading" + }, + "h2": { + "prefix": "h2", + "body": ["** $0"], + "description": "level 2 heading" + }, + "h3": { + "prefix": "h3", + "body": ["*** $0"], + "description": "level 3 heading" + }, + "h4": { + "prefix": "h4", + "body": ["**** $0"], + "description": "level 4 heading" + }, + "h5": { + "prefix": "h5", + "body": ["***** $0"], + "description": "level 5 heading" + }, + "h6": { + "prefix": "h6", + "body": ["****** $0"], + "description": "level 6 heading" + }, - "hr": { - "prefix": "hr", - "body": ["___", "$0"], - "description": "horizontal rule" - }, + "hr": { + "prefix": "hr", + "body": ["___", "$0"], + "description": "horizontal rule" + }, - "bold": { - "prefix": "bold", - "body": ["*$0*"], - "description": "bold words" - }, - "italic": { - "prefix": "italic", - "body": ["/$0/"], - "description": "italic words" - }, - "underline": { - "prefix": "underline", - "body": ["_$0_"], - "description": "underline words" - }, - "spoiler": { - "prefix": "spoiler", - "body": ["!$0!"], - "description": "spoiler" - }, - "strikethrough": { - "prefix": "strikethrough", - "body": ["-$0-"], - "description": "strike through" - }, - "inlinecomment": { - "prefix": "inlinecomment", - "body": ["%$0%"], - "description": "inline comment" - }, + "bold": { + "prefix": "bold", + "body": ["*$0*"], + "description": "bold words" + }, + "italic": { + "prefix": "italic", + "body": ["/$0/"], + "description": "italic words" + }, + "underline": { + "prefix": "underline", + "body": ["_$0_"], + "description": "underline words" + }, + "spoiler": { + "prefix": "spoiler", + "body": ["!$0!"], + "description": "spoiler" + }, + "strikethrough": { + "prefix": "strikethrough", + "body": ["-$0-"], + "description": "strike through" + }, + "inlinecomment": { + "prefix": "inlinecomment", + "body": ["%$0%"], + "description": "inline comment" + }, - "inlinecode": { - "prefix": "inlinecode", - "body": ["`$0`"], - "description": "inline code" - }, - "code": { - "prefix": "code", - "body": ["@code ${1:lang}", "$0", "@end"], - "description": "code block" - }, + "inlinecode": { + "prefix": "inlinecode", + "body": ["`$0`"], + "description": "inline code" + }, + "code": { + "prefix": "code", + "body": ["@code ${1:lang}", "$0", "@end"], + "description": "code block" + }, - "data": { - "prefix": "data", - "body": ["@data", "$0", "@end"], - "description": "data tags" - }, + "data": { + "prefix": "data", + "body": ["@data", "$0", "@end"], + "description": "data tags" + }, - "link": { - "prefix": "link", - "body": ["{${1:object}}[${2:description}]"], - "description": "links" - }, - "anchor": { - "prefix": "anchor", - "body": ["[${1:description}]{${2:object}}"], - "description": "anchors" - }, + "link": { + "prefix": "link", + "body": ["{${1:object}}[${2:description}]"], + "description": "links" + }, + "anchor": { + "prefix": "anchor", + "body": ["[${1:description}]{${2:object}}"], + "description": "anchors" + }, - "subscript": { - "prefix": "subscript", - "body": [",$0,"], - "description": "subscript" - }, - "superscript": { - "prefix": "superscript", - "body": ["^$0^"], - "description": "superscript" - }, - "inlinemath": { - "prefix": "inlinemath", - "body": ["$$0$"], - "description": "inline math" - }, - "rigidmath": { - "prefix": "rigidmath", - "body": ["$|$0|$"], - "description": "inline math (rigid syntax version)" - }, - "math": { - "prefix": "math", - "body": ["@math", "$0", "@end"], - "description": "math block" - }, + "subscript": { + "prefix": "subscript", + "body": [",$0,"], + "description": "subscript" + }, + "superscript": { + "prefix": "superscript", + "body": ["^$0^"], + "description": "superscript" + }, + "inlinemath": { + "prefix": "inlinemath", + "body": ["$$0$"], + "description": "inline math" + }, + "rigidmath": { + "prefix": "rigidmath", + "body": ["$|$0|$"], + "description": "inline math (rigid syntax version)" + }, + "math": { + "prefix": "math", + "body": ["@math", "$0", "@end"], + "description": "math block" + }, - "table": { - "prefix": "table", - "body": ["@table", "$0", "@end"], - "description": "table" - }, + "table": { + "prefix": "table", + "body": ["@table", "$0", "@end"], + "description": "table" + }, - "unordered_list": { - "prefix": "ulist1", - "body": ["- ${1:item}"], - "description": "level 1 unordered list" - }, - "unordered_list_2": { - "prefix": "ulist2", - "body": ["-- ${1:item}"], - "description": "level 2 unordered list" - }, - "unordered_list_3": { - "prefix": "ulist3", - "body": ["--- ${1:item}"], - "description": "level 3 unordered list" - }, - "unordered_list_4": { - "prefix": "ulist4", - "body": ["---- ${1:item}"], - "description": "level 4 unordered list" - }, - "unordered_list_5": { - "prefix": "ulist5", - "body": ["----- ${1:item}"], - "description": "level 5 unordered list" - }, - "unordered_list_6": { - "prefix": "ulist6", - "body": ["------ ${1:item}"], - "description": "level 6 unordered list" - }, + "unordered_list": { + "prefix": "ulist1", + "body": ["- ${1:item}"], + "description": "level 1 unordered list" + }, + "unordered_list_2": { + "prefix": "ulist2", + "body": ["-- ${1:item}"], + "description": "level 2 unordered list" + }, + "unordered_list_3": { + "prefix": "ulist3", + "body": ["--- ${1:item}"], + "description": "level 3 unordered list" + }, + "unordered_list_4": { + "prefix": "ulist4", + "body": ["---- ${1:item}"], + "description": "level 4 unordered list" + }, + "unordered_list_5": { + "prefix": "ulist5", + "body": ["----- ${1:item}"], + "description": "level 5 unordered list" + }, + "unordered_list_6": { + "prefix": "ulist6", + "body": ["------ ${1:item}"], + "description": "level 6 unordered list" + }, - "ordered_list": { - "prefix": "olist1", - "body": ["~ ${1:item}"], - "description": "level 1 ordered list" - }, - "ordered_list_2": { - "prefix": "olist2", - "body": ["~~ ${1:item}"], - "description": "level 2 ordered list" - }, - "ordered_list_3": { - "prefix": "olist3", - "body": ["~~~ ${1:item}"], - "description": "level 3 ordered list" - }, - "ordered_list_4": { - "prefix": "olist4", - "body": ["~~~~ ${1:item}"], - "description": "level 4 ordered list" - }, - "ordered_list_5": { - "prefix": "olist5", - "body": ["~~~~~ ${1:item}"], - "description": "level 5 ordered list" - }, - "ordered_list_6": { - "prefix": "olist6", - "body": ["~~~~~~ ${1:item}"], - "description": "level 6 ordered list" - }, + "ordered_list": { + "prefix": "olist1", + "body": ["~ ${1:item}"], + "description": "level 1 ordered list" + }, + "ordered_list_2": { + "prefix": "olist2", + "body": ["~~ ${1:item}"], + "description": "level 2 ordered list" + }, + "ordered_list_3": { + "prefix": "olist3", + "body": ["~~~ ${1:item}"], + "description": "level 3 ordered list" + }, + "ordered_list_4": { + "prefix": "olist4", + "body": ["~~~~ ${1:item}"], + "description": "level 4 ordered list" + }, + "ordered_list_5": { + "prefix": "olist5", + "body": ["~~~~~ ${1:item}"], + "description": "level 5 ordered list" + }, + "ordered_list_6": { + "prefix": "olist6", + "body": ["~~~~~~ ${1:item}"], + "description": "level 6 ordered list" + }, - "quote_1": { - "prefix": "quote1", - "body": ["> $0"], - "description": "level 1 quote" - }, - "quote_2": { - "prefix": "quote2", - "body": [">> $0"], - "description": "level 2 quote" - }, - "quote_3": { - "prefix": "quote3", - "body": [">>> $0"], - "description": "level 3 quote" - }, - "quote_4": { - "prefix": "quote4", - "body": [">>>> $0"], - "description": "level 4 quote" - }, - "quote_5": { - "prefix": "quote5", - "body": [">>>>> $0"], - "description": "level 5 quote" - }, - "quote_6": { - "prefix": "quote6", - "body": [">>>>>> $0"], - "description": "level 6 quote" - }, + "quote_1": { + "prefix": "quote1", + "body": ["> $0"], + "description": "level 1 quote" + }, + "quote_2": { + "prefix": "quote2", + "body": [">> $0"], + "description": "level 2 quote" + }, + "quote_3": { + "prefix": "quote3", + "body": [">>> $0"], + "description": "level 3 quote" + }, + "quote_4": { + "prefix": "quote4", + "body": [">>>> $0"], + "description": "level 4 quote" + }, + "quote_5": { + "prefix": "quote5", + "body": [">>>>> $0"], + "description": "level 5 quote" + }, + "quote_6": { + "prefix": "quote6", + "body": [">>>>>> $0"], + "description": "level 6 quote" + }, - "task": { - "prefix": "task", - "body": ["- ( ) ${1:task}"], - "description": "task" - }, - "done_task": { - "prefix": "dtask", - "body": ["- (x) ${1:task}"], - "description": "task (done)" - }, - "input_task": { - "prefix": "itask", - "body": ["- (?) ${1:task}"], - "description": "task (needs further input)" - }, - "urgent_task": { - "prefix": "utask", - "body": ["- (!) ${1:task}"], - "description": "task (high priority)" - }, - "recurring_task": { - "prefix": "rtask", - "body": ["- (+) ${1:task}"], - "description": "task (recurring, with children)" - }, - "pending_task": { - "prefix": "ptask", - "body": ["- (-) ${1:task}"], - "description": "task (in progress)" - }, - "hold_task": { - "prefix": "htask", - "body": ["- (=) ${1:task}"], - "description": "task (on hold)" - }, - "cancelled_task": { - "prefix": "ctask", - "body": ["- (_) ${1:task}"], - "description": "task (cancelled)" - }, + "task": { + "prefix": "task", + "body": ["- ( ) ${1:task}"], + "description": "task" + }, + "done_task": { + "prefix": "dtask", + "body": ["- (x) ${1:task}"], + "description": "task (done)" + }, + "input_task": { + "prefix": "itask", + "body": ["- (?) ${1:task}"], + "description": "task (needs further input)" + }, + "urgent_task": { + "prefix": "utask", + "body": ["- (!) ${1:task}"], + "description": "task (high priority)" + }, + "recurring_task": { + "prefix": "rtask", + "body": ["- (+) ${1:task}"], + "description": "task (recurring, with children)" + }, + "pending_task": { + "prefix": "ptask", + "body": ["- (-) ${1:task}"], + "description": "task (in progress)" + }, + "hold_task": { + "prefix": "htask", + "body": ["- (=) ${1:task}"], + "description": "task (on hold)" + }, + "cancelled_task": { + "prefix": "ctask", + "body": ["- (_) ${1:task}"], + "description": "task (cancelled)" + }, - "single_footnote": { - "prefix": "footnote", - "body": ["^ ${1:title}", "${2:content}"], - "description": "footnote (short version)" - }, - "single_footnote": { - "prefix": "footnoter", - "body": ["^^ ${1:title}", "${2:content}", "^^"], - "description": "footnote (ranged version)" - }, + "single_footnote": { + "prefix": "footnote", + "body": ["^ ${1:title}", "${2:content}"], + "description": "footnote (short version)" + }, + "ranged_single_footnote": { + "prefix": "footnoter", + "body": ["^^ ${1:title}", "${2:content}", "^^"], + "description": "footnote (ranged version)" + }, - "var": { - "prefix": "var", - "body": ["&${1:variable}&"], - "description": "variable" - } + "var": { + "prefix": "var", + "body": ["&${1:variable}&"], + "description": "variable" + } } diff --git a/snippets/perl.json b/snippets/perl.json index c45b5013..807dc2ad 100644 --- a/snippets/perl.json +++ b/snippets/perl.json @@ -92,7 +92,7 @@ }, "print to file": { "prefix": "file print", - "body": ["print \\$${1:fh} \"${1:string}\\n\";"] + "body": ["print \\$${1:fh} \"${2:string}\\n\";"] }, "read file into a scalar": { "prefix": "slurp", diff --git a/snippets/php/php.json b/snippets/php/php.json index 88e365e7..10125055 100644 --- a/snippets/php/php.json +++ b/snippets/php/php.json @@ -251,5 +251,16 @@ "prefix": "vd", "body": ["var_dump($0);"], "description": "var_dump" + }, + "enum …": { + "prefix": "enum", + "body": [ + "enum ${1:EnumName}", + "{", + "\tcase $0;", + "}", + "" + ], + "description": "Enum definition" } } diff --git a/snippets/ruby/rspec.json b/snippets/ruby/rspec.json new file mode 100644 index 00000000..96574d46 --- /dev/null +++ b/snippets/ruby/rspec.json @@ -0,0 +1,360 @@ +{ + "rspec_spec_skeleton": { + "prefix": "rspec", + "body": "# frozen_string_literal: true\n\nrequire 'spec_helper'\nrequire 'rails_helper'\n\nRSpec.describe ${1:${TM_DIRECTORY/(?:(?:\\~?\\/.*\\/)|_)([A-Za-z0-9]+)?/${1:/capitalize}/g}}::${2:${TM_FILENAME_BASE/(?:^|_)([A-Za-z0-9]+)(?:_spec)?/${1:/capitalize}/g}} do\n $0\nend\n", + "description": "RSpec test skeleton" + }, + + "rspec_describe": { + "prefix": "des", + "body": "describe '${1:}' do\n ${2:}$0\nend\n", + "description": "RSpec describe case" + }, + + "rspec_context": { + "prefix": "con", + "body": "context 'when ${1:some case}' do\n ${2:}$0\nend\n", + "description": "RSpec context case" + }, + + "rspec_let": { + "prefix": "let", + "body": "let(:${1:object}) { $0 }", + "description": "Use `let` to define memoized helper method" + }, + + "rspec_let!": { + "prefix": "letb", + "body": "let!(:${1:object}) { $0 }", + "description": [ + "Use `let!` to define a memoized", + "helper method that is called", + "in a `before` hook" + ] + }, + + "rspec_it": { + "prefix": "it", + "body": "it '${1:has some behaviour}' do\n ${2:}$0\nend\n", + "description": "example" + }, + + "rspec_pending": { + "prefix": "pending", + "body": "pending${1: '${2:reason}'}", + "description": "pending example" + }, + + "rspec_shared_example": { + "prefix": "sharex", + "body": "RSpec.shared_examples '${1:some example}' do ${3:|${2:parameter}|}\n ${4:$0}\nend\n", + "description": "RSpec shared example declaration" + }, + + "rspec_behaves_like": { + "prefix": "itbl", + "body": "it_behaves_like ${2:'$1'}$0", + "description": "RSpec shared example usage" + }, + + "rspec_expect_do": { + "prefix": "expdo", + "body": "expect do\n ${1:action}\nend.to ${2:matcher}$0", + "description": "expect do ... end.to something" + }, + "rspec_expect": { + "prefix": "exp", + "body": "expect(${1:subject}).to ${2:matcher}$0", + "description": "expect(subject).to something" + }, + + "rspec_expect_block": { + "prefix": "expto", + "body": "expect {${2: ${1:expression} }}.to ${3:matcher}", + "description": "expect with block" + }, + + "rspec_expect_be": { + "prefix": "expbe", + "body": "expect(${1:subject}).to be$0", + "description": [ + "Scenarios:", + "be matcher" + ] + }, + + "rspec_expect_be_": { + "prefix": "expbpm", + "body": "expect(${1:subject}).to be_${2|truthy,falsey,nil|}$0", + "description": [ + "Scenarios:", + "be_truthy matcher", + "be_falsey matcher", + "be_nil matcher" + ] + }, + + "rspec_expect_eq": { + "prefix": "expeq", + "body": "expect(${1:subject}).to eq(${2:value})$0", + "description": [ + "Equality matcher", + "compare using eq (==)" + ] + }, + + "rspec_expect_eql": { + "prefix": "expeql", + "body": "expect(${1:subject}).to eql(${2:value})$0", + "description": [ + "Equality matcher", + "compare using eql (eql?)" + ] + }, + + "rspec_expect_equal": { + "prefix": "expequal", + "body": "expect(${1:subject}).to equal(${2:value})$0", + "description": [ + "Equality matcher", + "compare using equal (equal?)" + ] + }, + + "rspec_expect_all": { + "prefix": "expall", + "body": "expect(${1:enumerable}).to all( ${2:matcher} )$0", + "description": [ + "Used to specify that a collection's", + "objects all pass an expected", + "matcher. This works on any", + "enumerable object." + ] + }, + + "rspec_expect_include": { + "prefix": "expinclude", + "body": "expect(${1:subject}).to include(${2:element})$0", + "description": [ + "Use the include matcher to specify", + "that a collection includes one or", + "more expected objects.", + "This works on any object that ", + "responds to #include? ", + "Scenarios: Array, String, Hash" + ] + }, + + "rspec_expect_match": { + "prefix": "expmatch", + "body": "expect(${1:subject}).to match(/${2:regexp}/)$0", + "description": [ + "The match matcher calls #match on", + "the object, passing if #match", + "returns a truthy (not false or nil)", + "value.", + "Scenarios: String, Regexp" + ] + }, + + "rspec_expect_contain_exactly": { + "prefix": "expcte", + "body": "expect(${1:array}).to contain_exactly(${2:elements})$0", + "description": [ + "Provides a way to test arrays", + "against each other in a way that", + "disregards differences in the", + "ordering between the actual and", + "expected array" + ] + }, + + "rspec_expect_exist": { + "prefix": "expexist", + "body": "expect(${1:subject}).to exist$0", + "description": [ + "The exist matcher is used to specify", + "that something exists", + "(#exist? or #exists?)" + ] + }, + + "rspec_expect_end_with": { + "prefix": "expenw", + "body": "expect(${1:subject}).to end_with(${2:value})$0", + "description": [ + "Used to specify that a string or", + "array ends with the expected", + "characters or elements", + "Scenarios: Array, String" + ] + }, + + "rspec_expect_start_with": { + "prefix": "expstw", + "body": "expect(${1:subject}).to start_with(${2:value})$0", + "description": [ + "Used to specify that a string or", + "array starts with the expected", + "characters or elements", + "Scenarios: Array, String" + ] + }, + + "rspec_expect_have_attributes": { + "prefix": "exphat", + "body": "expect(${1:subject}).to have_attributes(${2:hash})$0", + "description": [ + "Used to specify that an object's", + "attributes match the expected", + "attributes" + ] + }, + + "rspec_expect_raise": { + "prefix": "expraise", + "body": "expect { ${1:action} }.to raise_error(${2:Error})$0", + "description": [ + "Used to specify that a block of code", + "raises an error.", + "Scenarios", + "expect any error", + "expect specific error", + "match message with a string", + "match message with a regexp", + "matching message with `with_message`", + "match class + message with string", + "match class + message with regexp", + "set expectations on error object passed to block", + "expect no error at all" + ] + }, + + + "rspec_expect_satisfy": { + "prefix": "expsat", + "body": "expect(${1:subject}).to satisfy { |${2:obj}| ${3:expression} }$0", + "description": [ + "The satisfy matcher is extremely", + "flexible and can handle almost", + "anything you want to specify.", + "It passes if the block you provide", + "returns true" + ] + }, + + "rspec_expect_be_a_kind_of": { + "prefix": "expbko", + "body": "expect(${1:subject}).to be_a_kind_of(${2:klass})$0", + "description": [ + "Type matcher", + "Returns true if type is in obj's", + "class hierarchy or is a module and", + "is included in a class in obj's ", + "class hierarchy." + ] + }, + + "rspec_expect_be_an_instance_of": { + "prefix": "expbio", + "body": "expect(${1:subject}).to be_an_instance_of(${2:klass})$0", + "description": [ + "Type matcher", + "Returns true if and only if type if obj's class" + ] + }, + + "rspec_expect_respond_to": { + "prefix": "exprt", + "body": "expect(${1:subject}).to respond_to(:${2:method})$0", + "description": [ + "Use the respond_to matcher to", + "specify details of an object's", + "interface. ", + "Scenarios:", + "basic usage", + "specify arguments", + "specify arguments range", + "specify unlimited arguments", + "specify keywords", + "specify any keywords", + "specify required keywords" + ] + }, + + "rspec_before": { + "prefix": "bef", + "body": "before(${1|:all,:each,:suite,:context,:example|}) do\n ${2:}$0\nend\n", + "description": [ + "Before hook", + "Runs once before all of the examples", + "in a group" + ] + }, + + "rspec_after": { + "prefix": "aft", + "body": "after(${1|:all,:each,:suite,:context,:example|}) do\n ${2:}$0\nend\n", + "description": [ + "After hook", + "Runs once after all of the examples", + "in a group" + ] + }, + + "rspec_around": { + "prefix": "aro", + "body": "around(:${1:example}) do\n ${2:}$0\nend\n", + "description": [ + "Around hook", + "Lets you define code that should be", + "executed before and after the", + "example", + "Context hooks are NOT wrapped by", + "the `around` hook" + ] + }, + + "rspec_is_expected": { + "prefix": "itie", + "body": "it { is_expected.to ${1:matcher} }$0", + "description": [ + "RSpec supports a one-liner syntax", + "for setting an expectation on the", + "subject" + ] + }, + + "rspec_subject": { + "prefix": "subject", + "body": "subject(:${1:subject}) { ${2:} }$0", + "description": [ + "Explicit subject", + "Defines a memoized helper method" + ] + }, + + "rspec_described_class": { + "prefix": "subjectcls", + "body": "subject(:${1:subject}) { ${2:${TM_DIRECTORY/(?:(?:\\~?\\/.*\\/)|_)([A-Za-z0-9]+)?/${1:/capitalize}/g}}::${3:${TM_FILENAME_BASE/(?:^|_)([A-Za-z0-9]+)(?:_spec)?/${1:/capitalize}/g}}.new }$0", + "description": "subject(:subject) { described_class.new }" + }, + + "rspec_allow": { + "prefix": "allrec", + "body": "allow(${1:collaborator}).to receive(:${2:message})${3:.with(${4:args})}${5:.and_return(${6:result})}$0", + "description": "Method stub that returns values" + }, + + "rspec_expect_receive": { + "prefix": "exprecw", + "body": "expect(${1:collaborator}).to receive(:${2:message})${3:.with(${4:args})}$0", + "description": [ + "Expecting messages", + "Use to expect a message on a test", + "double. Unfulfilled message ", + "expectations trigger failures when", + "the example completes." + ] + } +} diff --git a/snippets/ruby/ruby.json b/snippets/ruby/ruby.json index 84d7a69d..b8d69c79 100644 --- a/snippets/ruby/ruby.json +++ b/snippets/ruby/ruby.json @@ -29,6 +29,26 @@ "end" ] }, + "Ruby Benchmark Measure": { + "prefix": "benchm", + "body": [ + "require 'benchmark'", + "", + "puts Benchmark.measure { ${1:# benchmark code} }" + ] + }, + "Ruby Benchmark BM": { + "prefix": "benchbm", + "body": [ + "require 'benchmark'", + "", + "n = ${1:50000}", + "Benchmark.bm do |x|", + " x.report(\"${2:Task 1}\") { n.times { ${3:\"task 1\"} } }", + " x.report(\"${4:Task 2}\") { n.times { ${5:\"task 2\"} } }", + "end" + ] + }, "Class definition with initialize": { "prefix": "class init", "body": [ diff --git a/snippets/sql.json b/snippets/sql.json index 1e656258..d47c3d17 100644 --- a/snippets/sql.json +++ b/snippets/sql.json @@ -224,15 +224,15 @@ "body": ["CONSTRAINT ${1:attribute} PRIMARY KEY(${2:attribute(s)})"], "description": "Constraint Primary Key" }, - "foreingk": { - "prefix": "foreingk", + "foreignk": { + "prefix": "foreignk", "body": [ "FOREIGN KEY(${1:attribute}) REFERENCES ${2:tableName}(${3:attribute})" ], "description": "Foreign Key" }, - "foreingkc": { - "prefix": "foreingkc", + "foreignkc": { + "prefix": "foreignkc", "body": [ "CONSTRAINT ${1:attribute} FOREIGN KEY (${2:attribute(s)})", "\tREFERENCES ${3:tableName}(${4:attribute})" diff --git a/snippets/zig.json b/snippets/zig.json index 7a06b3ee..ddf7041e 100644 --- a/snippets/zig.json +++ b/snippets/zig.json @@ -1,29 +1,25 @@ { - "Import": { - "prefix": "import", - "body": ["const ${1} = @import(\"${1}\")"], - "description": "Importing Librarys" - }, - "CImport": { - "prefix": "cimport", - "body": [ - "const c = @cImport({", - "@cDefine(\"${1}\")", - "});" - ], - "description": "Importing C Header Files" - }, - "buildExe": { - "prefix": "bExe", - "body": [ - "const exe = b.addExecutable(.{", - ".name = \"${1}",\", - ".root_source_file = b.path(\"${2: path}\"),", - ".target = target,", - ".optimize = optimize,", - "});", - "\n\n\n b.installArtifact(exe);", - ], - "description": "Building an exe" - } + "Import": { + "prefix": "import", + "body": ["const ${1} = @import(\"${1}\");"], + "description": "Importing Libraries" + }, + "CImport": { + "prefix": "cimport", + "body": ["const c = @cImport({", " @cDefine(\"${1}\");", "});"], + "description": "Importing C Header Files" + }, + "buildExe": { + "prefix": "bExe", + "body": [ + "const exe = b.addExecutable(.{", + " .name = \"${1}\",", + " .root_source_file = b.path(\"${2:path}\"),", + " .target = target,", + " .optimize = optimize,", + "});", + "b.installArtifact(exe);" + ], + "description": "Building an exe" + } }