Skip to main content

1 Code Style

To enforce code style in typescript we use Prettier and ESLint to format and lint our code. To share the settings between all developers we use a .eslintrc file, which is checked in to each repository. To share the same config in multiple repositories we decided to have a master file eslintrc-global.json in the octo-tols repository This is automtically synced by a github action. Every project must reference this file in the local .eslintrc file:

{
"extends": [".eslintrc-global.json"]
}

VS Code Plugins and Settigns

To use the same settings in VS Code we use the following extensions:

.vscode/extensions.json

{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": [
"angular.ng-template",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}

To prettify and lint the code on save we use the following settings:

.vscode/settings.json

{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}

Rider Configuration

To use eslint in rider the follwing settings must be set:

Settings -> Languages & Frameworks -> JavaScript -> Code Quality Tools -> ESLint

  • Enable Automatic ESLint configuration

  • Check Run eslint --fix on save

package.json

To use all the mentioned tooling a few packages and scripts have to be configured in the packages.json.
ATTENTION: Version infos are outdatet for sure
package.json

{
//rest of the file
"scripts": {
"build": "npm run lint && npm run build:my-service-name",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prettier": "prettier --write ."
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^35.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"prettier": "^2.8.8"
}
}