Skip to content

Commit

Permalink
Merge branch 'main' into json-rpc-middleware-12
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioAslau authored Jun 11, 2024
2 parents 242934d + 820a9aa commit 6cfbed3
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 102 deletions.
5 changes: 1 addition & 4 deletions .github/scripts/fitness-functions/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ enum AUTOMATION_TYPE {
PRE_PUSH_HOOK = 'pre-push-hook',
}

// only allow TS and TSX files in the app directory only
const APP_FOLDER_JS_REGEX = /^(app).*\.(js|jsx)$/;

export { EXCLUDE_REGEX, APP_FOLDER_JS_REGEX, AUTOMATION_TYPE };
export { EXCLUDE_REGEX, AUTOMATION_TYPE };
29 changes: 0 additions & 29 deletions .github/scripts/fitness-functions/common/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,6 @@ function filterDiffByFilePath(diff: string, regex: RegExp): string {
return filteredDiff;
}

function restrictedFilePresent(diff: string, regex: RegExp): boolean {
// split by `diff --git` and remove the first element which is empty
const diffBlocks = diff.split(`diff --git`).slice(1);
let jsOrJsxFilePresent = false;
diffBlocks
.map((block) => block.trim())
.filter((block) => {
block
// get the first line of the block which has the paths
.split('\n')[0]
.trim()
// split the two paths
.split(' ')
// remove `a/` and `b/` from the paths
.map((path) => path.substring(2))
// if at least one of the two paths matches the regex, filter the
// corresponding diff block in
.forEach((path) => {
if (regex.test(path)) {
// Not excluded, include in check
jsOrJsxFilePresent = true;
}
});
return jsOrJsxFilePresent;
})
return jsOrJsxFilePresent;
}

// This function returns all lines that are additions to files that are being
// modified but that previously already existed. Example:
// diff --git a/test.js b/test.js
Expand Down Expand Up @@ -139,7 +111,6 @@ function hasNumberOfCodeBlocksIncreased(

export {
filterDiffByFilePath,
restrictedFilePresent,
filterDiffFileCreations,
filterDiffLineAdditions,
hasNumberOfCodeBlocksIncreased,
Expand Down
8 changes: 1 addition & 7 deletions .github/scripts/fitness-functions/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { preventJavaScriptFileAdditions } from './javascript-additions';
import { preventCodeBlocksRule } from './prevent-code-blocks';

const RULES: IRule[] = [
Expand All @@ -7,11 +6,6 @@ const RULES: IRule[] = [
fn: preventCodeBlocksRule,
docURL: '[WIP] No documentation exists for this rule yet.',
},
{
name: 'Check for js or jsx file being added',
fn: preventJavaScriptFileAdditions,
docURL: '[WIP] No documentation exists for this rule yet.',
},
];

interface IRule {
Expand All @@ -38,5 +32,5 @@ function runFitnessFunctionRule(rule: IRule, diff: string): void {
}
}

export { RULES, runFitnessFunctionRule, preventJavaScriptFileAdditions };
export { RULES, runFitnessFunctionRule };
export type { IRule };

This file was deleted.

11 changes: 0 additions & 11 deletions .github/scripts/fitness-functions/rules/javascript-additions.ts

This file was deleted.

0 comments on commit 6cfbed3

Please sign in to comment.