117 lines
3.2 KiB
JavaScript
117 lines
3.2 KiB
JavaScript
import js from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import prettier from "eslint-plugin-prettier";
|
|
import { FlatCompat } from "@eslint/eslintrc";
|
|
import path from "node:path";
|
|
|
|
// Use FlatCompat to consume Next.js' legacy shareable configs under apps/portal
|
|
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 for all files
|
|
js.configs.recommended,
|
|
|
|
// Prettier integration (warn-only)
|
|
{
|
|
plugins: { prettier },
|
|
rules: {
|
|
"prettier/prettier": "warn",
|
|
},
|
|
},
|
|
|
|
// TypeScript (type-checked) for TS files only
|
|
...tseslint.configs.recommendedTypeChecked.map(config => ({
|
|
...config,
|
|
files: ["**/*.ts", "**/*.tsx"],
|
|
})),
|
|
{
|
|
files: ["apps/bff/**/*.ts", "packages/shared/**/*.ts"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
// Enable project service for monorepos without per-invocation project config
|
|
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"] }],
|
|
},
|
|
},
|
|
|
|
// Enforce consistent strict rules across shared as well
|
|
{
|
|
files: ["packages/shared/**/*.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: apply Next's recommended config; TS rules only on TS files
|
|
...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}"] })),
|
|
|
|
// Ensure type-aware rules in portal have parser services
|
|
{
|
|
files: ["apps/portal/**/*.{ts,tsx}"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
projectService: true,
|
|
tsconfigRootDir: process.cwd(),
|
|
},
|
|
},
|
|
},
|
|
|
|
// Node globals for Next config file
|
|
{
|
|
files: ["apps/portal/next.config.mjs"],
|
|
languageOptions: {
|
|
globals: {
|
|
process: "readonly",
|
|
module: "readonly",
|
|
__dirname: "readonly",
|
|
require: "readonly",
|
|
},
|
|
},
|
|
},
|
|
|
|
// BFF: strict rules enforced
|
|
{
|
|
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",
|
|
},
|
|
},
|
|
];
|