完成0.3.0版本#2
Conversation
- 新增映射规则支持 - 新增 TransformOptions 接口 - 新增 FilterRuleItem 和 MapRuleItem 类型 - 改进 transform 函数功能 - 添加完整的 CHANGELOG.md
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces version 0.3.0 of the postcss-wrap-up-layer plugin with significant enhancements including map rules support, transform options configuration, improved development tooling, and comprehensive test coverage. The update maintains backward compatibility while adding powerful new features for dynamic layer name generation.
- Added map rules functionality for dynamic layer name generation based on file paths
- Introduced transform options to control which at-rules stay outside @layer blocks
- Enhanced development environment with devcontainer, GitHub Actions CI/CD, and updated tooling
Reviewed Changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils.ts | New utility file defining FilterRuleItem, MapRuleItem interfaces and type guards |
| src/transform.ts | Enhanced transform function with TransformOptions interface and configurable outsideAtRules |
| src/index.ts | Updated main plugin logic to support both filter and map rules with transform options |
| tsconfig.main.json | Updated TypeScript configuration to extend Node.js 22 config and added verbatimModuleSyntax |
| package.json | Version bump to 0.3.0 with updated dependencies and build scripts |
| tests/*.test.ts | Expanded test suite covering new functionality and type definitions |
| README.md | Updated documentation with examples for new features and comprehensive API reference |
| CHANGELOG.md | Added comprehensive changelog following "Keep a Changelog" format |
| .github/workflows/tests.yml | New GitHub Actions workflow for automated testing across Node.js versions |
| .devcontainer/devcontainer.json | Development container configuration for consistent development environment |
Comments suppressed due to low confidence (1)
tests/index.test.ts:305
- The test for unknown rule types uses @ts-expect-error but doesn't verify runtime behavior. Consider adding assertions to ensure unknown rule types are properly filtered out or handled gracefully.
// @ts-expect-error - unknown rule type
| import { transform } from './transform'; | ||
| import { transform, type TransformOptions } from './transform.js'; | ||
| import { isFilterRule, isMapRule, type RuleItem } from './utils.js'; | ||
| export type { RuleItem, FilterRuleItem, MapRuleItem } from './utils.js'; |
There was a problem hiding this comment.
[nitpick] Consider placing type exports at the end of the file after the main plugin export to follow conventional TypeScript module organization patterns.
| } else if (isMapRule(rule)) { | ||
| const mapResult = rule.map(path, source.input); | ||
| if (typeof mapResult === 'string') { | ||
| root.nodes = transform(nodes, mapResult, root.source, Object.assign({}, opts.transformOptions)); |
There was a problem hiding this comment.
The Object.assign pattern is used inconsistently. Consider using the spread operator { ...opts.transformOptions } for consistency with line 49, or use Object.assign consistently throughout.
| root.nodes = transform(nodes, mapResult, root.source, Object.assign({}, opts.transformOptions)); | |
| root.nodes = transform(nodes, mapResult, root.source, { ...opts.transformOptions }); |
This pull request introduces several significant updates to the project, including the addition of a development container, a GitHub Actions workflow for testing, enhancements to documentation, and expanded test coverage. Below is a breakdown of the most important changes:
Development Environment Enhancements
.devcontainer/devcontainer.jsonto streamline setup with a pre-configured TypeScript Node environment and useful VS Code extensions.Continuous Integration
.github/workflows/tests.ymlto automate testing across Node.js versions 18, 20, and 22. The workflow also uploads code coverage reports to Codecov.Documentation Improvements
CHANGELOG.mdfile following the "Keep a Changelog" format to document all notable changes in the project.README.mdandREADME.zh-CN.mdwith examples for new features, such as map rules, transform options, and nested processing. Added a Codecov badge to indicate test coverage. [1] [2] [3] [4] [5] [6]Feature Enhancements
__tests__/index.test.tsto include both filter and map rule scenarios, ensuring comprehensive coverage of the new functionality. [1] [2] [3]These changes collectively improve the project's development experience, testing reliability, and documentation clarity.