Dependency Management
Relevant source files
The following files were used as context for generating this wiki page:
Dependency management in nth-check is handled primarily through package.json, which defines the production dependencies, development tools, and environment constraints for the project. The project follows a minimalist approach to production dependencies to maintain a small footprint and high performance, while utilizing a robust suite of development tools for linting, formatting, and testing.
The project is structured as a TypeScript-based ECMAScript module (type: module), requiring Node.js version 20.19.0 or higher. It produces distribution files in the dist/ directory, including type definitions for consumers.
Sources: package.json:2-10, package.json:54-56, tsconfig.json:8-9
Production Dependencies
The project maintains a single production dependency, which is utilized for handling edge cases in CSS selector logic where a formula results in a function that always returns false or true.
| Dependency | Version | Purpose |
|---|---|---|
boolbase | ^2.0.0 | Provides standard trueFunc and falseFunc for optimized return values. |
Sources: package.json:58-60, src/compile.ts:1
Integration with Core Logic
The boolbase dependency is integrated within the compilation logic to return optimized functions when a formula is determined to match no elements or all elements based on the CSS nth-child specification.
Sources: src/compile.ts:38-43
Development Environment and Tooling
The development dependencies are categorized into three main areas: language support (TypeScript), code quality (ESLint and Biome), and testing (Vitest).
Tooling Overview
| Category | Packages | Description |
|---|---|---|
| Language | typescript, @types/node | Provides static typing and Node.js environment types. |
| Linting/Formatting | eslint, @biomejs/biome, typescript-eslint | Ensures code style consistency and identifies potential bugs. |
| Testing | vitest | Executes unit tests and performance checks. |
Sources: package.json:61-70
Build and Linting Workflows
The project defines specific scripts to manage the lifecycle of the code, from formatting to distribution.
Sources: package.json:23-34
Configuration Management
Dependencies and environment settings are further managed through specific configuration files that dictate how tools interact with the source code.
TypeScript Configuration
The project uses tsconfig.json to define compiler behavior, targeting es2022 and using nodenext for module resolution to ensure compatibility with modern Node.js ESM standards.
Sources: tsconfig.json:3-6
Biome and ESLint Integration
The project employs both Biome and ESLint for overlapping but complementary code quality checks. Biome is configured via biome.json to handle formatting (using spaces with a width of 4) and a variety of linting rules focusing on performance and style.
{
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"performance": {
"useTopLevelRegex": "error"
}
}
}
}
Sources: biome.json:14-25
Conclusion
nth-check follows a highly disciplined dependency strategy, relying on a single external utility (boolbase) for its runtime operations. This minimizes the risk of supply chain vulnerabilities and keeps the package lightweight. The extensive list of development dependencies reflects a commitment to modern development practices, including strict type checking, automated formatting, and comprehensive testing via Vitest.