trendmicro-frontend / tonic-ui

Tonic UI is a UI component library for React, built with Emotion and Styled System. It is designed to be easy to use and easy to customize.
https://trendmicro-frontend.github.io/tonic-ui
MIT License
125 stars 29 forks source link

chore: integrate latest v2 updates into v1 branch #926

Closed cheton closed 2 months ago

cheton commented 2 months ago

PR Type

Enhancement, Tests, Documentation, Configuration changes


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
10 files
index.js
Implement changelog generator for GitHub with release line functions

packages/changelog-github/src/index.js
  • Added a changelog generator for GitHub with functions to get release
    lines.
  • Implemented validation for repository options.
  • Integrated GitHub info retrieval for commits and pull requests.
  • Added functions to format dependency and release lines.
  • +154/-0 
    sidebar-routes.js
    Update sidebar routes with new sections and icons               

    packages/react-docs/config/sidebar-routes.js
  • Updated sidebar routes with new sections for Contributing and
    Migrations.
  • Added icons for new sections.
  • Renamed 'Versions' to 'Tonic UI Versions'.
  • +30/-2   
    cli.js
    Enhance CLI for GitHub issue comments with new options     

    scripts/github-issue-comment-cli/bin/cli.js
  • Updated CLI options for GitHub token and pattern search.
  • Replaced lodash find with native JavaScript find method.
  • Improved comment handling logic.
  • +14/-6   
    algolia-search-indexing.js
    Refactor Algolia search indexing script for efficiency     

    packages/react-docs/scripts/algolia-search-indexing.js
  • Added utility function to check for non-empty strings.
  • Removed unused icon property from flatten function.
  • Improved node processing logic in flatten function.
  • +5/-4     
    Sidebar.js
    Enhance Sidebar component with improved route handling     

    packages/react-docs/components/Sidebar.js
  • Updated base path environment variable.
  • Improved logic for determining expanded state of routes.
  • Added key update for AccordionItem to ensure re-rendering.
  • +9/-2     
    TableOfContents.js
    Improve Table of Contents node selection with scope           

    packages/react-docs/components/TableOfContents.js
  • Updated heading selection logic to use :scope pseudo-class.
  • Improved node selection for table of contents generation.
  • +3/-1     
    BorderedBox.js
    Add BorderedBox component with color mode support               

    packages/react-docs/components/BorderedBox.js
  • Added new BorderedBox component with color mode support.
  • Utilized Box and useColorMode from @tonic-ui/react.
  • +19/-0   
    codesandbox.js
    Enhance CodeSandbox dependency resolution with commit info

    packages/react-docs/sandbox/codesandbox.js
  • Updated logic to ensure commit short hash is correctly derived.
  • Improved handling of environment variables for commit information.
  • +1/-1     
    index.page.js
    Optimize initial routing with useOnce hook                             

    packages/react-docs/pages/getting-started/index.page.js
  • Replaced useEffect with useOnce for initial routing.
  • Improved routing logic for getting started page.
  • +4/-5     
    index.page.js
    Add migration guidance page with initial routing                 

    packages/react-docs/pages/migrations/index.page.js
  • Added new page for migration guidance.
  • Utilized useOnce for initial routing to migration content.
  • +14/-0   
    Tests
    6 files
    index.test.js
    Add tests for changelog generator functions                           

    packages/changelog-github/src/__tests__/index.test.js
  • Added tests for getDependencyReleaseLine and getReleaseLine functions.
  • Mocked GitHub info retrieval for testing.
  • Verified formatted output for dependencies and release lines.
  • +74/-0   
    index.test.js
    Add export verification tests for utils package                   

    packages/utils/__tests__/index.test.js
  • Added tests to verify expected exports from @tonic-ui/utils.
  • Listed all utility functions to be tested.
  • +55/-0   
    index.test.js
    Add export verification tests for styled-system package   

    packages/styled-system/__tests__/index.test.js
  • Added tests to verify expected exports from @tonic-ui/styled-system.
  • Listed all styled-system functions to be tested.
  • +18/-0   
    index.test.js
    Add export verification tests for react-lab package           

    packages/react-lab/__tests__/index.test.js
  • Added tests to verify expected exports from @tonic-ui/react-lab.
  • Listed all lab components to be tested.
  • +17/-1   
    index.test.js
    Add export verification tests for changelog-github package

    packages/changelog-github/__tests__/index.test.js
  • Added tests to verify expected exports from
    @tonic-ui/changelog-github.
  • Listed all changelog functions to be tested.
  • +11/-0   
    index.test.js
    Add export verification tests for theme package                   

    packages/theme/__tests__/index.test.js
  • Added tests to verify expected exports from @tonic-ui/theme.
  • Listed all theme functions to be tested.
  • +11/-0   
    Configuration changes
    23 files
    Header.js
    Update environment variables for documentation paths         

    packages/react-docs/components/Header.js
  • Changed environment variable for base path.
  • Removed unused environment variable.
  • Updated version map URLs with new environment variables.
  • +4/-6     
    index.page.js
    Update base path environment variable for index page         

    packages/react-docs/pages/index.page.js
  • Updated base path environment variable.
  • Ensured consistent use of new environment variable across pages.
  • +1/-1     
    _document.page.js
    Update base path environment variable for document setup 

    packages/react-docs/pages/_document.page.js
  • Updated base path environment variable.
  • Ensured consistent use of new environment variable across document
    setup.
  • +1/-1     
    AnimatedCube.js
    Update base path environment variable for AnimatedCube     

    packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js
  • Updated base path environment variable.
  • Ensured consistent use of new environment variable in component.
  • +1/-1     
    notification-center.js
    Update base path environment variable for notification center

    packages/react-docs/pages/patterns/notification/notification-center.js
  • Updated base path environment variable.
  • Ensured consistent use of new environment variable in notification
    center.
  • +1/-1     
    .eslintrc.js
    Add ESLint configuration for changelog-github package       

    packages/changelog-github/.eslintrc.js
  • Added ESLint configuration for changelog-github package.
  • Set up environment and plugins for linting.
  • +14/-0   
    babel.config.js
    Add Babel configuration for changelog-github package         

    packages/changelog-github/babel.config.js
  • Added Babel configuration for changelog-github package.
  • Set up presets for JavaScript transformation.
  • +6/-0     
    ci-pr.yml
    Add GitHub Actions workflow for pull request CI                   

    .github/workflows/ci-pr.yml
  • Added GitHub Actions workflow for pull request CI.
  • Configured build, test, and deployment steps.
  • Integrated artifact upload and deployment to gh-pages.
  • +155/-0 
    ci-branch.yml
    Add GitHub Actions workflow for branch CI                               

    .github/workflows/ci-branch.yml
  • Added GitHub Actions workflow for branch CI.
  • Configured build, test, and deployment steps.
  • Integrated artifact upload and deployment to gh-pages.
  • +134/-0 
    ci-tag.yml
    Add GitHub Actions workflow for tag CI                                     

    .github/workflows/ci-tag.yml
  • Added GitHub Actions workflow for tag CI.
  • Configured build, test, and deployment steps.
  • Integrated artifact upload and deployment to gh-pages.
  • +131/-0 
    tonic-ui.env
    Update environment variables for documentation paths         

    packages/react-docs/tonic-ui.env
  • Updated environment variables for documentation paths.
  • Ensured consistent use of new base path variable.
  • +10/-9   
    package.json
    Add package configuration for changelog-github                     

    packages/changelog-github/package.json
  • Added package configuration for changelog-github.
  • Defined scripts, dependencies, and Jest configuration.
  • Set up metadata and repository information.
  • +82/-0   
    next.config.mjs
    Update Next.js configuration with new environment variables

    packages/react-docs/next.config.mjs
  • Updated environment variables for Next.js configuration.
  • Adjusted base path and output directory settings.
  • +7/-7     
    package.json
    Update package scripts and dependencies for changeset management

    package.json
  • Updated scripts for publishing and changeset management.
  • Added @changesets/cli and @tonic-ui/changelog-github as dependencies.
  • Refined Lerna publish commands with additional checks.
  • +7/-4     
    changesets-release.yml
    Add GitHub Actions workflow for Changesets release             

    .github/workflows/changesets-release.yml
  • Added GitHub Actions workflow for releasing packages with Changesets.
  • Configured steps for building and publishing packages.
  • Integrated changeset action for versioning and changelog generation.
  • +60/-0   
    rollup.config.mjs
    Add Rollup configuration for changelog-github package       

    packages/changelog-github/rollup.config.mjs
  • Added Rollup configuration for changelog-github package.
  • Configured input, output, and plugins for module bundling.
  • +45/-0   
    algolia-search-indexing.yml
    Update Algolia search indexing workflow with new action versions

    .github/workflows/algolia-search-indexing.yml
  • Updated GitHub Actions workflow for Algolia search indexing.
  • Adjusted node version and action versions.
  • +5/-3     
    ci-publish.yml
    Add GitHub Actions workflow for CI publishing                       

    .github/workflows/ci-publish.yml
  • Added GitHub Actions workflow for CI publishing.
  • Configured steps for package installation and publishing.
  • +37/-0   
    update-yarn-lock-file.yml
    Update yarn lock file workflow with new action versions   

    .github/workflows/update-yarn-lock-file.yml
  • Updated GitHub Actions workflow for updating yarn lock file.
  • Adjusted node version and action versions.
  • +2/-2     
    config.json
    Add Changesets configuration for versioning and changelogs

    .changeset/config.json
  • Added Changesets configuration file.
  • Set up changelog generation with @tonic-ui/changelog-github.
  • Defined base branch and access settings.
  • +11/-0   
    codeql-analysis.yml
    Update CodeQL analysis workflow with branch settings         

    .github/workflows/codeql-analysis.yml
  • Updated GitHub Actions workflow for CodeQL analysis.
  • Adjusted branch settings for push and pull request triggers.
  • +4/-2     
    .eslintignore
    Add .eslintignore for changelog-github package                     

    packages/changelog-github/.eslintignore
  • Added .eslintignore file for changelog-github package.
  • Ignored build, dist, and node_modules directories.
  • +3/-0     
    .npmignore
    Add .npmignore for changelog-github package                           

    packages/changelog-github/.npmignore
  • Added .npmignore file for changelog-github package.
  • Ignored lock files for npm publishing.
  • +2/-0     
    Documentation
    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
  • Added example component for contributing guide.
  • Demonstrated usage of Code component from @tonic-ui/react.
  • +8/-0     
    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
  • Added comprehensive migration guide from v0.x to v1.
  • Detailed upgrade steps, breaking changes, and system updates.
  • Provided examples and code snippets for migration.
  • +435/-0 
    index.page.mdx
    Add contributing guidelines with setup and commit conventions

    packages/react-docs/pages/contributing/index.page.mdx
  • Added contributing guidelines for Tonic UI.
  • Included setup instructions, commit conventions, and changeset usage.
  • Provided examples for commit messages and changesets.
  • +205/-0 
    CONTRIBUTING.md
    Update contributing guidelines with detailed instructions

    CONTRIBUTING.md
  • Updated contributing guidelines with detailed instructions.
  • Added sections on creating pull requests and adding changesets.
  • Included commit message conventions and examples.
  • +164/-1 
    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
  • Added part 2 of contributing guide for React components.
  • Included coding style, context provider, and controlled component
    examples.
  • Provided naming conventions and prop guidelines.
  • +212/-0 
    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
  • Added part 1 of contributing guide for React components.
  • Included workflow for creating and documenting a component.
  • Provided steps for exporting, building, and testing components.
  • +191/-0 
    react-documentation-site.page.mdx
    Add guide for contributing to documentation site                 

    packages/react-docs/pages/contributing/react-documentation-site.page.mdx
  • Added guide for contributing to the documentation site.
  • Explained directory structure and page creation.
  • Provided instructions for writing component API documentation.
  • +118/-0 
    publishing.page.mdx
    Add guide for publishing packages and release notes           

    packages/react-docs/pages/contributing/publishing.page.mdx
  • Added guide for publishing packages to NPM.
  • Included steps for generating GitHub release notes.
  • Provided example release notes format.
  • +65/-0   
    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
  • Added guide for pull request review process.
  • Introduced CodiumAI PR-Agent for automated analysis.
  • Provided usage instructions for PR-Agent commands.
  • +79/-0   
    react-icons.page.mdx
    Add guide for contributing to React Icons                               

    packages/react-docs/pages/contributing/react-icons.page.mdx
  • Added guide for contributing to React Icons.
  • Included steps for updating dependencies and generating icons.
  • Provided verification and submission instructions.
  • +61/-0   
    LICENSE
    Add MIT License for changelog-github package                         

    packages/changelog-github/LICENSE
  • Added MIT License file for changelog-github package.
  • Specified terms and conditions for software usage.
  • +21/-0   
    README.md
    Add README for Changesets configuration                                   

    .changeset/README.md
  • Added README for Changesets configuration.
  • Provided links to Changesets documentation.
  • +8/-0     

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codesandbox[bot] commented 2 months ago

    Review or Edit in CodeSandbox

    Open the branch in Web EditorVS CodeInsiders
    Open Preview

    changeset-bot[bot] commented 2 months ago

    โš ๏ธ No Changeset found

    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.

    This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    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

    codiumai-pr-agent-free[bot] commented 2 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ 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.
    codiumai-pr-agent-free[bot] commented 2 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    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 secret
    scanning 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]: 9 Why: 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 help
    users 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]: 8 Why: 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 after
    successful 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]: 8 Why: 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]: 7 Why: 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 the defaultIsExpanded 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]: 8 Why: 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 the
    workflow 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]: 8 Why: 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 pull
    request 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//tonic-ui.git cd tonic-ui ``` +## Running Tests Locally + +Before submitting a pull request, it's important to run tests locally to ensure code quality. Follow these steps: + +1. Install dependencies if you haven't already: +```bash +yarn +``` + +2. Run the test suite: +```bash +yarn test +``` + +3. Ensure all tests pass before proceeding with your pull request. + ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: 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 across
    contributions.** [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]: 7 Why: 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 to
    catch 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]: 7 Why: 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 found
    to 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]: 6 Why: 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

    trendmicro-frontend-bot commented 2 months ago

    Tonic UI Demo

    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/