Skip to content

Commit

Permalink
added changes based on review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcsapo committed Sep 29, 2020
1 parent 33be041 commit 88e1edb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/rules/no-test-support-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
const ERROR_MESSAGE_NO_IMPORT =
'Do not import a file from test-support into production code, only into test files.';

function hasTestSupportDirectory(importSource) {
return (
importSource.startsWith('test-support/') ||
importSource.endsWith('/test-support') ||
importSource.includes('/test-support/')
);
}

module.exports = {
ERROR_MESSAGE_NO_IMPORT,

Expand All @@ -30,7 +38,7 @@ module.exports = {
const importSource = node.source.value;

if (
importSource.includes('test-support') &&
hasTestSupportDirectory(importSource) &&
!(
fileName.includes('/tests/') ||
fileName.includes('/addon-test-support/') ||
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/rules/no-test-support-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ruleTester.run('no-test-support-import', rule, {
errors: [
{
message: ERROR_MESSAGE_NO_IMPORT,
type: 'ImportDeclaration',
},
],
},
Expand All @@ -62,6 +63,7 @@ ruleTester.run('no-test-support-import', rule, {
errors: [
{
message: ERROR_MESSAGE_NO_IMPORT,
type: 'ImportDeclaration',
},
],
},
Expand All @@ -74,6 +76,7 @@ ruleTester.run('no-test-support-import', rule, {
errors: [
{
message: ERROR_MESSAGE_NO_IMPORT,
type: 'ImportDeclaration',
},
],
},
Expand Down

0 comments on commit 88e1edb

Please sign in to comment.