@@ -63,20 +63,21 @@ var avoid_multiline_template_expression_default = createRule({
63
63
schema : [ ]
64
64
} ,
65
65
name : RULE_NAME ,
66
- create ( context ) {
67
- return {
68
- TemplateLiteral : ( node ) => {
69
- if ( AST . isMultiLine ( node ) ) {
70
- context . report ( {
71
- messageId : "avoidMultilineTemplateExpression" ,
72
- node
73
- } ) ;
74
- }
75
- }
76
- } ;
77
- } ,
66
+ create,
78
67
defaultOptions : [ ]
79
68
} ) ;
69
+ function create ( context ) {
70
+ return {
71
+ TemplateLiteral : ( node ) => {
72
+ if ( AST . isMultiLine ( node ) ) {
73
+ context . report ( {
74
+ messageId : "avoidMultilineTemplateExpression" ,
75
+ node
76
+ } ) ;
77
+ }
78
+ }
79
+ } ;
80
+ }
80
81
81
82
// src/rules/no-shadow-underscore.ts
82
83
var RULE_NAME2 = "no-shadow-underscore" ;
@@ -94,22 +95,23 @@ var no_shadow_underscore_default = createRule({
94
95
schema : [ ]
95
96
} ,
96
97
name : RULE_NAME2 ,
97
- create ( context ) {
98
- return {
99
- "Identifier[name='_']" ( node ) {
100
- const initialScope = context . sourceCode . getScope ( node ) ;
101
- const isFromImport = isInitializedFromSource ( "_" , "@eslint-react/eff" , initialScope ) ;
102
- if ( ! isFromImport ) {
103
- context . report ( {
104
- messageId : "noShadowUnderscore" ,
105
- node
106
- } ) ;
107
- }
108
- }
109
- } ;
110
- } ,
98
+ create : create2 ,
111
99
defaultOptions : [ ]
112
100
} ) ;
101
+ function create2 ( context ) {
102
+ return {
103
+ "Identifier[name='_']" ( node ) {
104
+ const initialScope = context . sourceCode . getScope ( node ) ;
105
+ const isFromImport = isInitializedFromSource ( "_" , "@eslint-react/eff" , initialScope ) ;
106
+ if ( ! isFromImport ) {
107
+ context . report ( {
108
+ messageId : "noShadowUnderscore" ,
109
+ node
110
+ } ) ;
111
+ }
112
+ }
113
+ } ;
114
+ }
113
115
var RULE_NAME3 = "prefer-eqeq-nullish-comparison" ;
114
116
var prefer_eqeq_nullish_comparison_default = createRule ( {
115
117
meta : {
@@ -126,59 +128,60 @@ var prefer_eqeq_nullish_comparison_default = createRule({
126
128
schema : [ ]
127
129
} ,
128
130
name : RULE_NAME3 ,
129
- create ( context ) {
130
- return {
131
- BinaryExpression ( node ) {
132
- if ( node . operator === "===" || node . operator === "!==" ) {
133
- const offendingChild = [ node . left , node . right ] . find (
134
- ( child ) => child . type === AST_NODE_TYPES . Identifier && child . name === "undefined" || child . type === AST_NODE_TYPES . Literal && child . raw === "null"
135
- ) ;
136
- if ( offendingChild == null ) {
137
- return ;
138
- }
139
- const operatorToken = nullThrows (
140
- context . sourceCode . getFirstTokenBetween (
141
- node . left ,
142
- node . right ,
143
- ( token ) => token . value === node . operator
144
- ) ,
145
- NullThrowsReasons . MissingToken ( node . operator , "binary expression" )
146
- ) ;
147
- const wasLeft = node . left === offendingChild ;
148
- const nullishKind = offendingChild . type === AST_NODE_TYPES . Identifier ? "undefined" : "null" ;
149
- const looseOperator = node . operator === "===" ? "==" : "!=" ;
150
- context . report ( {
151
- messageId : "unexpectedComparison" ,
152
- data : {
153
- nullishKind,
154
- strictOperator : node . operator
155
- } ,
156
- loc : wasLeft ? {
157
- end : operatorToken . loc . end ,
158
- start : node . left . loc . start
159
- } : {
160
- end : node . right . loc . end ,
161
- start : operatorToken . loc . start
162
- } ,
163
- suggest : [
164
- {
165
- messageId : "useLooseComparisonSuggestion" ,
166
- data : {
167
- looseOperator
168
- } ,
169
- fix : ( fixer ) => [
170
- fixer . replaceText ( offendingChild , "null" ) ,
171
- fixer . replaceText ( operatorToken , looseOperator )
172
- ]
173
- }
174
- ]
175
- } ) ;
176
- }
177
- }
178
- } ;
179
- } ,
131
+ create : create3 ,
180
132
defaultOptions : [ ]
181
133
} ) ;
134
+ function create3 ( context ) {
135
+ return {
136
+ BinaryExpression ( node ) {
137
+ if ( node . operator === "===" || node . operator === "!==" ) {
138
+ const offendingChild = [ node . left , node . right ] . find (
139
+ ( child ) => child . type === AST_NODE_TYPES . Identifier && child . name === "undefined" || child . type === AST_NODE_TYPES . Literal && child . raw === "null"
140
+ ) ;
141
+ if ( offendingChild == null ) {
142
+ return ;
143
+ }
144
+ const operatorToken = nullThrows (
145
+ context . sourceCode . getFirstTokenBetween (
146
+ node . left ,
147
+ node . right ,
148
+ ( token ) => token . value === node . operator
149
+ ) ,
150
+ NullThrowsReasons . MissingToken ( node . operator , "binary expression" )
151
+ ) ;
152
+ const wasLeft = node . left === offendingChild ;
153
+ const nullishKind = offendingChild . type === AST_NODE_TYPES . Identifier ? "undefined" : "null" ;
154
+ const looseOperator = node . operator === "===" ? "==" : "!=" ;
155
+ context . report ( {
156
+ messageId : "unexpectedComparison" ,
157
+ data : {
158
+ nullishKind,
159
+ strictOperator : node . operator
160
+ } ,
161
+ loc : wasLeft ? {
162
+ end : operatorToken . loc . end ,
163
+ start : node . left . loc . start
164
+ } : {
165
+ end : node . right . loc . end ,
166
+ start : operatorToken . loc . start
167
+ } ,
168
+ suggest : [
169
+ {
170
+ messageId : "useLooseComparisonSuggestion" ,
171
+ data : {
172
+ looseOperator
173
+ } ,
174
+ fix : ( fixer ) => [
175
+ fixer . replaceText ( offendingChild , "null" ) ,
176
+ fixer . replaceText ( operatorToken , looseOperator )
177
+ ]
178
+ }
179
+ ]
180
+ } ) ;
181
+ }
182
+ }
183
+ } ;
184
+ }
182
185
183
186
// src/index.ts
184
187
var index_default = {
0 commit comments