Created
October 9, 2024 10:41
-
-
Save bossever/871730339ab549e5784eb696cd288228 to your computer and use it in GitHub Desktop.
ESLint config for a Next.js project, including import ordering with @ aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @type {import("eslint").Linter.Config} */ | |
| const config = { | |
| parser: "@typescript-eslint/parser", | |
| parserOptions: { | |
| project: true, | |
| }, | |
| plugins: ["@typescript-eslint", "react", "prettier", "import"], | |
| extends: [ | |
| "next/core-web-vitals", | |
| "plugin:@typescript-eslint/recommended-type-checked", | |
| "plugin:@typescript-eslint/stylistic-type-checked", | |
| ], | |
| rules: { | |
| "@typescript-eslint/array-type": "off", | |
| "@typescript-eslint/consistent-type-definitions": "off", | |
| "@typescript-eslint/consistent-type-imports": [ | |
| "warn", | |
| { | |
| prefer: "type-imports", | |
| fixStyle: "separate-type-imports", | |
| }, | |
| ], | |
| "@typescript-eslint/no-unused-vars": [ | |
| "warn", | |
| { | |
| args: "all", | |
| argsIgnorePattern: "^_", | |
| varsIgnorePattern: "^_", | |
| caughtErrorsIgnorePattern: "^_", | |
| }, | |
| ], | |
| "@typescript-eslint/require-await": "off", | |
| "@typescript-eslint/no-misused-promises": [ | |
| "error", | |
| { | |
| checksVoidReturn: { | |
| attributes: false, | |
| }, | |
| }, | |
| ], | |
| "import/resolver": { | |
| typescript: { | |
| project: "./tsconfig.json", | |
| }, | |
| }, | |
| "import/order": [ | |
| "error", | |
| { | |
| pathGroups: [ | |
| { | |
| pattern: "@/**", | |
| group: "external", | |
| position: "after", | |
| }, | |
| ], | |
| groups: [ | |
| "builtin", | |
| "external", | |
| "internal", | |
| ["parent", "sibling"], | |
| "index", | |
| "object", | |
| "type", | |
| ], | |
| alphabetize: { | |
| order: "asc", | |
| caseInsensitive: true, | |
| }, | |
| "newlines-between": "always", | |
| warnOnUnassignedImports: false, | |
| }, | |
| ], | |
| "@typescript-eslint/naming-convention": [ | |
| "error", | |
| { | |
| selector: ["parameter", "variable"], | |
| leadingUnderscore: "require", | |
| format: ["camelCase"], | |
| modifiers: ["unused"], | |
| }, | |
| { | |
| selector: ["parameter", "variable"], | |
| leadingUnderscore: "allowDouble", | |
| format: ["camelCase", "PascalCase", "UPPER_CASE"], | |
| }, | |
| ], | |
| }, | |
| }; | |
| module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment