File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,10 @@ module.exports = {
31
31
try {
32
32
const origin = context . options [ 0 ] . origin ;
33
33
const destination = context . options [ 0 ] . destination ;
34
- const msg = `Do not import directly from '${ origin } '. Please use '${ destination } ' (autofix available).` ;
34
+ const message = `Do not import directly from '${ origin } '. Please use '${ destination } ' (autofix available).` ;
35
35
context . report ( {
36
36
node,
37
- message : ` ${ msg } ` ,
37
+ message,
38
38
fix ( fixer ) {
39
39
if ( node && destination ) {
40
40
return fixer . replaceText ( node . source , `'${ destination } '` ) ;
@@ -46,7 +46,7 @@ module.exports = {
46
46
}
47
47
}
48
48
49
- function checkImportDeclaretion ( node ) {
49
+ function checkImportDeclaration ( node ) {
50
50
const origin = context . options [ 0 ] . origin ;
51
51
const source = node . source . value ;
52
52
if ( source && origin && source === origin ) {
@@ -55,7 +55,7 @@ module.exports = {
55
55
}
56
56
57
57
return {
58
- ImportDeclaration : node => checkImportDeclaretion ( node ) ,
58
+ ImportDeclaration : checkImportDeclaration
59
59
} ;
60
60
} ,
61
61
} ;
Original file line number Diff line number Diff line change @@ -10,20 +10,21 @@ RuleTester.setDefaultConfig({
10
10
11
11
const ruleTester = new RuleTester ( ) ;
12
12
13
- const valideExample = `import {Component} from 'another-module';` ;
14
- const invalideExample = `import {Component} from 'some-module';` ;
13
+ const validExample = `import {Component} from 'another-module';` ;
14
+ const invalidExample = `import {Component} from 'some-module';` ;
15
15
16
16
ruleTester . run ( 'no-direct-import' , rule , {
17
17
valid : [
18
18
{
19
19
options : ruleOptions ,
20
- code : valideExample ,
20
+ code : validExample ,
21
21
} ,
22
22
] ,
23
23
invalid : [
24
24
{
25
25
options : ruleOptions ,
26
- code : invalideExample ,
26
+ code : invalidExample ,
27
+ output : `import {Component} from 'another-module';` ,
27
28
errors : [
28
29
{ message : `Do not import directly from 'some-module'. Please use 'another-module' (autofix available).` } ,
29
30
] ,
You can’t perform that action at this time.
0 commit comments