-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/eth-json-rpc
- Loading branch information
Showing
99 changed files
with
3,424 additions
and
2,760 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
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
51 changes: 51 additions & 0 deletions
51
.github/scripts/fitness-functions/rules/javascript-additions.test.ts
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,51 @@ | ||
import { | ||
generateModifyFilesDiff, | ||
generateCreateFileDiff, | ||
} from '../common/test-data'; | ||
import { preventJavaScriptFileAdditions } from './javascript-additions'; | ||
|
||
describe('preventJavaScriptFileAdditions()', (): void => { | ||
it('should pass when receiving an empty diff', (): void => { | ||
const testDiff = ''; | ||
|
||
const hasRulePassed = preventJavaScriptFileAdditions(testDiff); | ||
|
||
expect(hasRulePassed).toBe(true); | ||
}); | ||
|
||
it('should pass when receiving a diff with a new TS file on the shared folder', (): void => { | ||
const testDiff = [ | ||
generateModifyFilesDiff('new-file.ts', 'foo', 'bar'), | ||
generateModifyFilesDiff('old-file.js', undefined, 'pong'), | ||
generateCreateFileDiff('app/test.ts', 'yada yada yada yada'), | ||
].join(''); | ||
|
||
const hasRulePassed = preventJavaScriptFileAdditions(testDiff); | ||
|
||
expect(hasRulePassed).toBe(true); | ||
}); | ||
|
||
it('should not pass when receiving a diff with a new JS file on the shared folder', (): void => { | ||
const testDiff = [ | ||
generateModifyFilesDiff('new-file.ts', 'foo', 'bar'), | ||
generateModifyFilesDiff('old-file.js', undefined, 'pong'), | ||
generateCreateFileDiff('app/test.js', 'yada yada yada yada'), | ||
].join(''); | ||
|
||
const hasRulePassed = preventJavaScriptFileAdditions(testDiff); | ||
|
||
expect(hasRulePassed).toBe(false); | ||
}); | ||
|
||
it('should not pass when receiving a diff with a new JSX file on the shared folder', (): void => { | ||
const testDiff = [ | ||
generateModifyFilesDiff('new-file.ts', 'foo', 'bar'), | ||
generateModifyFilesDiff('old-file.js', undefined, 'pong'), | ||
generateCreateFileDiff('app/test.jsx', 'yada yada yada yada'), | ||
].join(''); | ||
|
||
const hasRulePassed = preventJavaScriptFileAdditions(testDiff); | ||
|
||
expect(hasRulePassed).toBe(false); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
.github/scripts/fitness-functions/rules/javascript-additions.ts
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,12 @@ | ||
import { APP_FOLDER_JS_REGEX } from '../common/constants'; | ||
import { filterDiffFileCreations, restrictedFilePresent } from '../common/shared'; | ||
|
||
function preventJavaScriptFileAdditions(diff: string): boolean { | ||
const diffAdditions = filterDiffFileCreations(diff); | ||
if (restrictedFilePresent(diffAdditions, APP_FOLDER_JS_REGEX)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
export { preventJavaScriptFileAdditions }; |
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
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
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
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
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
Oops, something went wrong.