-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add local-rules/disallow-test-import-export-from-src * remove observers.specHelper exports
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
meta: { | ||
docs: { | ||
description: | ||
'Disallow importing or exporting test code in src code to avoid bloating customer package with test code', | ||
recommended: false, | ||
}, | ||
schema: [], | ||
}, | ||
create(context) { | ||
return { | ||
ImportDeclaration(node) { | ||
checkTestImportExportFromSrc(context, node) | ||
}, | ||
ExportNamedDeclaration(node) { | ||
checkTestImportExportFromSrc(context, node) | ||
}, | ||
ExportAllDeclaration(node) { | ||
checkTestImportExportFromSrc(context, node) | ||
}, | ||
} | ||
}, | ||
} | ||
|
||
function checkTestImportExportFromSrc(context, node) { | ||
if (!isTestCode(context.getFilename()) && node.source && isTestCode(node.source.value)) { | ||
context.report({ | ||
node: node.source, | ||
message: 'Test code import or export is not allowed in src code', | ||
}) | ||
} | ||
} | ||
|
||
function isTestCode(filename) { | ||
return /(\/test|\.specHelper|\.spec)/.test(filename) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export { initObservers } from './observers' | ||
export { InputCallback, initInputObserver } from './inputObserver' | ||
export { initMutationObserver, MutationCallBack, RumMutationRecord } from './mutationObserver' | ||
export { DEFAULT_CONFIGURATION } from './observers.specHelper' | ||
export { DEFAULT_SHADOW_ROOT_CONTROLLER } from './observers.specHelper' |