Skip to content

Instantly share code, notes, and snippets.

@htunnicliff
Created June 3, 2025 03:25
Show Gist options
  • Save htunnicliff/a7914590c1d92a038ce74721922af723 to your computer and use it in GitHub Desktop.
Save htunnicliff/a7914590c1d92a038ce74721922af723 to your computer and use it in GitHub Desktop.
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json
id: bad-type-imports
message: Cannot use type keyword within a type import
severity: error
language: TypeScript
rule:
kind: import_specifier
pattern: type $IMPORT
inside:
kind: named_imports
inside:
kind: import_clause
follows:
regex: type
rewriters:
- id: remove-bad-type
rule:
kind: import_specifier
fix: '$IMPORT'
transform:
LITERAL:
rewrite:
rewriters: [remove-bad-type]
source: $IMPORT
fix: '$LITERAL'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment