Skip to content

Commit

Permalink
Add test case for import/resolve extensions order
Browse files Browse the repository at this point in the history
When there are multiple files with same names and different extensions,
the resolver will go by extensions in the order specified in
import/resolve settings.

This test case ensures that the "extensions" rule is correctly forcing
the extension when omitting it would cause it to resolve to the wrong
file.

Closes #965.
  • Loading branch information
silvenon committed Feb 2, 2018
1 parent 655c33d commit 364e841
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/src/rules/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ ruleTester.run('extensions', rule, {
},
],
}),
// extension resolve order (#965)
test({
code: [
'import component from "./bar.jsx"',
'import data from "./bar.json"',
].join('\n'),
options: [ { json: 'always', js: 'never', jsx: 'never' } ],
settings: { 'import/resolve': { 'extensions': [ '.jsx', '.json', '.js' ] } },
errors: [
{
message: 'Unexpected use of file extension "jsx" for "./bar.jsx"',
line: 1,
column: 23,
},
],
}),

test({
code: [
Expand Down

0 comments on commit 364e841

Please sign in to comment.