mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
632ae0b7c3
* Prevent new JS files in shared folder * migrate to typescript * fix types * cleanup
31 lines
863 B
TypeScript
31 lines
863 B
TypeScript
import { EXCLUDE_E2E_TESTS_REGEX } from '../common/constants';
|
|
import {
|
|
filterDiffLineAdditions,
|
|
filterDiffByFilePath,
|
|
hasNumberOfCodeBlocksIncreased,
|
|
} from '../common/shared';
|
|
|
|
const codeBlocks = [
|
|
"import { strict as assert } from 'assert';",
|
|
'assert.deepEqual',
|
|
'assert.equal',
|
|
'assert.rejects',
|
|
'assert.strictEqual',
|
|
'sinon.',
|
|
];
|
|
|
|
function preventSinonAssertSyntax(diff: string): boolean {
|
|
const diffByFilePath = filterDiffByFilePath(diff, EXCLUDE_E2E_TESTS_REGEX);
|
|
const diffAdditions = filterDiffLineAdditions(diffByFilePath);
|
|
const hashmap = hasNumberOfCodeBlocksIncreased(diffAdditions, codeBlocks);
|
|
|
|
const haveOccurencesOfAtLeastOneCodeBlockIncreased =
|
|
Object.values(hashmap).includes(true);
|
|
if (haveOccurencesOfAtLeastOneCodeBlockIncreased) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export { preventSinonAssertSyntax };
|