Skip to content

Commit 215d9a8

Browse files
authored
fix #1276 Pre-commit hooks to ensure code complies with standards (#1277)
* sanitize code * gulp file to check code hygiene * fix preLaunchTask in launch.json * added missing packages * enabled pre-commit using husky * enabled a few checks for precommit hook * fix tslint warnings when running tslint via gulp * exclude webpack building, else tries to pull in tests as well * improved checks for commits (strict) * added new lines
1 parent e1ea437 commit 215d9a8

File tree

12 files changed

+408
-35
lines changed

12 files changed

+408
-35
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Tab indentation
7+
[*]
8+
indent_style = space
9+
indent_size = 4
10+
trim_trailing_whitespace = true
11+
12+
# The indent size used in the `package.json` file cannot be changed
13+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
14+
[{.travis.yml,npm-shrinkwrap.json,package.json}]
15+
indent_style = space
16+
indent_size = 4

.eslintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{
3+
"env": {
4+
"node": true,
5+
"es6": true
6+
},
7+
"rules": {
8+
"no-console": 0,
9+
"no-cond-assign": 0,
10+
"no-unused-vars": 1,
11+
"no-extra-semi": "warn",
12+
"semi": "warn"
13+
},
14+
"extends": "eslint:recommended"
15+
}

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jshintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"node": true,
3+
4+
"curly": true,
5+
"latedef": true,
6+
"quotmark": true,
7+
"undef": true,
8+
"unused": true,
9+
"trailing": true
10+
}

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"stopOnEntry": false,
3232
"sourceMaps": true,
3333
"outDir": "${workspaceRoot}/out",
34-
"preLaunchTask": "npm"
34+
"preLaunchTask": "compile"
3535
},
3636
{
3737
"name": "Launch Extension as debugServer", // https://code.visualstudio.com/docs/extensions/example-debuggers
@@ -62,7 +62,7 @@
6262
"outFiles": [
6363
"${workspaceRoot}/out/**/*.js"
6464
],
65-
"preLaunchTask": "npm"
65+
"preLaunchTask": "compile"
6666
},
6767
{
6868
"name": "Python",

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
33
"files.exclude": {
4-
"out": false, // set this to true to hide the "out" folder with the compiled JS files
4+
"out": true, // set this to true to hide the "out" folder with the compiled JS files
55
"**/*.pyc": true,
66
"**/__pycache__": true,
77
"node_modules": true
@@ -15,6 +15,5 @@
1515
"python.formatting.formatOnSave": false,
1616
"python.unitTest.promptToConfigure": false,
1717
"python.workspaceSymbols.enabled": false,
18-
"python.pythonPath": "/Users/donjayamanne/Projects/PythonEnvs/p27/bin/python",
1918
"python.formatting.provider": "yapf"
2019
}

.vscode/tasks.json

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,54 @@
55
// ${fileDirname}: the current opened file's dirname
66
// ${fileExtname}: the current opened file's extension
77
// ${cwd}: the current working directory of the spawned process
8-
98
// A task runner that calls a custom npm script that compiles the extension.
109
{
11-
"version": "0.1.0",
12-
13-
// we want to run npm
14-
"command": "npm",
15-
16-
// the command is a shell script
17-
"isShellCommand": true,
18-
19-
// show the output window only if unrecognized errors occur.
20-
"showOutput": "silent",
21-
22-
// we run the custom script "compile" as defined in package.json
23-
"args": ["run", "compile", "--loglevel", "silent"],
24-
"isBackground": true,
25-
26-
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
27-
"problemMatcher": "$tsc-watch"
28-
}
10+
"version": "2.0.0",
11+
"presentation": {
12+
"echo": true,
13+
"reveal": "always",
14+
"focus": false,
15+
"panel": "shared"
16+
},
17+
"tasks": [
18+
{
19+
"label": "compile",
20+
"type": "npm",
21+
"script": "compile",
22+
"group": "build",
23+
"isBackground": true,
24+
"problemMatcher": [
25+
"$tsc",
26+
{
27+
"base": "$tslint5",
28+
"fileLocation": "relative"
29+
}
30+
]
31+
},
32+
{
33+
"type": "npm",
34+
"script": "lint",
35+
"problemMatcher": {
36+
"base": "$tslint5",
37+
"fileLocation": "relative"
38+
}
39+
},
40+
{
41+
"type": "npm",
42+
"script": "watch",
43+
"isBackground": true,
44+
"problemMatcher": "$tsc-watch"
45+
},
46+
{
47+
"type": "gulp",
48+
"task": "hygiene",
49+
"problemMatcher": [
50+
"$tsc",
51+
{
52+
"base": "$tslint5",
53+
"fileLocation": "relative"
54+
}
55+
]
56+
}
57+
]
58+
}

0 commit comments

Comments
 (0)