eslint-config-typed-fp
v5.4.0
Published
An opinionated ESLint config to encourage pure(ish), typeful functional programming in TypeScript.
Downloads
1,603
Readme
eslint-config-typed-fp
An opinionated ESLint config to encourage pure(ish), typeful functional programming in TypeScript.
Installation
yarn add --dev eslint-config-typed-fp \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint \
eslint-plugin-functional \
eslint-plugin-total-functions \
typescript
Usage
- Turn on TypeScript's strict mode and noUncheckedIndexedAccess option.
- Set up ESLint + TypeScript.
- Update your
.eslintrc.js
:
module.exports = {
+ parser: "@typescript-eslint/parser",
parserOptions: {
+ project: "./tsconfig.json",
+ ecmaVersion: 2018,
+ sourceType: "module"
},
extends: [
+ "typed-fp",
...
],
plugins: [
+ "@typescript-eslint",
+ "functional",
+ "total-functions",
...
],
rules: {
...
}
};
What's in the box?
Basically,
- the recommended rules from ESLint itself,
- the strict and recommended-requiring-type-checking rules from typescript-eslint,
- the strict rules from eslint-plugin-functional,
- the recommended rules from my own eslint-plugin-total-functions, plus
- a selection of rules not included in the recommended rulesets from all the above to encourage typed, functional programming.
See the extends
and rules
sections in index.ts for the details.
How can I help?
Check out the TODOs in index.ts and of course the issues. Contributions welcome.
Why typed FP?
TypeScript (in)famously considers slavish adherance to type-safety and soundness (at least at the cost of developer ergonomics) a non-goal. With this ESLint config we take the opposite position.
Here's a selection of articles to motivate "why typed FP":
- the case for immutability from immutable-js
- The abject failure of weak typing - Ken Scambler
- No, dynamic type systems are not inherently more open - Alexis King
- Parse, don’t validate - Alexis King
- Types as axioms, or: playing god with static types - Alexis King
- There are more types than classes - Stephen Compall
- Dynamic Languages are Static Languages - Robert Harper
- Static Optimizability from From first principles: Why I bet on Scala.js - Li Haoyi
- From Rust to TypeScript - Alan Darmasaputra
- https://counterexamples.org/
See Also
- TypeScript for Functional Programmers
- Typed functional programming in TypeScript (fp-ts)
- https://github.com/danielnixon/eslint-plugin-total-functions
- https://github.com/agiledigital/readonly-types
- https://github.com/eslint-functional/eslint-plugin-functional
- https://github.com/gcanti/fp-ts
- https://github.com/plantain-00/type-coverage (and its strict mode)
- https://github.com/immutable-js/immutable-js
- https://github.com/uhyo/better-typescript-lib