From fdcd4d9adb1b51492d8562dc738ebc9afb35f808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Marohni=C4=87?= Date: Fri, 2 Feb 2018 09:40:49 +0100 Subject: [PATCH] Add a .coffee test proving extension resolve order Add a test for a more unconventional extension to prove that the "extensions" rule can take anything, as long as the extension resolve order is correct, i.e. it can only remove the extension if it would resolve to the correct file. Ref. #965. Closes #583. --- tests/files/bar.coffee | 1 + tests/src/rules/extensions.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/files/bar.coffee diff --git a/tests/files/bar.coffee b/tests/files/bar.coffee new file mode 100644 index 000000000..2bc5e4224 --- /dev/null +++ b/tests/files/bar.coffee @@ -0,0 +1 @@ +console.log 'bar' diff --git a/tests/src/rules/extensions.js b/tests/src/rules/extensions.js index d36e493e7..9e1ee7cba 100644 --- a/tests/src/rules/extensions.js +++ b/tests/src/rules/extensions.js @@ -183,7 +183,7 @@ ruleTester.run('extensions', rule, { }, ], }), - // extension resolve order (#965) + // extension resolve order (#583/#965) test({ code: [ 'import component from "./bar.jsx"', @@ -199,6 +199,18 @@ ruleTester.run('extensions', rule, { }, ], }), + test({ + code: 'import "./bar.coffee"', + errors: [ + { + message: 'Unexpected use of file extension "coffee" for "./bar.coffee"', + line: 1, + column: 8, + }, + ], + options: ['never', { js: 'always', jsx: 'always' }], + settings: { 'import/resolve': { 'extensions': ['.coffee', '.js'] } }, + }), test({ code: [