Skip to content

Instantly share code, notes, and snippets.

@parollon
Created May 27, 2025 08:21
Show Gist options
  • Select an option

  • Save parollon/30dbb23ad9dd0809210bca23082c68eb to your computer and use it in GitHub Desktop.

Select an option

Save parollon/30dbb23ad9dd0809210bca23082c68eb to your computer and use it in GitHub Desktop.
ESLint-Prettier.md

Eslint + Prettier + Ionic/Angular

npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

npm install --save-dev @ionic/eslint-config

ESLint

.eslintrc.json

{
  "root": true,
  "ignorePatterns": ["projects/**/*"],
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "plugins": ["@typescript-eslint", "prettier"],
  "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
  "rules": {
    "prettier/prettier": "error",
    "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
  },
  "overrides": [
    {
      "files": ["*.ts"],
      "parserOptions": {
        "project": ["tsconfig.json"],
        "createDefaultProgram": true
      },
      "extends": ["plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates"],
      "rules": {
        "@angular-eslint/component-class-suffix": [
          "error",
          {
            "suffixes": ["Page", "Component"]
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "app",
            "style": "kebab-case"
          }
        ],
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "app",
            "style": "camelCase"
          }
        ],
        "camelcase": "warn"
      }
    },
    {
      "files": ["*.html"],
      "extends": ["plugin:@angular-eslint/template/recommended"],
      "rules": {}
    }
  ]
}

Prettier

.prettierrc.json

{
  "printWidth": 120,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "quoteProps": "as-needed",
  "jsxSingleQuote": false,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "bracketSameLine": false,
  "arrowParens": "always",
  "overrides": [
    {
      "files": ["*.java"],
      "options": {
        "printWidth": 140,
        "tabWidth": 4,
        "useTabs": false,
        "trailingComma": "none"
      }
    }
  ]
}

.prettierignore

build
coverage
ios
android
www
node_modules


VSCode

.vscode/extensions.json

{
  "recommendations": [
    "ionic.ionic",
    "dbaeumer.vscode-eslint" 
  ]
}

.vscode/settings.json

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.organizeImports": true
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment