Rule catalog
Slop Block is a set of ast-grep rules that agents run after editing Rust, TypeScript, Dart and Java code; the README explains how to set them up.
51 of 51 rules
no-abbreviations
WarningUse full words in bindings, parameters, functions, fields and type names.
idis the only allowed abbreviation.WarningNaming- Rust
- TypeScript
- Dart
- Java
Naming- Rust
- TypeScript
- Dart
- Java
Avoid
.filter().map()and.map().filter()on arrays. Without type information, objects with similar methods also match.HintPerformance- TypeScript
Performance- TypeScript
no-async-fn-in-traits
WarningTrait methods return
impl Future<Output = T>. Implementations may useasync fn.WarningIdioms- Rust
Idioms- Rust
Do not chain type assertions such as
x as unknown as User.ErrorTypes- TypeScript
Types- TypeScript
- Comments
- Rust
- TypeScript
- Dart
- Java
Do not spread a conditional object with an empty branch, such as
...(condition ? { value } : {}).WarningIdioms- TypeScript
Idioms- TypeScript
no-debug-output
WarningRemove debug output:
println!/dbg!,console.log/debugger,print/debugPrint, orSystem.out/printStackTrace.WarningLogging- Rust
- TypeScript
- Dart
- Java
Logging- Rust
- TypeScript
- Dart
- Java
no-default-exports
WarningUse named exports. The rule skips config files and Expo Router routes. Use an
ast-grep-ignorecomment for any other framework entry point that needs a default export.WarningOrganization- TypeScript
Organization- TypeScript
no-else
ErrorAvoid
elseandelse if. Return, continue or break early, or usematch/switch. Rust's let-else is allowed.ErrorControl flow- Rust
- TypeScript
- Dart
- Java
Control flow- Rust
- TypeScript
- Dart
- Java
Keep suppressions local: no
#![allow],/* eslint-disable */,@ts-nocheckorignore_for_file.WarningComments- Rust
- TypeScript
- Dart
Comments- Rust
- TypeScript
- Dart
no-grouped-imports
ErrorSplit
use a::{B, C};intouse a::B;anduse a::C;on separate lines.ErrorOrganization- Rust
Organization- Rust
- Types
- Rust
no-inline-properties-type
WarningDeclare component properties as a named type. Do not write an object type literal in the parameter.
WarningTypes- TypeScript
Types- TypeScript
no-known-value-widening
WarningDo not annotate literals as
unknown,objectorRecord<string, T>. Usesatisfiesto keep the inferred keys.WarningTypes- TypeScript
Types- TypeScript
- Types
- TypeScript
no-reduce-accumulator-copy
WarningDo not copy a growing reducer accumulator with spreads,
concatorslice.WarningPerformance- TypeScript
Performance- TypeScript
- Types
- TypeScript
no-runtime-typeof
WarningAvoid
typeofnarrowing, except comparisons with"undefined".WarningTypes- TypeScript
Types- TypeScript
no-section-comments
WarningRemove separator comments such as
// ─── Section ───or// #region.WarningComments- Rust
- TypeScript
- Dart
- Java
Comments- Rust
- TypeScript
- Dart
- Java
- Naming
- Rust
- TypeScript
- Dart
- Java
no-single-statement-braces
WarningAutomatic fixDrop braces around a single-line statement when the
ifhas noelse. TypeScript puts the statement on the next line; Dart and Java keep it on the same line.ast-grep scan --update-allfixes it.WarningAutomatic fixControl flow- TypeScript
- Dart
- Java
Control flow- TypeScript
- Dart
- Java
no-tracing-macro-imports
WarningCall tracing macros by path, as in
tracing::debug!(...), instead of importing them.WarningLogging- Rust
Logging- Rust
Use concrete parameter types. Avoid
unknown,dynamicandObject. TypeScript allowscauseand type-predicate parameters; Dart allowsoperator ==.ErrorTypes- TypeScript
- Dart
Types- TypeScript
- Dart
no-unknown-returns
ErrorDeclare a concrete return type, not
unknown,dynamic,Objector theirPromise/Futureforms.ErrorTypes- TypeScript
- Dart
Types- TypeScript
- Dart
Do not alias
unknown(TypeScript) ordynamic(Dart).ErrorTypes- TypeScript
- Dart
Types- TypeScript
- Dart
Give dictionary values a concrete type. Generic constraints such as
T extends Record<string, unknown>are allowed.ErrorTypes- TypeScript
- Dart
Types- TypeScript
- Dart
no-unwrap
ErrorPropagate errors with
?. Code under#[cfg(test)]and intests/may unwrap.ErrorError handling- Rust
Error handling- Rust
prefer-early-continue
WarningWhen a loop body is a single
if, invert the condition andcontinueearly.WarningControl flow- Rust
- TypeScript
- Dart
- Java
Control flow- Rust
- TypeScript
- Dart
- Java
Consider a trait method when a free function takes
&PgPool,&Contextor a similar type first.HintIdioms- Rust
Idioms- Rust
prefer-function-components
WarningDeclare React components with
function, not as arrow functions assigned to aconst.WarningIdioms- TypeScript
Idioms- TypeScript
prefer-guard-clause
WarningWhen a function body is a single
if, invert the condition and return early.WarningControl flow- Rust
- TypeScript
- Dart
- Java
Control flow- Rust
- TypeScript
- Dart
- Java
prefer-type-alias
WarningDeclare object types with
type.interfaceis allowed only insidedeclare moduleanddeclare global.WarningTypes- TypeScript
Types- TypeScript
Leave a blank line after a one-line guard such as
if (index < 0) return;.WarningSpacing- Dart
- Java
Spacing- Dart
- Java
Leave a blank line after a multi-line statement, such as a control-flow block, an
ifor loop without braces, a method chain or a multi-line literal.WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Leave a blank line before a comment inside a body, unless it is the first line of the block or continues another comment.
WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Leave a blank line before a multi-line
if, loop,match,switchortry, even when it checks the value declared on the line above. The rule skips one-line guards in Dart and Java.WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Separate the final
returnof a function or closure body from the statements above it, even when the body has two statements.ifbodies and match arms are skipped.WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Separate struct fields, enum variants and class fields that have doc comments with blank lines.
WarningSpacing- Rust
- Dart
- Java
Spacing- Rust
- Dart
- Java
Separate import groups with one blank line and keep the imports of a group together.
WarningSpacing- TypeScript
Spacing- TypeScript
Leave a blank line after each multi-line member of an
impl,trait,modor class body.WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Separate multi-line top-level declarations with a blank line. Single-line declarations and imports can stay grouped.
WarningSpacing- Rust
- TypeScript
- Dart
- Java
Spacing- Rust
- TypeScript
- Dart
- Java
Put a single-statement
returnorthrowon the line after theifcondition, with or without braces.WarningControl flow- TypeScript
Control flow- TypeScript
require-explicit-return
ErrorAutomatic fixEnd functions and block closures with
return value;.ast-grep scan --update-allfixes it.ErrorAutomatic fixControl flow- Rust
Control flow- Rust
A local trait implemented for a foreign type, such as
PgPool,SchemaBuilderorContext, ends inExtension.WarningNaming- Rust
Naming- Rust
require-impl-after-trait
WarningWhen a file declares and implements a trait, the first
implcomes right after the trait.WarningOrganization- Rust
Organization- Rust
In an inherent
impl, putnewfirst and public methods before private ones.HintOrganization- Rust
Organization- Rust
require-import-group-order
WarningOrder imports by group: side-effect, type, built-in, external, index, then internal and relative, then virtual modules.
WarningOrganization- TypeScript
Organization- TypeScript
Put private
usedeclarations beforemoddeclarations.WarningOrganization- Rust
Organization- Rust
Give a reason for each suppression:
#[allow],eslint-disable-next-line,@ts-expect-erroror// ignore:.WarningComments- Rust
- TypeScript
- Dart
Comments- Rust
- TypeScript
- Dart
Sort the names in an import list alphabetically by local name, ignoring case. The check compares first letters only.
HintOrganization- TypeScript
Organization- TypeScript
require-uppercase-acronyms
WarningUse all capitals for acronyms in type, variant and method names, as in
UserIDandParseURL.WarningNaming- Rust
- Java
Naming- Rust
- Java