Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { FlatCompat } from "@eslint/eslintrc";
import ts from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import nextCoreWebVitals from "eslint-config-next/core-web-vitals";
import nextTypescript from "eslint-config-next/typescript";
import tseslint from "typescript-eslint";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
// Base config for all files
{
languageOptions: {
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: __dirname,
},
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
},

// eslint-config-next 16 ships native flat configs, so they are imported directly.
// The old FlatCompat bridge (@eslint/eslintrc) cannot convert them ("Converting circular
// structure to JSON") and ESLint 10 dropped eslintrc support from core.
const eslintConfig = tseslint.config(
// Configure global ignores (replaces .eslintignore)
{
ignores: [
Expand All @@ -37,19 +23,45 @@ const eslintConfig = [
],
},

// Base config for all files
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
},

// Extend configurations
...compat.extends(
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"next/core-web-vitals",
"next/typescript"
),
...nextCoreWebVitals,
...nextTypescript,

// Files tsconfig.json excludes have no type information, so type-aware rules cannot run on them.
{
files: [
"scripts/**/*.{ts,tsx}",
"tests/**/*.{ts,tsx}",
"src/workers/**/*.ts",
"src/app/(app)/(ai)/**/*.{ts,tsx}",
"src/app/(app)/(demo)/examples/**/*.{ts,tsx}",
"*.config.ts",
"*.config.*.ts",
],
extends: [tseslint.configs.disableTypeChecked],
},

// TypeScript files configuration
{
files: ["**/*.{ts,tsx}"],
ignores: [
"scripts/**",
"tests/**",
"src/workers/**",
"src/app/(app)/(ai)/**",
"src/app/(app)/(demo)/examples/**",
"*.config.ts",
"*.config.*.ts",
],
extends: [tseslint.configs.recommendedTypeChecked, tseslint.configs.stylisticTypeChecked],
languageOptions: {
parser: tsParser,
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: __dirname,
Expand All @@ -60,11 +72,7 @@ const eslintConfig = [
},
},
},
plugins: {
"@typescript-eslint": ts,
},
rules: {
...ts.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": [
"warn",
{
Expand All @@ -90,7 +98,7 @@ const eslintConfig = [
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
},
},
];
}
);

export default eslintConfig;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"audit:lh:loop": "bun run scripts/lighthouse/loop.ts",
"lint": "npm run lint:biome && npm run lint:eslint && npm run lint:prettier",
"lint:biome": "biome lint .",
"lint:eslint": "next lint",
"lint:eslint": "eslint .",
"lint:prettier": "prettier --check \"**/*.{ts,tsx,md,mdx,json}\"",
"lint:fix": "npm run lint:fix:biome && npm run lint:fix:eslint && npm run lint:fix:prettier",
"lint:fix:biome": "biome check --write .",
"lint:fix:eslint": "next lint --fix",
"lint:fix:eslint": "eslint . --fix",
"lint:fix:prettier": "prettier --write \"**/*.{ts,tsx,md,mdx,json}\"",
"start": "next start",
"pull": "node --experimental-strip-types ./scripts/sync-upstream.ts",
Expand Down Expand Up @@ -169,7 +169,6 @@
},
"devDependencies": {
"@biomejs/biome": "2.5.13",
"@eslint/eslintrc": "^3.3.7",
"@mdx-js/loader": "3.1.1",
"@mdx-js/mdx": "^3.1.1",
"@next/bundle-analyzer": "16.3.5",
Expand Down Expand Up @@ -209,6 +208,7 @@
"remark-mdx-frontmatter": "^5.2.0",
"tailwindcss": "3.4.17",
"typescript": "^5",
"typescript-eslint": "8.70.0",
"vite-tsconfig-paths": "^6.1.1",
"vitest": "^4.1.10"
},
Expand Down
Loading
Loading