feat: Cấu hình ESLint flat config mới, thêm jsconfig.json, và sắp xếp lại các import tự động.
This commit is contained in:
145
packages/config/eslint-config/eslint.config.js
Normal file
145
packages/config/eslint-config/eslint.config.js
Normal file
@@ -0,0 +1,145 @@
|
||||
// EN: ESLint v9 Flat Config for GoodGo Services
|
||||
// VI: ESLint v9 Flat Config cho GoodGo Services
|
||||
import tseslint from '@typescript-eslint/eslint-plugin';
|
||||
import tsparser from '@typescript-eslint/parser';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
|
||||
export default [
|
||||
{
|
||||
// EN: Ignore patterns
|
||||
// VI: Các pattern bỏ qua
|
||||
ignores: [
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
'**/build/**',
|
||||
'**/.next/**',
|
||||
'**/coverage/**',
|
||||
'**/.turbo/**',
|
||||
'**/prisma/migrations/**',
|
||||
'**/_prisma_client/**',
|
||||
],
|
||||
},
|
||||
{
|
||||
// EN: Configuration for test files (no project requirement)
|
||||
// VI: Cấu hình cho test files (không yêu cầu project)
|
||||
files: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**/*.ts'],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
sourceType: 'module',
|
||||
// EN: Don't require project for test files
|
||||
// VI: Không yêu cầu project cho test files
|
||||
},
|
||||
globals: {
|
||||
// Node.js globals
|
||||
console: 'readonly',
|
||||
process: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
module: 'readonly',
|
||||
require: 'readonly',
|
||||
exports: 'readonly',
|
||||
globalThis: 'readonly',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tseslint,
|
||||
import: importPlugin,
|
||||
},
|
||||
rules: {
|
||||
// EN: Relax rules for test files
|
||||
// VI: Nới lỏng rules cho test files
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'import/order': [
|
||||
'error',
|
||||
{
|
||||
groups: [
|
||||
'builtin',
|
||||
'external',
|
||||
'internal',
|
||||
'parent',
|
||||
'sibling',
|
||||
'index',
|
||||
],
|
||||
'newlines-between': 'always',
|
||||
alphabetize: { order: 'asc' },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// EN: Base configuration for TypeScript files
|
||||
// VI: Cấu hình cơ bản cho TypeScript files
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
languageOptions: {
|
||||
parser: tsparser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
sourceType: 'module',
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
globals: {
|
||||
// Node.js globals
|
||||
console: 'readonly',
|
||||
process: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
module: 'readonly',
|
||||
require: 'readonly',
|
||||
exports: 'readonly',
|
||||
// ES2020 globals
|
||||
globalThis: 'readonly',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tseslint,
|
||||
import: importPlugin,
|
||||
},
|
||||
rules: {
|
||||
// EN: TypeScript rules
|
||||
// VI: TypeScript rules
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{ argsIgnorePattern: '^_' },
|
||||
],
|
||||
|
||||
// EN: Import rules
|
||||
// VI: Import rules
|
||||
'import/order': [
|
||||
'error',
|
||||
{
|
||||
groups: [
|
||||
'builtin',
|
||||
'external',
|
||||
'internal',
|
||||
'parent',
|
||||
'sibling',
|
||||
'index',
|
||||
],
|
||||
'newlines-between': 'always',
|
||||
alphabetize: { order: 'asc' },
|
||||
},
|
||||
],
|
||||
|
||||
// EN: General rules
|
||||
// VI: General rules
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'no-debugger': 'error',
|
||||
'prefer-const': 'error',
|
||||
'no-var': 'error',
|
||||
},
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
alwaysTryTypes: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "@goodgo/eslint-config",
|
||||
"version": "1.0.0",
|
||||
"description": "Shared ESLint configuration",
|
||||
"main": "index.js",
|
||||
"main": "eslint.config.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^8.52.0",
|
||||
"@typescript-eslint/parser": "^8.52.0",
|
||||
@@ -10,4 +11,4 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.32.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@goodgo/prettier-config",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"description": "Shared Prettier configuration",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@goodgo/tsconfig",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"description": "Shared TypeScript configurations",
|
||||
"main": "base.json",
|
||||
"files": ["base.json", "node.json", "nextjs.json"]
|
||||
|
||||
Reference in New Issue
Block a user