Skip to content

Commit

Permalink
Add eslint and prettier (#342)
Browse files Browse the repository at this point in the history
* Add configuration for eslint and prettier, include check in PR build flow

Signed-off-by: Yevhen Vydolob <[email protected]>

* Use same node version as yaml-ls

Signed-off-by: Yevhen Vydolob <[email protected]>

* Fix review comments

Signed-off-by: Yevhen Vydolob <[email protected]>

* Use space for indentation

Signed-off-by: Yevhen Vydolob <[email protected]>

* Small change to trigger CI

Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob authored Aug 18, 2020
1 parent b304d34 commit 2a394cc
Show file tree
Hide file tree
Showing 27 changed files with 1,800 additions and 928 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Tab indentation
[*]
indent_style = tab
indent_size = 4
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[{.travis.yml,npm-shrinkwrap.json,package.json}]
indent_style = space
indent_size = 2
indent_size = 2
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
env: {
node: true,
es6: true,
},
parserOptions: {
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/explicit-function-return-type': [1, { allowExpressions: true }],
'eol-last': ['error'],
'space-infix-ops': ['error', { int32Hint: false }],
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'keyword-spacing': ['error'],
},
};
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode-test
out
syntaxes/
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "always",
"printWidth": 130,
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "auto"
}
32 changes: 16 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
sudo: false
language: node_js
node_js:
- '10.9.0'
- '12'
os:
- osx
- linux
- osx
- linux
before_install:
- npm install -g typescript
- npm install -g typescript
install:
- |
if [ $TRAVIS_OS_NAME == "linux" ]; then
export DISPLAY=':99.0';
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
fi
- npm install
- npm run vscode:prepublish
- npm install -g vsce
- vsce package
- |
if [ $TRAVIS_OS_NAME == "linux" ]; then
export DISPLAY=':99.0';
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
fi
- npm install
- npm run build
- npm install -g vsce
- vsce package
script:
- npm test
- npm test
deploy:
provider : npm
email : [email protected]
provider: npm
email: [email protected]
api_key:
secure: BOtaGfNaAl0zGlsuVakvQTe45FHxxbvVaS7O1h1mVmoxr/a985UeRPF9dxxcAaAhVdCZ93OwY6f3fdP2Mn87hOPksCaBfvlTccOBxyWfnF4TaRecsAOcq+iVzZwBNEsQBD0YRESUYiMjv7uT17pkVxOJ7Id8L3FfEUcN9EUWb+AfMFw8qJjCXIT8KjfdeG2EPkJll4qvsYXbOepPJOnPchTJpkYMc8gGGlFVAAqO+RX0r3wanSuUF0oxmunOwGcrF2qKgFCGgLMAkv7r6MAGcD3iK0xVaU4xBU9XSNYSrsgap43f7LFb1lWMpxpSCxB1Vw/D4s2TeJX1CozfrM0SPhOU6B8re1iift8aUCqKee2qjaYitpE8FIha9LWdtxAfCItO96jzVOxuYcxeM94hpl5aMeUaCTTC7Bln+qS+J6Vg2eBn6k3uVvyDmtT+2dul0L/iMuIgECBtiATEWAkMo/TheiQWAAKKlFEx0e7tzBfnlW42d4t4fTVE/znMPp/fMcLF25h64I2wYsemMMPh/yN6zQRKhONlLlNFY+x+3hDyUD2FHukk4xifZfJrvjF00bGPGB3HwIGbVvIcoyWiXSzWSmycgey7ZZM8uclJ/9B1Y8Ct73C6zz1rqlgQ1tqBm07v+nNOGNJASphTEWmrdVXY3ZCHB2OnBbnD11a9NUA=
16 changes: 8 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"ms-vscode.vscode-typescript-tslint-plugin",
"EditorConfig.EditorConfig"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig"
]
}
83 changes: 37 additions & 46 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,39 @@
{
"version": "0.2.0",
"configurations": [
{
// A launch configuration that compiles the extension and then opens it inside a new window
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
"preLaunchTask": "compile typescript"
},
{
// A launch configuration that compiles the extension and runs mocha unit tests
"type": "node",
"request": "launch",
"name": "Launch Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"-r",
"ts-node/register",
"${workspaceRoot}/test/*.test.ts"
],
"preLaunchTask": "compile typescript"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test",
"${workspaceRoot}/test/testFixture"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"]
}
]
"version": "0.2.0",
"configurations": [
{
// A launch configuration that compiles the extension and then opens it inside a new window
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/src/**/*.js"],
"preLaunchTask": "compile typescript"
},
{
// A launch configuration that compiles the extension and runs mocha unit tests
"type": "node",
"request": "launch",
"name": "Launch Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": ["-u", "tdd", "--timeout", "999999", "--colors", "-r", "ts-node/register", "${workspaceRoot}/test/*.test.ts"],
"preLaunchTask": "compile typescript"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test",
"${workspaceRoot}/test/testFixture"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"]
}
]
}
26 changes: 13 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
},
}
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
}
44 changes: 22 additions & 22 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
// A task runner that calls a custom npm script that compiles the extension.
{
"label": "compile typescript",
// the command is a shell script
"type": "shell",
// we run the custom npm script "compile" as defined in package.json
"command": "npm run compile --loglevel silent",
// show the output window only if unrecognized errors occur.
"presentation": {
"reveal": "silent",
},
// The tsc compiler is started in watching mode
"isBackground": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
]
}
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
// A task runner that calls a custom npm script that compiles the extension.
{
"label": "compile typescript",
// the command is a shell script
"type": "shell",
// we run the custom npm script "compile" as defined in package.json
"command": "npm run compile --loglevel silent",
// show the output window only if unrecognized errors occur.
"presentation": {
"reveal": "silent"
},
// The tsc compiler is started in watching mode
"isBackground": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
]
}
Loading

0 comments on commit 2a394cc

Please sign in to comment.