Skip to content

Commit 927cced

Browse files
feat: Add pinia snippets (#13)
* Add pinia snippets #4 Snippets list: - pstore Co-authored-by: Daniel Kelly <[email protected]>
1 parent 765a428 commit 927cced

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
{
3838
"language": "typescript",
3939
"path": "./snippets/vue-script.code-snippets"
40+
},
41+
{
42+
"language": "javascript",
43+
"path": "./snippets/pinia.code-snippets"
44+
},
45+
{
46+
"language": "typescript",
47+
"path": "./snippets/pinia.code-snippets"
4048
}
4149
]
4250
}

snippets/pinia.code-snippets

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Pinia Store Base": {
3+
"prefix": "pstore",
4+
"body": [
5+
"import { defineStore, acceptHMRUpdate } from \"pinia\"",
6+
"",
7+
"export const use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store = defineStore(\"$TM_FILENAME_BASE\", {",
8+
"\tstate: () => ({",
9+
"\t\t$0",
10+
"\t}),",
11+
"\tgetters: {},",
12+
"\tactions: {},",
13+
"})",
14+
"",
15+
"if (import.meta.hot) {",
16+
"\timport.meta.hot.accept(acceptHMRUpdate(use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store, import.meta.hot))",
17+
"}",
18+
""
19+
],
20+
"description": "Base code needed for a Pinia store file"
21+
}
22+
}

0 commit comments

Comments
 (0)