Skip to content

Commit 6782978

Browse files
authored
Merge pull request #203 from microsoft/connor4312/prettier-and-eslint
chore: adopt prettier and eslint hook
2 parents a8c51de + d9b458c commit 6782978

14 files changed

+538
-121
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"dbaeumer.vscode-eslint"
5+
]
6+
}

.vscode/settings.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"editor.insertSpaces": true,
3+
"editor.insertSpaces": true,
44
"files.eol": "\n",
55
"files.trimTrailingWhitespace": true,
6-
"files.exclude": {
7-
"**/.git": true,
8-
"**/.DS_Store": true,
9-
"**/*.js": {
10-
"when": "$(basename).ts"
11-
}
6+
"files.exclude": {
7+
"**/.git": true,
8+
"**/.DS_Store": true,
9+
"**/*.js": {
10+
"when": "$(basename).ts"
11+
}
1212
},
13-
"githubIssues.queries":[
13+
"editor.formatOnSave": true,
14+
"editor.defaultFormatter": "esbenp.prettier-vscode",
15+
"githubIssues.queries": [
1416
{
1517
"label": "Recent Issues",
1618
"query": "state:open repo:${owner}/${repository} sort:updated-desc"

CHANGELOG.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
### 1.1.0 | 2019-08-02
122122

123123
- Add `resolveCliPathFromVSCodeExecutablePath` that would resolve `vscodeExecutablePath` to VS Code CLI path, which can be used
124-
for extension management features such as `--install-extension` and `--uninstall-extension`. [#31](https://github.com/microsoft/vscode-test/issues/31).
124+
for extension management features such as `--install-extension` and `--uninstall-extension`. [#31](https://github.com/microsoft/vscode-test/issues/31).
125125

126126
### 1.0.2 | 2019-07-17
127127

@@ -144,13 +144,13 @@ for extension management features such as `--install-extension` and `--uninstall
144144
### 1.0.0-next.0 | 2019-06-24
145145

146146
- Updated API:
147-
- One single set of options.
148-
- `extensionPath` => `extensionDevelopmentPath` to align with VS Code launch flags
149-
- `testRunnerPath` => `extensionTestsPath` to align with VS Code launch flags
150-
- `testRunnerEnv` => `extensionTestsEnv` to align with VS Code launch flags
151-
- `additionalLaunchArgs` => `launchArgs`
152-
- `testWorkspace` removed. Pass path to file/folder/workspace as first argument to `launchArgs` instead.
153-
- `locale` removed. Pass `--locale` to `launchArgs` instead.
147+
- One single set of options.
148+
- `extensionPath` => `extensionDevelopmentPath` to align with VS Code launch flags
149+
- `testRunnerPath` => `extensionTestsPath` to align with VS Code launch flags
150+
- `testRunnerEnv` => `extensionTestsEnv` to align with VS Code launch flags
151+
- `additionalLaunchArgs` => `launchArgs`
152+
- `testWorkspace` removed. Pass path to file/folder/workspace as first argument to `launchArgs` instead.
153+
- `locale` removed. Pass `--locale` to `launchArgs` instead.
154154

155155
### 0.4.3 | 2019-05-30
156156

@@ -163,7 +163,7 @@ for extension management features such as `--install-extension` and `--uninstall
163163
### 0.4.1 | 2019-05-02
164164

165165
- Fix Linux crash because `testRunnerEnv` is not merged with `process.env` for spawning the
166-
testing process. [#14](https://github.com/Microsoft/vscode-test/issues/14c).
166+
testing process. [#14](https://github.com/Microsoft/vscode-test/issues/14c).
167167

168168
### 0.4.0 | 2019-04-18
169169

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ import { runTests } from '@vscode/test-electron';
2020

2121
async function go() {
2222
try {
23-
const extensionDevelopmentPath = path.resolve(__dirname, '../../../')
24-
const extensionTestsPath = path.resolve(__dirname, './suite')
23+
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
24+
const extensionTestsPath = path.resolve(__dirname, './suite');
2525

2626
/**
2727
* Basic usage
2828
*/
2929
await runTests({
3030
extensionDevelopmentPath,
31-
extensionTestsPath
32-
})
31+
extensionTestsPath,
32+
});
3333

34-
const extensionTestsPath2 = path.resolve(__dirname, './suite2')
35-
const testWorkspace = path.resolve(__dirname, '../../../test-fixtures/fixture1')
34+
const extensionTestsPath2 = path.resolve(__dirname, './suite2');
35+
const testWorkspace = path.resolve(__dirname, '../../../test-fixtures/fixture1');
3636

3737
/**
3838
* Running another test suite on a specific workspace
3939
*/
4040
await runTests({
4141
extensionDevelopmentPath,
4242
extensionTestsPath: extensionTestsPath2,
43-
launchArgs: [testWorkspace]
44-
})
43+
launchArgs: [testWorkspace],
44+
});
4545

4646
/**
4747
* Use 1.36.1 release for testing
@@ -50,8 +50,8 @@ async function go() {
5050
version: '1.36.1',
5151
extensionDevelopmentPath,
5252
extensionTestsPath,
53-
launchArgs: [testWorkspace]
54-
})
53+
launchArgs: [testWorkspace],
54+
});
5555

5656
/**
5757
* Use Insiders release for testing
@@ -60,32 +60,32 @@ async function go() {
6060
version: 'insiders',
6161
extensionDevelopmentPath,
6262
extensionTestsPath,
63-
launchArgs: [testWorkspace]
64-
})
63+
launchArgs: [testWorkspace],
64+
});
6565

6666
/**
6767
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
6868
*/
69-
await downloadAndUnzipVSCode('1.36.1')
69+
await downloadAndUnzipVSCode('1.36.1');
7070

7171
/**
7272
* Manually download VS Code 1.35.0 release for testing.
7373
*/
74-
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0')
74+
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0');
7575
await runTests({
7676
vscodeExecutablePath,
7777
extensionDevelopmentPath,
7878
extensionTestsPath,
79-
launchArgs: [testWorkspace]
80-
})
79+
launchArgs: [testWorkspace],
80+
});
8181

8282
/**
8383
* Install Python extension
8484
*/
8585
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
8686
cp.spawnSync(cli, [...args, '--install-extension', 'ms-python.python'], {
8787
encoding: 'utf-8',
88-
stdio: 'inherit'
88+
stdio: 'inherit',
8989
});
9090

9191
/**
@@ -99,11 +99,11 @@ async function go() {
9999
launchArgs: [
100100
testWorkspace,
101101
// This disables all extensions except the one being tested
102-
'--disable-extensions'
102+
'--disable-extensions',
103103
],
104104
// Custom environment variables for extension test script
105-
extensionTestsEnv: { foo: 'bar' }
106-
})
105+
extensionTestsEnv: { foo: 'bar' },
106+
});
107107

108108
/**
109109
* Use win64 instead of win32 for testing Windows
@@ -113,17 +113,16 @@ async function go() {
113113
extensionDevelopmentPath,
114114
extensionTestsPath,
115115
version: '1.40.0',
116-
platform: 'win32-x64-archive'
116+
platform: 'win32-x64-archive',
117117
});
118118
}
119-
120119
} catch (err) {
121-
console.error('Failed to run tests')
122-
process.exit(1)
120+
console.error('Failed to run tests');
121+
process.exit(1);
123122
}
124123
}
125124

126-
go()
125+
go();
127126
```
128127

129128
## Development

SECURITY.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ If you believe you have found a security vulnerability in any Microsoft-owned re
1212

1313
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
1414

15-
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
15+
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
1616

17-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
17+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
1818

1919
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
2020

21-
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22-
* Full paths of source file(s) related to the manifestation of the issue
23-
* The location of the affected source code (tag/branch/commit or direct URL)
24-
* Any special configuration required to reproduce the issue
25-
* Step-by-step instructions to reproduce the issue
26-
* Proof-of-concept or exploit code (if possible)
27-
* Impact of the issue, including how an attacker might exploit the issue
21+
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22+
- Full paths of source file(s) related to the manifestation of the issue
23+
- The location of the affected source code (tag/branch/commit or direct URL)
24+
- Any special configuration required to reproduce the issue
25+
- Step-by-step instructions to reproduce the issue
26+
- Proof-of-concept or exploit code (if possible)
27+
- Impact of the issue, including how an attacker might exploit the issue
2828

2929
This information will help us triage your report more quickly.
3030

lib/del.ts

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

lib/download.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('fetchTargetInferredVersion', () => {
8888
cachePath: join(extensionsDevelopmentPath, '.cache'),
8989
platform: 'win32-archive',
9090
timeout: 5000,
91-
extensionsDevelopmentPath: paths.map(p => join(extensionsDevelopmentPath, p)),
91+
extensionsDevelopmentPath: paths.map((p) => join(extensionsDevelopmentPath, p)),
9292
});
9393

9494
test('matches stable if no workspace', async () => {

lib/download.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { tmpdir } from 'os';
99
import * as path from 'path';
1010
import { pipeline, Readable } from 'stream';
1111
import { promisify } from 'util';
12-
import * as del from './del';
1312
import { ConsoleReporter, ProgressReporter, ProgressReportStage } from './progress';
1413
import * as request from './request';
1514
import * as semver from 'semver';
@@ -101,7 +100,8 @@ export async function fetchTargetInferredVersion(options: IFetchInferredOptions)
101100
return found2;
102101
}
103102

104-
console.warn(`No version of VS Code satisfies all extension engine constraints (${extVersions.join(', ')}). Falling back to stable.`);
103+
const v = extVersions.join(', ');
104+
console.warn(`No version of VS Code satisfies all extension engine constraints (${v}). Falling back to stable.`);
105105

106106
return stable[0]; // 🤷
107107
} catch (e) {
@@ -215,18 +215,33 @@ async function downloadVSCodeArchive(options: DownloadOptions) {
215215
const isZip = contentType ? contentType === 'application/zip' : url.endsWith('.zip');
216216

217217
const timeoutCtrl = new request.TimeoutController(timeout);
218-
options.reporter?.report({ stage: ProgressReportStage.Downloading, url, bytesSoFar: 0, totalBytes });
218+
options.reporter?.report({
219+
stage: ProgressReportStage.Downloading,
220+
url,
221+
bytesSoFar: 0,
222+
totalBytes,
223+
});
219224

220225
let bytesSoFar = 0;
221226
download.on('data', (chunk) => {
222227
bytesSoFar += chunk.length;
223228
timeoutCtrl.touch();
224-
options.reporter?.report({ stage: ProgressReportStage.Downloading, url, bytesSoFar, totalBytes });
229+
options.reporter?.report({
230+
stage: ProgressReportStage.Downloading,
231+
url,
232+
bytesSoFar,
233+
totalBytes,
234+
});
225235
});
226236

227237
download.on('end', () => {
228238
timeoutCtrl.dispose();
229-
options.reporter?.report({ stage: ProgressReportStage.Downloading, url, bytesSoFar: totalBytes, totalBytes });
239+
options.reporter?.report({
240+
stage: ProgressReportStage.Downloading,
241+
url,
242+
bytesSoFar: totalBytes,
243+
totalBytes,
244+
});
230245
});
231246

232247
timeoutCtrl.signal.addEventListener('abort', () => {
@@ -375,7 +390,7 @@ export async function download(options: Partial<DownloadOptions> = {}): Promise<
375390
newDate: new Date(latestTimestamp),
376391
newHash: latestHash,
377392
});
378-
await del.rmdir(downloadedPath);
393+
await fs.promises.rm(downloadedPath, { force: true, recursive: true });
379394
} catch (err) {
380395
reporter.error(err);
381396
throw Error(`Failed to remove outdated Insiders at ${downloadedPath}.`);
@@ -397,7 +412,13 @@ export async function download(options: Partial<DownloadOptions> = {}): Promise<
397412
const downloadStaging = `${downloadedPath}.tmp`;
398413
await fs.promises.rm(downloadStaging, { recursive: true, force: true });
399414

400-
const { stream, format } = await downloadVSCodeArchive({ version, platform, cachePath, reporter, timeout });
415+
const { stream, format } = await downloadVSCodeArchive({
416+
version,
417+
platform,
418+
cachePath,
419+
reporter,
420+
timeout,
421+
});
401422
// important! do not put anything async here, since unzipVSCode will need
402423
// to start consuming the stream immediately.
403424
await unzipVSCode(reporter, downloadStaging, extractSync, stream, format);

0 commit comments

Comments
 (0)