Refactor ESLint configuration and update lint scripts
- Reorganized `eslint.config.mjs` imports for clarity and consistency. - Simplified eslint ignores by standardizing patterns and removing redundant file extensions. - Updated lint scripts in `package.json` to use `eslint` directly, replacing `next lint`.
This commit is contained in:
@@ -1,27 +1,28 @@
|
|||||||
import { dirname } from "path";
|
import { FlatCompat } from '@eslint/eslintrc';
|
||||||
import { fileURLToPath } from "url";
|
import path from 'path';
|
||||||
import { FlatCompat } from "@eslint/eslintrc";
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
const compat = new FlatCompat({
|
const compat = new FlatCompat({
|
||||||
baseDirectory: __dirname,
|
baseDirectory: __dirname,
|
||||||
});
|
});
|
||||||
|
|
||||||
const eslintConfig = [
|
export default [
|
||||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
...compat.extends('next/core-web-vitals'),
|
||||||
|
...compat.extends('next/typescript'),
|
||||||
{
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
"**/node_modules/**",
|
'node_modules/**',
|
||||||
"**/.next/**",
|
'.next/**',
|
||||||
"**/out/**",
|
'out/**',
|
||||||
"**/build/**",
|
'build/**',
|
||||||
"**/dist/**",
|
'dist/**',
|
||||||
"**/coverage/**",
|
'coverage/**',
|
||||||
"**/src/lib/api/generated/**",
|
'src/lib/api/generated/**',
|
||||||
"**/*.gen.ts",
|
'*.gen.ts',
|
||||||
"**/*.gen.tsx",
|
'*.gen.tsx',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -30,15 +31,19 @@ const eslintConfig = [
|
|||||||
// Components/hooks must use useAuth() from AuthContext, not useAuthStore directly
|
// Components/hooks must use useAuth() from AuthContext, not useAuthStore directly
|
||||||
// This ensures testability via DI (E2E mocks, unit test props)
|
// This ensures testability via DI (E2E mocks, unit test props)
|
||||||
// Exception: Non-React contexts (client.ts) use dynamic import + __TEST_AUTH_STORE__ check
|
// Exception: Non-React contexts (client.ts) use dynamic import + __TEST_AUTH_STORE__ check
|
||||||
"no-restricted-imports": ["error", {
|
'no-restricted-imports': [
|
||||||
"patterns": [{
|
'error',
|
||||||
"group": ["**/stores/authStore"],
|
{
|
||||||
"importNames": ["useAuthStore"],
|
patterns: [
|
||||||
"message": "Import useAuth from '@/lib/auth/AuthContext' instead. Direct authStore imports bypass dependency injection and break test mocking."
|
{
|
||||||
}]
|
group: ['**/stores/authStore'],
|
||||||
}]
|
importNames: ['useAuthStore'],
|
||||||
}
|
message:
|
||||||
}
|
"Import useAuth from '@/lib/auth/AuthContext' instead. Direct authStore imports bypass dependency injection and break test mocking.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default eslintConfig;
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "eslint .",
|
||||||
"lint:fix": "next lint --fix",
|
"lint:fix": "eslint --fix .",
|
||||||
"lint:tests": "eslint tests --max-warnings=0",
|
"lint:tests": "eslint tests --max-warnings=0",
|
||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
|
||||||
@@ -61,7 +61,6 @@
|
|||||||
"zustand": "^4.5.7"
|
"zustand": "^4.5.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3",
|
|
||||||
"@hey-api/openapi-ts": "^0.86.11",
|
"@hey-api/openapi-ts": "^0.86.11",
|
||||||
"@next/bundle-analyzer": "^16.0.1",
|
"@next/bundle-analyzer": "^16.0.1",
|
||||||
"@peculiar/webcrypto": "^1.5.0",
|
"@peculiar/webcrypto": "^1.5.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user