Skip to content

Commit 5345c66

Browse files
committed
test: add tests
1 parent b70ae60 commit 5345c66

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

src/import-paths.test.ts

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ tester.run('import-paths', rule, {
1818
filename: path.resolve('./src/index.ts'),
1919
code: `import baz from './baz/index';`,
2020
},
21+
{
22+
name: 'import from alias root',
23+
filename: path.resolve('./src/index.ts'),
24+
code: `import baz from '@foo';`,
25+
},
2126
{
2227
name: 'alias import from alias directory',
2328
filename: path.resolve('./src/foo/index.ts'),
@@ -41,40 +46,18 @@ tester.run('import-paths', rule, {
4146
],
4247
invalid: [
4348
{
44-
options: [{}],
49+
name: 'relative import from alias must be fixed',
4550
filename: path.resolve('./src/index.ts'),
46-
code: `import globalFoo from './foo/index';`,
47-
errors: ['Update import to @foo/index'],
48-
output: `import globalFoo from '@foo/index';`,
51+
code: `import z from './foo/x/y/z';`,
52+
errors: ['Update import to @foo/x/y/z'],
53+
output: `import z from '@foo/x/y/z';`,
4954
},
5055
{
51-
options: [{}],
56+
name: 'relative import from alias used in file under another alias must be fixed',
5257
filename: path.resolve('./src/foo/index.ts'),
53-
code: `
54-
// import globalFoo from '../foo/index';
55-
import globalBar from '../bar/index';
56-
import bar1 from '../bar/1';
57-
// import bar2 from 'bar/1/2';
58-
// import bar3 from 'bar/1/2/3';
59-
60-
// import globalBaz from './baz';
61-
// import baz1 from './baz/main';
62-
// import baz2 from '../baz/main';
63-
// import baz3 from '../../baz/main';
64-
`.replace(/\t/g, ''),
65-
errors: ['Update import to @bar/index', 'Update import to @bar/1'],
66-
output: `
67-
// import globalFoo from '../foo/index';
68-
import globalBar from '@bar/index';
69-
import bar1 from '@bar/1';
70-
// import bar2 from 'bar/1/2';
71-
// import bar3 from 'bar/1/2/3';
72-
73-
// import globalBaz from './baz';
74-
// import baz1 from './baz/main';
75-
// import baz2 from '../baz/main';
76-
// import baz3 from '../../baz/main';
77-
`.replace(/\t/g, ''),
58+
code: `import z from '../bar/x/y/z';`,
59+
errors: ['Update import to @bar/x/y/z'],
60+
output: `import z from '@bar/x/y/z';`,
7861
},
7962
],
8063
});

0 commit comments

Comments
 (0)