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: stripe/tempo-lints@v1
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 |
# Run directly with npx
npx @stripe/tempo-lints rust ./src
npx @stripe/tempo-lints typescript
npx @stripe/tempo-lints all --json
# Or install globally
npm install -g @stripe/tempo-lints
tempo-lints rust ./src# Using the CLI vendor command (recommended)
npx @stripe/tempo-lints vendor --lang rust --dest /path/to/your-project
npx @stripe/tempo-lints vendor --lang typescript --dest /path/to/your-project
npx @stripe/tempo-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.ymltempo-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:
tempo-lints rust
tempo-lints typescript ./src
tempo-lints all --json
tempo-lints rust --exclude no-dbg-macro,no-unwrap-in-lib
tempo-lints typescript --fix
tempo-lints rust --github-action # For CI with annotations
Vendor Subcommand:
tempo-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:
tempo-lints vendor --lang rust --dest ./my-project
tempo-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 rules/rust/sgconfig.yml /path/to/code- Fork this repo
- Add or modify rules
- Run
npm testto verify - Open a PR with description of the rule and rationale