Dev - #16
Merged
Merged
Conversation
- Updated package name from "@fabidev/jsx-utils" to "@fabi-dev/jsx-utils"
- Create a new workflow for basic integrity checks on pull requests - Set up Node.js environment and install dependencies - Run build and test commands as part of the CI process
- Changed test script to exit with code 0 instead of 1 - Added a build script placeholder
…egrity Ci/add basic GitHub ci for integrity
- Correct package name format in package-lock.json and package.json - Add devDependencies for @types/react and react - Ensure peerDependencies for react are properly defined
- Added @testing-library/jest-dom and @testing-library/react for testing. - Included jsdom, publint, tsup, and vitest for improved development tools. - Updated TypeScript version to ^6.0.3.
Agent-Logs-Url: https://github.com/FabioGaming/jsx-utils/sessions/1984e615-ac4d-421e-9d3e-dbe477140e34 Co-authored-by: FabioGaming <61352968+FabioGaming@users.noreply.github.com>
Chore/add dependencies
- Added Prettier version 3.8.3 to package.json and package-lock.json
- Set print width to 80 characters - Use 2 spaces for indentation - Enable semicolons and disable single quotes - Configure trailing commas for ES5 - Require parentheses for arrow functions - Set line endings to LF
- Exclude node_modules, dist, and package-lock.json from Prettier formatting
- Created a new file for placeholder functionality.
- Added "format:check" script to check code formatting with Prettier. - Added "format:write" script to automatically format code with Prettier.
Added format:check step in integrity ci workflow
Feat/add prettier
- Exclude .vscode/settings.json and .vscode/extensions.json from .gitignore
- Added a new extensions.json file with recommended VSCode extensions. - Includes Prettier, ESLint, and TypeScript support.
- Enable format on save - Set default formatter to Prettier - Configure code actions to fix all issues on save
Core/add vscode editor configs
- Set importModuleSpecifier to "non-relative" - Set importModuleSpecifierEnding to "minimal"
- Set compiler options for TypeScript project - Include paths and module resolution settings - Enable strict type checking and declaration generation
Chore/add tsconfig
- Set up entry point for TypeScript compilation - Specify output formats: ESM and CJS - Enable TypeScript declaration files and source maps - Clean output directory before build - Mark 'react' as an external dependency
- Changed the build script from a placeholder to use tsup for building the project.
- Added "ignoreDeprecations": "6.0" to compilerOptions in tsconfig.json
chore(tsup): add initial tsup configuration file
- Set "test" script to run Vitest - Updated "test:run" script to execute Vitest in run mode
- Set up Vitest with jsdom environment - Enable global variables and specify setup files
- Import "@testing-library/jest-dom" to enhance testing capabilities.
- Implement tests to verify rendering of items in For component. - Ensure that both "a" and "b" are correctly displayed.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Added tests for rendering items, including handling empty arrays. - Verified index passing to the render function. - Included tests for rendering single items, objects, and numbers.
Feat/add for component
- Added tests for rendering children with truthy values (non-boolean). - Included tests for rendering fallback with falsy values (0, empty string, null, undefined). - Added tests for rendering complex JSX children and fallback. - Verified behavior when no fallback is provided and condition is false.
…component test(Show): add additional tests for Show component behavior
- Introduced Match component to render children based on a condition. - Defined MatchProps type for component props.
feat(Match): add Match component for conditional rendering
- Removed unused paths configuration - Ensured "test" directory is included in the compilation
chore(tsconfig): clean up tsconfig configuration
- Implemented the Switch component to render children based on Match conditions. - Utilizes React's Children API to process child elements.
- Updated import statement for Match and MatchProps to use relative path.
- Implement tests for rendering behavior of Switch and Match components. - Verify that no matches render when conditions are falsy. - Ensure the first truthy match is displayed correctly. - Check that non-Match children are ignored. - Test rendering of complex JSX from the first truthy match.
Feat/add switch component
- Import useState and fireEvent for testing state changes. - Implement a test to verify that the For component updates when the items state changes.
- Import fireEvent and useState for testing state changes. - Implement a new test to verify the Show component updates when the condition state changes.
- Introduced a new test to verify the behavior of the Switch component when state changes. - Added a Harness component to manage state and simulate button clicks. - Ensured that the correct Match component is rendered based on the current state.
…-tests Chore/finalize components and tests
- Export For, Match, Show, and Switch components from index file.
feat(index): add entry point exports for components
Contributor
There was a problem hiding this comment.
Pull request overview
Sets up the initial jsx-utils React component utility library, including core control-flow components, build/test tooling, and CI to support a publishable, well-tested package.
Changes:
- Added foundational React utility components:
For,Show,Match,Switch, and exported them fromsrc/index.ts. - Introduced Vitest + Testing Library setup with component test suites and a smoke test.
- Added bundling (tsup), TypeScript configuration, Prettier configuration, VSCode workspace settings, and a basic GitHub Actions CI workflow.
Reviewed changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Configures Vitest to run in jsdom with globals and a setup file. |
| tsup.config.ts | Adds tsup bundling config (ESM+CJS, dts, sourcemaps, externals). |
| tsconfig.json | Defines TS compilation options (strict, react-jsx, declarations). |
| src/index.ts | Re-exports public components from the library entrypoint. |
| src/components/For.tsx | Adds For list-render utility component. |
| src/components/Show.tsx | Adds Show conditional-render utility component. |
| src/components/Match.tsx | Adds Match branch component used by Switch. |
| src/components/Switch.tsx | Adds Switch first-truthy-match control-flow component. |
| test/For.test.tsx | Adds unit tests for For. |
| test/Show.test.tsx | Adds unit tests for Show. |
| test/Switch.test.tsx | Adds unit tests for Switch (and indirectly Match). |
| test/smoke.test.ts | Adds smoke tests for vitest + jsdom availability. |
| test/setup.ts | Loads @testing-library/jest-dom matchers. |
| package.json | Adds scripts and devDependencies for build/format/test; updates package name. |
| package-lock.json | Captures dependency lock for the new toolchain. |
| .prettierrc | Adds Prettier formatting rules. |
| .prettierignore | Excludes build artifacts and lockfile from Prettier. |
| .vscode/settings.json | Adds editor formatting/import preferences. |
| .vscode/extensions.json | Recommends editor extensions for the project. |
| .gitignore | Updates ignore rules and attempts to include VSCode settings files. |
| .github/workflows/integrity-ci.yml | Adds CI workflow to run format check, build, and tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+10
to
+11
| "format:check": "prettier src/ --check", | ||
| "format:write": "prettier src/ --write" |
- Verify rendering of children when 'when' prop is truthy - Ensure nothing is rendered when 'when' prop is falsy - Test updates to rendering based on state changes
…onent test(Match): add tests for Match component behavior
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request sets up a new React utility component library with a strong focus on developer experience, code quality, and testing. It introduces foundational components (
For,Show,Match,Switch), adds comprehensive tests, and configures formatting, build, and CI workflows. The most important changes are:Component Implementation:
For,Show,Match, andSwitchin thesrc/componentsdirectory, and re-exported them fromsrc/index.ts. These provide declarative control flow utilities for React. [1] [2] [3] [4] [5]Testing Infrastructure:
jest-dommatchers. [1] [2] [3] [4] [5]Build and Tooling Configuration:
tsup.config.tsfor TypeScript bundling and type declarations, and updatedpackage.jsonwith scripts for build, format, and test, as well as relevant dev dependencies. [1] [2]Code Quality and Editor Setup:
.prettierrcand.prettierignore, and set up VSCode recommendations and settings for consistent formatting and import management. [1] [2] [3] [4]Continuous Integration: