Skip to content

Commit b69f34c

Browse files
authored
Add tests and tweak linting configuration (#5)
* Run prettier through eslint This makes it so there is only one command you ever need to run and simplifies editor integration. * Add .editorconfig * Set up tests * Set up coverage * Enforce import order * Use master for test and package workflow triggers * Enforce lf line endings Otherwise Prettier on Windows fails since it expects lf. * Use npx to run vsce
1 parent 92df28c commit b69f34c

23 files changed

+12052
-3768
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
trim_trailing_whitespace = true
6+
indent_size = 2

.eslintrc.json

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"ecmaVersion": 6,
6-
"sourceType": "module"
7-
},
8-
"plugins": [
9-
"@typescript-eslint"
10-
],
11-
"rules": {
12-
"@typescript-eslint/naming-convention": "off",
13-
"@typescript-eslint/semi": "off",
14-
"curly": "warn",
15-
"eqeqeq": "warn",
16-
"no-throw-literal": "warn",
17-
"semi": "off"
18-
}
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": [
9+
"@typescript-eslint",
10+
"prettier"
11+
],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"plugin:import/recommended",
16+
"plugin:import/typescript",
17+
"plugin:md/prettier",
18+
"prettier"
19+
],
20+
"overrides": [{
21+
"files": ["*.md"],
22+
"parser": "markdown-eslint-parser"
23+
}],
24+
"rules": {
25+
"curly": "error",
26+
"eqeqeq": "error",
27+
"no-throw-literal": "error",
28+
"no-console": "error",
29+
"prettier/prettier": "error",
30+
"import/order": ["error", {
31+
"alphabetize": {
32+
"order": "asc"
33+
},
34+
"groups": [["builtin", "external", "internal"], "parent", "sibling"]
35+
}],
36+
"import/no-unresolved": ["error", {
37+
"ignore": ["vscode"]
38+
}]
39+
},
40+
"ignorePatterns": [
41+
"out",
42+
"dist",
43+
"**/*.d.ts"
44+
]
1945
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/package.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
on:
22
push:
3+
branches:
4+
- master
5+
36
name: Package Extension
7+
48
jobs:
59
package:
610
runs-on: ubuntu-20.04
711
steps:
812
- uses: actions/checkout@v2
13+
914
- uses: actions/setup-node@v2
1015
with:
11-
node-version: '15'
16+
node-version: '16'
17+
1218
- run: npm ci
13-
- run: npm install -g vsce
14-
- run: vsce package --out coder.vsix
19+
20+
- run: npx vsce package --out coder.vsix
21+
1522
- uses: actions/upload-artifact@v2
1623
with:
1724
name: coder.vsix

.github/workflows/publish.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ on:
33
release:
44
types:
55
- created
6+
67
name: Publish Extension
8+
79
jobs:
810
publish:
911
runs-on: ubuntu-20.04
1012
steps:
1113
- uses: actions/checkout@v2
14+
1215
- uses: actions/setup-node@v2
1316
with:
14-
node-version: '15'
17+
node-version: '16'
18+
1519
- run: npm ci
16-
- run: npm install -g vsce
17-
- name: Publish
18-
run: vsce publish -p "$VS_TOKEN"
20+
21+
- name: vsce publish
22+
run: npx vsce publish -p "$VS_TOKEN"
1923
env:
2024
VS_TOKEN: ${{ secrets.VS_MARKETPLACE_PAT }}

.github/workflows/test.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
9+
name: Test Extension
10+
11+
jobs:
12+
test:
13+
strategy:
14+
matrix:
15+
platform: [ubuntu-latest, macos-latest, windows-latest]
16+
runs-on: ${{ matrix.platform }}
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- uses: actions/setup-node@v2
22+
with:
23+
node-version: '16'
24+
25+
# VS Code requires a display (it will fail to start without one) so use
26+
# Xvfb to provide one on Linux since Linux does not have one running by
27+
# default unlike the other platforms. We run VS Code because the tests
28+
# include integration tests that run inside VS Code.
29+
- if: ${{ matrix.platform == 'ubuntu-latest' }}
30+
run: sudo apt install -y xvfb
31+
32+
- name: Run Xvfb
33+
if: ${{ matrix.platform == 'ubuntu-latest' }}
34+
run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
35+
36+
- run: npm ci
37+
38+
- run: npm run test
39+
env:
40+
# This tells the application on which display it should run. Set to
41+
# the display we started on Linux via Xvfb. The other platforms do not
42+
# use this and will ignore the variable.
43+
DISPLAY: ":99.0"

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
dist/
2-
node_modules/
3-
out/
1+
/dist/
2+
/node_modules/
3+
/out/
4+
/.vscode-test/
5+
/.nyc_output/
6+
/coverage/

