|
1 | 1 | # Modern JavaScript Snippets ⚡ |
2 | 2 |
|
3 | | -*Work in progress* |
| 3 | +> Short and memorable JavaScript & TypeScript snippets for the modern-day developer. |
| 4 | +
|
| 5 | +🚧 *Work in progress* |
4 | 6 |
|
5 | 7 | --- |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Support |
| 14 | +Only JavaScript and TypeScript will be supported. |
| 15 | +Specific frameworks will get their own extensions. No bloat. |
| 16 | + |
| 17 | +Supported file extensions: |
| 18 | +- `.js` |
| 19 | +- `.ts` |
| 20 | +- `.jsx` |
| 21 | +- `.tsx` |
| 22 | + |
| 23 | + |
| 24 | +## Setup |
| 25 | +The following is not mandatory, but provides a nicer experience. |
| 26 | + |
| 27 | +Search for `editor.snippetSuggestions` and `editor.snippetSuggestions` in user settings, or edit the settings.json directly: |
| 28 | +```json |
| 29 | +// Show snippet suggestions on top of other suggestions. |
| 30 | +"editor.snippetSuggestions": "top", |
| 31 | + |
| 32 | +// Tab complete will insert the best matching suggestion when pressing tab. |
| 33 | +"editor.snippetSuggestions": "on" |
| 34 | +``` |
| 35 | + |
| 36 | +## Style |
| 37 | +All code snippets are without semicolons (`;`). |
| 38 | + |
| 39 | +You can use these snippets along with Prettier/ESLint to have your code automatically formatted to your preference. |
| 40 | + |
| 41 | +## Snippet syntax |
| 42 | + |
| 43 | +### Tabstops |
| 44 | +- With tabstops you can make the editor cursor move inside a snippet |
| 45 | +- `$1`, `$2`, `$3` specify cursor locations, in order in which tabstops will be visited |
| 46 | +- `$0` denotes the final cursor position |
| 47 | +- Multiple occurrences of the same tabstop are linked and updated in sync |
| 48 | + |
| 49 | +### Placeholders |
| 50 | +- Placeholders are tabstops with values, such as `${1:name}` |
| 51 | +- Placeholder text will be inserted and selected such that it can be easily changed |
| 52 | +- Can be nested, like `${1:another ${2:placeholder}}`. |
| 53 | + |
| 54 | + |
| 55 | +## Snippets |
6 | 56 |
|
7 | 57 | ### Declarations |
8 | 58 |
|
@@ -111,7 +161,7 @@ const ${1:name} = ($2) => {$0} |
111 | 161 |
|
112 | 162 | #### `enfn` - export named arrow function |
113 | 163 | ```js |
114 | | -const ${1:name} = ($2) => {$0} |
| 164 | +export const ${1:name} = ($2) => {$0} |
115 | 165 | ``` |
116 | 166 |
|
117 | 167 | #### `af` - arrow function |
@@ -142,7 +192,7 @@ console.log($0) |
142 | 192 |
|
143 | 193 | #### `clm` - console.log message |
144 | 194 | ```js |
145 | | -console.log($0) |
| 195 | +console.log('$0') |
146 | 196 | ``` |
147 | 197 |
|
148 | 198 | #### `clo` - console.log object |
@@ -179,3 +229,5 @@ console.error('$1 ->', ${2:$1}) |
179 | 229 | ```js |
180 | 230 | console.warn('$1 ->', ${2:$1}) |
181 | 231 | ``` |
| 232 | + |
| 233 | +*...and many more (evertyhing will be documented)* |
0 commit comments