Skip to content

ESLint

This page assumes you are using ESLint with TypeScript.

Install

pnpm i -D @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier eslint

Style Guide

{
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking"
        "prettier"
    ],
    "plugins": ["@typescript-eslint"],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": ["./tsconfig.json"]
    },
    "rules": {
        // https://github.com/xojs/eslint-config-xo-typescript/issues/48#issuecomment-1000089183
        "@typescript-eslint/naming-convention": [
            "error",
            {
                "selector": [
                    "variable",
                    "function",
                    "objectLiteralProperty",
                    "objectLiteralMethod"
                ],
                "types": ["function"],
                "format": ["StrictPascalCase", "strictCamelCase"]
            }
        ]
    }
}

Notes

  • "prettier" needs to be the last plugin in the "extends" array

References


Last update: August 12, 2023
Created: May 27, 2023