Skip to content

Commit

Permalink
Detecting react component - log results
Browse files Browse the repository at this point in the history
  • Loading branch information
sebryu committed Sep 26, 2023
1 parent dbdcafb commit ba51334
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ const items = [
"I verified that each component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions",
];

function detectReactComponent(code) {
console.log('code', code);
function detectReactComponent(code, filename) {
if (!code) {
return;
}
Expand All @@ -242,6 +241,7 @@ function detectReactComponent(code) {
(node) => node.type === 'ReturnStatement' && node.argument.type === 'JSXElement'
)
) {
console.log('detected react component in file', filename)
isReactComponent = true;
}
},
Expand All @@ -263,8 +263,11 @@ async function detectReactComponentInFile(filename) {
};
try {
const { data } = await GithubUtils.octokit.repos.getContent(params);
if (!data) {
console.log('no data', data, params);
}
const content = 'content' in data ? nodeBase64ToUtf8(data.content || '') : data;
return detectReactComponent(content);
return detectReactComponent(content, filename);
} catch (error) {
console.error(`An unknown error occurred with the GitHub API: ${error}, while fetching ${params}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const items = [
"I verified that each component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions",
];

function detectReactComponent(code) {
console.log('code', code);
function detectReactComponent(code, filename) {
if (!code) {
return;
}
Expand All @@ -41,6 +40,7 @@ function detectReactComponent(code) {
(node) => node.type === 'ReturnStatement' && node.argument.type === 'JSXElement'
)
) {
console.log('detected react component in file', filename)
isReactComponent = true;
}
},
Expand All @@ -62,8 +62,11 @@ async function detectReactComponentInFile(filename) {
};
try {
const { data } = await GithubUtils.octokit.repos.getContent(params);
if (!data) {
console.log('no data', data, params);
}
const content = 'content' in data ? nodeBase64ToUtf8(data.content || '') : data;
return detectReactComponent(content);
return detectReactComponent(content, filename);
} catch (error) {
console.error(`An unknown error occurred with the GitHub API: ${error}, while fetching ${params}`);
}
Expand Down

0 comments on commit ba51334

Please sign in to comment.