Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
pull_request:
push:
branches:
- develop
- main

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.30.3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Verify
run: pnpm run verify

58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
release-type: node

- name: Checkout
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4

- name: Setup pnpm
if: ${{ steps.release.outputs.release_created }}
uses: pnpm/action-setup@v4
with:
version: 10.30.3

- name: Setup Node.js
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org/

- name: Update npm
if: ${{ steps.release.outputs.release_created }}
run: npm install --global npm@latest

- name: Install dependencies
if: ${{ steps.release.outputs.release_created }}
run: pnpm install --frozen-lockfile

- name: Verify
if: ${{ steps.release.outputs.release_created }}
run: pnpm run verify

- name: Publish to npm
if: ${{ steps.release.outputs.release_created }}
run: npm publish --provenance --access public
env:
HUSKY: 0
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
.idea/
.claude/

node_modules/
dist/
coverage/
.rslib/
.rstest/
.rsbuild/

*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm exec commitlint --edit "$1"

2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm exec lint-staged

2 changes: 2 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm run test && pnpm run build

3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
engine-strict=false
fund=false

2 changes: 2 additions & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
22

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.

This project uses Conventional Commits and Release Please to generate releases.

## 0.0.1 - 2026-05-02

### Added

- Initial npm package scaffold.
- TypeScript source entrypoint.
- Rslib dual ESM/CommonJS build with TypeScript declarations.
- Rstest, Biome, publint, commitlint, and Husky development workflow.
- GitHub Actions workflows for CI, Release Please, and npm Trusted Publishing.
166 changes: 166 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Contributing

Thanks for taking the time to improve `srcset-kit`.

This package is intentionally small: it parses, validates, and serializes HTML
`srcset` values without runtime dependencies. Contributions are most helpful
when they keep that focus clear.

## Getting Started

Requirements:

- Node.js 22 or newer;
- pnpm 10 or newer.

Install dependencies:

```sh
pnpm install
```

Run the full local check:

```sh
pnpm run verify
```

`verify` is the same kind of check expected before a release. It runs formatting
checks, linting, type checking, tests, the production build, and package export
validation.

## Useful Commands

Use the full check before opening a pull request:

```sh
pnpm run verify
```

Use focused commands while developing:

```sh
pnpm run test
pnpm run test:watch
pnpm run typecheck
pnpm run lint
pnpm run format
pnpm run format:check
pnpm run build
pnpm run pack:check
```

## Project Shape

The main files are:

- `src/parse.ts` for the public parser entrypoint;
- `src/parser.ts` for internal tokenization;
- `src/validator.ts` for validation rules and issue codes;
- `src/stringify.ts` for serialization;
- `src/types.ts` for public types;
- `src/errors.ts` for package-specific errors;
- `tests/index.test.ts` for behavior coverage;
- `README.md` for public examples and user-facing API docs.

## Public API Changes

Keep the public surface small and intentional. The runtime API is:

- `parse`;
- `validate`;
- `stringify`.

When changing public behavior, update these together:

- exported types in `src/types.ts`;
- exports in `src/index.ts`;
- user-facing examples in `README.md`;
- tests in `tests/index.test.ts`.

Please avoid adding dependencies unless the benefit is clearly worth the extra
package weight.

## Testing Guidelines

Add focused tests for the behavior you change.

Parser changes should cover cases like:

- commas inside URLs;
- `data:` URLs;
- relative and absolute URLs;
- query strings and fragments;
- whitespace and newlines;
- tolerant parsing of invalid descriptor sets.

Validator changes should assert stable issue codes, not only messages.

Stringifier changes should cover normalized output and round trips with
`parse()` when possible.

If object validation changes, add candidate-array tests in addition to string
input tests.

## Documentation Guidelines

Keep README examples short, copyable, and aligned with the actual API.

If a feature affects how users call `parse`, `validate`, or `stringify`, update
the README in the same pull request. Use the repository's TypeScript formatting
style in examples, including compact object and import braces:

```ts
import {parse, validate} from "srcset-kit";

validate([{url: "image.png", density: 1}]);
```

## Commits

This repository uses Conventional Commits. Examples:

```text
feat: add srcset parser
fix: keep descriptor whitespace valid
docs: improve validation examples
chore(release): merge main back into develop
```

Husky runs `commitlint` for commit messages.

## Branch Flow

The repository follows a GitFlow-like process without requiring the GitFlow CLI:

- feature and fix pull requests target `develop`;
- release pull requests merge `develop` into `main`;
- Release Please creates a release pull request in `main`;
- after the release pull request is merged, GitHub Release and npm publishing run automatically;
- merge `main` back into `develop` after every release so `develop` receives the version, changelog, and lockfile updates.

When a merge commit is created manually, keep the merge message conventional:

```text
chore(release): merge main back into develop
feat: merge feature/parser
```

## Hooks

Husky hooks are installed by `pnpm install`.

- `pre-commit` formats staged files with Biome through lint-staged and keeps the formatted result in the current commit.
- `commit-msg` validates Conventional Commits.
- `pre-push` runs tests and the build.

## Release Readiness

Before a release, make sure:

- `pnpm run verify` passes;
- README examples match the exported API;
- public type changes are covered by tests;
- `CHANGELOG.md` is ready for the release flow;
- package metadata in `package.json` still matches the published package;
- the license file remains `LICENSE.md`.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# MIT License

Copyright (c): Anjey Tsibylskij

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading
Loading