@@ -20,7 +20,7 @@ module.exports = {
20
20
schema : [ MAP_SCHEMA ] ,
21
21
} ,
22
22
create ( context ) {
23
- function reportDeprecatedTypography ( node , options ) {
23
+ function reportDeprecatedTypography ( node , options , useShortVersion ) {
24
24
try {
25
25
const { dueDate} = context . options [ 0 ] ;
26
26
const dueDateNotice = dueDate ? ` Please fix this issue by ${ dueDate } !` : '' ;
@@ -30,7 +30,8 @@ module.exports = {
30
30
message : `${ msg } ` ,
31
31
fix ( fixer ) {
32
32
if ( options . fix ) {
33
- return fixer . replaceText ( node , options . fix ) ;
33
+ const fix = useShortVersion ? options . fix . substr ( `${ defaultImportName } .` . length ) : options . fix ;
34
+ return fixer . replaceText ( node , fix ) ;
34
35
}
35
36
} ,
36
37
} ) ;
@@ -47,23 +48,23 @@ module.exports = {
47
48
localImportSpecifier = utils . getLocalImportSpecifier ( node , source , defaultImportName ) ;
48
49
}
49
50
50
- function findAndReportDeprecation ( node , possibleDeprecation ) {
51
+ function findAndReportDeprecation ( node , possibleDeprecation , useShortVersion ) {
51
52
const path = `${ defaultImportName } .${ possibleDeprecation } ` ;
52
53
const foundDeprecation = _ . find ( deprecations , { path} ) ;
53
54
if ( foundDeprecation ) {
54
- reportDeprecatedTypography ( node , foundDeprecation ) ;
55
+ reportDeprecatedTypography ( node , foundDeprecation , useShortVersion ) ;
55
56
}
56
57
}
57
58
58
59
function testMemberDeprecation ( node ) {
59
60
if ( node && node . object && node . property && node . object . name === localImportSpecifier ) {
60
- findAndReportDeprecation ( node , node . property . name ) ;
61
+ findAndReportDeprecation ( node , node . property . name , false ) ;
61
62
}
62
63
}
63
64
64
65
function testJSXAttribute ( node ) {
65
66
if ( node && node . name ) {
66
- findAndReportDeprecation ( node , node . name . name ) ;
67
+ findAndReportDeprecation ( node , node . name . name , true ) ;
67
68
}
68
69
}
69
70
0 commit comments