File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ const rule = require('../prefer-strict-equal');
66const ruleTester = new RuleTester ( ) ;
77
88ruleTester . run ( 'prefer-strict-equal' , rule , {
9- valid : [ 'expect(something).toStrictEqual(somethingElse);' ] ,
9+ valid : [
10+ 'expect(something).toStrictEqual(somethingElse);' ,
11+ "a().toEqual('b')" ,
12+ ] ,
1013 invalid : [
1114 {
1215 code : 'expect(something).toEqual(somethingElse);' ,
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ const expectCase = require ( './util' ) . expectCase ;
34const getDocsUrl = require ( './util' ) . getDocsUrl ;
5+ const method = require ( './util' ) . method ;
46
57module . exports = {
68 meta : {
@@ -12,14 +14,19 @@ module.exports = {
1214 create ( context ) {
1315 return {
1416 CallExpression ( node ) {
15- const propertyName = node . callee . property && node . callee . property . name ;
17+ if ( ! expectCase ( node ) ) {
18+ return ;
19+ }
20+
21+ const propertyName = method ( node ) && method ( node ) . name ;
22+
1623 if ( propertyName === 'toEqual' ) {
1724 context . report ( {
1825 fix ( fixer ) {
19- return [ fixer . replaceText ( node . callee . property , 'toStrictEqual' ) ] ;
26+ return [ fixer . replaceText ( method ( node ) , 'toStrictEqual' ) ] ;
2027 } ,
2128 message : 'Use toStrictEqual() instead' ,
22- node : node . callee . property ,
29+ node : method ( node ) ,
2330 } ) ;
2431 }
2532 } ,
You can’t perform that action at this time.
0 commit comments