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 .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Changesets

Hello! 👋

This folder contains [Changesets](https://github.com/changesets/changesets) for the project. Changesets help us manage version bumps and changelogs.

## Creating a Changeset

When you make a change that should be included in the next release, create a changeset by running:

```bash
pnpm changeset
```

This will:
1. Ask you to select the type of change (patch, minor, or major)
2. Prompt you to write a summary of the change
3. Create a new changeset file in this directory

## What gets a changeset?

Create a changeset for:
- Bug fixes (patch)
- New features (minor)
- Breaking changes (major)
- Documentation improvements (patch)
- Performance improvements (patch)

## Releasing

When changesets are merged to `main`, our release workflow will:
1. Create a "Version Packages" PR that consumes all changesets
2. Update the version in `package.json`
3. Update `CHANGELOG.md`
4. When the Version Packages PR is merged, create a GitHub Release with the changelog

For more information, see the [Changesets documentation](https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md).
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/tired-experts-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tempoxyz/lints": patch
---

initialize github package
139 changes: 139 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Contributing to Tempo Lints

Thank you for your interest in contributing! This guide will help you get started.

## Development Setup

1. **Clone the repository:**
```bash
git clone https://github.com/tempoxyz/lints.git
cd lints
```

2. **Install dependencies:**
```bash
pnpm install
```

3. **Verify everything works:**
```bash
pnpm test
pnpm typecheck
pnpm lint
```

## Making Changes

1. **Create a new branch:**
```bash
git checkout -b your-feature-name
```

2. **Make your changes:**
- Add or modify lint rules in `src/rust/rules/` or `src/typescript/rules/`
- Add tests in `src/*/tests/`
- Update documentation if needed

3. **Test your changes:**
```bash
# Run all tests
pnpm test

# Run specific language tests
pnpm test:rust
pnpm test:typescript

# Type check
pnpm typecheck

# Lint
pnpm lint
```

4. **Create a changeset:**

Before committing, create a changeset to document your changes:

```bash
pnpm changeset
```

This will prompt you to:
- Select the type of change (patch/minor/major)
- Write a summary of your change

The changeset file will be committed along with your changes.

**Change types:**
- **Patch** (`0.0.x`): Bug fixes, documentation updates, minor improvements
- **Minor** (`0.x.0`): New features, new rules, backward-compatible changes
- **Major** (`x.0.0`): Breaking changes (rarely needed)

5. **Commit your changes:**
```bash
git add .
git commit -m "feat: add new rule for xyz"
```

6. **Push and create a pull request:**
```bash
git push origin your-feature-name
```

Then create a PR on GitHub.

## Release Process

Releases are automated using Changesets:

1. When PRs with changesets are merged to `main`, a "Version Packages" PR is automatically created
2. The Version Packages PR:
- Bumps the version in `package.json`
- Updates `CHANGELOG.md` with all changeset summaries
- Deletes the consumed changeset files
3. When maintainers merge the Version Packages PR:
- A GitHub Release is created
- Git tags are created and pushed
- Major version tags (e.g., `v0`, `v1`) are updated to point to the latest release

## Adding New Rules

To add a new lint rule:

1. **Create the rule file:**
```
src/rust/rules/your-rule-name.yml
# or
src/typescript/rules/your-rule-name.yml
```

2. **Add test cases:**
```
src/rust/tests/your-rule-name-test.yml
# or
src/typescript/tests/your-rule-name-test.yml
```

3. **Run tests to generate snapshots:**
```bash
pnpm test
```

4. **Document the rule:**
- Add description and rationale to the rule YAML file
- Update README.md if the rule is noteworthy

## Code Style

- We use [Biome](https://biomejs.dev/) for linting and formatting
- Run `pnpm check` to format code automatically
- Run `pnpm lint` to check for issues

## Questions?

If you have questions or need help:
- Open an issue on GitHub
- Check existing issues for similar questions
- Review the [ast-grep documentation](https://ast-grep.github.io/)

Thank you for contributing! 🎉
69 changes: 69 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Update Release Tags

on:
release:
types: [published]

permissions:
contents: write

jobs:
update-tags:
name: Update major version tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Update major version tag
run: |
# Get the release tag (e.g., v1.2.3)
TAG="${{ github.event.release.tag_name }}"

# Extract major version (e.g., v1)
if [[ $TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR_TAG="v${BASH_REMATCH[1]}"

echo "Updating $MAJOR_TAG to point to $TAG"

# Safety check: ensure we're not downgrading
if git rev-parse "$MAJOR_TAG" >/dev/null 2>&1; then
echo "Existing $MAJOR_TAG found, verifying this is not a downgrade..."
CURRENT_COMMIT=$(git rev-list -n 1 "$MAJOR_TAG")
NEW_COMMIT=$(git rev-list -n 1 "$TAG")

# Check if new tag is ancestor of current (would be a downgrade)
if git merge-base --is-ancestor "$NEW_COMMIT" "$CURRENT_COMMIT" 2>/dev/null; then
if [ "$NEW_COMMIT" != "$CURRENT_COMMIT" ]; then
echo "Error: $TAG ($NEW_COMMIT) is an ancestor of current $MAJOR_TAG ($CURRENT_COMMIT)"
echo "This would be a downgrade. Aborting."
exit 1
fi
fi
echo "Safety check passed"
else
echo "No existing $MAJOR_TAG found, creating new tag"
fi

# Create and force push the major version tag
git tag -f "$MAJOR_TAG" "$TAG"
if ! git push --force origin "$MAJOR_TAG"; then
echo "Error: Failed to push $MAJOR_TAG"
exit 1
fi

echo "Successfully updated $MAJOR_TAG to $TAG"
else
echo "Tag $TAG does not match expected format (vX.Y.Z)"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Enable Corepack
run: corepack enable

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

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

- name: Run tests and linting
run: |
pnpm test
pnpm lint

- name: Create Release PR or Tag
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version
publish: pnpm run release
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
if: steps.changesets.outputs.published == 'true'
run: |
# Get the version from package.json using jq
VERSION=$(jq -r '.version' package.json)
TAG="v${VERSION}"

# Wait for tag to be available (changesets creates it asynchronously)
# Total wait time: 20 seconds (10 attempts × 2 seconds)
MAX_ATTEMPTS=10
SLEEP_SECONDS=2
echo "Waiting for tag $TAG to be available..."
for i in $(seq 1 $MAX_ATTEMPTS); do
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG found"
break
fi
if [ $i -eq $MAX_ATTEMPTS ]; then
echo "Error: Tag $TAG not found after waiting ${MAX_ATTEMPTS} attempts ($(($MAX_ATTEMPTS * $SLEEP_SECONDS)) seconds total)"
exit 1
fi
echo "Attempt $i/$MAX_ATTEMPTS: Tag not yet available, waiting..."
sleep $SLEEP_SECONDS
done

# Create GitHub release using gh CLI
gh release create "$TAG" \
--title "$TAG" \
--notes "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @stripe/tempo-lints
# @tempoxyz/lints

## 0.1.0

Expand All @@ -7,5 +7,5 @@
- Initial release of Tempo Lints
- Rust rules: `no-dbg-macro`, `no-mem-transmute`, `no-unwrap-in-lib`, `unsafe-needs-safety-comment`, `tracing-no-format`, `no-emojis`, `no-leading-whitespace-strings`
- TypeScript rules: `no-console-log`, `no-explicit-any`, `no-non-null-assertion`, `no-await-in-loop`, `prefer-const`, `no-emojis`, `no-leading-whitespace-strings`
- CLI with `npx @stripe/tempo-lints` support
- CLI with `npx @tempoxyz/lints` support
- GitHub Action for CI integration
Loading