From d0bd5dd8d999aeb50ecd47d74eed66bf052fbc23 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Thu, 18 Apr 2024 19:08:29 +1200 Subject: [PATCH] feat(prefer-immutable-types): change the options in recommeneded and lite configs Recommended: Parameters must be deeply readonly when typed with a type defined in a local file. Types defined in packages in the ts lib must be readonly shallow. Lite: Parameters must be shallowly readonly when typed with a type defined in a local file. There is no enforcement on types defined elsewhere. --- src/configs/lite.ts | 17 +++++++++++++---- src/configs/recommended.ts | 33 +++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/configs/lite.ts b/src/configs/lite.ts index 79bb9a28d..03638ca63 100644 --- a/src/configs/lite.ts +++ b/src/configs/lite.ts @@ -22,10 +22,19 @@ const overrides = { "error", { enforcement: "None", - ignoreInferredTypes: true, - parameters: { - enforcement: "ReadonlyShallow", - }, + overrides: [ + { + specifiers: { + from: "file", + }, + options: { + ignoreInferredTypes: true, + parameters: { + enforcement: "ReadonlyShallow", + }, + }, + }, + ], }, ], } satisfies FlatConfig.Config["rules"]; diff --git a/src/configs/recommended.ts b/src/configs/recommended.ts index eb33b2bd9..117870d9b 100644 --- a/src/configs/recommended.ts +++ b/src/configs/recommended.ts @@ -74,10 +74,35 @@ const overrides = { "error", { enforcement: "None", - ignoreInferredTypes: true, - parameters: { - enforcement: "ReadonlyDeep", - }, + overrides: [ + { + specifiers: [ + { + from: "lib", + }, + { + from: "package", + }, + ], + options: { + ignoreInferredTypes: true, + parameters: { + enforcement: "ReadonlyShallow", + }, + }, + }, + { + specifiers: { + from: "file", + }, + options: { + ignoreInferredTypes: true, + parameters: { + enforcement: "ReadonlyDeep", + }, + }, + }, + ], }, ], [typeDeclarationImmutability.fullName]: [