configuration-oxlint/rules/typescript.ts
gcch 64c121e89c 0.0.5
- ref: désactive des règles pénibles
- ref: désactive des règles en conflit avec Effect
2026-04-18 11:36:40 +02:00

456 lines
12 KiB
TypeScript

import type { DummyRuleMap } from "oxlint";
/** Longueur minimale de la description accompagnat une directive (p. ex. `@ts-expect-error`). */
const MIN_DIRECTIVE_DESCRIPTION_LENGTH = 10;
const typeScriptRules: DummyRuleMap = {
"typescript/adjacent-overload-signatures": "deny",
"typescript/array-type": [
"deny",
{
default: "generic",
readonly: "generic",
},
],
"typescript/await-thenable": "deny",
"typescript/ban-ts-comment": [
"deny",
{
minimumDescriptionLength: MIN_DIRECTIVE_DESCRIPTION_LENGTH,
"ts-check": false,
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
},
],
"typescript/ban-tslint-comment": "deny",
"typescript/class-literal-property-style": ["deny", "fields"],
"typescript/consistent-generic-constructors": [
"deny",
{
option: "constructor",
},
],
"typescript/consistent-indexed-object-style": ["deny", "record"],
"typescript/consistent-return": [
"deny",
{
treatUndefinedAsUnspecified: false,
},
],
"typescript/consistent-type-assertions": [
"deny",
{
assertionStyle: "never",
},
],
"typescript/consistent-type-definitions": ["deny", "type"],
"typescript/consistent-type-exports": [
"deny",
{
fixMixedExportsWithInlineTypeSpecifier: false,
},
],
"typescript/consistent-type-imports": [
"deny",
{
disallowTypeAnnotations: true,
fixStyle: "separate-type-imports",
prefer: "type-imports",
},
],
/**
* Enforce dot notation whenever property access can be written safely as `obj.prop`.
*
* Dot notation is generally more readable and concise than bracket notation for static property names.
*/
"typescript/dot-notation": [
"deny",
{
/** Allow bracket notation for properties covered by an index signature. */
allowIndexSignaturePropertyAccess: true,
/** Allow bracket notation for ES3 keyword property names (for example `obj["class"]`). */
allowKeywords: false,
/** Regex pattern for property names that are allowed to use bracket notation. */
allowPattern: "",
/** Allow bracket notation for private class members. */
allowPrivateClassPropertyAccess: true,
/** Allow bracket notation for protected class members. */
allowProtectedClassPropertyAccess: true,
},
],
"typescript/explicit-function-return-type": [
"deny",
{
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
allowDirectConstAssertionInArrowFunctions: true,
allowedNames: [],
allowExpressions: false,
allowFunctionsWithoutTypeParameters: false,
allowHigherOrderFunctions: true,
allowIIFEs: false,
allowTypedFunctionExpressions: true,
},
],
"typescript/explicit-module-boundary-types": [
"deny",
{
allowArgumentsExplicitlyTypedAsAny: false,
allowDirectConstAssertionInArrowFunctions: true,
allowedNames: [],
allowHigherOrderFunctions: true,
allowOverloadFunctions: false,
allowTypedFunctionExpressions: true,
},
],
"typescript/no-array-delete": "deny",
"typescript/no-base-to-string": [
"deny",
{
checkUnknown: true,
ignoredTypeNames: ["deny", "RegExp", "URL", "URLSearchParams"],
},
],
"typescript/no-confusing-non-null-assertion": "deny",
"typescript/no-confusing-void-expression": [
"deny",
{
ignoreArrowShorthand: false,
ignoreVoidOperator: false,
ignoreVoidReturningFunctions: false,
},
],
"typescript/no-deprecated": "deny",
"typescript/no-duplicate-enum-values": "deny",
"typescript/no-duplicate-type-constituents": [
"deny",
{
ignoreIntersections: false,
ignoreUnions: false,
},
],
"typescript/no-dynamic-delete": "deny",
"typescript/no-empty-interface": [
"deny",
{
allowSingleExtends: false,
},
],
"typescript/no-empty-object-type": [
"deny",
{
allowInterfaces: "never",
allowObjectTypes: "never",
},
],
"typescript/no-explicit-any": [
"deny",
{
fixToUnknown: true,
ignoreRestArgs: false,
},
],
"typescript/no-extra-non-null-assertion": "deny",
"typescript/no-extraneous-class": [
"deny",
{
allowConstructorOnly: false,
allowEmpty: false,
allowStaticOnly: false,
allowWithDecorator: false,
},
],
"typescript/no-floating-promises": [
"deny",
{
allowForKnownSafeCalls: [],
allowForKnownSafePromises: [],
checkThenables: true,
ignoreIIFE: false,
ignoreVoid: false,
},
],
"typescript/no-for-in-array": "deny",
"typescript/no-implied-eval": "deny",
"typescript/no-import-type-side-effects": "deny",
//
"typescript/no-inferrable-types": [
"deny",
{
ignoreParameters: true,
ignoreProperties: true,
},
],
"typescript/no-invalid-void-type": [
"deny",
{
allowAsThisParameter: false,
allowInGenericTypeArguments: true,
},
],
"typescript/no-meaningless-void-operator": [
"deny",
{
checkNever: true,
},
],
"typescript/no-misused-new": "deny",
"typescript/no-misused-promises": [
"deny",
{
checksConditionals: true,
checksSpreads: true,
checksVoidReturn: true,
},
],
"typescript/no-misused-spread": [
"deny",
{
allow: [],
},
],
"typescript/no-mixed-enums": "deny",
"typescript/no-namespace": [
"deny",
{
allowDeclarations: false,
allowDefinitionFiles: true,
},
],
"typescript/no-non-null-asserted-nullish-coalescing": "deny",
"typescript/no-non-null-asserted-optional-chain": "deny",
"typescript/no-non-null-assertion": "deny",
"typescript/no-redundant-type-constituents": "deny",
"typescript/no-require-imports": [
"deny",
{
allow: [],
allowAsImport: false,
},
],
"typescript/no-this-alias": [
"deny",
{
allowDestructuring: false,
allowedNames: [],
},
],
// J'apprécie de pouvoir être explicite dans la comparaison.
"typescript/no-unnecessary-boolean-literal-compare": "allow",
"typescript/no-unnecessary-condition": [
"deny",
{
allowConstantLoopConditions: "never",
checkTypePredicates: true,
},
],
"typescript/no-unnecessary-parameter-property-assignment": "deny",
"typescript/no-unnecessary-qualifier": "deny",
"typescript/no-unnecessary-template-expression": "deny",
"typescript/no-unnecessary-type-arguments": "deny",
"typescript/no-unnecessary-type-assertion": [
"deny",
{
checkLiteralConstAssertions: false,
typesToIgnore: [],
},
],
"typescript/no-unnecessary-type-constraint": "deny",
"typescript/no-unnecessary-type-conversion": "deny",
"typescript/no-unnecessary-type-parameters": "deny",
"typescript/no-unsafe-argument": "deny",
"typescript/no-unsafe-assignment": "deny",
"typescript/no-unsafe-call": "deny",
"typescript/no-unsafe-declaration-merging": "deny",
"typescript/no-unsafe-enum-comparison": "deny",
"typescript/no-unsafe-function-type": "deny",
"typescript/no-unsafe-member-access": [
"deny",
{
allowOptionalChaining: false,
},
],
"typescript/no-unsafe-return": "deny",
"typescript/no-unsafe-type-assertion": "deny",
"typescript/no-unsafe-unary-minus": "deny",
"typescript/no-useless-default-assignment": "deny",
"typescript/no-useless-empty-export": "deny",
"typescript/no-wrapper-object-types": "deny",
"typescript/non-nullable-type-assertion-style": "allow",
"typescript/only-throw-error": [
"deny",
{
allow: [],
allowRethrowing: true,
allowThrowingAny: false,
allowThrowingUnknown: false,
},
],
"typescript/parameter-properties": [
"deny",
{
prefer: "class-property",
},
],
"typescript/prefer-as-const": "deny",
"typescript/prefer-enum-initializers": "deny",
"typescript/prefer-find": "deny",
"typescript/prefer-for-of": "deny",
"typescript/prefer-function-type": "deny",
"typescript/prefer-includes": "deny",
"typescript/prefer-literal-enum-member": [
"deny",
{
allowBitwiseExpressions: false,
},
],
"typescript/prefer-nullish-coalescing": [
"deny",
{
ignoreBooleanCoercion: false,
ignoreConditionalTests: true,
ignoreIfStatements: false,
ignoreMixedLogicalExpressions: false,
ignorePrimitives: false,
ignoreTernaryTests: false,
},
],
"typescript/prefer-optional-chain": [
"deny",
{
checkAny: true,
checkBigInt: true,
checkBoolean: true,
checkNumber: true,
checkString: true,
checkUnknown: true,
requireNullish: false,
},
],
"typescript/prefer-promise-reject-errors": [
"deny",
{
allowEmptyReject: false,
allowThrowingAny: false,
allowThrowingUnknown: false,
},
],
"typescript/prefer-readonly": [
"deny",
{
onlyInlineLambdas: false,
},
],
// Nécessite trop de bruit dans le code avec l'ajout d'annotations de type `Readonly`.
"typescript/prefer-readonly-parameter-types": [
"allow",
{
allow: [],
checkParameterProperties: true,
ignoreInferredTypes: true,
treatMethodsAsReadonly: false,
},
],
"typescript/prefer-reduce-type-parameter": "deny",
"typescript/prefer-regexp-exec": "deny",
"typescript/prefer-return-this-type": "deny",
"typescript/prefer-string-starts-ends-with": ["deny", { allowSingleElementEquality: "never" }],
// Règle rendue caduque par typescript/ban-ts-comment.
"typescript/prefer-ts-expect-error": "allow",
"typescript/promise-function-async": [
"deny",
{
allowAny: false,
allowedPromiseNames: [],
checkArrowFunctions: true,
checkFunctionDeclarations: true,
checkFunctionExpressions: true,
checkMethodDeclarations: true,
},
],
"typescript/related-getter-setter-pairs": "deny",
"typescript/require-array-sort-compare": [
"deny",
{
ignoreStringArrays: true,
},
],
"typescript/require-await": "deny",
"typescript/restrict-plus-operands": [
"deny",
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
allowRegExp: false,
},
],
"typescript/restrict-template-expressions": [
"deny",
{
allow: [{ from: "lib", name: ["Error", "URL", "URLSearchParams"] }],
allowAny: false,
allowBoolean: false,
allowNever: false,
allowNullish: false,
allowNumber: false,
allowRegExp: false,
},
],
"typescript/return-await": ["deny", "error-handling-correctness-only"],
"typescript/strict-boolean-expressions": [
"deny",
{
allowAny: false,
allowNullableBoolean: true,
allowNullableEnum: true,
allowNullableNumber: false,
allowNullableObject: false,
allowNullableString: false,
allowNumber: false,
allowString: false,
},
],
"typescript/strict-void-return": [
"deny",
{
allowReturnAny: false,
},
],
"typescript/switch-exhaustiveness-check": [
"deny",
{
allowDefaultCaseForExhaustiveSwitch: true,
considerDefaultExhaustiveForUnions: false,
defaultCaseCommentPattern: "@skip-exhaustive-check",
requireDefaultForNonUnion: false,
},
],
"typescript/triple-slash-reference": [
"deny",
{
lib: "never",
path: "never",
types: "prefer-import",
},
],
/** Trop de faux négatifs dans les pipelines. */
"typescript/unbound-method": [
"allow",
{
ignoreStatic: false,
},
],
"typescript/unified-signatures": [
"deny",
{
ignoreDifferentlyNamedParameters: false,
ignoreOverloadsWithDifferentJSDoc: false,
},
],
"typescript/use-unknown-in-catch-callback-variable": "deny",
};
export default typeScriptRules;