Skip to content

Instantly share code, notes, and snippets.

@bossever
Created October 9, 2024 10:41
Show Gist options
  • Select an option

  • Save bossever/871730339ab549e5784eb696cd288228 to your computer and use it in GitHub Desktop.

Select an option

Save bossever/871730339ab549e5784eb696cd288228 to your computer and use it in GitHub Desktop.
ESLint config for a Next.js project, including import ordering with @ aliases
/** @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