From a90061f9cf673955fafd512484e663c3bceea200 Mon Sep 17 00:00:00 2001 From: huazhuang80-star <295584745+huazhuang80-star@users.noreply.github.com> Date: Mon, 22 Jun 2026 20:21:19 +0800 Subject: [PATCH] chore: warn on console usage in eslint --- .eslintrc.js | 20 +++++++++++++++++++- app/backend/eslint.config.mjs | 9 +++++++++ app/frontend/eslint.config.mjs | 11 +++++++++++ app/mobile/eslint.config.js | 11 +++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index c05e23c0..84ed66e0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,5 +25,23 @@ module.exports = { '@typescript-eslint/no-floating-promises': 'warn', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', + 'no-console': ['warn', { allow: ['warn', 'error'] }], }, -}; \ No newline at end of file + overrides: [ + { + files: [ + '**/*.test.ts', + '**/*.spec.ts', + '**/test/**/*.ts', + '**/tests/**/*.ts', + '**/scripts/**/*.ts', + '**/scripts/**/*.js', + '**/examples/**/*.ts', + '**/examples/**/*.js', + ], + rules: { + 'no-console': 'off', + }, + }, + ], +}; diff --git a/app/backend/eslint.config.mjs b/app/backend/eslint.config.mjs index 2302ed46..40277a9a 100644 --- a/app/backend/eslint.config.mjs +++ b/app/backend/eslint.config.mjs @@ -32,9 +32,17 @@ export default tseslint.config( '@typescript-eslint/no-unsafe-member-access': 'warn', '@typescript-eslint/no-unsafe-return': 'warn', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], + 'no-console': ['warn', { allow: ['warn', 'error'] }], "prettier/prettier": ["error", { endOfLine: "auto" }], }, }, + { + // Dev-only scripts and usage examples intentionally write progress to stdout. + files: ['prisma/seed.ts', 'src/**/examples/**/*.ts', 'scripts/**/*.ts', 'scripts/**/*.js'], + rules: { + 'no-console': 'off', + }, + }, { // Specific configuration for error handling files files: ['src/common/filters/*.ts', 'src/common/interceptors/*.ts'], @@ -56,6 +64,7 @@ export default tseslint.config( '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', '@typescript-eslint/unbound-method': 'off', + 'no-console': 'off', }, } ); diff --git a/app/frontend/eslint.config.mjs b/app/frontend/eslint.config.mjs index 05e726d1..3f2159a1 100644 --- a/app/frontend/eslint.config.mjs +++ b/app/frontend/eslint.config.mjs @@ -5,6 +5,17 @@ import nextTs from "eslint-config-next/typescript"; const eslintConfig = defineConfig([ ...nextVitals, ...nextTs, + { + rules: { + "no-console": ["warn", { allow: ["warn", "error"] }], + }, + }, + { + files: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"], + rules: { + "no-console": "off", + }, + }, // Override default ignores of eslint-config-next. globalIgnores([ // Default ignores of eslint-config-next: diff --git a/app/mobile/eslint.config.js b/app/mobile/eslint.config.js index c90475c4..b4e8c4f1 100644 --- a/app/mobile/eslint.config.js +++ b/app/mobile/eslint.config.js @@ -6,4 +6,15 @@ export default defineConfig([ { ignores: ['dist/**'], }, + { + rules: { + 'no-console': ['warn', { allow: ['warn', 'error'] }], + }, + }, + { + files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'], + rules: { + 'no-console': 'off', + }, + }, ]);