File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
packages/eslint-config-airbnb-base/rules Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ meta : {
3
+ type : 'problem' ,
4
+ docs : {
5
+ description : 'Disallow console.log() in production environments' ,
6
+ category : 'Best Practices' ,
7
+ recommended : true ,
8
+ } ,
9
+ schema : [ ] ,
10
+ } ,
11
+ create ( context ) {
12
+ return {
13
+ CallExpression ( node ) {
14
+ if (
15
+ node . callee . object &&
16
+ node . callee . object . name === 'console' &&
17
+ node . callee . property &&
18
+ node . callee . property . name === 'log'
19
+ ) {
20
+ const isProduction = process . env . NODE_ENV === 'production' ;
21
+
22
+ context . report ( {
23
+ node,
24
+ message : isProduction
25
+ ? '❌ console.log() is not allowed in production. Use a proper logger instead.'
26
+ : '⚠️ Consider removing console.log() before pushing to production.' ,
27
+ } ) ;
28
+ }
29
+ } ,
30
+ } ;
31
+ } ,
32
+ } ;
You can’t perform that action at this time.
0 commit comments