Skip to content

Linter ​

tyrus lint reports style, correctness, safety, performance, and architecture diagnostics that are separate from compiler errors. The linter reads tyrus-lint.json from the project root when it exists; omitted rules use their built-in default severity.

Commands ​

shell
tyrus lint
tyrus lint --fix
tyrus lint --format json
tyrus lint --max-warnings 0
tyrus lint --explain no-unused-vars
tyrus lint --init
tyrus lint --default

--fix applies deterministic safe fixes and then runs lint again. --format json emits machine-readable reports. --max-warnings 0 is useful for CI. --explain <rule> prints the rule documentation in the terminal. --init creates or updates tyrus-lint.json without changing configured severities. --default resets the file to built-in defaults.

Configuration ​

The file is a flat JSON object that maps rule names to severities. There is no extends, no presets, and no rules wrapper.

json
{
  "no-unused-vars": "warn",
  "no-unused-imports": "warn",
  "prefer-const": "warn",
  "no-unreachable-code": "error",
  "no-empty-block": "warn",
  "no-force-unwrap": "error",
  "no-null-literal": "error",
  "exhaustive-match": "error",
  "no-duplicate-case": "error",
  "no-shadow": "warn"
}
SeverityMeaning
offRule disabled.
infoInformational diagnostic.
warnWarning; does not fail CI by default.
errorError; exits with code 1.

Rules ​

RuleDefaultCategoryAutofixSummary
api-no-verb-in-pathwarnstylenoWarns when route paths use action verbs instead of resource-oriented paths.
api-prefer-resource-nounswarnstylenoWarns when route paths do not look like resource nouns.
controller-must-send-responseerrorcorrectnessnoRequires every controller success path to send a response.
controller-no-db-accesserrorsafetynoForbids direct database access from controllers.
controller-no-try-catchwarnsafetynoWarns when controllers catch expected errors instead of delegating mapping.
db-explicit-select-columnsinfostyleyesPrefers explicit SELECT projections and expands fields from the local result interface.
db-no-extra-select-columnsinfoperformancenoWarns when a typed query selects output columns that are not declared by its result interface.
exhaustive-matcherrorcorrectnessnoRequires match over closed types to cover every case.
http-no-raw-status-codewarnsafetynoSuggests HttpStatus instead of raw numeric response codes.
no-duplicate-caseerrorcorrectnessnoDetects duplicate switch or match cases.
no-duplicate-importserrorcorrectnessnoDetects multiple import declarations from the same module.
no-empty-blockwarnstylenoDetects empty blocks without an explanatory comment.
no-empty-catchwarnsafetynoDetects empty catch blocks without an explanatory comment.
no-floating-enumerrorcorrectnessnoForbids f64/f128 values in enums.
no-force-unwraperrorsafetynoForbids forced optional unwrap with expr!.
no-heterogeneous-enumerrorcorrectnessnoForbids mixing primitive value types inside one enum.
no-implicit-enum-primitive-casterrorsafetynoRequires explicit as casts from enum values to primitives.
no-implicit-heavy-movewarnperformancenoWarns about surprising moves of large or non-Copy values.
no-layer-skipwarnsafetynoWarns when API code skips route-controller-service-repository layering.
no-null-literalerrorcorrectnessnoForbids the null keyword; use T?, optional fields, and ??.
no-shadowwarnstylenoDetects bindings that shadow enclosing bindings.
no-string-concat-in-loopwarnperformancenoDetects repeated string concatenation inside loops.
no-uninitialized-variablewarncorrectnessnoSurfaces definite-assignment diagnostics for deferred let x: T;.
no-unnecessary-allocationinfoperformancenoDetects clearly unnecessary allocations.
no-unnecessary-awaitwarnstyleyesDetects and fixes redundant return await promise delegation.
no-unnecessary-clonewarnperformancenoDetects clones that could be replaced with borrows.
no-upward-importserrorsafetynoForbids lower API layers importing higher layers.
no-unreachable-codeerrorcorrectnessnoDetects code after return, break, continue, or throw.
no-unsafe-finallyerrorsafetynoDetects control-flow changes inside finally.
no-useless-null-checkwarncorrectnessnoDetects null checks on values that can never be null.
no-unused-functionswarncorrectnessnoDetects non-exported functions that are never called.
no-unused-importswarncorrectnessyesDetects and can remove unused import specifiers.
no-unused-varswarncorrectnessnoDetects unused variables; prefix with _ when intentional.
prefer-borrowinfoperformancenoSuggests passing references when ownership is unnecessary.
prefer-constwarnstyleyesSuggests const for bindings that are never reassigned.
prefer-nullish-coalescinginfostylenoSuggests ?? for nullable fallback patterns.
repository-no-http-errorwarnsafetynoWarns when repositories depend on HttpReply.
repository-only-db-accesserrorsafetynoRestricts direct database access to repository modules.
route-no-business-logicwarncomplexitynoWarns when route modules contain business logic.
service-no-replyerrorsafetynoForbids services from depending on HttpReply.
use-caught-errorwarnsafetynoDetects caught errors that are never used.

Exhaustive Match ​

exhaustive-match requires a match over a closed type, a tagged union, a literal union, or a boolean, to cover every case. It is enforced by the compiler as E0004, so it reports even with the lint rule disabled.

tyrus
type Result = { tag: "success"; data: string } | { tag: "error"; code: i32 };

const handle = (result: Result): void => {
    match (result) {
        ({ tag: "success", data }) => {
            print(data); // "data value"
        }
        ({ tag: "error", code }) => {
            print(code); // error code
        }
    }
};

Nullable Code ​

tyrus does not use the null literal in normal code. Express absence with T?, optional fields, optional parameters, and ??.

tyrus
interface Message {
    text?: string;
}

const message: Message = {};
const text: string = message.text ?? "default";

API Architecture ​

Projects created by choosing the API target in the tyrus new prompts receive API-oriented lint defaults. Route modules declare routes, controllers translate HTTP boundaries, services contain business behavior, and repositories own direct database access.

tyrus
import { HttpReply, HttpStatus } from "tyrus:http";

interface CreatedUserResponse {
    ok: boolean;
}

export const createUserController = (request: EmptyRequest, reply: HttpReply<CreatedUserResponse>): void => {
    reply.status(HttpStatus.Created).send({ ok: true });
};

Quick Fixes ​

Rules expose Quick Fixes when the edit is deterministic. prefer-const can rewrite let to const; no-unused-imports can remove unused import specifiers. Rules that require a design choice, such as renaming a shadowed variable, report help but do not invent an edit.

diff
- import { readFileSync, writeFileSync } from "tyrus:fs";
+ import { readFileSync } from "tyrus:fs";

const text = readFileSync("README.md");

Architecture rules are intentionally not auto-fixed

Rules such as controller-no-db-access and service-no-reply identify design problems. They require moving code to the correct layer, not a mechanical edit.