Functional
Functional-programming policy rules from eslint-plugin-functional. Pushes code toward immutability, side-effect-free expressions, and expression-style control flow. Most rules are useful in pieces, projects rarely enable the whole family at "error". Enabling the whole set together expresses a strict functional-core / imperative-shell discipline. Diagnostic-only: ttsc fix does not rewrite mutation, classes, exceptions, loops, or branching into a functional design.
Source: eslint-plugin-functional (MIT).
functional/functional-parameters: Enforce functional parameter style: rejectarguments, reject rest parameters, and optionally enforce a per-function parameter-count policy.functional/immutable-data: Reject property assignment (obj.x = ...), element assignment (arr[0] = ...), andMap/Setmutation methods.functional/no-class-inheritance: Rejectabstractclasses andextendsclauses on class declarations; prefer composition and structural typing.functional/no-classes: Rejectclassdeclarations and class expressions altogether.functional/no-conditional-statements: Rejectifandswitchstatements.functional/no-expression-statements: Reject expression statements that exist purely for their side effects (mutate(x);); pure code is built up from expressions with assigned or returned results.functional/no-let: Rejectletdeclarations so every binding isconst.functional/no-loop-statements: Rejectfor,while, anddo/whileloop statements; use recursive helpers or array methods (map,reduce) instead.functional/no-mixed-types: Reject interfaces and type literals that mix property, method, call, and index member kinds; mixed shapes make composition harder.functional/no-promise-reject: Reject any call toPromise.reject(...); resolve with anOption/Resultshape so failures stay in the value channel.functional/no-return-void: Reject void returns and functions whose declared return type isvoid; functions should always return a value.functional/no-this-expressions: Reject anythisexpression.functional/no-throw-statements: Rejectthrowstatements; functional code surfaces failures through return values (Either,Result) instead.functional/no-try-statements: Rejecttry/catchandtry/finallystatements as a corollary offunctional/no-throw-statements.functional/prefer-immutable-types: Require declared variable, parameter, and property types to bereadonlyor otherwise structurally immutable.functional/prefer-property-signatures: Prefer function-property signatures (fn: () => T) over method shorthand (fn(): T) in interfaces and type literals.functional/prefer-readonly-type: Preferreadonlyarray, tuple, collection, and property types over their mutable counterparts.functional/prefer-tacit: Reject trivial wrappers such asx => f(x)in favor of the tacit formf; reduces noise in functional pipelines.functional/readonly-type: Enforce one consistent spelling for readonly types,readonly T[]vsReadonlyArray<T>, across the project.functional/type-declaration-immutability: Enforce readonly/immutable type declarations by declaration name policy, for projects that want only types matching certain naming conventions to be locked down.
// lint.config.ts
import type { ITtscLintConfig } from "@ttsc/lint";
export default {
rules: {
"functional/no-let": "error",
"functional/no-loop-statements": "error",
"functional/no-conditional-statements": "error",
"functional/no-throw-statements": "error",
"functional/no-try-statements": "error",
"functional/no-classes": "error",
"functional/immutable-data": "error",
"functional/prefer-readonly-type": "error",
"functional/type-declaration-immutability": ["error", {
rules: [{ identifiers: ".*" }],
}],
},
} satisfies ITtscLintConfig;Last updated on