11import * as AST from '@eslint-react/ast' ;
22import { ESLintUtils , AST_NODE_TYPES } from '@typescript-eslint/utils' ;
3+ import * as VAR from '@eslint-react/var' ;
34import { nullThrows , NullThrowsReasons } from '@typescript-eslint/utils/eslint-utils' ;
45
56// package.json
@@ -42,7 +43,40 @@ var avoid_multiline_template_expression_default = createRule({
4243 } ,
4344 defaultOptions : [ ]
4445} ) ;
45- var RULE_NAME2 = "prefer-eqeq-nullish-comparison" ;
46+ var RULE_NAME2 = "no-shadowing-underscore" ;
47+ var RULE_FEATURES2 = [
48+ "CHK"
49+ ] ;
50+ var no_shadowing_underscore_default = createRule ( {
51+ meta : {
52+ type : "problem" ,
53+ docs : {
54+ description : "disallow multiline template expressions" ,
55+ [ Symbol . for ( "rule_features" ) ] : RULE_FEATURES2
56+ } ,
57+ messages : {
58+ noShadowingUnderscore : "In this codebase, '_' is used to represent the undefined. Avoid shadowing it."
59+ } ,
60+ schema : [ ]
61+ } ,
62+ name : RULE_NAME2 ,
63+ create ( context ) {
64+ return {
65+ "Identifier[name='_']" ( node ) {
66+ const initialScope = context . sourceCode . getScope ( node ) ;
67+ const isFromImport = VAR . isInitializedFromSource ( "_" , "@eslint-react/eff" , initialScope ) ;
68+ if ( ! isFromImport ) {
69+ context . report ( {
70+ messageId : "noShadowingUnderscore" ,
71+ node
72+ } ) ;
73+ }
74+ }
75+ } ;
76+ } ,
77+ defaultOptions : [ ]
78+ } ) ;
79+ var RULE_NAME3 = "prefer-eqeq-nullish-comparison" ;
4680var prefer_eqeq_nullish_comparison_default = createRule ( {
4781 meta : {
4882 type : "suggestion" ,
@@ -57,7 +91,7 @@ var prefer_eqeq_nullish_comparison_default = createRule({
5791 } ,
5892 schema : [ ]
5993 } ,
60- name : RULE_NAME2 ,
94+ name : RULE_NAME3 ,
6195 create ( context ) {
6296 return {
6397 BinaryExpression ( node ) {
@@ -119,6 +153,7 @@ var index_default = {
119153 version
120154 } ,
121155 rules : {
156+ "no-shadowing-underscore" : no_shadowing_underscore_default ,
122157 "avoid-multiline-template-expression" : avoid_multiline_template_expression_default ,
123158 "prefer-eqeq-nullish-comparison" : prefer_eqeq_nullish_comparison_default
124159 }
0 commit comments