.prettierignore

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

.vscode/launch.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Run Extension",
6-
"type": "extensionHost",
7-
"request": "launch",
8-
"args": [
9-
"--extensionDevelopmentPath=${workspaceFolder}"
10-
],
11-
"outFiles": [
12-
"${workspaceFolder}/dist/**/*.js"
13-
],
14-
"preLaunchTask": "${defaultBuildTask}"
15-
},
16-
{
17-
"name": "Extension Tests",
18-
"type": "extensionHost",
19-
"request": "launch",
20-
"args": [
21-
"--extensionDevelopmentPath=${workspaceFolder}",
22-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
23-
],
24-
"outFiles": [
25-
"${workspaceFolder}/out/test/**/*.js"
26-
],
27-
"preLaunchTask": "npm: test-watch"
28-
}
29-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Run Extension",
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"args": [
9+
"--extensionDevelopmentPath=${workspaceFolder}"
10+
],
11+
"outFiles": [
12+
"${workspaceFolder}/dist/**/*.js"
13+
],
14+
"preLaunchTask": "${defaultBuildTask}"
15+
},
16+
{
17+
"name": "Extension Tests",
18+
"type": "extensionHost",
19+
"request": "launch",
20+
"args": [
21+
"--extensionDevelopmentPath=${workspaceFolder}",
22+
"--extensionTestsPath=${workspaceFolder}/out/test/runner"
23+
],
24+
"outFiles": [
25+
"${workspaceFolder}/out/**/*.test.js"
26+
],
27+
"preLaunchTask": "npm: test:watch"
28+
}
29+
]
3030
}

.vscode/tasks.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"type": "npm",
6-
"script": "watch",
7-
"problemMatcher": [
8-
"$ts-webpack-watch",
9-
"$tslint-webpack-watch"
10-
],
11-
"isBackground": true,
12-
"presentation": {
13-
"reveal": "never"
14-
},
15-
"group": {
16-
"kind": "build",
17-
"isDefault": true
18-
}
19-
},
20-
{
21-
"type": "npm",
22-
"script": "test-watch",
23-
"problemMatcher": "$tsc-watch",
24-
"isBackground": true,
25-
"presentation": {
26-
"reveal": "never"
27-
},
28-
"group": "build"
29-
}
30-
]
31-
}
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "watch",
7+
"problemMatcher": [
8+
"$ts-webpack-watch",
9+
"$tslint-webpack-watch"
10+
],
11+
"isBackground": true,
12+
"presentation": {
13+
"reveal": "never"
14+
},
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"type": "npm",
22+
"script": "test:watch",
23+
"problemMatcher": "$tsc-watch",
24+
"isBackground": true,
25+
"presentation": {
26+
"reveal": "never"
27+
},
28+
"group": "build"
29+
}
30+
]
31+
}

.vscodeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.vscode/**
22
.vscode-test/**
3+
.nyc_output/**
4+
coverage/**
35
out/**
46
src/**
57
.gitignore
68
**/tsconfig.json
79
**/.eslintrc.json
10+
**/.editorconfig
811
**/*.map
912
**/*.ts

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
2-
31
# vscode-coder
42

53
> Work in Progress
64
75
<img width="1081" alt="Screen Shot 2021-03-08 at 12 01 25 PM" src="https://user-images.githubusercontent.com/7585078/110361753-0cedc400-8006-11eb-826f-214bfb3dfc6c.png">
86

7+
## Development
8+
9+
- Install Node (preferably >= 16)
10+
- Clone the repository locally
11+
- Run `npm install`
12+
13+
From here you have a few choices:
14+
15+
- Run through VS Code:
16+
- `Run Extension` task
17+
- `Extension Tests` task
18+
- Run `npm run test` from the CLI
19+
- On Linux to run headless install and run `xvfb`
20+
- Refer to CI test workflow for more details
21+
22+
To fix automatically fixable linting issues run:
23+
24+
```shell
25+
npm run lint -- --fix
26+
```
27+
928
## Known issues
1029

1130
- Context menu action `Show Logs` is blocking, and blocks until a rebuild completes
@@ -16,10 +35,12 @@
1635
## Planned work
1736

1837
- Rethink `Open` UX
38+
1939
- should we link to Remote SSH panel?
2040
- should we allow opening directly into project dirs ourselves?
2141

2242
- Authenticate the CLI from VS Code
43+
2344
- Install the CLI from VS Code
2445
- Run without the CLI installed
2546

0 commit comments

Comments
 (0)