Skip to content

Commit

Permalink
feat: 添加一些 react rn 相关snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
radiorz committed Aug 15, 2022
1 parent 74f4ee5 commit 9435fef
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 6 deletions.
9 changes: 9 additions & 0 deletions build/java.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
"System.out.println(\"$1\" + \" \" + $1);"
]
},
"java_time": {
"prefix": [
"time"
],
"description": "\nSystem.currentTimeMillis();\n",
"body": [
"System.currentTimeMillis();"
]
},
"method_header": {
"prefix": [
"!mh"
Expand Down
22 changes: 19 additions & 3 deletions build/javascript.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@
},
"delay": {
"prefix": [
"await",
"wait",
"delay"
],
"description": "\nawait new Promise(resolve=>{setTimeout(resolve,${1:1000})})\n",
"description": "\nconst timeout = ${1:1000}\nawait new Promise((resolve) => setTimeout(resolve, timeout))\n",
"body": [
"await new Promise(resolve=>{setTimeout(resolve,${1:1000})})"
"const timeout = ${1:1000}",
"await new Promise((resolve) => setTimeout(resolve, timeout))"
]
},
"esmodule__dirname": {
Expand Down Expand Up @@ -297,6 +298,21 @@
")"
]
},
"react_hook": {
"prefix": [
"!hook"
],
"description": "\nimport { useState, useEffect } from \"react\";\n// import { useDispatch } from \"react-redux\";\n\nexport default function use${1:Something}() {\n const [$2] = useState(null);\n return {$2};\n}\n\n",
"body": [
"import { useState, useEffect } from \"react\";",
"// import { useDispatch } from \"react-redux\";",
"",
"export default function use${1:Something}() {",
" const [$2] = useState(null);",
" return {$2};",
"}"
]
},
"redux_toolkit_slice": {
"prefix": [
"!slice"
Expand Down
15 changes: 15 additions & 0 deletions build/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@
")"
]
},
"react_hook": {
"prefix": [
"!hook"
],
"description": "\nimport { useState, useEffect } from \"react\";\n// import { useDispatch } from \"react-redux\";\n\nexport default function use${1:Something}() {\n const [$2] = useState(null);\n return {$2};\n}\n\n",
"body": [
"import { useState, useEffect } from \"react\";",
"// import { useDispatch } from \"react-redux\";",
"",
"export default function use${1:Something}() {",
" const [$2] = useState(null);",
" return {$2};",
"}"
]
},
"redux_toolkit_slice": {
"prefix": [
"!slice"
Expand Down
5 changes: 3 additions & 2 deletions snippets/delay.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const body = `
await new Promise(resolve=>{setTimeout(resolve,\${1:1000})})
const timeout = \${1:1000}
await new Promise((resolve) => setTimeout(resolve, timeout))
`;
const description = "";

module.exports = {
prefix: ["await", "delay"],
prefix: ["wait", "delay"],
type: ["javascript"],
description: description || body,
body: body.trim(),
Expand Down
11 changes: 11 additions & 0 deletions snippets/java_time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const body = `
System.currentTimeMillis();
`
const description = "";

module.exports = {
prefix: ["time"],
type: ["java"],
description: description || body,
body: body.trim(),
};
18 changes: 18 additions & 0 deletions snippets/react_hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const body = `
import { useState, useEffect } from "react";
// import { useDispatch } from "react-redux";
export default function use\${1:Something}() {
const [\$2] = useState(null);
return {\$2};
}
`;
const description = "";

module.exports = {
prefix: ["!hook"],
type: ["javascript", "typescript"],
description: description || body,
body: body.trim(),
};
18 changes: 18 additions & 0 deletions snippets/try_catch_finally.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const body = `
try {
} catch (err) {
console.log('err',err)
} finally {
}
`;
const description = "";

module.exports = {
disabled: true, // javscript snippets 已经有了
prefix: ["tcf"],
type: ["javascript"],
description: description || body,
body: body.trim(),
};
1 change: 0 additions & 1 deletion src/gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ const isObject = (a) => typeof a === "object";
console.log(`language done`, language);
});
})();

0 comments on commit 9435fef

Please sign in to comment.