-
Notifications
You must be signed in to change notification settings - Fork 0
Code Style & Linting Guidelines
Danilo Joksimovic edited this page Oct 10, 2019
·
1 revision
- Always use
async/awaitinstead of.then() - Wrap async operations in try/catch blocks
- USE YARN instead of npm
- If you see
npm installornpm i-> useyarn addinstead - See
yarn --helpfor info on commands - If dependencies aren't needed in production ->
yarn add <package-name> --dev
- Keep imports inline unless there are a lot from the same directory
- Separate package imports, local imports, and asset imports
- Export files respectively in the index.js of each sub-directory (e.g.
app/screens/index.js)
Run npm run lint and fix any lint errors before pushing any code
Make sure eslint is installed: eslint --version
- Install the eslint VS Code extension
- Add the following line to your VS Code settings (
srvice-api/.vscode/settings.json):"eslint.options": { "configFile": "<Path to .eslintrc.js>" }
- Open your VS Code settings (
Cmd + ,/Ctrl + ,) - Click on srvice-api folder settings
- Select the Extensions drop-down menu in the left side-bar of the Settings page
- Make sure the
Eslint: Enablecheckbox is selected -
Cmd + Shift + P / Ctrl + Shift + P->Reload->Developer: Reload Window
- Open Preferences (
Cmd + ,) - Search for "eslint" (Languages & Frameworks > JavaScript > Code Quality Tools > ESLint)
- Select "Manual ESLint configuration"
- Make sure Node Interpreter isn't empty
- Set "ESLint package" to
<path of srvice-api/node_modules/eslint> - Set "Configuration file" to
<path to srvice-api/.eslintrc.js>