Closed cheton closed 2 months ago
Open the branch in Web Editor • VS Code • Insiders
Open Preview
Latest commit: 27d9ba0c50ce77ab7be456b22fa0efaf3f3c046a
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
โฑ๏ธ Estimated effort to review: 4 ๐ต๐ต๐ต๐ตโช |
๐งช PR contains tests |
๐ No security concerns identified |
โก Key issues to review Code Organization New sections added to sidebar routes. Ensure proper organization and naming conventions are followed. Environment Variable Usage Changed usage of BASE_PATH environment variable. Verify if this change is intentional and doesn't break existing functionality. Configuration Changes Multiple changes to environment variables and build configuration. Ensure these changes are correct and don't introduce unintended side effects. |
Category | Suggestion | Score |
Security |
Add a step to scan for sensitive information in the PR___ **Consider adding a step to check for sensitive information in the PR using a secretscanning tool to enhance security.** [.github/workflows/ci-pr.yml [59-63]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-d7f7c1fd6d4e4da806b57e0d5a1bee46c0f8654468beedd7d571b91761474ff9R59-R63) ```diff - name: Build & Test run: | yarn build yarn lint yarn test +- name: Check for sensitive information + uses: trufflesecurity/trufflehog@main + with: + path: ./ + base: ${{ github.event.pull_request.base.ref }} + head: ${{ github.event.pull_request.head.ref }} ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 9Why: Scanning for sensitive information is crucial for maintaining security in the codebase. This suggestion addresses a significant security concern, making it highly valuable. | 9 |
Enhancement |
Add a table of contents to improve navigation through the migration guide___ **Consider adding a table of contents at the beginning of the migration guide to helpusers navigate through the different sections more easily.** [packages/react-docs/pages/migrations/migrating-from-v0-to-v1.page.mdx [1-7]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-31800e79b84cfd9e581467940a247c9cf75a502d93634cf59c53c35c581255e0R1-R7) ```diff # Migration From v0.x to v1 โ ๏ธ This is the Tonic UI migration guide for upgrading from v0.x to v1. You have to consider whether you will do the upgrade if the breaking changes are not acceptable to you at the moment. A proper way for the migration is to make v0.x and v1 coexist for a while, then remove v0.x packages once you have finished the migration. + +## Table of Contents +1. [Upgrade Steps](#upgrade-steps) +2. [System Updates](#system-updates) +3. [Component Updates](#component-updates) +4. [Transition Updates](#transition-updates) ## Upgrade Steps ### 1. Update the dependencies ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: Adding a table of contents significantly improves the usability of the migration guide by allowing users to quickly navigate to the sections they need, enhancing the overall user experience. | 8 |
Add a step to update the PR with the deployment URL___ **Consider adding a step to automatically update the PR with the deployment URL aftersuccessful deployment to improve visibility and ease of testing.** [.github/workflows/ci-pr.yml [139-146]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-d7f7c1fd6d4e4da806b57e0d5a1bee46c0f8654468beedd7d571b91761474ff9R139-R146) ```diff - name: Deploy to gh-pages run: | rm -rf "react/${TONIC_UI_REACT_DOCS_VERSION}" mkdir -p "react/${TONIC_UI_REACT_DOCS_VERSION}" cp -af artifact/react-docs/** "react/${TONIC_UI_REACT_DOCS_VERSION}/" git add "react/${TONIC_UI_REACT_DOCS_VERSION}" git commit -m "Deploy ${TONIC_UI_REACT_DOCS_VERSION} to gh-pages [skip ci]" git push origin gh-pages +- name: Update PR with deployment URL + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Deployed to: https://trendmicro-frontend.github.io/tonic-ui-demo/react/${TONIC_UI_REACT_DOCS_VERSION}/' + }) ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: Automatically updating the PR with the deployment URL enhances visibility and facilitates testing, providing a useful improvement to the workflow process. | 8 | |
Use optional chaining for safer property access___ **Consider using optional chaining (?. ) for accessing nested properties to avoid potential errors if the object structure is not as expected.** [packages/react-docs/scripts/algolia-search-indexing.js [21-22]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-524558b1eb2e20fecd53ec7404727e57a165a3a8e248a52f14b3b1781afc029bR21-R22) ```diff const { title = '', path = '', [stateKey]: state = {} } = node; -const { level = 0, parent = null } = state; +const { level = 0, parent = null } = state ?? {}; ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: The suggestion to use optional chaining improves code safety by preventing potential runtime errors when accessing nested properties, which is a good practice for maintainability. | 7 | |
Performance |
Memoize complex calculations to improve performance___ **Consider memoizing thedefaultIsExpanded calculation to optimize performance, especially if the routes array is large.** [packages/react-docs/components/Sidebar.js [143-149]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-c10c9d154baca8ae33de9b4a356351fc771f9bb73452bbf8450bbf8b13944608R143-R149) ```diff -const defaultIsExpanded = routes.some((route) => { - if (!route.path) { - return false; - } +const defaultIsExpanded = React.useMemo(() => { + return routes.some((route) => { + if (!route.path) { + return false; + } + return currentPath.startsWith(route.path) || (route.path === currentPath); + }); +}, [routes, currentPath]); - return currentPath.startsWith(route.path) || (route.path === currentPath); -}); - ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: Memoizing the `defaultIsExpanded` calculation can significantly enhance performance, especially with large datasets, making this a valuable optimization. | 8 |
Add caching for dependencies to improve workflow execution time___ **Consider adding a step to cache dependencies using actions/cache to speed up theworkflow execution time.** [.github/workflows/ci-pr.yml [55-58]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-d7f7c1fd6d4e4da806b57e0d5a1bee46c0f8654468beedd7d571b91761474ff9R55-R58) ```diff +- name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- - name: Install packages run: | yarn up yarn install ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: Caching dependencies is a common practice to improve CI/CD workflow performance by reducing installation time. This suggestion is valid and aligns with best practices for optimizing workflow execution. | 8 | |
Best practice |
Add instructions for running tests locally before submitting a pull request___ **Consider adding a section on how to run tests locally before submitting a pullrequest to ensure code quality and prevent potential issues.** [packages/react-docs/pages/contributing/index.page.mdx [7-13]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-170aa7f5f8d6e6c9c935410aae404cf383be1202f933ef7cf74a980efa97d528R7-R13) ```diff ## Set Up Documentation Site Follow these steps to set up the documentation site: 1. Fork the Tonic UI repository. 2. Clone the repository you forked to your local machine: ```bash git clone https://github.com/ Suggestion importance[1-10]: 7Why: Including instructions for running tests locally is a good practice that helps maintain code quality and reduces the likelihood of introducing errors, making it a valuable addition to the contributing guidelines. | 7 |
Add a section on code style and linting to ensure consistency in contributions___ **Consider adding a section on code style and linting to ensure consistency acrosscontributions.** [CONTRIBUTING.md [1-5]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055R1-R5) ```diff # Contributing Guidelines Thank you for your interest in contributing to this project. +## Code Style and Linting + +To maintain code consistency across the project, we use ESLint and Prettier. Before submitting your changes, please ensure your code adheres to our style guidelines: + +1. Install dependencies if you haven't already: +```bash +yarn +``` + +2. Run the linter: +```bash +yarn lint +``` + +3. Fix any linting errors before committing your changes. + ## Set Up Documentation Site ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: Adding a section on code style and linting promotes consistency and quality in code contributions, which is important for maintaining a clean and uniform codebase. This suggestion aligns with best practices for open-source projects. | 7 | |
Add a step to validate the YAML syntax of the workflow file___ **Consider adding a step to validate the YAML syntax of the workflow file itself tocatch potential errors early.** [.github/workflows/ci-pr.yml [1-11]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-d7f7c1fd6d4e4da806b57e0d5a1bee46c0f8654468beedd7d571b91761474ff9R1-R11) ```diff name: ci-pr on: pull_request: types: - opened - reopened - synchronize branches: - v1 +jobs: + validate-yaml: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: YAML Lint + uses: ibiqlik/action-yamllint@v3 + with: + file_or_dir: .github/workflows/ci-pr.yml + ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: Adding YAML validation helps catch syntax errors early, improving the reliability of the workflow. This is a good practice, though not critical, hence a moderate score. | 7 | |
Error handling |
Add error handling for missing DOM elements___ **Consider adding error handling for cases where the main content element is not foundto prevent potential runtime errors.** [packages/react-docs/components/TableOfContents.js [54-59]](https://github.com/trendmicro-frontend/tonic-ui/pull/926/files#diff-7d911fb33c63d98facd721452c1b164cdc4feb20ada93b7d18da075099c3eaa2R54-R59) ```diff const mainContent = document.querySelector('#main-content'); if (mainContent) { // Use the `:scope` pseudo-class to select all direct child heading elements of the main content, excluding h1 const headingSelectors = ['h2', 'h3', 'h4', 'h5', 'h6'].map(h => `:scope>${h}`).join(','); setNodes(Array.from(mainContent.querySelectorAll(headingSelectors))); +} else { + console.warn('Main content element not found'); + setNodes([]); } ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 6Why: Adding error handling for missing DOM elements is a minor improvement that enhances robustness by preventing potential runtime errors, though it may not be crucial in all contexts. | 6 |
๐ก Need additional feedback ? start a PR chat
On 2024-09-18 08:12:38 +0000, PR #926 (27d9ba0c50ce77ab7be456b22fa0efaf3f3c046a) was successfully deployed. You can view it at the following link: https://trendmicro-frontend.github.io/tonic-ui-demo/react/pr-926/
PR Type
Enhancement, Tests, Documentation, Configuration changes
Description
BorderedBox
component with color mode support.changelog-github
package.changelog-github
package..circleci/config.yml
as part of CI workflow updates.Changes walkthrough ๐
10 files
index.js
Implement changelog generator for GitHub with release line functions
packages/changelog-github/src/index.js
lines.
sidebar-routes.js
Update sidebar routes with new sections and icons
packages/react-docs/config/sidebar-routes.js
Migrations.
cli.js
Enhance CLI for GitHub issue comments with new options
scripts/github-issue-comment-cli/bin/cli.js
find
with native JavaScriptfind
method.algolia-search-indexing.js
Refactor Algolia search indexing script for efficiency
packages/react-docs/scripts/algolia-search-indexing.js
icon
property from flatten function.Sidebar.js
Enhance Sidebar component with improved route handling
packages/react-docs/components/Sidebar.js
AccordionItem
to ensure re-rendering.TableOfContents.js
Improve Table of Contents node selection with scope
packages/react-docs/components/TableOfContents.js
:scope
pseudo-class.BorderedBox.js
Add BorderedBox component with color mode support
packages/react-docs/components/BorderedBox.js
BorderedBox
component with color mode support.Box
anduseColorMode
from@tonic-ui/react
.codesandbox.js
Enhance CodeSandbox dependency resolution with commit info
packages/react-docs/sandbox/codesandbox.js
index.page.js
Optimize initial routing with useOnce hook
packages/react-docs/pages/getting-started/index.page.js
useEffect
withuseOnce
for initial routing.index.page.js
Add migration guidance page with initial routing
packages/react-docs/pages/migrations/index.page.js
useOnce
for initial routing to migration content.6 files
index.test.js
Add tests for changelog generator functions
packages/changelog-github/src/__tests__/index.test.js
getDependencyReleaseLine
andgetReleaseLine
functions.index.test.js
Add export verification tests for utils package
packages/utils/__tests__/index.test.js
@tonic-ui/utils
.index.test.js
Add export verification tests for styled-system package
packages/styled-system/__tests__/index.test.js
@tonic-ui/styled-system
.index.test.js
Add export verification tests for react-lab package
packages/react-lab/__tests__/index.test.js
@tonic-ui/react-lab
.index.test.js
Add export verification tests for changelog-github package
packages/changelog-github/__tests__/index.test.js
@tonic-ui/changelog-github
.index.test.js
Add export verification tests for theme package
packages/theme/__tests__/index.test.js
@tonic-ui/theme
.23 files
Header.js
Update environment variables for documentation paths
packages/react-docs/components/Header.js
index.page.js
Update base path environment variable for index page
packages/react-docs/pages/index.page.js
_document.page.js
Update base path environment variable for document setup
packages/react-docs/pages/_document.page.js
setup.
AnimatedCube.js
Update base path environment variable for AnimatedCube
packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js
notification-center.js
Update base path environment variable for notification center
packages/react-docs/pages/patterns/notification/notification-center.js
center.
.eslintrc.js
Add ESLint configuration for changelog-github package
packages/changelog-github/.eslintrc.js
changelog-github
package.babel.config.js
Add Babel configuration for changelog-github package
packages/changelog-github/babel.config.js
changelog-github
package.ci-pr.yml
Add GitHub Actions workflow for pull request CI
.github/workflows/ci-pr.yml
ci-branch.yml
Add GitHub Actions workflow for branch CI
.github/workflows/ci-branch.yml
ci-tag.yml
Add GitHub Actions workflow for tag CI
.github/workflows/ci-tag.yml
tonic-ui.env
Update environment variables for documentation paths
packages/react-docs/tonic-ui.env
package.json
Add package configuration for changelog-github
packages/changelog-github/package.json
changelog-github
.next.config.mjs
Update Next.js configuration with new environment variables
packages/react-docs/next.config.mjs
package.json
Update package scripts and dependencies for changeset management
package.json
@changesets/cli
and@tonic-ui/changelog-github
as dependencies.changesets-release.yml
Add GitHub Actions workflow for Changesets release
.github/workflows/changesets-release.yml
rollup.config.mjs
Add Rollup configuration for changelog-github package
packages/changelog-github/rollup.config.mjs
changelog-github
package.algolia-search-indexing.yml
Update Algolia search indexing workflow with new action versions
.github/workflows/algolia-search-indexing.yml
ci-publish.yml
Add GitHub Actions workflow for CI publishing
.github/workflows/ci-publish.yml
update-yarn-lock-file.yml
Update yarn lock file workflow with new action versions
.github/workflows/update-yarn-lock-file.yml
config.json
Add Changesets configuration for versioning and changelogs
.changeset/config.json
@tonic-ui/changelog-github
.codeql-analysis.yml
Update CodeQL analysis workflow with branch settings
.github/workflows/codeql-analysis.yml
.eslintignore
Add .eslintignore for changelog-github package
packages/changelog-github/.eslintignore
.eslintignore
file forchangelog-github
package..npmignore
Add .npmignore for changelog-github package
packages/changelog-github/.npmignore
.npmignore
file forchangelog-github
package.12 files
react-components-part-1-example.js
Add example component for contributing guide
packages/react-docs/pages/contributing/react-components-part-1-example.js
Code
component from@tonic-ui/react
.migrating-from-v0-to-v1.page.mdx
Add migration guide from v0.x to v1 with examples
packages/react-docs/pages/migrations/migrating-from-v0-to-v1.page.mdx
index.page.mdx
Add contributing guidelines with setup and commit conventions
packages/react-docs/pages/contributing/index.page.mdx
CONTRIBUTING.md
Update contributing guidelines with detailed instructions
CONTRIBUTING.md
react-components-part-2.page.mdx
Add part 2 of contributing guide for React components
packages/react-docs/pages/contributing/react-components-part-2.page.mdx
examples.
react-components-part-1.page.mdx
Add part 1 of contributing guide for React components
packages/react-docs/pages/contributing/react-components-part-1.page.mdx
react-documentation-site.page.mdx
Add guide for contributing to documentation site
packages/react-docs/pages/contributing/react-documentation-site.page.mdx
publishing.page.mdx
Add guide for publishing packages and release notes
packages/react-docs/pages/contributing/publishing.page.mdx
pull-request-review.page.mdx
Add guide for pull request review with CodiumAI PR-Agent
packages/react-docs/pages/contributing/pull-request-review.page.mdx
react-icons.page.mdx
Add guide for contributing to React Icons
packages/react-docs/pages/contributing/react-icons.page.mdx
LICENSE
Add MIT License for changelog-github package
packages/changelog-github/LICENSE
changelog-github
package.README.md
Add README for Changesets configuration
.changeset/README.md