Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/eslint-config-airbnb-base/rules/no-console-in-prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow console.log() in production environments',
category: 'Best Practices',
recommended: true,
},
schema: [],
},
create(context) {
return {
CallExpression(node) {
if (
node.callee.object &&
node.callee.object.name === 'console' &&
node.callee.property &&
node.callee.property.name === 'log'
) {
const isProduction = process.env.NODE_ENV === 'production';

context.report({
node,
message: isProduction
? '❌ console.log() is not allowed in production. Use a proper logger instead.'
: '⚠️ Consider removing console.log() before pushing to production.',
});
}
},
};
},
};