1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/development/fitness-functions/rules/javascript-additions.ts
Pedro Figueiredo 632ae0b7c3
Prevent new JS files in shared folder (#17737)
* Prevent new JS files in shared folder

* migrate to typescript

* fix types

* cleanup
2023-04-24 15:44:42 +01:00

19 lines
578 B
TypeScript

import { SHARED_FOLDER_JS_REGEX } from '../common/constants';
import {
filterDiffByFilePath,
filterDiffFileCreations,
} from '../common/shared';
function preventJavaScriptFileAdditions(diff: string): boolean {
const sharedFolderDiff = filterDiffByFilePath(diff, SHARED_FOLDER_JS_REGEX);
const sharedFolderCreationDiff = filterDiffFileCreations(sharedFolderDiff);
const hasCreatedAtLeastOneJSFileInShared = sharedFolderCreationDiff !== '';
if (hasCreatedAtLeastOneJSFileInShared) {
return false;
}
return true;
}
export { preventJavaScriptFileAdditions };