Shared ast-grep lint rules for Tempo projects.
This package requires ast-grep (sg CLI) to run lints.
macOS (Homebrew):
brew install ast-grepCargo (Rust):
cargo install ast-grep --lockednpm (global):
npm install -g @ast-grep/cliVerify installation:
sg --version
# Should output: ast-grep 0.25.x or higherNote: When using this package via npm/pnpm, the
@ast-grep/clidependency is included and installs thesgbinary automatically via postinstall.
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tempoxyz/lints@v0
with:
language: rust # or 'typescript' or 'all'Action Inputs:
| Input | Required | Default | Description |
|---|---|---|---|
language |
✅ | — | rust, typescript, or all |
path |
. |
Path to scan | |
fail-on-error |
true |
Fail if errors found | |
exclude-rules |
— | Comma-separated rule IDs to skip | |
fix |
false |
Apply auto-fixes where available | |
post-comment |
false |
Post results as PR comment | |
github-token |
— | Required if post-comment: true |
Install directly from GitHub:
# Install from GitHub
npm install github:tempoxyz/lints
# Run with npx
npx @tempoxyz/lints rust ./src
npx @tempoxyz/lints typescript
npx @tempoxyz/lints all --jsonOr use npx directly without installing:
npx github:tempoxyz/lints rust ./src# Using the CLI vendor command (recommended)
npx @tempoxyz/lints vendor --lang rust --dest /path/to/your-project
npx @tempoxyz/lints vendor --lang typescript --dest /path/to/your-project
npx @tempoxyz/lints vendor --lang all --dest /path/to/your-projectThis copies both language-specific rules and shared rules to .ast-grep/ and generates an sgconfig.yml.
After vendoring, run lints with:
ast-grep scan --config sgconfig.yml@tempoxyz/lints <language> [path] [options]
Arguments:
language Required: rust, typescript, or all
path Path to scan (default: current directory)
Options:
--exclude <rules> Comma-separated list of rules to exclude
--json Output results as JSON
--fix Apply auto-fixes where available
--github-action Output in GitHub Actions format with annotations
--help, -h Show help
--version, -v Show version
Examples:
npx @tempoxyz/lints rust
npx @tempoxyz/lints typescript ./src
npx @tempoxyz/lints all --json
npx @tempoxyz/lints rust --exclude no-dbg-macro,no-unwrap-in-lib
npx @tempoxyz/lints typescript --fix
npx @tempoxyz/lints rust --github-action # For CI with annotations
Vendor Subcommand:
npx @tempoxyz/lints vendor --lang <language> --dest <path>
Copy lint rules to a destination project for offline/locked usage.
Options:
--lang <language> Language rules to vendor (rust, typescript, or all)
--dest <path> Destination project path
Examples:
npx @tempoxyz/lints vendor --lang rust --dest ./my-project
npx @tempoxyz/lints vendor --lang all --dest /path/to/project
// ast-grep-ignore: no-emojis
let emoji = "🎉";// ast-grep-ignore: no-console-log
console.log("debug");// ast-grep-ignore-start
let emoji1 = "🎉";
let emoji2 = "🚀";
// ast-grep-ignore-end- Create the rule YAML in the appropriate
rules/directory - Add test cases in
rules/<language>/tests/<rule-id>-test.yml - Run
npm testto generate snapshots
# Install dependencies
npm install
# Test all rules
npm test
# Test specific language
npm run test:rust
npm run test:typescript
npm run test:shared-rules
# Update snapshots
npm run test:update-snapshots
# Typecheck
npm run typecheck
# Lint & format
npm run check
# Scan a directory manually
ast-grep scan --config src/rust/sgconfig.yml /path/to/codeThis package uses GitHub releases for distribution. When using the GitHub Action, you can pin to major versions:
- uses: tempoxyz/lints@v0 # Automatically uses latest v0.x.x
- uses: tempoxyz/lints@v0.2.1 # Pin to specific version
- uses: tempoxyz/lints@main # Use latest from main branch (not recommended)Major version tags (v0, v1, etc.) are automatically updated to point to the latest release in that major version.
We welcome contributions! Please see our Contributing Guide for details.
Quick start:
- Fork this repo
- Make your changes
- Create a changeset:
pnpm changeset - Run tests:
pnpm test - Open a PR
See .github/CONTRIBUTING.md for detailed instructions on:
- Development setup
- Creating changesets
- Adding new rules
- Release process