Assist_Design/eslint.config.mjs
barsa 89b495db1a Update ESLint configuration, package dependencies, and improve Prisma integration
- Refactored ESLint configuration for better clarity and organization, including updates to TypeScript rules and Next.js app settings.
- Upgraded package dependencies, including Next.js to version 16.0.8 and Prisma to version 7.1.0, enhancing performance and compatibility.
- Modified Dockerfile for BFF to reflect updated Prisma version and optimize build settings.
- Improved Prisma service to utilize PostgreSQL connection pooling with the new PrismaPg adapter, ensuring better database management.
- Cleaned up TypeScript configuration files for consistency and updated module settings to align with ESNext standards.
- Adjusted pre-commit script to streamline security audits and removed unnecessary linting during development.
2025-12-10 13:59:41 +09:00

161 lines
4.2 KiB
JavaScript

/* eslint-env node */
import process from "node:process";
import path from "node:path";
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import prettier from "eslint-plugin-prettier";
import { FlatCompat } from "@eslint/eslintrc";
import globals from "globals";
const compat = new FlatCompat({ baseDirectory: path.resolve("apps/portal") });
export default [
// Global ignores
{
ignores: [
"**/node_modules/**",
"**/dist/**",
"**/.next/**",
"**/build/**",
"**/coverage/**",
"**/next-env.d.ts",
],
},
// Base JS recommendations
js.configs.recommended,
// Prettier integration
{
plugins: { prettier },
rules: { "prettier/prettier": "warn" },
},
// TypeScript type-checked rules for all TS files
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
...(config.languageOptions || {}),
globals: { ...globals.node },
},
})),
// Backend & domain packages
{
files: ["apps/bff/**/*.ts", "packages/domain/**/*.ts"],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: process.cwd(),
},
},
rules: {
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"no-console": ["warn", { allow: ["warn", "error"] }],
},
},
// Strict rules for shared packages
{
files: ["packages/**/*.ts"],
rules: {
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
},
},
// Next.js app config
...compat.extends("next/core-web-vitals").map((config) => ({
...config,
files: ["apps/portal/**/*.{js,jsx,ts,tsx}"],
})),
...compat.extends("next/typescript").map((config) => ({
...config,
files: ["apps/portal/**/*.{ts,tsx}"],
})),
// Portal type-aware rules
{
files: ["apps/portal/**/*.{ts,tsx}"],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: process.cwd(),
},
},
rules: {
"@next/next/no-html-link-for-pages": "off",
},
},
// Prevent hard navigation in authenticated pages
{
files: ["apps/portal/src/app/(authenticated)/**/*.{ts,tsx}"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: "MemberExpression[object.name='window'][property.name='location']",
message: "Use next/link or useRouter for navigation.",
},
],
},
},
// Exceptions for specific files
{
files: ["apps/portal/src/app/(authenticated)/layout.tsx"],
rules: { "no-restricted-imports": "off" },
},
{
files: ["apps/portal/src/app/(authenticated)/billing/invoices/[id]/page.tsx"],
rules: { "no-restricted-syntax": "off" },
},
// Enforce domain imports architecture
{
files: ["apps/portal/src/**/*.{ts,tsx}", "apps/bff/src/**/*.ts"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@customer-portal/domain/**/src/**"],
message: "Import from @customer-portal/domain/<module> instead of internals.",
},
],
},
],
},
},
// BFF strict type safety
{
files: ["apps/bff/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/no-floating-promises": "error",
},
},
// Node globals for config files
{
files: ["*.config.mjs", "apps/portal/next.config.mjs"],
languageOptions: {
globals: { ...globals.node },
},
},
];