From e604a8dd7092d60a104cc696b2218a0349732a38 Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sun, 7 Aug 2022 14:04:00 +0300 Subject: [PATCH] Add pinia snippets #4 Snippets list: - pstore Co-Authored-By: Daniel Kelly --- package.json | 8 ++++++++ snippets/pinia.code-snippets | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 snippets/pinia.code-snippets diff --git a/package.json b/package.json index f426dd6..ddc8327 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,14 @@ { "language": "typescript", "path": "./snippets/vue-script.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/pinia.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/pinia.code-snippets" } ] } diff --git a/snippets/pinia.code-snippets b/snippets/pinia.code-snippets new file mode 100644 index 0000000..92d1433 --- /dev/null +++ b/snippets/pinia.code-snippets @@ -0,0 +1,22 @@ +{ + "Pinia Store Base": { + "prefix": "pstore", + "body": [ + "import { defineStore, acceptHMRUpdate } from \"pinia\"", + "", + "export const use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store = defineStore(\"$TM_FILENAME_BASE\", {", + "\tstate: () => ({", + "\t\t$0", + "\t}),", + "\tgetters: {},", + "\tactions: {},", + "})", + "", + "if (import.meta.hot) {", + "\timport.meta.hot.accept(acceptHMRUpdate(use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store, import.meta.hot))", + "}", + "" + ], + "description": "Base code needed for a Pinia store file" + } +}