Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment #243

Closed
wants to merge 9 commits into from
Closed

Environment #243

wants to merge 9 commits into from

Conversation

mndgs1
Copy link

@mndgs1 mndgs1 commented Aug 9, 2023

Added dev dependencies Prettier & ESLint. Added format & lint scripts. Executed the scripts.

Summary by CodeRabbit

Chore:

  • Added dev dependencies Prettier & ESLint, along with format and lint scripts.
  • Executed the scripts with minor changes to the code by adding semicolons to function calls.
  • Updated workflow file for installing dependencies, building SASS, and deploying to GitHub Pages.
  • Modified apiBase constant value and added a missing semicolon at the end of the apiPath export statement.
  • Adjusted BLANK_POST constant property names and added a new _count property.
  • Refactored getSearchParams and setSearchParams functions.
  • Added error handling for missing template IDs.

Style:

  • Updated CSS file: modified font-family property, added quotes around attribute values, adjusted border-radius, added missing semicolons, and refactored keyframes animations.

🎉 With each semicolon in place, our code now has grace. 🕺
ESLint and Prettier, making our code prettier. 💅
From CSS to JS files, every change brings smiles. 😊
Celebrate this chore, for our code is cleaner than before! 🎊

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Image description CodeRabbit

Walkthrough

This pull request primarily focuses on improving code quality and readability. It introduces Prettier and ESLint as dev dependencies, adds format and lint scripts, and applies these to the codebase. Minor changes include adding missing semicolons, adjusting CSS properties, and refactoring some JavaScript functions for better clarity. No significant alterations were made to the logic or functionality of the code.

Changes

