website refactor
This commit is contained in:
48
apps/website/eslint-rules/no-console.js
Normal file
48
apps/website/eslint-rules/no-console.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file no-console.js
|
||||
* Forbid console usage in website code.
|
||||
*
|
||||
* Use ConsoleLogger instead:
|
||||
* import { logger } from '@/lib/infrastructure/logging/logger'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Forbid console.* usage (use ConsoleLogger wrapper instead)',
|
||||
category: 'Logging',
|
||||
recommended: true,
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
noConsole:
|
||||
'Do not use console. Use the project logger instead (ConsoleLogger). Import: `logger` from `@/lib/infrastructure/logging/logger`.',
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const filename = context.getFilename();
|
||||
|
||||
// Allow console within the logging infrastructure itself.
|
||||
// (ConsoleLogger implements the console adapter.)
|
||||
if (
|
||||
filename.includes('/lib/infrastructure/logging/') ||
|
||||
filename.includes('/lib/infrastructure/EnhancedErrorReporter') ||
|
||||
filename.includes('/lib/infrastructure/GlobalErrorHandler') ||
|
||||
filename.includes('/lib/infrastructure/ErrorReplay') ||
|
||||
filename.includes('/eslint-rules/')
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
// console.log / console.error / console.warn / console.info / console.debug / console.group* ...
|
||||
if (node.object && node.object.type === 'Identifier' && node.object.name === 'console') {
|
||||
context.report({ node, messageId: 'noConsole' });
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user