2025-08-27 10:54:05 +09:00
|
|
|
/* eslint-env node */
|
|
|
|
|
import process from "node:process";
|
2025-12-12 11:02:59 +09:00
|
|
|
|
2025-08-22 17:02:49 +09:00
|
|
|
import js from "@eslint/js";
|
2025-12-12 11:02:59 +09:00
|
|
|
import nextPlugin from "@next/eslint-plugin-next";
|
|
|
|
|
import reactHooks from "eslint-plugin-react-hooks";
|
2025-08-22 17:02:49 +09:00
|
|
|
import tseslint from "typescript-eslint";
|
|
|
|
|
import prettier from "eslint-plugin-prettier";
|
2025-08-23 17:24:37 +09:00
|
|
|
import globals from "globals";
|
2025-08-22 17:02:49 +09:00
|
|
|
|
|
|
|
|
export default [
|
|
|
|
|
// Global ignores
|
|
|
|
|
{
|
|
|
|
|
ignores: [
|
|
|
|
|
"**/node_modules/**",
|
|
|
|
|
"**/dist/**",
|
|
|
|
|
"**/.next/**",
|
|
|
|
|
"**/build/**",
|
|
|
|
|
"**/coverage/**",
|
|
|
|
|
"**/next-env.d.ts",
|
2025-12-10 16:08:34 +09:00
|
|
|
"**/prisma/**",
|
2025-08-22 17:02:49 +09:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Base JS recommendations
|
2025-08-22 17:02:49 +09:00
|
|
|
js.configs.recommended,
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Prettier integration
|
2025-08-22 17:02:49 +09:00
|
|
|
{
|
|
|
|
|
plugins: { prettier },
|
2025-12-10 13:59:41 +09:00
|
|
|
rules: { "prettier/prettier": "warn" },
|
2025-08-22 17:02:49 +09:00
|
|
|
},
|
|
|
|
|
|
2025-12-12 11:47:17 +09:00
|
|
|
// TypeScript recommended rules (fast, no type info)
|
|
|
|
|
...tseslint.configs.recommended.map((config) => ({
|
2025-08-22 17:02:49 +09:00
|
|
|
...config,
|
|
|
|
|
files: ["**/*.ts", "**/*.tsx"],
|
2025-08-23 17:24:37 +09:00
|
|
|
languageOptions: {
|
|
|
|
|
...(config.languageOptions || {}),
|
2025-12-12 11:47:17 +09:00
|
|
|
// Keep config simple: allow both environments; app-specific blocks can tighten later
|
|
|
|
|
globals: { ...globals.browser, ...globals.node },
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
|
|
|
|
|
// TypeScript type-aware rules only where we really want them (backend + shared packages)
|
|
|
|
|
...tseslint.configs.recommendedTypeChecked.map((config) => ({
|
|
|
|
|
...config,
|
|
|
|
|
files: ["apps/bff/**/*.ts", "packages/**/*.ts"],
|
|
|
|
|
languageOptions: {
|
|
|
|
|
...(config.languageOptions || {}),
|
|
|
|
|
parserOptions: {
|
|
|
|
|
...((config.languageOptions && config.languageOptions.parserOptions) || {}),
|
|
|
|
|
projectService: true,
|
|
|
|
|
tsconfigRootDir: process.cwd(),
|
|
|
|
|
},
|
2025-12-10 13:59:41 +09:00
|
|
|
globals: { ...globals.node },
|
2025-08-23 17:24:37 +09:00
|
|
|
},
|
2025-08-22 17:02:49 +09:00
|
|
|
})),
|
2025-12-10 13:59:41 +09:00
|
|
|
|
|
|
|
|
// Backend & domain packages
|
2025-08-22 17:02:49 +09:00
|
|
|
{
|
2025-12-10 13:59:41 +09:00
|
|
|
files: ["apps/bff/**/*.ts", "packages/domain/**/*.ts"],
|
2025-08-22 17:02:49 +09:00
|
|
|
languageOptions: {
|
|
|
|
|
parserOptions: {
|
|
|
|
|
projectService: true,
|
|
|
|
|
tsconfigRootDir: process.cwd(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
"@typescript-eslint/consistent-type-imports": "error",
|
2025-12-10 13:59:41 +09:00
|
|
|
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
2025-08-22 17:02:49 +09:00
|
|
|
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Strict rules for shared packages
|
2025-08-22 17:02:49 +09:00
|
|
|
{
|
2025-12-10 13:59:41 +09:00
|
|
|
files: ["packages/**/*.ts"],
|
2025-08-22 17:02:49 +09:00
|
|
|
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",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-12 11:02:59 +09:00
|
|
|
// Portal (Next.js) rules (flat-config friendly)
|
|
|
|
|
{
|
|
|
|
|
...nextPlugin.configs["core-web-vitals"],
|
2025-12-10 13:59:41 +09:00
|
|
|
files: ["apps/portal/**/*.{js,jsx,ts,tsx}"],
|
2025-12-12 11:02:59 +09:00
|
|
|
},
|
|
|
|
|
{
|
2025-12-12 11:47:17 +09:00
|
|
|
// Keep this minimal (defaults-first): only the two classic hook rules.
|
2025-12-12 11:02:59 +09:00
|
|
|
files: ["apps/portal/**/*.{jsx,tsx}"],
|
2025-12-12 11:47:17 +09:00
|
|
|
plugins: { "react-hooks": reactHooks },
|
|
|
|
|
rules: {
|
|
|
|
|
"react-hooks/rules-of-hooks": "error",
|
|
|
|
|
"react-hooks/exhaustive-deps": "warn",
|
|
|
|
|
},
|
2025-12-12 11:02:59 +09:00
|
|
|
},
|
2025-08-22 17:02:49 +09:00
|
|
|
|
2025-12-12 11:47:17 +09:00
|
|
|
// Portal overrides
|
2025-08-22 17:02:49 +09:00
|
|
|
{
|
|
|
|
|
files: ["apps/portal/**/*.{ts,tsx}"],
|
|
|
|
|
languageOptions: {
|
2025-12-12 11:02:59 +09:00
|
|
|
globals: { ...globals.browser, ...globals.node },
|
2025-08-22 17:02:49 +09:00
|
|
|
},
|
2025-08-23 17:24:37 +09:00
|
|
|
rules: {
|
2025-12-12 11:47:17 +09:00
|
|
|
"@typescript-eslint/no-unused-vars": [
|
|
|
|
|
"error",
|
|
|
|
|
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
|
|
|
|
],
|
2025-08-23 17:24:37 +09:00
|
|
|
"@next/next/no-html-link-for-pages": "off",
|
|
|
|
|
},
|
2025-08-22 17:02:49 +09:00
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Prevent hard navigation in authenticated pages
|
2025-09-11 14:23:33 +09:00
|
|
|
{
|
2025-09-18 16:39:57 +09:00
|
|
|
files: ["apps/portal/src/app/(authenticated)/**/*.{ts,tsx}"],
|
2025-09-11 14:23:33 +09:00
|
|
|
rules: {
|
|
|
|
|
"no-restricted-syntax": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
2025-09-17 18:43:43 +09:00
|
|
|
selector: "MemberExpression[object.name='window'][property.name='location']",
|
2025-12-10 13:59:41 +09:00
|
|
|
message: "Use next/link or useRouter for navigation.",
|
2025-09-11 14:23:33 +09:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-12-10 13:59:41 +09:00
|
|
|
|
|
|
|
|
// Exceptions for specific files
|
2025-09-11 14:23:33 +09:00
|
|
|
{
|
2025-09-18 16:39:57 +09:00
|
|
|
files: ["apps/portal/src/app/(authenticated)/layout.tsx"],
|
2025-12-10 13:59:41 +09:00
|
|
|
rules: { "no-restricted-imports": "off" },
|
2025-09-11 14:23:33 +09:00
|
|
|
},
|
|
|
|
|
{
|
2025-09-18 16:39:57 +09:00
|
|
|
files: ["apps/portal/src/app/(authenticated)/billing/invoices/[id]/page.tsx"],
|
2025-12-10 13:59:41 +09:00
|
|
|
rules: { "no-restricted-syntax": "off" },
|
2025-09-11 14:23:33 +09:00
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Enforce domain imports architecture
|
2025-09-17 18:43:43 +09:00
|
|
|
{
|
2025-10-03 14:26:55 +09:00
|
|
|
files: ["apps/portal/src/**/*.{ts,tsx}", "apps/bff/src/**/*.ts"],
|
2025-09-17 18:43:43 +09:00
|
|
|
rules: {
|
|
|
|
|
"no-restricted-imports": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
patterns: [
|
2025-10-03 14:26:55 +09:00
|
|
|
{
|
2025-10-03 17:33:39 +09:00
|
|
|
group: ["@customer-portal/domain/**/src/**"],
|
2025-12-10 13:59:41 +09:00
|
|
|
message: "Import from @customer-portal/domain/<module> instead of internals.",
|
2025-09-17 18:43:43 +09:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
2025-08-22 17:02:49 +09:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// BFF strict type safety
|
2025-08-22 17:02:49 +09:00
|
|
|
{
|
|
|
|
|
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",
|
2025-10-03 14:26:55 +09:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-10 13:59:41 +09:00
|
|
|
// Node globals for config files
|
2025-10-03 14:26:55 +09:00
|
|
|
{
|
2025-12-10 13:59:41 +09:00
|
|
|
files: ["*.config.mjs", "apps/portal/next.config.mjs"],
|
|
|
|
|
languageOptions: {
|
|
|
|
|
globals: { ...globals.node },
|
2025-08-22 17:02:49 +09:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|