Files Summary
.eslintrc.json, .github/workflows/pages.yml, index.js, src/js/api/*.js, src/js/listeners/*.js, src/js/router/*.js, src/js/storage/*.js, src/js/templates/*.js, src/js/tools/*.js, src/js/ui/*.js, src/js/views/*.js Added Prettier & ESLint as dev dependencies along with format and lint scripts. Applied these scripts resulting in minor changes like adding semicolons. No changes to the code logic or functionality.
src/js/api/apiBase.js, src/js/api/constants.js Updated the apiBase constant value and added a missing semicolon at the end of the apiPath export statement.
src/js/data/blank/post.js Modified the BLANK_POST constant by changing the property names from strings to identifiers and added a new _count property.
src/js/router/searchParams.js Refactored getSearchParams and setSearchParams functions for better clarity.
src/scss/index.scss Adjusted CSS properties such as font-family, border-radius, and refactored keyframes animations. Added missing semicolons.

@mndgs1 mndgs1 closed this Aug 9, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 5cdcf16 and bf0f0e3 commits.
Files selected (85)
  • .eslintrc.json (1)
  • .github/workflows/pages.yml (2)
  • index.html (1)
  • index.js (1)
  • src/js/api/apiBase.js (1)
  • src/js/api/auth/index.js (1)
  • src/js/api/auth/login.js (1)
  • src/js/api/auth/logout.js (1)
  • src/js/api/auth/register.js (1)
  • src/js/api/auth/state.js (1)
  • src/js/api/constants.js (1)
  • src/js/api/headers.js (2)
  • src/js/api/index.js (1)
  • src/js/api/posts/comment.js (1)
  • src/js/api/posts/create.js (1)
  • src/js/api/posts/delete.js (1)
  • src/js/api/posts/index.js (1)
  • src/js/api/posts/react.js (1)
  • src/js/api/posts/read.js (1)
  • src/js/api/posts/update.js (1)
  • src/js/api/profiles/delete.js (1)
  • src/js/api/profiles/follow.js (1)
  • src/js/api/profiles/index.js (1)
  • src/js/api/profiles/read.js (1)
  • src/js/api/profiles/unfollow.js (1)
  • src/js/api/profiles/update.js (1)
  • src/js/data/blank/post.js (1)
  • src/js/index.js (1)
  • src/js/listeners/auth/index.js (1)
  • src/js/listeners/auth/login.js (1)
  • src/js/listeners/auth/logout.js (1)
  • src/js/listeners/auth/register.js (1)
  • src/js/listeners/index.js (1)
  • src/js/listeners/post/comment.js (1)
  • src/js/listeners/post/index.js (1)
  • src/js/listeners/post/reaction.js (1)
  • src/js/listeners/profile/follow.js (1)
  • src/js/listeners/profile/index.js (1)
  • src/js/listeners/profile/unfollow.js (1)
  • src/js/router/index.js (1)
  • src/js/router/searchParams.js (1)
  • src/js/storage/index.js (1)
  • src/js/storage/load.js (1)
  • src/js/storage/save.js (1)
  • src/js/templates/comment/badge.js (1)
  • src/js/templates/comment/comment.js (3)
  • src/js/templates/comment/form.js (1)
  • src/js/templates/comment/index.js (1)
  • src/js/templates/index.js (1)
  • src/js/templates/instance.js (1)
  • src/js/templates/post/actions.js (1)
  • src/js/templates/post/comments.js (1)
  • src/js/templates/post/footer.js (1)
  • src/js/templates/post/form.js (3)
  • src/js/templates/post/header.js (1)
  • src/js/templates/post/index.js (1)
  • src/js/templates/post/loader.js (1)
  • src/js/templates/post/media.js (2)
  • src/js/templates/post/page.js (1)
  • src/js/templates/post/reactions.js (1)
  • src/js/templates/post/tabs.js (1)
  • src/js/templates/post/tags.js (1)
  • src/js/templates/post/thumbnail.js (1)
  • src/js/templates/profile/button.js (1)
  • src/js/templates/profile/followers.js (1)
  • src/js/templates/profile/following.js (1)
  • src/js/templates/profile/follows.js (1)
  • src/js/templates/profile/index.js (1)
  • src/js/templates/profile/page.js (1)
  • src/js/templates/profile/thumbnail.js (1)
  • src/js/tools/clear.js (1)
  • src/js/tools/emojiSubset.js (1)
  • src/js/tools/index.js (1)
  • src/js/ui/auth.js (1)
  • src/js/ui/footer.js (1)
  • src/js/ui/header.js (1)
  • src/js/ui/index.js (1)
  • src/js/ui/modals.js (1)
  • src/js/ui/renderView.js (1)
  • src/js/views/index.js (1)
  • src/js/views/postList.js (1)
  • src/js/views/postPage.js (2)
  • src/js/views/profileList.js (1)
  • src/js/views/profilePage.js (1)
  • src/scss/index.scss (6)
Files ignored due to filter (2)
  • package-lock.json
  • package.json
Files not summarized due to errors (1)
  • index.html (diff tokens exceeds limit)
Files skipped from review due to trivial changes (81)
  • .eslintrc.json
  • .github/workflows/pages.yml
  • index.js
  • src/js/api/apiBase.js
  • src/js/api/auth/index.js
  • src/js/api/auth/login.js
  • src/js/api/auth/logout.js
  • src/js/api/auth/register.js
  • src/js/api/auth/state.js
  • src/js/api/constants.js
  • src/js/api/headers.js
  • src/js/api/index.js
  • src/js/api/posts/comment.js
  • src/js/api/posts/create.js
  • src/js/api/posts/delete.js
  • src/js/api/posts/index.js
  • src/js/api/posts/react.js
  • src/js/api/posts/read.js
  • src/js/api/posts/update.js
  • src/js/api/profiles/delete.js
  • src/js/api/profiles/follow.js
  • src/js/api/profiles/index.js
  • src/js/api/profiles/read.js
  • src/js/api/profiles/unfollow.js
  • src/js/api/profiles/update.js
  • src/js/data/blank/post.js
  • src/js/index.js
  • src/js/listeners/auth/index.js
  • src/js/listeners/auth/login.js
  • src/js/listeners/auth/logout.js
  • src/js/listeners/auth/register.js
  • src/js/listeners/index.js
  • src/js/listeners/post/comment.js
  • src/js/listeners/post/index.js
  • src/js/listeners/post/reaction.js
  • src/js/listeners/profile/index.js
  • src/js/listeners/profile/unfollow.js
  • src/js/router/index.js
  • src/js/storage/index.js
  • src/js/storage/load.js
  • src/js/storage/save.js
  • src/js/templates/comment/badge.js
  • src/js/templates/comment/comment.js
  • src/js/templates/comment/form.js
  • src/js/templates/comment/index.js
  • src/js/templates/index.js
  • src/js/templates/post/actions.js
  • src/js/templates/post/comments.js
  • src/js/templates/post/footer.js
  • src/js/templates/post/form.js
  • src/js/templates/post/header.js
  • src/js/templates/post/index.js
  • src/js/templates/post/loader.js
  • src/js/templates/post/media.js
  • src/js/templates/post/page.js
  • src/js/templates/post/reactions.js
  • src/js/templates/post/tabs.js
  • src/js/templates/post/tags.js
  • src/js/templates/post/thumbnail.js
  • src/js/templates/profile/button.js
  • src/js/templates/profile/followers.js
  • src/js/templates/profile/following.js
  • src/js/templates/profile/follows.js
  • src/js/templates/profile/index.js
  • src/js/templates/profile/page.js
  • src/js/templates/profile/thumbnail.js
  • src/js/tools/emojiSubset.js
  • src/js/tools/index.js
  • src/js/ui/auth.js
  • src/js/ui/footer.js
  • src/js/ui/header.js
  • src/js/ui/index.js
  • src/js/ui/modals.js
  • src/js/ui/renderView.js
  • src/js/views/index.js
  • src/js/views/postList.js
  • src/js/views/postPage.js
  • src/js/views/profileList.js
  • src/js/views/profilePage.js
  • src/scss/index.scss
  • index.html (diff too large)
Review comments generated (8)
  • Review: 5
  • LGTM: 3

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines 1 to 5
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
} No newline at end of file
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [6-6]

There's a missing newline at the end of the file. It's a common convention to end files with a newline because some tools like git or cat can have unexpected behavior if you don't.

Suggested change
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
}
\ No newline at end of file
}
}
\n

Comment on lines 0 to 8
export const templateInstance = (id = "404") => {
const template = document.querySelector(`template#${id}`);
if (template) {
return template.content.cloneNode(true)
return template.content.cloneNode(true);
}

throw new Error(`Template #${id} not found`)
} No newline at end of file
throw new Error(`Template #${id} not found`);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [8-9]

The error handling here is good, but it might be more helpful to provide a more descriptive error message. This could include suggesting possible solutions or providing more context about why the error occurred.

Suggested change
export const templateInstance = (id = "404") => {
const template = document.querySelector(`template#${id}`);
if (template) {
return template.content.cloneNode(true)
return template.content.cloneNode(true);
}
throw new Error(`Template #${id} not found`)
}
\ No newline at end of file
throw new Error(`Template #${id} not found`);
};
throw new Error(`Template with ID #${id} not found. Please ensure that the template exists and the ID is correct.`);

Comment on lines 6 to 13
export const setSearchParams = (params) => {
const newParams = {
...getSearchParams(),
...params
}
...params,
};

const searchParams = new URLSearchParams(newParams);
window.location.search = searchParams.toString();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The setSearchParams function directly modifies the window.location.search, which will cause a page reload. If you want to change the URL without reloading the page, consider using the history.pushState() method.

Suggested change
export const setSearchParams = (params) => {
const newParams = {
...getSearchParams(),
...params
}
...params,
};
const searchParams = new URLSearchParams(newParams);
window.location.search = searchParams.toString();
export const setSearchParams = (params) => {
const newParams = {
...getSearchParams(),
...params,
};
const searchParams = new URLSearchParams(newParams);
history.pushState({}, '', '?' + searchParams.toString());
};

@@ -7,9 +7,9 @@ export async function followListener(event) {
if (name) {
try {
await followProfile(name);
location.reload()
location.reload();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Reloading the entire page can be a performance issue, especially if the page is heavy. It would be better to just update the part of the UI that needs to change after following a profile.

Suggested change
location.reload();
// Code to update the UI after following a profile

Comment on lines 12 to 13
return alert("There was a problem following this profile");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Instead of using alert for error handling, consider using a more user-friendly way to display errors, such as a modal or an inline message in the UI. Alerts can be disruptive and are not considered good practice for user experience.

Suggested change
return alert("There was a problem following this profile");
}
// Code to handle error and display it in a user-friendly way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant