39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import type { Linter } from "eslint";
|
|
|
|
import functional from "eslint-plugin-functional";
|
|
import typescriptEslint from "typescript-eslint";
|
|
|
|
export const règlesProgrammationFonctionnelle: Readonly<Linter.Config> = {
|
|
name: "Programmation fonctionnelle",
|
|
plugins: { functional: functional as typeof typescriptEslint.plugin },
|
|
rules: {
|
|
...functional.configs.noExceptions.rules,
|
|
...functional.configs.noMutations.rules,
|
|
...functional.configs.externalTypeScriptRecommended.rules,
|
|
...functional.configs.stylistic.rules,
|
|
// Choix stylistique.
|
|
"@typescript-eslint/array-type": ["error", { default: "generic", readonly: "generic" }],
|
|
// L'imposition d'une immutabilité plus importante est extrêmement contraignante.
|
|
"functional/prefer-immutable-types": ["error", { enforcement: "ReadonlyShallow" }],
|
|
// Le style tacite complique la lecture du code.
|
|
"functional/prefer-tacit": "off",
|
|
// Choix stylistique.
|
|
"functional/readonly-type": ["error", "generic"],
|
|
// L'imposition d'une immutabilité plus importante est extrêmement contraignante.
|
|
"functional/type-declaration-immutability": [
|
|
"error",
|
|
{
|
|
ignoreInterfaces: false,
|
|
rules: [
|
|
{
|
|
comparator: "AtLeast",
|
|
fixer: false,
|
|
identifiers: "^(?!I?Mutable).+",
|
|
immutability: "ReadonlyShallow",
|
|
suggestions: false,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
};
|