Setup & Onboarding
Editor Setup

Editor setup

🙏️

Regardless of the editor you use, you should always format and lint your code on save, or at least before committing. Formatting and linting should be performed by locally installed Prettier and ESlint to prevent inconsistencies.

Visual Studio Code

We recommend using Visual Studio Code (opens in a new tab) with the following settings and extensions.

If you prefer a different editor, it's completely fine. Still, you should find the counterparts of the extensions and setup mentioned above that help you with formatting and a suitable typescript integration (which is a part of default VS Code installation).

Setup formatting and linting

Install Eslint (opens in a new tab), Prettier (opens in a new tab), and Remove Unused Imports (opens in a new tab).

Open User Settings (JSON) and insert following lines:

settings.json
{
  // ...
 
  "editor.codeActionsOnSave": {
    "source.removeUnusedImports": true,
    "source.formatDocument": true,
    "source.fixAll.eslint": true
  },
  "files.insertFinalNewline": true,
  "javascript.preferences.importModuleSpecifier": "non-relative",
  "typescript.preferences.importModuleSpecifier": "non-relative",
 
  // optionally
  "files.autoSave": "onFocusChange"
}
  • removeUnusedImports removes all unused imports without sorting them as source.organizeImports does. This way conflicts with ESLint are avoided.
  • formatDocument will run prettier, and fixAll.eslint will run eslint fix. The order of these commands is important.
  • files.insertFinalNewline will add a new line at the end of the document.
  • ...preferences.importModuleSpecifier will make sure you always use absolute imports, which is a good practice.

Extensions

These are not crucial, but either they improve dev experience, or they may help prevent some common mistakes.

For frontend devs:

Other useful extensions:

Example of settings.json

This is how your full User Settings could look like:

settings.json
{
  "files.autoSave": "onFocusChange",
  "files.insertFinalNewline": true,
  "editor.fontFamily": "Fira Code",
  "editor.fontLigatures": true,
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "editor.accessibilitySupport": "off",
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": {
    "source.formatDocument": true,
    "source.fixAll.eslint": true
  },
  "prettier.enableDebugLogs": true,
  "prettier.printWidth": 100,
  "prettier.jsxSingleQuote": true,
  "prettier.semi": false,
  "files.associations": {
    ".env.bratiska-cli-build.*": "dotenv"
  },
  "diffEditor.ignoreTrimWhitespace": false,
  "editor.inlineSuggest.enabled": true,
  "typescript.suggest.autoImports": true,
  "javascript.preferences.importModuleSpecifier": "non-relative",
  "typescript.preferences.importModuleSpecifier": "non-relative",
  "svg.preview.mode": "svg"
}

WebStorm

If you use WebStorm, make sure to run eslint and prettier on save (or at least before commit).

Setup

Below are the setting that worked for me. You have to enable eslint and prettier, and set them to run on save.

⚠️

Other combination of checked options may lead to inconsistencies. I also added json to be formatted by prettier, and I have to choose prettier for each project manually.

WebStorm On Save setup

WebStorm Prettier setup

WebStorm Eslint setup

Plugins