Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wobsoriano/0cb17a77acbe99d985269f684c352074 to your computer and use it in GitHub Desktop.
Save wobsoriano/0cb17a77acbe99d985269f684c352074 to your computer and use it in GitHub Desktop.
AdonisJS ESLint, Prettier & Airbnb Setup

AdonisJs VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-plugin-html eslint-config-node
npx install-peerdeps --dev eslint-config-airbnb

3. Create .prettierrc for any prettier rules (semicolons, quotes, etc)

{
  "singleQuote": true,
  "useTabs": true
}

4. Create .eslintrc file

{
  "extends": ["airbnb", "prettier", "plugin:node/recommended"],
  "plugins": ["prettier", "html"],
  "settings": {
    "html/html-extensions": ["edge"],
    "html/report-bad-indent": "warn",
  },
  "rules": {
    "prettier/prettier": "error",
    "no-unused-vars": "warn",
    "no-console": "off",
    "func-names": "off",
    "no-process-exit": "off",
    "object-shorthand": "off",
    "class-methods-use-this": "off",
    "no-empty-function": "warn"
  },
  "globals": {
    "use": true
  }
}

5. VS Code Settings

// Auto-save configs
"editor.formatOnSave": true,
// tell the ESLint plugin to run on save
"eslint.autoFixOnSave": true,

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment