Skip to content

Commit 8e9e555

Browse files
authored
Merge pull request #109 from zardoy/develop
2 parents 791c6bc + fa5dca7 commit 8e9e555

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1341
-2033
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ jobs:
66
test:
77
strategy:
88
matrix:
9-
os: [ubuntu-latest, macos-latest, windows-latest]
9+
os: [ubuntu-latest, windows-latest]
1010
fail-fast: true
1111
runs-on: ${{ matrix.os }}
1212
timeout-minutes: 30
1313
steps:
1414
- uses: actions/checkout@v2
15-
- run: npx prettier --check src/**
15+
- run: npx prettier --check "{src,typescript}/**/*.ts" --ignore-path .gitignore
1616
- name: Cache pnpm modules
1717
uses: actions/cache@v2
1818
with:

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
- run: npm -v
1414
- run: node -v
1515
- uses: actions/checkout@v2
16-
- run: npx prettier --check src/**
1716
- name: Cache pnpm modules
1817
uses: actions/cache@v2
1918
with:
@@ -26,7 +25,6 @@ jobs:
2625
version: latest
2726
run_install: |
2827
args: [--frozen-lockfile, --strict-peer-dependencies]
29-
- run: pnpm lint
3028
- run: pnpx zardoy-release vscode-extension
3129
env:
3230
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

README.MD

Lines changed: 104 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ TOC:
77

88
- [Top Features](#top-features)
99
- [Minor Useful Features](#minor-useful-features)
10+
- [Method Snippets](#method-snippets)
1011
- [Auto Imports](#auto-imports)
12+
- [Type Driven Completions](#type-driven-completions)
1113
- [Rename Features](#rename-features)
1214
- [Special Commands List](#special-commands-list)
1315
- [Contributed Code Actions](#contributed-code-actions)
@@ -35,19 +37,6 @@ Also is not supported in the web.
3537

3638
90% work done in this extension highly improves completions experience!
3739

38-
### Method Snippets
39-
40-
(*enabled by default*)
41-
42-
Expands arrow callbacks with signature snippet with adding additional undo stack!
43-
44-
Example:
45-
46-
```ts
47-
const callback = (arg) => {}
48-
callback -> callback(arg)
49-
```
50-
5140
### Strict Emmet
5241

5342
(*enabled by default*) when react langs are in `emmet.excludeLanguages`
@@ -127,7 +116,9 @@ There is web-only feature: fix clicking on relative `import` paths.
127116

128117
(*enabled by default*)
129118

130-
Highlights and lifts non-function methods. Also applies for static class methods.
119+
Highlights non-function methods and properties. Also applies for static class methods.
120+
121+
![non-function-methods](media/non-function-methods.png)
131122

132123
### Indexed Signature Completions
133124

@@ -175,8 +166,6 @@ Try to restore [original](https://github.com/microsoft/TypeScript/issues/49012)
175166
We extend completion list with extensions from module augmentation (e.g. `.css` files if you have `declare module '*.css'`).
176167
But for unchecked contexts list of extensions can be extended with `tsEssentialPlugins.additionalIncludeExtensions` setting.
177168

178-
<!-- ## Type-Driven Completions -->
179-
180169
### Mark Code Actions
181170

182171
(*enabled by default* with two settings)
@@ -205,6 +194,102 @@ const a = 5
205194
a = 6
206195
```
207196

197+
### Format Ignore Directives
198+
199+
We support [format ignore directives](https://github.com/microsoft/TypeScript/issues/18261)
200+
201+
## Type-Driven Completions
202+
203+
All in this section requires TypeScript nightly extension.
204+
205+
### JSX Elements
206+
207+
To Enable: `"tsEssentialPlugins.experiments.excludeNonJsxCompletions": true`
208+
209+
We can filter out completions so only Function Components stay in your list:
210+
211+
```tsx
212+
class Foo {}
213+
const Bar = () => <div />
214+
215+
const elem = </* Bar is suggested, Foo not
216+
```
217+
218+
Super handy in MUI + Electron projects.
219+
220+
Class components are not supported (no need).
221+
222+
### Change kind to function
223+
224+
Enable with `tsEssentialPlugins.experiments.changeKindToFunction`
225+
226+
![change-icon-kind](media/change-kind.png)
227+
228+
## Method Snippets
229+
230+
(*enabled by default*)
231+
232+
Expands arrow callback completions with signature snippet. Also adds additional undo stack!
233+
234+
Example:
235+
236+
```ts
237+
const callback = (arg) => {}
238+
callback -> callback(arg)
239+
```
240+
241+
#### Configuration
242+
243+
There are value descriptions for two settings:
244+
245+
`tsEssentialPlugins.methodSnippets.insertText`:
246+
247+
```ts
248+
const example = ({ a }, b?, c = 5, ...d) => { }
249+
// binding-name (default)
250+
example({ a }, b, c, ...d)
251+
// always-declaration (also popular)
252+
example({ a }, b?, c = 5, ...d)
253+
// always-name
254+
example(__0, b, c, d)
255+
```
256+
257+
`tsEssentialPlugins.methodSnippets.skip`:
258+
259+
```ts
260+
const example = ({ a }, b?, c = 5, ...d) => { }
261+
// only-rest
262+
example({ a }, b, c)
263+
// optional-and-rest
264+
example({ a })
265+
// no-skip (default)
266+
example({ a }, b, c, ...d)
267+
```
268+
269+
`tsEssentialPlugins.methodSnippets.multipleSignatures`:
270+
271+
```ts
272+
// overload 1
273+
function foo(this: {}, a)
274+
// overload 2
275+
function foo(this: {}, b)
276+
function foo(this: {}) {}
277+
278+
// pick-first (default)
279+
foo(a)
280+
// empty
281+
foo(|)
282+
```
283+
284+
`disableMethodSnippets.jsxAttributes`:
285+
286+
```tsx
287+
const callback = (arg) => {}
288+
function Foo() {
289+
return <div onClick={callback/* when true (default) - no expansion here */} />
290+
}
291+
```
292+
208293
## Auto Imports
209294

210295
With this plugin you have total (almost) control over auto imports that appear in completions, quick fixes and import all quick fix. Some examples of what you can do:
@@ -320,7 +405,9 @@ Another options that is accepted is
320405

321406
### Go to / Select Nodes by Kind
322407

323-
Use cases: search excluding comments, search & replace only within strings, find interested JSX attribute node
408+
Extremely powerful command that allows you to leverage AST knowledge of opened file.
409+
410+
Use cases: select all comments to exclude searching in comments. Or search & replace only within strings / find interested JSX attribute node.
324411

325412
## Contributed Code Actions
326413

REFACTOR-EXTENSIONS-COMPARING.MD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# VS CODE Refactor Extensions Comparing
2+
3+
All of these extensions are free to use and can be used offline.
4+
5+
| Extension | Good number of actions | Actions quality | Performance Optimizations |
6+
| --------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------------------------------------------------------------------- | --------------------------------------------------- |
7+
| [JS Refactor :: JS CodeFormer](https://marketplace.visualstudio.com/items?itemName=cmstead.jsrefactor) || ❌ (Extension abandoned) | ? |
8+
| [Abracadabra, refactor this!](https://marketplace.visualstudio.com/items?itemName=nicoespeon.abracadabra) || ❌ Sometimes buggy, doesn't work with syntax errors, no TS types auto-infer | ❌ (Uses extension host, slow downs other extension) |
9+
| [JS Refactoring Assistant (P42)](https://marketplace.visualstudio.com/items?itemName=p42ai.refactor) || JS - ✅, TS - ❌ (You need to write types yourself) | ✅ (Dedicated language server) |
10+
| [TypeScript Essential Plugins](https://marketplace.visualstudio.com/items?itemName=zardoy.ts-essential-plugins) || ✅? (Auto infers types, but missing a lot of tests) | ✅ (Best possible, reuses TS language server) |

integration/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ export const run = async () => {
1313
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
1414
if (err) throw err
1515

16-
for (const file of files) mocha.addFile(join(testsRoot, file))
16+
const preFiles = [] as string[]
17+
const postFiles = ['outline.test.js'] as string[]
18+
19+
for (const file of preFiles) {
20+
mocha.addFile(join(testsRoot, file))
21+
}
22+
23+
for (const file of files.filter(file => !preFiles.includes(file) && !postFiles.includes(file))) {
24+
mocha.addFile(join(testsRoot, file))
25+
}
26+
27+
for (const file of postFiles) {
28+
mocha.addFile(join(testsRoot, file))
29+
}
1730

1831
mocha.run(failures => {
1932
if (failures > 0) {

integration/suite/completions.test.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

integration/suite/jsx.test.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

media/change-kind.png

7.53 KB
Loading

media/non-function-methods.png

48.8 KB
Loading

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"test-plugin": "vitest --globals --dir typescript/test/ --environment ts-plugin",
105105
"integration-test": "node integration/prerun.mjs && tsc -p tsconfig.test.json && node testsOut/runTests.js",
106106
"integration-test:watch": "chokidar \"integration/**\" -c \"pnpm integration-test\" --initial",
107-
"postinstall": "patch-package"
107+
"postinstall": "patch-package && tsm ./typescript/scripts/patchModules.ts"
108108
},
109109
"devDependencies": {
110110
"@milahu/patch-package-with-pnpm-support": "^6.4.8",
@@ -123,7 +123,8 @@
123123
"vite": "^4.1.1",
124124
"vitest": "^0.26.0",
125125
"vitest-environment-ts-plugin": "./vitest-environment-ts-plugin",
126-
"vscode-manifest": "^0.0.4"
126+
"vscode-manifest": "^0.0.4",
127+
"tsm": "^2.3.0"
127128
},
128129
"pnpm": {
129130
"overrides": {

0 commit comments

Comments
 (0)