no-httpinterceptor-class
August 20, 2026 · View on GitHub
Restrict the usage of HttpInterceptor which was the way to declare a legacy class-based interceptor.
Use HttpInterceptorFn with a functional interceptor instead.
Documentation
Configuration
- in the
recommendedpreset - in the
functionalpreset - or just this rule:
{
rules: {
'eslint-plugin-angular-modern/no-httpinterceptor-class': 'error'
}
}
Tip
See the README for the global and presets configuration.
❌ Invalid
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
return next.handle(req);
}
}
✅ Valid
export const authInterceptor: HttpInterceptorFn = (req, next) => {
return next(req);
};