1797 lines
No EOL
66 KiB
JavaScript
1797 lines
No EOL
66 KiB
JavaScript
import { defineConfig } from "oxlint";
|
||
|
||
//#region ../rules/astro.ts
|
||
const astroConfig = {
|
||
env: { astro: true },
|
||
files: ["**/*.astro"],
|
||
jsPlugins: ["eslint-plugin-astro"],
|
||
rules: {
|
||
"astro/jsx-a11y/alt-text": "deny",
|
||
"astro/jsx-a11y/anchor-ambiguous-text": "deny",
|
||
"astro/jsx-a11y/anchor-has-content": "deny",
|
||
"astro/jsx-a11y/anchor-is-valid": "deny",
|
||
"astro/jsx-a11y/aria-activedescendant-has-tabindex": "deny",
|
||
"astro/jsx-a11y/aria-props": "deny",
|
||
"astro/jsx-a11y/aria-proptypes": "deny",
|
||
"astro/jsx-a11y/aria-role": "deny",
|
||
"astro/jsx-a11y/aria-unsupported-elements": "deny",
|
||
"astro/jsx-a11y/autocomplete-valid": "deny",
|
||
"astro/jsx-a11y/click-events-have-key-events": "deny",
|
||
"astro/jsx-a11y/control-has-associated-label": "deny",
|
||
"astro/jsx-a11y/heading-has-content": "deny",
|
||
"astro/jsx-a11y/html-has-lang": "deny",
|
||
"astro/jsx-a11y/iframe-has-title": "deny",
|
||
"astro/jsx-a11y/img-redundant-alt": "deny",
|
||
"astro/jsx-a11y/interactive-supports-focus": "deny",
|
||
"astro/jsx-a11y/label-has-associated-control": "deny",
|
||
"astro/jsx-a11y/lang": "deny",
|
||
"astro/jsx-a11y/media-has-caption": "deny",
|
||
"astro/jsx-a11y/mouse-events-have-key-events": "deny",
|
||
"astro/jsx-a11y/no-access-key": "deny",
|
||
"astro/jsx-a11y/no-aria-hidden-on-focusable": "deny",
|
||
"astro/jsx-a11y/no-autofocus": "deny",
|
||
"astro/jsx-a11y/no-distracting-elements": "deny",
|
||
"astro/jsx-a11y/no-interactive-element-to-noninteractive-role": "deny",
|
||
"astro/jsx-a11y/no-noninteractive-element-interactions": "deny",
|
||
"astro/jsx-a11y/no-noninteractive-element-to-interactive-role": "deny",
|
||
"astro/jsx-a11y/no-noninteractive-tabindex": "deny",
|
||
"astro/jsx-a11y/no-redundant-roles": "deny",
|
||
"astro/jsx-a11y/no-static-element-interactions": "deny",
|
||
"astro/jsx-a11y/prefer-tag-over-role": "deny",
|
||
"astro/jsx-a11y/role-has-required-aria-props": "deny",
|
||
"astro/jsx-a11y/role-supports-aria-props": "deny",
|
||
"astro/jsx-a11y/scope": "deny",
|
||
"astro/jsx-a11y/tabindex-no-positive": "deny",
|
||
"astro/missing-client-only-directive-value": "deny",
|
||
"astro/no-conflict-set-directives": "deny",
|
||
"astro/no-deprecated-astro-canonicalurl": "deny",
|
||
"astro/no-deprecated-astro-fetchcontent": "deny",
|
||
"astro/no-deprecated-astro-resolve": "deny",
|
||
"astro/no-deprecated-getentrybyslug": "deny",
|
||
"astro/no-exports-from-components": "deny",
|
||
"astro/no-set-html-directive": "deny",
|
||
"astro/no-set-text-directive": "deny",
|
||
"astro/no-unused-css-selector": "deny",
|
||
"astro/no-unused-define-vars-in-style": "deny",
|
||
"astro/prefer-class-list-directive": "deny",
|
||
"astro/prefer-object-class-list": "deny",
|
||
"astro/prefer-split-class-list": ["deny", { splitLiteral: false }],
|
||
"astro/sort-attributes": ["deny", {
|
||
ignoreCase: false,
|
||
order: "asc",
|
||
type: "alphabetical"
|
||
}],
|
||
"astro/valid-compile": "deny"
|
||
}
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/eslint.ts
|
||
const esLintRules = {
|
||
"eslint/accessor-pairs": ["deny", { enforceForTSTypes: true }],
|
||
"eslint/array-callback-return": ["deny", { checkForEach: true }],
|
||
"eslint/arrow-body-style": [
|
||
"deny",
|
||
"as-needed",
|
||
{ requireReturnForObjectLiteral: false }
|
||
],
|
||
"eslint/block-scoped-var": "deny",
|
||
"eslint/capitalized-comments": [
|
||
"deny",
|
||
"always",
|
||
{
|
||
block: { ignoreConsecutiveComments: true },
|
||
line: { ignoreConsecutiveComments: true }
|
||
}
|
||
],
|
||
"eslint/constructor-super": "deny",
|
||
"eslint/curly": ["deny", "all"],
|
||
"eslint/default-case": "deny",
|
||
"eslint/default-case-last": "deny",
|
||
"eslint/default-param-last": "deny",
|
||
"eslint/eqeqeq": "deny",
|
||
"eslint/for-direction": "deny",
|
||
"eslint/func-names": "allow",
|
||
"eslint/func-style": [
|
||
"deny",
|
||
"expression",
|
||
{ allowArrowFunctions: true }
|
||
],
|
||
"eslint/getter-return": "deny",
|
||
"eslint/grouped-accessor-pairs": [
|
||
"deny",
|
||
"setBeforeGet",
|
||
{ enforceForTSTypes: true }
|
||
],
|
||
"eslint/guard-for-in": "deny",
|
||
"eslint/id-length": ["deny", {
|
||
checkGeneric: true,
|
||
exceptionPatterns: [],
|
||
exceptions: ["_"],
|
||
max: 1e8,
|
||
min: 2,
|
||
properties: "always"
|
||
}],
|
||
"eslint/init-declarations": ["deny", "always"],
|
||
"eslint/new-cap": ["deny", {
|
||
capIsNew: false,
|
||
newIsCap: true,
|
||
properties: true
|
||
}],
|
||
"eslint/no-alert": "deny",
|
||
"eslint/no-array-constructor": "deny",
|
||
"eslint/no-async-promise-executor": "deny",
|
||
"eslint/no-await-in-loop": "deny",
|
||
"eslint/no-bitwise": "deny",
|
||
"eslint/no-caller": "deny",
|
||
"eslint/no-case-declarations": "deny",
|
||
"eslint/no-class-assign": "deny",
|
||
"eslint/no-compare-neg-zero": "deny",
|
||
"eslint/no-cond-assign": "deny",
|
||
"eslint/no-console": "allow",
|
||
"eslint/no-const-assign": "deny",
|
||
"eslint/no-constant-binary-expression": "deny",
|
||
"eslint/no-constant-condition": ["deny", { checkLoops: "allExceptWhileTrue" }],
|
||
"eslint/no-constructor-return": "deny",
|
||
"eslint/no-continue": "allow",
|
||
"eslint/no-control-regex": "deny",
|
||
"eslint/no-debugger": "deny",
|
||
"eslint/no-delete-var": "deny",
|
||
"eslint/no-div-regex": "allow",
|
||
"eslint/no-dupe-class-members": "deny",
|
||
"eslint/no-dupe-else-if": "deny",
|
||
"eslint/no-dupe-keys": "deny",
|
||
"eslint/no-duplicate-case": "deny",
|
||
"eslint/no-duplicate-imports": ["deny", {
|
||
allowSeparateTypeImports: true,
|
||
includeExports: false
|
||
}],
|
||
"eslint/no-else-return": "allow",
|
||
"eslint/no-empty": ["deny", { allowEmptyCatch: false }],
|
||
"eslint/no-empty-character-class": "deny",
|
||
"eslint/no-empty-function": ["deny", { allow: [] }],
|
||
"eslint/no-empty-pattern": "deny",
|
||
"eslint/no-empty-static-block": "deny",
|
||
"eslint/no-eq-null": "deny",
|
||
"eslint/no-eval": "deny",
|
||
"eslint/no-ex-assign": "deny",
|
||
"eslint/no-extend-native": "deny",
|
||
"eslint/no-extra-bind": "deny",
|
||
"eslint/no-extra-boolean-cast": ["deny", { enforceForInnerExpressions: true }],
|
||
"eslint/no-extra-label": "deny",
|
||
"eslint/no-fallthrough": ["deny", {
|
||
allowEmptyCase: false,
|
||
reportUnusedFallthroughComment: true
|
||
}],
|
||
"eslint/no-func-assign": "deny",
|
||
"eslint/no-global-assign": "deny",
|
||
"eslint/no-implicit-coercion": ["deny", {
|
||
allow: [],
|
||
boolean: true,
|
||
disallowTemplateShorthand: false,
|
||
number: true,
|
||
string: true
|
||
}],
|
||
"eslint/no-import-assign": "deny",
|
||
"eslint/no-inline-comments": "deny",
|
||
"eslint/no-inner-declarations": [
|
||
"deny",
|
||
"both",
|
||
"disallow"
|
||
],
|
||
"eslint/no-invalid-regexp": "deny",
|
||
"eslint/no-irregular-whitespace": "deny",
|
||
"eslint/no-iterator": "deny",
|
||
"eslint/no-label-var": "deny",
|
||
"eslint/no-labels": "deny",
|
||
"eslint/no-lone-blocks": "deny",
|
||
"eslint/no-lonely-if": "deny",
|
||
"eslint/no-loop-func": "deny",
|
||
"eslint/no-loss-of-precision": "deny",
|
||
"eslint/no-magic-numbers": ["warn", {
|
||
detectObjects: true,
|
||
enforceConst: true,
|
||
ignoreEnums: true,
|
||
ignoreNumericLiteralTypes: true,
|
||
ignoreTypeIndexes: true
|
||
}],
|
||
"eslint/no-misleading-character-class": "deny",
|
||
"eslint/no-multi-assign": "deny",
|
||
"eslint/no-multi-str": "deny",
|
||
"eslint/no-negated-condition": "deny",
|
||
"eslint/no-nested-ternary": "deny",
|
||
"eslint/no-new": "deny",
|
||
"eslint/no-new-func": "deny",
|
||
"eslint/no-new-native-nonconstructor": "deny",
|
||
"eslint/no-new-wrappers": "deny",
|
||
"eslint/no-nonoctal-decimal-escape": "deny",
|
||
"eslint/no-obj-calls": "deny",
|
||
"eslint/no-object-constructor": "deny",
|
||
"eslint/no-param-reassign": ["deny", {
|
||
ignorePropertyModificationsFor: [],
|
||
props: true
|
||
}],
|
||
"eslint/no-plusplus": "deny",
|
||
"eslint/no-promise-executor-return": "deny",
|
||
"eslint/no-proto": "deny",
|
||
"eslint/no-prototype-builtins": "deny",
|
||
"eslint/no-redeclare": ["deny", { builtinGlobals: true }],
|
||
"eslint/no-regex-spaces": "deny",
|
||
"eslint/no-return-assign": ["deny", "always"],
|
||
"eslint/no-script-url": "deny",
|
||
"eslint/no-self-assign": ["deny", { props: true }],
|
||
"eslint/no-self-compare": "deny",
|
||
"eslint/no-sequences": ["deny", { allowInParentheses: false }],
|
||
"eslint/no-setter-return": "deny",
|
||
"eslint/no-shadow": ["deny", {
|
||
allow: ["Option"],
|
||
builtinGlobals: true,
|
||
hoist: "functions-and-types",
|
||
ignoreFunctionTypeParameterNameValueShadow: true,
|
||
ignoreOnInitialization: false,
|
||
ignoreTypeValueShadow: true
|
||
}],
|
||
"eslint/no-shadow-restricted-names": ["deny", { reportGlobalThis: true }],
|
||
"eslint/no-sparse-arrays": "deny",
|
||
"eslint/no-template-curly-in-string": "deny",
|
||
"eslint/no-ternary": "deny",
|
||
"eslint/no-this-before-super": "deny",
|
||
"eslint/no-throw-literal": "allow",
|
||
"eslint/no-unassigned-vars": "deny",
|
||
"eslint/no-undef": ["deny", { typeof: true }],
|
||
"eslint/no-undefined": "deny",
|
||
"eslint/no-unexpected-multiline": "deny",
|
||
"eslint/no-unmodified-loop-condition": "deny",
|
||
"eslint/no-unneeded-ternary": ["deny", { defaultAssignment: false }],
|
||
"eslint/no-unreachable": "deny",
|
||
"eslint/no-unsafe-finally": "deny",
|
||
"eslint/no-unsafe-negation": ["deny", { enforceForOrderingRelations: true }],
|
||
"eslint/no-unsafe-optional-chaining": ["deny", { disallowArithmeticOperators: true }],
|
||
"eslint/no-unused-expressions": ["deny", {
|
||
allowShortCircuit: false,
|
||
allowTaggedTemplates: false,
|
||
allowTernary: false,
|
||
enforceForJSX: true
|
||
}],
|
||
"eslint/no-unused-labels": "deny",
|
||
"eslint/no-unused-private-class-members": "deny",
|
||
"eslint/no-unused-vars": ["deny", {
|
||
args: "all",
|
||
argsIgnorePattern: "^_",
|
||
caughtErrors: "all",
|
||
fix: {
|
||
ignoreClassWithStaticInitBlock: false,
|
||
ignoreRestSiblings: false,
|
||
ignoreUsingDeclarations: false,
|
||
imports: "suggestion",
|
||
reportVarsOnlyUsedAsTypes: false,
|
||
variables: "suggestion",
|
||
vars: "all"
|
||
}
|
||
}],
|
||
"eslint/no-use-before-define": ["deny", {
|
||
allowNamedExports: false,
|
||
classes: true,
|
||
enums: true,
|
||
functions: true,
|
||
ignoreTypeReferences: true,
|
||
typedefs: true,
|
||
variables: true
|
||
}],
|
||
/**
|
||
* Flags assignments where the newly assigned value is never read afterward (a "dead store"). This helps catch wasted
|
||
* work or accidental mistakes.
|
||
*
|
||
* Dead stores add noise and can hide real bugs (e.g., you meant to use that value or wrote to the wrong variable).
|
||
* Removing them improves clarity and performance.
|
||
*/
|
||
"eslint/no-useless-assignment": "deny",
|
||
"eslint/no-useless-backreference": "deny",
|
||
"eslint/no-useless-call": "deny",
|
||
"eslint/no-useless-catch": "deny",
|
||
"eslint/no-useless-computed-key": ["deny", { enforceForClassMembers: true }],
|
||
"eslint/no-useless-concat": "deny",
|
||
"eslint/no-useless-constructor": "deny",
|
||
"eslint/no-useless-escape": "deny",
|
||
"eslint/no-useless-rename": ["deny", {
|
||
ignoreDestructuring: false,
|
||
ignoreExport: false,
|
||
ignoreImport: false
|
||
}],
|
||
"eslint/no-useless-return": "deny",
|
||
"eslint/no-var": "deny",
|
||
"eslint/no-void": ["deny", { allowAsStatement: false }],
|
||
"eslint/no-warning-comments": ["warn", { location: "anywhere" }],
|
||
"eslint/no-with": "deny",
|
||
"eslint/operator-assignment": ["deny", "never"],
|
||
"eslint/prefer-const": ["deny", {
|
||
destructuring: "any",
|
||
ignoreReadBeforeAssign: true
|
||
}],
|
||
"eslint/prefer-destructuring": ["deny", {
|
||
AssignmentExpression: {
|
||
array: true,
|
||
object: true
|
||
},
|
||
enforceForRenamedProperties: false,
|
||
VariableDeclarator: {
|
||
array: true,
|
||
object: true
|
||
}
|
||
}],
|
||
"eslint/prefer-exponentiation-operator": "deny",
|
||
"eslint/prefer-numeric-literals": "deny",
|
||
"eslint/prefer-object-has-own": "deny",
|
||
"eslint/prefer-object-spread": "deny",
|
||
"eslint/prefer-promise-reject-errors": ["deny", { allowEmptyReject: false }],
|
||
"eslint/prefer-rest-params": "deny",
|
||
"eslint/prefer-spread": "deny",
|
||
"eslint/prefer-template": "deny",
|
||
"eslint/preserve-caught-error": "allow",
|
||
"eslint/radix": "deny",
|
||
"eslint/require-await": "allow",
|
||
/**
|
||
* This rule generates warnings for generator functions that do not have the yield keyword.
|
||
*
|
||
* Probably a mistake.
|
||
*
|
||
* GCCH: Cette règle est désactivée car elle soulève des erreurs pour des `Effect.fn` sans `yield*`.
|
||
*/
|
||
"eslint/require-yield": "allow",
|
||
"eslint/sort-imports": "allow",
|
||
"eslint/sort-keys": "allow",
|
||
"eslint/sort-vars": "allow",
|
||
"eslint/symbol-description": "deny",
|
||
"eslint/unicode-bom": ["deny", "never"],
|
||
"eslint/use-isnan": ["deny", {
|
||
enforceForIndexOf: true,
|
||
enforceForSwitchCase: true
|
||
}],
|
||
"eslint/valid-typeof": ["deny", { requireStringLiterals: true }],
|
||
"eslint/vars-on-top": "deny",
|
||
"eslint/yoda": [
|
||
"deny",
|
||
"never",
|
||
{
|
||
exceptRange: false,
|
||
onlyEquality: false
|
||
}
|
||
]
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/functional.ts
|
||
const functionalRules = {
|
||
"functional/immutable-data": "deny",
|
||
"functional/no-let": "deny",
|
||
"functional/no-throw-statements": "deny",
|
||
"functional/no-try-statements": "deny",
|
||
"functional/prefer-property-signatures": "deny",
|
||
"functional/readonly-type": ["deny", "generic"]
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/import.ts
|
||
const importRules = {
|
||
"import/consistent-type-specifier-style": ["deny", "prefer-top-level"],
|
||
"import/default": "deny",
|
||
"import/export": "deny",
|
||
"import/exports-last": "deny",
|
||
"import/extensions": [
|
||
"deny",
|
||
"always",
|
||
{
|
||
checkTypeImports: true,
|
||
ignorePackages: true
|
||
}
|
||
],
|
||
"import/first": ["deny", "absolute-first"],
|
||
"import/group-exports": "deny",
|
||
"import/max-dependencies": "allow",
|
||
"import/named": "deny",
|
||
"import/namespace": ["deny", { allowComputed: false }],
|
||
"import/no-absolute-path": ["deny", {
|
||
amd: false,
|
||
commonjs: true,
|
||
esmodule: true
|
||
}],
|
||
"import/no-amd": "deny",
|
||
"import/no-anonymous-default-export": ["deny", {
|
||
allowAnonymousClass: false,
|
||
allowAnonymousFunction: false,
|
||
allowArray: false,
|
||
allowArrowFunction: false,
|
||
allowCallExpression: false,
|
||
allowLiteral: false,
|
||
allowNew: false,
|
||
allowObject: false
|
||
}],
|
||
"import/no-commonjs": ["deny", {
|
||
allowConditionalRequire: false,
|
||
allowPrimitiveModules: false,
|
||
allowRequire: false
|
||
}],
|
||
"import/no-cycle": ["deny", {
|
||
allowUnsafeDynamicCyclicDependency: false,
|
||
ignoreExternal: false,
|
||
ignoreTypes: true,
|
||
maxDepth: 4294967295
|
||
}],
|
||
"import/no-default-export": "allow",
|
||
"import/no-duplicates": ["deny", {
|
||
considerQueryString: true,
|
||
preferInline: false
|
||
}],
|
||
"import/no-dynamic-require": ["deny", { esmodule: true }],
|
||
"import/no-empty-named-blocks": "deny",
|
||
"import/no-mutable-exports": "deny",
|
||
"import/no-named-as-default": "deny",
|
||
"import/no-named-as-default-member": "deny",
|
||
"import/no-named-default": "deny",
|
||
/**
|
||
* Prohibit named exports.
|
||
*
|
||
* Named exports require strict identifier matching and can lead to fragile imports, while default exports enforce a
|
||
* single, consistent module entry point.
|
||
*
|
||
* Activer cette règle empêche l'existence de multiples exports au sein d'un module.
|
||
*/
|
||
"import/no-named-export": "allow",
|
||
"import/no-namespace": "deny",
|
||
"import/no-nodejs-modules": "allow",
|
||
"import/no-relative-parent-imports": "allow",
|
||
"import/no-self-import": "deny",
|
||
"import/no-unassigned-import": "deny",
|
||
"import/no-webpack-loader-syntax": "deny",
|
||
"import/prefer-default-export": ["deny", { target: "single" }],
|
||
"import/unambiguous": "deny"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/jsdoc.ts
|
||
const jsDocRules = {
|
||
"jsdoc/check-access": "warn",
|
||
"jsdoc/check-property-names": "warn",
|
||
"jsdoc/check-tag-names": ["warn", {
|
||
definedTags: ["link"],
|
||
typed: true
|
||
}],
|
||
"jsdoc/empty-tags": "warn",
|
||
"jsdoc/implements-on-classes": "warn",
|
||
"jsdoc/no-defaults": ["warn", { noOptionalParamNames: true }],
|
||
"jsdoc/require-param": ["warn", {
|
||
checkConstructors: true,
|
||
checkDestructured: true,
|
||
checkDestructuredRoots: true,
|
||
checkGetters: true,
|
||
checkRestProperty: true,
|
||
checkSetters: true
|
||
}],
|
||
"jsdoc/require-param-description": "warn",
|
||
"jsdoc/require-param-name": "warn",
|
||
"jsdoc/require-param-type": "allow",
|
||
"jsdoc/require-property": "warn",
|
||
"jsdoc/require-property-description": "warn",
|
||
"jsdoc/require-property-name": "warn",
|
||
"jsdoc/require-property-type": "allow",
|
||
"jsdoc/require-returns": ["warn", {
|
||
checkConstructors: true,
|
||
checkGetters: true,
|
||
forceRequireReturn: true,
|
||
forceReturnsWithAsync: true
|
||
}],
|
||
"jsdoc/require-returns-description": "warn",
|
||
"jsdoc/require-returns-type": "allow",
|
||
/** GCCH: Pose soucis avec `Effect`. */
|
||
"jsdoc/require-yields": ["allow", {
|
||
forceRequireYields: false,
|
||
withGeneratorTag: false
|
||
}]
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/node.ts
|
||
const nodeRules = {
|
||
"node/global-require": "deny",
|
||
"node/handle-callback-err": "allow",
|
||
"node/no-exports-assign": "deny",
|
||
"node/no-new-require": "deny",
|
||
"node/no-path-concat": "deny",
|
||
"node/no-process-env": "deny"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/oxc.ts
|
||
const oxcRules = {
|
||
"oxc/approx-constant": "deny",
|
||
"oxc/bad-array-method-on-arguments": "deny",
|
||
"oxc/bad-bitwise-operator": "deny",
|
||
"oxc/bad-char-at-comparison": "deny",
|
||
"oxc/bad-comparison-sequence": "deny",
|
||
"oxc/bad-min-max-func": "deny",
|
||
"oxc/bad-object-literal-comparison": "deny",
|
||
"oxc/bad-replace-all-arg": "deny",
|
||
"oxc/branches-sharing-code": "warn",
|
||
"oxc/const-comparisons": "deny",
|
||
"oxc/double-comparisons": "deny",
|
||
"oxc/erasing-op": "deny",
|
||
"oxc/misrefactored-assign-op": "deny",
|
||
"oxc/missing-throw": "deny",
|
||
"oxc/no-accumulating-spread": "deny",
|
||
"oxc/no-async-await": "allow",
|
||
"oxc/no-async-endpoint-handlers": "allow",
|
||
"oxc/no-barrel-file": ["deny", { threshold: 100 }],
|
||
"oxc/no-const-enum": "deny",
|
||
"oxc/no-map-spread": "allow",
|
||
"oxc/no-optional-chaining": "allow",
|
||
"oxc/no-rest-spread-properties": "allow",
|
||
"oxc/no-this-in-exported-function": "deny",
|
||
"oxc/number-arg-out-of-range": "deny",
|
||
"oxc/only-used-in-recursion": "deny",
|
||
"oxc/uninvoked-array-callback": "deny"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/perfectionist.ts
|
||
const perfectionistRules = {
|
||
"perfectionist/sort-array-includes": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-classes": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-decorators": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-enums": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-export-attributes": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-exports": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-heritage-clauses": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-import-attributes": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-interfaces": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-intersection-types": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-jsx-props": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-maps": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-modules": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-named-exports": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-named-imports": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-object-types": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-objects": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-sets": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-switch-case": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-union-types": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}],
|
||
"perfectionist/sort-variable-declarations": ["deny", {
|
||
order: "asc",
|
||
type: "natural"
|
||
}]
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/promise.ts
|
||
const promiseRules = {
|
||
"promise/always-return": ["deny", {
|
||
ignoreAssignmentVariable: ["globalThis"],
|
||
ignoreLastCallback: false
|
||
}],
|
||
"promise/avoid-new": "deny",
|
||
"promise/catch-or-return": ["deny", {
|
||
allowFinally: false,
|
||
allowThen: false,
|
||
terminationMethod: ["catch"]
|
||
}],
|
||
"promise/no-callback-in-promise": ["deny", {
|
||
callbacks: [
|
||
"callback",
|
||
"cb",
|
||
"done",
|
||
"next"
|
||
],
|
||
exceptions: [],
|
||
timeoutsErr: false
|
||
}],
|
||
"promise/no-multiple-resolved": "deny",
|
||
"promise/no-nesting": "deny",
|
||
"promise/no-new-statics": "deny",
|
||
"promise/no-promise-in-callback": "deny",
|
||
"promise/no-return-in-finally": "deny",
|
||
"promise/no-return-wrap": ["deny", { allowReject: false }],
|
||
"promise/param-names": ["deny", {
|
||
rejectPattern: "^_?reject$",
|
||
resolvePattern: "^_?resolve$"
|
||
}],
|
||
"promise/prefer-await-to-callbacks": "allow",
|
||
"promise/prefer-await-to-then": ["deny", { strict: true }],
|
||
"promise/prefer-catch": "deny",
|
||
"promise/spec-only": ["deny", { allowedMethods: [] }],
|
||
"promise/valid-params": "deny"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/typescript.ts
|
||
const typeScriptRules = {
|
||
"typescript/adjacent-overload-signatures": "deny",
|
||
"typescript/array-type": ["deny", {
|
||
default: "generic",
|
||
readonly: "generic"
|
||
}],
|
||
"typescript/await-thenable": "deny",
|
||
"typescript/ban-ts-comment": ["deny", {
|
||
minimumDescriptionLength: 10,
|
||
"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: []
|
||
}],
|
||
"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 }],
|
||
"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" }],
|
||
"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"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../rules/unicorn.ts
|
||
const unicornRules = {
|
||
/**
|
||
* This rule enforces consistent and descriptive naming for error variables in `catch` statements, preventing the use
|
||
* of vague names like `badName` or _ when the error is used.
|
||
*
|
||
* Using non-descriptive names like `badName` or _ makes the code harder to read and understand, especially when
|
||
* debugging. It's important to use clear, consistent names to represent errors.
|
||
*/
|
||
"unicorn/catch-error-name": ["deny", { ignore: ["_"] }],
|
||
/** Enforces consistent usage of the `assert` module. */
|
||
"unicorn/consistent-assert": "deny",
|
||
/**
|
||
* The `Date` constructor can clone a `Date` object directly when passed as an argument, making timestamp conversion
|
||
* unnecessary. This rule enforces the use of the direct `Date` cloning instead of using `.getTime()` for conversion.
|
||
*
|
||
* Using `.getTime()` to convert a `Date` object to a timestamp and then back to a `Date` is redundant and
|
||
* unnecessary. Simply passing the `Date` object to the `Date` constructor is cleaner and more efficient.
|
||
*/
|
||
"unicorn/consistent-date-clone": "deny",
|
||
/**
|
||
* When spreading a ternary in an array, we can use both `[]` and `''` as fallbacks, but it's better to have
|
||
* consistent types in both branches.
|
||
*/
|
||
"unicorn/consistent-empty-array-spread": "deny",
|
||
/**
|
||
* Enforce consistent style for element existence checks with `indexOf()`, `lastIndexOf()`, `findIndex()`, and
|
||
* `findLastIndex()`. This ensures that comparisons are performed in a standard and clear way.
|
||
*
|
||
* This rule is meant to enforce a specific style and improve code clarity. Using inconsistent comparison styles
|
||
* (e.g., `index < 0`, `index >= 0`) can make the intention behind the code unclear, especially in large codebases.
|
||
*/
|
||
"unicorn/consistent-existence-index-check": "deny",
|
||
/**
|
||
* Disallow functions that are declared in a scope which does not capture any variables from the outer scope.
|
||
*
|
||
* Moving function declarations to the highest possible scope improves readability, directly improves performance and
|
||
* allows JavaScript engines to better optimize your performance.
|
||
*/
|
||
"unicorn/consistent-function-scoping": ["deny", {
|
||
/** Whether to check scoping with arrow functions. */
|
||
checkArrowFunctions: true }],
|
||
/**
|
||
* Enforces the only valid way of `Error` subclassing. It works with any super class that ends in `Error`.
|
||
*
|
||
* Incorrectly defined custom errors can lead to unexpected behaviour when catching and identifying errors. Missing
|
||
* `super()` calls, wrong `name` property values, or nonstandard class names make error handling unreliable.
|
||
*/
|
||
"unicorn/custom-error-definition": "deny",
|
||
/**
|
||
* Removes the extra spaces or new line characters inside a pair of braces that does not contain additional code. This
|
||
* ensures that braces are clean and do not contain unnecessary spaces or newlines.
|
||
*
|
||
* Extra spaces inside braces can negatively impact the readability of the code. Keeping braces clean and free of
|
||
* unnecessary characters improves consistency and makes the code easier to understand and maintain.
|
||
*/
|
||
"unicorn/empty-brace-spaces": "deny",
|
||
/**
|
||
* Enforces providing a `message` when creating built-in `Error` objects to improve readability and debugging.
|
||
*
|
||
* Throwing an `Error` without a message, like throw new `Error()`, provides no context on what went wrong, making
|
||
* debugging harder. A clear error message improves code clarity and helps developers quickly identify issues.
|
||
*/
|
||
"unicorn/error-message": "deny",
|
||
/**
|
||
* Enforces defining escape sequence values with uppercase characters rather than lowercase ones. This promotes
|
||
* readability by making the escaped value more distinguishable from the identifier.
|
||
*/
|
||
"unicorn/escape-case": "deny",
|
||
/** Enforce explicitly comparing the `length` or `size` property of a value. */
|
||
"unicorn/explicit-length-check": ["deny", { "non-zero": "not-equal" }],
|
||
/**
|
||
* Enforces a consistent case style for filenames to improve project organization and maintainability. By default,
|
||
* `kebab-case` is enforced, but other styles can be configured.
|
||
*
|
||
* Files named `index.js`, `index.ts`, etc. are exempt from this rule as they cannot reliably be renamed to other
|
||
* casings (mainly just a problem with PascalCase).
|
||
*
|
||
* Inconsistent file naming conventions make it harder to locate files, navigate projects, and enforce consistency
|
||
* across a codebase. Standardizing naming conventions improves readability, reduces cognitive overhead, and aligns
|
||
* with best practices in large-scale development.
|
||
*/
|
||
"unicorn/filename-case": ["deny", {
|
||
case: "kebabCase",
|
||
ignore: "",
|
||
multipleFileExtensions: true
|
||
}],
|
||
/** Enforces the use of `new` for many built-ins and disallow it for some other. */
|
||
"unicorn/new-for-builtins": "deny",
|
||
/** Disallows `oxlint-disable` or `eslint-disable` comments without specifying rules. */
|
||
"unicorn/no-abusive-eslint-disable": "deny",
|
||
/**
|
||
* Disallow recursive access to `this` within getters and setters.
|
||
*
|
||
* This rule prevents recursive access to `this` within getter and setter methods in objects and classes, avoiding
|
||
* infinite recursion and stack overflow errors.
|
||
*/
|
||
"unicorn/no-accessor-recursion": "deny",
|
||
/** Disallows anonymous functions and classes as default exports. */
|
||
"unicorn/no-anonymous-default-export": "deny",
|
||
/**
|
||
* Prevents passing a function reference directly to iterator methods.
|
||
*
|
||
* Passing functions to iterator methods can cause issues when the function is changed without realizing that the
|
||
* iterator passes two more parameters to it (index and array). This can lead to unexpected behaviour when the
|
||
* function signature changes.
|
||
*
|
||
* GCCH: Cause des soucis avec les pipelines `Effect`.
|
||
*/
|
||
"unicorn/no-array-callback-reference": "allow",
|
||
/**
|
||
* Forbids the use of Array#forEach in favour of a for loop.
|
||
*
|
||
* Je préfère utiliser les méthodes `.forEach` dans les pipelines.
|
||
*/
|
||
"unicorn/no-array-for-each": "allow",
|
||
/**
|
||
* Disallows the use of the `thisArg` parameter in array iteration methods such as `map`, `filter`, `some`, `every`,
|
||
* and similar.
|
||
*
|
||
* The `thisArg` parameter makes code harder to understand and reason about. Instead, prefer arrow functions or bind
|
||
* explicitly in a clearer way. Arrow functions inherit `this` from the lexical scope, which is more intuitive and
|
||
* less error-prone.
|
||
*
|
||
* Cause des soucis avec les pipelines `Effect`.
|
||
*/
|
||
"unicorn/no-array-method-this-argument": "allow",
|
||
/**
|
||
* Disallow `Array#reduce()` and `Array#reduceRight()`.
|
||
*
|
||
* `reduce()` est utile dans certains cas.
|
||
*/
|
||
"unicorn/no-array-reduce": "allow",
|
||
/**
|
||
* Prefer using `Array#toReversed()` over `Array#reverse()`.
|
||
*
|
||
* `Array#reverse()` modifies the original array in place, which can lead to unintended side effects—especially when
|
||
* the original array is used elsewhere in the code.
|
||
*/
|
||
"unicorn/no-array-reverse": ["deny", {
|
||
/**
|
||
* This rule allows `array.reverse()` as an expression statement by default. Set to `false` to forbid
|
||
* `Array#reverse()` even if it's an expression statement.
|
||
*/
|
||
allowExpressionStatement: false }],
|
||
/**
|
||
* Prefer using `Array#toSorted()` over `Array#sort()`.
|
||
*
|
||
* `Array#sort()` modifies the original array in place, which can lead to unintended side effects—especially when the
|
||
* original array is used elsewhere in the code.
|
||
*/
|
||
"unicorn/no-array-sort": ["deny", {
|
||
/**
|
||
* When set to `true` (default), allows `array.sort()` as an expression statement. Set to `false` to forbid
|
||
* `Array#sort()` even if it's an expression statement.
|
||
*/
|
||
allowExpressionStatement: false }],
|
||
/**
|
||
* Disallows member access from `await` expressions.
|
||
*
|
||
* When accessing a member from an `await` expression, the `await` expression has to be parenthesized, which is not
|
||
* readable.
|
||
*/
|
||
"unicorn/no-await-expression-member": "deny",
|
||
/** Disallow using await in Promise method parameters. */
|
||
"unicorn/no-await-in-promise-methods": "deny",
|
||
/**
|
||
* Disallows leading/trailing space inside `console.log()` and similar methods.
|
||
*
|
||
* The `console.log()` method and similar methods join the parameters with a space so adding a leading/trailing space
|
||
* to a parameter, results in two spaces being added.
|
||
*/
|
||
"unicorn/no-console-spaces": "deny",
|
||
/** Disallows direct use of [`document.cookie`](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie). */
|
||
"unicorn/no-document-cookie": "deny",
|
||
/** Disallows files that do not contain any meaningful code. */
|
||
"unicorn/no-empty-file": "deny",
|
||
/** Enforces a convention of using Unicode escapes instead of hexadecimal escapes for consistency and clarity. */
|
||
"unicorn/no-hex-escape": "deny",
|
||
/** Disallows mutating a variable immediately after initialization. */
|
||
"unicorn/no-immediate-mutation": "deny",
|
||
/** Require `Array.isArray()` instead of `instanceof Array`. */
|
||
"unicorn/no-instanceof-array": "deny",
|
||
/**
|
||
* Disallows the use of `instanceof` with ECMAScript built-in constructors because:
|
||
*
|
||
* - It breaks across execution contexts (`iframe`, Web Worker, Node VM, etc.);
|
||
* - It is often misleading (e.g. `instanceof Array` fails for a subclass);
|
||
* - There is always a clearer and safer alternative `(Array.isArray`, `typeof`, `Buffer.isBuffer`, …).
|
||
*
|
||
* `instanceof` breaks across execution contexts (`iframe`, Web Worker, Node `vm`), and may give misleading results
|
||
* for subclasses or exotic objects.
|
||
*/
|
||
"unicorn/no-instanceof-builtins": ["deny", {
|
||
/** Constructor names to exclude from checking. */
|
||
exlude: [],
|
||
/**
|
||
* Additional constructor names to check beyond the default set. Use this to extend the rule with additional
|
||
* constructors.
|
||
*/
|
||
include: [],
|
||
/**
|
||
* Controls which built-in constructors are checked.
|
||
*
|
||
* - `"loose"` (default): Only checks `Array`, `Function`, `Error` (if `useErrorIsError` is `true`), and primitive
|
||
* wrappers;
|
||
* - `"strict"`: Additionally checks `Error` types, collections, typed arrays, and other built-in constructors.
|
||
*/
|
||
strategy: "strict",
|
||
/**
|
||
* When `true`, checks `instanceof Error` and suggests using `Error.isError()` instead. Requires the
|
||
* `Error.isError()` function to be available.
|
||
*/
|
||
useErrorIsError: true
|
||
}],
|
||
/**
|
||
* Disallow invalid options in `fetch()` and new `Request().` Specifically, this rule ensures that a body is not
|
||
* provided when the method is `GET` or `HEAD,` as it will result in a `TypeError.`
|
||
*/
|
||
"unicorn/no-invalid-fetch-options": "deny",
|
||
/** It warns when you use a non-function value as the second argument of `removeEventListener`. */
|
||
"unicorn/no-invalid-remove-event-listener": "deny",
|
||
/** Disallow using `length` as the end argument of a `slice` call. */
|
||
"unicorn/no-length-as-slice-end": "deny",
|
||
/** Disallow `if` statements as the only statement in `if` blocks without `else`. */
|
||
"unicorn/no-lonely-if": "deny",
|
||
/**
|
||
* Disallow magic numbers for
|
||
* [`Array.prototype.flat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
|
||
* depth.
|
||
*
|
||
* Magic numbers are hard to understand and maintain. When calling `Array.prototype.flat`, it is usually called with
|
||
* `1`, or `Infinity`. If you are using a different number, it is better to add a comment explaining the reason for
|
||
* the depth provided.
|
||
*/
|
||
"unicorn/no-magic-array-flat-depth": "deny",
|
||
"unicorn/no-negated-condition": "deny",
|
||
/** Disallow negated expressions on the left of (in)equality checks. */
|
||
"unicorn/no-negation-in-equality-check": "deny",
|
||
/**
|
||
* This rule disallows deeply nested ternary expressions. Nested ternary expressions that are only one level deep and
|
||
* wrapped in parentheses are allowed.
|
||
*
|
||
* Nesting ternary expressions can make code more difficult to understand.
|
||
*/
|
||
"unicorn/no-nested-ternary": "deny",
|
||
/** Disallow new `Array()`. */
|
||
"unicorn/no-new-array": "deny",
|
||
/** Disallows the deprecated new `Buffer()` constructor. */
|
||
"unicorn/no-new-buffer": "deny",
|
||
/**
|
||
* Disallow the use of the `null` literal, to encourage using undefined instead.
|
||
*
|
||
* There are some reasons for using `undefined` instead of `null`.
|
||
*
|
||
* - From experience, most developers use `null` and `undefined` inconsistently and interchangeably, and few know when
|
||
* to use which.
|
||
* - Supporting both `null` and `undefined` complicates input validation.
|
||
* - Using `null` makes TypeScript types more verbose: `type A = {foo?: string | null} vs type A = {foo?: string}`.
|
||
*/
|
||
"unicorn/no-null": ["deny", { checkStrictEquality: true }],
|
||
/** Disallow the use of an object literal as a default value for a parameter. */
|
||
"unicorn/no-object-as-default-parameter": "deny",
|
||
/**
|
||
* Disallow all usage of `process.exit()`.
|
||
*
|
||
* `process.exit()` should generally only be used in command-line utilities. In all other types of applications, the
|
||
* code should throw an error instead.
|
||
*/
|
||
"unicorn/no-process-exit": "deny",
|
||
/** Disallow passing single-element arrays to `Promise` methods. */
|
||
"unicorn/no-single-promise-in-promise-methods": "deny",
|
||
/** Disallow `class` declarations that exclusively contain `static` members. */
|
||
"unicorn/no-static-only-class": "deny",
|
||
/** Disallow defining a `then` property. */
|
||
"unicorn/no-thenable": "deny",
|
||
/** Disallow assigning `this` to a variable. */
|
||
"unicorn/no-this-assignment": "deny",
|
||
/** Disallow `typeof` comparisons with `undefined`. */
|
||
"unicorn/no-typeof-undefined": "deny",
|
||
/** Disallows passing `1` to `Array.prototype.flat`. */
|
||
"unicorn/no-unnecessary-array-flat-depth": "deny",
|
||
/**
|
||
* Disallows passing `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#splice()` or
|
||
* `Array#toSpliced()`.
|
||
*/
|
||
"unicorn/no-unnecessary-array-splice-count": "deny",
|
||
/** Disallow awaiting on non-`Promise` values. */
|
||
"unicorn/no-unnecessary-await": "deny",
|
||
/** Disallows unnecessarily passing a second argument to `slice(...)`, for cases where it would not change the result. */
|
||
"unicorn/no-unnecessary-slice-end": "deny",
|
||
/**
|
||
* Disallows destructuring values from an array in ways that are difficult to read.
|
||
*
|
||
* Destructuring can be very useful, but it can also make some code harder to read. This rule prevents ignoring
|
||
* consecutive values (e.g. `let [,,foo] = array`) when destructuring from an array.
|
||
*/
|
||
"unicorn/no-unreadable-array-destructuring": "deny",
|
||
/** This rule disallows IIFEs with a parenthesized arrow function body. */
|
||
"unicorn/no-unreadable-iife": "deny",
|
||
/**
|
||
* Disallow useless values or fallbacks in `Set`, `Map`, `WeakSet`, or `WeakMap`.
|
||
*
|
||
* It is unnecessary to pass an empty array or empty string when constructing a `Set`, `Map`, `WeakSet`, or `WeakMap`,
|
||
* since they accept nullish values.
|
||
*
|
||
* It is also unnecessary to provide a fallback for possible nullish values.
|
||
*/
|
||
"unicorn/no-useless-collection-argument": "deny",
|
||
/**
|
||
* Disallows unnecessary `Error.captureStackTrace(…)` in error constructors.
|
||
*
|
||
* Calling `Error.captureStackTrace(…)` inside the constructor of a built-in `Error` subclass is unnecessary, since
|
||
* the `Error` constructor calls it automatically.
|
||
*/
|
||
"unicorn/no-useless-error-capture-stack-trace": "deny",
|
||
/** Disallow useless fallback when spreading in object literals. */
|
||
"unicorn/no-useless-fallback-in-spread": "deny",
|
||
/**
|
||
* Disallow unnecessary `.toArray()` on iterators.
|
||
*
|
||
* `Iterator.prototype.toArray()` converts an iterator to an array. However, this conversion is unnecessary in many
|
||
* cases.
|
||
*
|
||
* Array callbacks receive additional arguments (for example, the 3rd array argument) that Iterator callbacks do not.
|
||
* Removing `.toArray()` can change behavior if callbacks depend on those extra arguments, so those cases are reported
|
||
* as suggestions.
|
||
*
|
||
* This rule does not flag `.filter()`, `.map()`, or `.flatMap()` because their Iterator versions return iterators,
|
||
* not arrays, so the semantics differ.
|
||
*/
|
||
"unicorn/no-useless-iterator-to-array": "deny",
|
||
/** It checks for an unnecessary array length check in a logical expression. */
|
||
"unicorn/no-useless-length-check": "deny",
|
||
/**
|
||
* Disallows returning values wrapped in `Promise.resolve` or `Promise.reject` in an async function or a
|
||
* `Promise#then/catch/finally` callback.
|
||
*/
|
||
"unicorn/no-useless-promise-resolve-reject": ["deny", { allowReject: false }],
|
||
/**
|
||
* Disallows using spread syntax in following, unnecessary cases:
|
||
*
|
||
* - Spread an array literal as elements of an array literal.
|
||
* - Spread an array literal as arguments of a call or a new call.
|
||
* - Spread an object literal as properties of an object literal.
|
||
* - Use spread syntax to clone an array created inline.
|
||
*/
|
||
"unicorn/no-useless-spread": "deny",
|
||
/** Disallows useless `default` cases in `switch` statements. */
|
||
"unicorn/no-useless-switch-case": "deny",
|
||
/** Prevents usage of undefined in cases where it would be useless. */
|
||
"unicorn/no-useless-undefined": "deny",
|
||
/**
|
||
* Prevents the use of zero fractions.
|
||
*
|
||
* There is no difference in JavaScript between, for example, `1,` `1.0` and `1.`, so prefer the former for
|
||
* consistency and brevity.
|
||
*/
|
||
"unicorn/no-zero-fractions": "deny",
|
||
/**
|
||
* This rule enforces proper case for numeric literals.
|
||
*
|
||
* When both an identifier and a numeric literal are in lowercase, it can be hard to differentiate between them.
|
||
*/
|
||
"unicorn/number-literal-case": "deny",
|
||
/**
|
||
* Enforces a convention of grouping digits using numeric separators.
|
||
*
|
||
* A long series of digits can be difficult to read, and it can be difficult to determine the value of the number at a
|
||
* glance. Breaking up the digits with numeric separators (`_`) can greatly improve readability.
|
||
*/
|
||
"unicorn/numeric-separators-style": ["deny", {
|
||
binary: {
|
||
groupLength: 3,
|
||
minimumDigits: 4
|
||
},
|
||
hexadecimal: {
|
||
groupLength: 3,
|
||
minimumDigits: 4
|
||
},
|
||
number: {
|
||
groupLength: 3,
|
||
minimumDigits: 4
|
||
},
|
||
octal: {
|
||
groupLength: 3,
|
||
minimumDigits: 4
|
||
},
|
||
onlyIfContainsSeparator: false
|
||
}],
|
||
/**
|
||
* Enforces the use of `.addEventListener()` and `.removeEventListener()` over their on-function counterparts.
|
||
*
|
||
* For example, `foo.addEventListener('click', handler);` is preferred over `foo.onclick = handler;` for HTML DOM
|
||
* Events.
|
||
*
|
||
* There are numerous advantages of using `addEventListener`. Some of these advantages include registering unlimited
|
||
* event handlers and optionally having the event handler invoked only once.
|
||
*/
|
||
"unicorn/prefer-add-event-listener": "deny",
|
||
/**
|
||
* Encourages using `Array.prototype.find` instead of `filter(...)[0]` or similar patterns when only the first
|
||
* matching element is needed.
|
||
*/
|
||
"unicorn/prefer-array-find": "deny",
|
||
/** Prefers `Array#flat()` over legacy techniques to flatten arrays. */
|
||
"unicorn/prefer-array-flat": "deny",
|
||
/** Prefers the use of `.flatMap()` when `map().flat()` are used together. */
|
||
"unicorn/prefer-array-flat-map": "deny",
|
||
/**
|
||
* Enforces using `indexOf` or `lastIndexOf` instead of `findIndex` or `findLastIndex` when the callback is a simple
|
||
* strict equality comparison.
|
||
*
|
||
* Using `findIndex(x => x === value)` is unnecessarily verbose when `indexOf(value)` accomplishes the same thing more
|
||
* concisely and clearly. It also avoids the overhead of creating a callback function.
|
||
*/
|
||
"unicorn/prefer-array-index-of": "deny",
|
||
/**
|
||
* Prefers using `Array#some()` over `Array#find()`, `Array#findLast()` with comparing to `undefined`, or
|
||
* `Array#findIndex()`, `Array#findLastIndex()` and a non-zero length check on the result of `Array#filter()`.
|
||
*/
|
||
"unicorn/prefer-array-some": "deny",
|
||
/**
|
||
* Prefer the `Array#at()` and `String#at()` methods for index access.
|
||
*
|
||
* This rule also discourages using `String#charAt()`.
|
||
*/
|
||
"unicorn/prefer-at": ["deny", {
|
||
/**
|
||
* Check all index access, not just special patterns like `array.length - 1`. When enabled, `array[0]`,
|
||
* `array[1]`, etc. will also be flagged.
|
||
*/
|
||
checkAllIndexAccess: true,
|
||
/**
|
||
* List of function names to treat as "get last element" functions. These functions will be checked for `.at(-1)`
|
||
* usage.
|
||
*/
|
||
getLastElementFunctions: []
|
||
}],
|
||
/**
|
||
* Requires using `BigInt` literals (e.g. `123n`) instead of calling the `BigInt()` constructor with literal arguments
|
||
* such as numbers or numeric strings.
|
||
*
|
||
* Using `BigInt(…)` with literal values is unnecessarily verbose and less idiomatic than using a `BigInt` literal.
|
||
*/
|
||
"unicorn/prefer-bigint-literals": "deny",
|
||
/**
|
||
* Recommends using `Blob#text()` and `Blob#arrayBuffer()` over `FileReader#readAsText()` and
|
||
* `FileReader#readAsArrayBuffer()`.
|
||
*/
|
||
"unicorn/prefer-blob-reading-methods": "deny",
|
||
/**
|
||
* Prefers class field declarations over `this` assignments in constructors for static values.
|
||
*
|
||
* Class field declarations are more readable and less error-prone than assigning static values to `this` in the
|
||
* constructor. Using class fields keeps the constructor cleaner and makes the intent clearer.
|
||
*/
|
||
"unicorn/prefer-class-fields": "deny",
|
||
/**
|
||
* Prefers the use of `element.classList.toggle(className, condition)` over conditional add/remove patterns.
|
||
*
|
||
* The `toggle()` method is more concise and expressive than using conditional logic to switch between `add()` and
|
||
* `remove()`.
|
||
*/
|
||
"unicorn/prefer-classlist-toggle": "deny",
|
||
/**
|
||
* Prefers usage of `String.prototype.codePointAt` over `String.prototype.charCodeAt.` Prefers usage of
|
||
* `String.fromCodePoint` over `String.fromCharCode`.
|
||
*/
|
||
"unicorn/prefer-code-point": "deny",
|
||
/** Prefers use of `Date.now()` over new `Date().getTime()` or new `Date().valueOf()`. */
|
||
"unicorn/prefer-date-now": "deny",
|
||
/**
|
||
* Instead of reassigning a function parameter, default parameters should be used. The `foo = foo || 123` statement
|
||
* evaluates to `123` when `foo` is falsy, possibly leading to confusing behavior, whereas default parameters only
|
||
* apply when passed an `undefined` value. This rule only reports reassignments to literal values.
|
||
*
|
||
* You should disable this rule if you want your functions to deal with `null` and other falsy values the same way as
|
||
* `undefined`. Default parameters are exclusively applied when undefined is received.. However, we recommend moving
|
||
* away from null.
|
||
*
|
||
* Using default parameters makes it clear that a parameter has a default value, improving code readability and
|
||
* maintainability.
|
||
*/
|
||
"unicorn/prefer-default-parameters": "deny",
|
||
/**
|
||
* Enforces the use of, for example, `document.body.append(div);` over `document.body.appendChild(div);` for DOM
|
||
* nodes.
|
||
*/
|
||
"unicorn/prefer-dom-node-append": "deny",
|
||
/**
|
||
* Use `.dataset` on DOM elements over `getAttribute(…)`, `.setAttribute(…)`, `.removeAttribute(…)` and
|
||
* ``.hasAttribute(…)`.
|
||
*/
|
||
"unicorn/prefer-dom-node-dataset": "allow",
|
||
/** Prefers the use of `child.remove()` over `parentNode.removeChild(child)`. */
|
||
"unicorn/prefer-dom-node-remove": "deny",
|
||
/**
|
||
* Enforces the use of `.textContent` over `.innerText` for DOM nodes.
|
||
*
|
||
* There are some disadvantages of using `.innerText`.
|
||
*
|
||
* - `.innerText` is much more performance-heavy as it requires layout information to return the result.
|
||
* - `.innerText` is defined only for `HTMLElement` objects, while `.textContent` is defined for all `Node` objects.
|
||
* - `.innerText` is not standard, for example, it is not present in Firefox.
|
||
*/
|
||
"unicorn/prefer-dom-node-text-content": "deny",
|
||
/**
|
||
* Prefers `EventTarget` over `EventEmitter`.
|
||
*
|
||
* This rule reduces the bundle size and makes your code more cross-platform friendly.
|
||
*/
|
||
"unicorn/prefer-event-target": "deny",
|
||
/**
|
||
* Enforces the use of `globalThis` instead of environment‑specific global object aliases `(window,` `self,` or
|
||
* `global`).
|
||
*
|
||
* Using the standard `globalThis` makes your code portable across browsers, Web Workers, Node.js, and future
|
||
* JavaScript runtimes.
|
||
*
|
||
* `window` is only defined in browser main threads, `self` is used in Web Workers, and `global` is Node‑specific.
|
||
* Choosing the wrong alias causes runtime crashes when the code is executed outside of its original environment.
|
||
*
|
||
* `globalThis` clearly communicates that you are referring to the global object itself rather than a particular
|
||
* platform.
|
||
*/
|
||
"unicorn/prefer-global-this": "deny",
|
||
/**
|
||
* Prefer `import.meta.{dirname,filename}` over legacy techniques for getting file paths.
|
||
*
|
||
* Starting with Node.js 20.11, `import.meta.dirname` and `import.meta.filename` have been introduced in ES modules.
|
||
* `import.meta.filename` is equivalent to `url.fileURLToPath(import.meta.url)`. `import.meta.dirname` is equivalent
|
||
* to `path.dirname(import.meta.filename).` This rule replaces legacy patterns with `import.meta.dirname` and
|
||
* `import.meta.filename`.
|
||
*/
|
||
"unicorn/prefer-import-meta-properties": "deny",
|
||
/**
|
||
* Prefer `includes()` over `indexOf()` when checking for existence or non-existence. All built-ins have `.includes()`
|
||
* in addition to `.indexOf()`.
|
||
*
|
||
* The `.includes()` method is more readable and less error-prone than `.indexOf()`.
|
||
*/
|
||
"unicorn/prefer-includes": "deny",
|
||
/**
|
||
* Enforces the use of `KeyboardEvent#key` over `KeyboardEvent#keyCode`, which is deprecated.
|
||
*
|
||
* The `.key` property is also more semantic and readable.
|
||
*
|
||
* The `keyCode,` `which`, and `charCode` properties are deprecated and should be avoided in favor of the `key`
|
||
* property.
|
||
*/
|
||
"unicorn/prefer-keyboard-event-key": "deny",
|
||
/**
|
||
* This rule finds ternary expressions that can be simplified to a logical operator.
|
||
*
|
||
* Using a logical operator is shorter and simpler than a ternary expression.
|
||
*/
|
||
"unicorn/prefer-logical-operator-over-ternary": "deny",
|
||
/** Prefers use of `Math.min()` and `Math.max()` instead of ternary expressions when performing simple comparisons. */
|
||
"unicorn/prefer-math-min-max": "deny",
|
||
/** Prefers use of `Math.trunc()` instead of bitwise operations for clarity and more reliable results. */
|
||
"unicorn/prefer-math-trunc": "deny",
|
||
/**
|
||
* Enforces the use of:
|
||
*
|
||
* - `childNode.replaceWith(newNode)` over `parentNode.replaceChild(newNode, oldNode)` ;
|
||
* - `referenceNode.before(newNode)` over `parentNode.insertBefore(newNode, referenceNode)` ;
|
||
* - `referenceNode.before('text')` over `referenceNode.insertAdjacentText('beforebegin', 'text')` ;
|
||
* - `referenceNode.before(newNode)` over `referenceNode.insertAdjacentElement('beforebegin', newNode)`.
|
||
*/
|
||
"unicorn/prefer-modern-dom-apis": "deny",
|
||
/**
|
||
* Checks for usage of legacy patterns for mathematical operations.
|
||
*
|
||
* Modern JavaScript provides more concise and readable alternatives to legacy patterns.
|
||
*
|
||
* Currently, the following cases are checked:
|
||
*
|
||
* - Prefer `Math.log10(x)` over alternatives
|
||
* - Prefer `Math.hypot(…)` over alternatives
|
||
*/
|
||
"unicorn/prefer-modern-math-apis": "deny",
|
||
/**
|
||
* Prefer JavaScript modules (ESM) over CommonJS.
|
||
*
|
||
* CommonJS globals and patterns (`require`, `module`, `exports`, `__filename`, `__dirname`) make code harder to
|
||
* migrate and can block ESM-only features.
|
||
*/
|
||
"unicorn/prefer-module": "deny",
|
||
/** Prefers built-in functions, over custom ones with the same functionality. */
|
||
"unicorn/prefer-native-coercion-functions": "deny",
|
||
/**
|
||
* Prefer using a negative index over `.length - index` when possible.
|
||
*
|
||
* Using a negative index with `at` or `slice` is generally more readable and concise than using `.length - index`.
|
||
*/
|
||
"unicorn/prefer-negative-index": "deny",
|
||
/**
|
||
* Prefer using the `node:protocol` when importing Node.js builtin modules.
|
||
*
|
||
* Node.js builtin modules should be imported using the `node:` protocol to avoid ambiguity with local modules.
|
||
*/
|
||
"unicorn/prefer-node-protocol": "deny",
|
||
/**
|
||
* Disallows use of parseInt(), parseFloat(), isNan(), isFinite(), Nan, Infinity and -Infinity as global variables.
|
||
*
|
||
* ECMAScript 2015 moved globals onto the Number constructor for consistency and to slightly improve them. This rule
|
||
* enforces their usage to limit the usage of globals:
|
||
*
|
||
* - `Number.parseInt()` over `parseInt()`
|
||
* - `Number.parseFloat()` over `parseFloat()`
|
||
* - `Number.isNaN()` over `isNaN()` (they have slightly different behavior)
|
||
* - `Number.isFinite()` over `isFinite()` (they have slightly different behavior)
|
||
* - `Number.NaN` over `NaN`
|
||
* - `Number.POSITIVE_INFINITY` over `Infinity`
|
||
* - `Number.NEGATIVE_INFINITY` over `-Infinity`
|
||
*/
|
||
"unicorn/prefer-number-properties": ["deny", {
|
||
/** If set to `true`, checks for usage of `Infinity` and `-Infinity` as global variables. */
|
||
checkInfinity: true,
|
||
/** If set to `true`, checks for usage of `NaN` as a global variable. */
|
||
checkNaN: true
|
||
}],
|
||
/**
|
||
* Encourages using `Object.fromEntries` when converting an array of key-value pairs into an object.
|
||
*
|
||
* Manually constructing objects from key-value pairs using `reduce` or `forEach` is more verbose, error-prone, and
|
||
* harder to understand. The `Object.fromEntries` method is clearer, more declarative, and built for exactly this
|
||
* purpose.
|
||
*/
|
||
"unicorn/prefer-object-from-entries": "deny",
|
||
/**
|
||
* Prefers omitting the catch binding parameter if it is unused.
|
||
*
|
||
* It is unnecessary to bind the error to a variable if it is not used.
|
||
*/
|
||
"unicorn/prefer-optional-catch-binding": "deny",
|
||
/**
|
||
* “Borrowing” a method from an instance of `Array` or `Object` is less clear than getting it from the corresponding
|
||
* prototype.
|
||
*/
|
||
"unicorn/prefer-prototype-methods": "deny",
|
||
/**
|
||
* Prefer `.querySelector()` over `.getElementById().` And prefer `.querySelectorAll()` over
|
||
* `.getElementsByClassName()`, `.getElementsByTagName()`, and `.getElementsByName()`.
|
||
*/
|
||
"unicorn/prefer-query-selector": "deny",
|
||
/**
|
||
* Disallows the use of `Function.prototype.apply()` and suggests using `Reflect.apply()` instead.
|
||
*
|
||
* `Reflect.apply()` is arguably less verbose and easier to understand. In addition, when you accept arbitrary
|
||
* methods, it's not safe to assume `.apply()` exists or is not overridden.
|
||
*/
|
||
"unicorn/prefer-reflect-apply": "deny",
|
||
/** Prefers `RegExp#test()` over `String#match()` and `String#exec()`. */
|
||
"unicorn/prefer-regexp-test": "deny",
|
||
/**
|
||
* Enforces the use of `Response.json()` over `new Response(JSON.stringify())`.
|
||
*
|
||
* `Response.json()` is a more concise and semantically clear way to create JSON responses. It automatically sets the
|
||
* correct `Content-Type` header (`application/json`) and handles serialization, making the code more maintainable and
|
||
* less error-prone.
|
||
*/
|
||
"unicorn/prefer-response-static-json": "deny",
|
||
/** Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. */
|
||
"unicorn/prefer-set-has": "deny",
|
||
/** Prefer `Set#size` over `Set#length` when the `Set` is converted to an array. */
|
||
"unicorn/prefer-set-size": "deny",
|
||
/**
|
||
* Enforces the use of the spread operator (...) over outdated patterns.
|
||
*
|
||
* Using the spread operator is more concise and readable.
|
||
*/
|
||
"unicorn/prefer-spread": "deny",
|
||
/**
|
||
* Prefers use of `String.raw` to avoid escaping `\`.
|
||
*
|
||
* Excessive backslashes can make string values less readable which can be avoided by using `String.raw`.
|
||
*/
|
||
"unicorn/prefer-string-raw": "deny",
|
||
/** Prefers `String#replaceAll()` over `String#replace()` when using a regex with the global flag. */
|
||
"unicorn/prefer-string-replace-all": "deny",
|
||
/** Prefer `String#slice()` over `String#substr()` and `String#substring()`. */
|
||
"unicorn/prefer-string-slice": "deny",
|
||
/** Prefer `String#startsWith()` and `String#endsWith()` over using a regex with `/^foo/` or `/foo$/`. */
|
||
"unicorn/prefer-string-starts-ends-with": "deny",
|
||
/**
|
||
* `String#trimLeft()` and `String#trimRight()` are aliases of `String#trimStart()` and `String#trimEnd()`. This is to
|
||
* ensure consistency and use direction-independent wording.
|
||
*
|
||
* The `trimLeft` and `trimRight` names are confusing and inconsistent with the rest of the language.
|
||
*/
|
||
"unicorn/prefer-string-trim-start-end": "deny",
|
||
/**
|
||
* Prefer using `structuredClone` to create a deep clone.
|
||
*
|
||
* `structuredClone` is the modern way to create a deep clone of a value.
|
||
*/
|
||
"unicorn/prefer-structured-clone": "deny",
|
||
/**
|
||
* Prefers ternary expressions over simple `if/else` statements.
|
||
*
|
||
* Simple `if/else` branches for the same operation are often shorter and clearer when expressed as a ternary.
|
||
*
|
||
* Je n'aime pas les ternaires.
|
||
*/
|
||
"unicorn/prefer-ternary": "allow",
|
||
/** Prefer top-level await over top-level promises and async function calls. */
|
||
"unicorn/prefer-top-level-await": "deny",
|
||
/** Enforce throwing a `TypeError` instead of a generic `Error` after a type checking if-statement. */
|
||
"unicorn/prefer-type-error": "deny",
|
||
/**
|
||
* Enforce consistent relative URL style.
|
||
*
|
||
* When using a relative URL in `new URL()`, the URL should either never or always use the `./` prefix consistently.
|
||
*/
|
||
"unicorn/relative-url-style": ["deny", "always"],
|
||
/**
|
||
* Enforce using the separator argument with `Array#join()`.
|
||
*
|
||
* It's better to make it clear what the separator is when calling `Array#join()`, instead of relying on the default
|
||
* comma (`','`) separator.
|
||
*/
|
||
"unicorn/require-array-join-separator": "deny",
|
||
/**
|
||
* This rule enforces non-empty attribute list in `import`/`export` statements and `import()` expressions.
|
||
*
|
||
* Import attributes are meant to provide metadata about how a module should be loaded (e.g., with `{ type: "json"
|
||
* }`). An empty attribute object provides no information and should be removed.
|
||
*/
|
||
"unicorn/require-module-attributes": "deny",
|
||
/**
|
||
* Enforce non-empty specifier list in `import` and `export` statements.
|
||
*
|
||
* Empty `import`/`export` specifiers add no value and can be confusing. If you want to import a module for side
|
||
* effects, use `import 'module'` instead.
|
||
*/
|
||
"unicorn/require-module-specifiers": "deny",
|
||
/** Enforce using the digits argument with `Number#toFixed()`. */
|
||
"unicorn/require-number-to-fixed-digits-argument": "deny",
|
||
/**
|
||
* Enforce using the `targetOrigin` argument with `window.postMessage()`.
|
||
*
|
||
* Note that this rule may have false positives, as it is not capable of detecting all cases correctly without type
|
||
* information. As such, it may not be a good idea to enable in cases where `postMessage()` may be used with
|
||
* `BroadcastChannel` or worker/service worker contexts (for example, `WorkerGlobalScope#postMessage`, where the
|
||
* second argument is a transfer list or options object, not `targetOrigin`).
|
||
*
|
||
* When calling `window.postMessage()` without the `targetOrigin` argument, the message cannot be received by any
|
||
* window.
|
||
*/
|
||
"unicorn/require-post-message-target-origin": "deny",
|
||
/**
|
||
* Requires empty switch cases to omit braces, while non-empty cases must use braces. This reduces visual clutter for
|
||
* empty cases and enforces proper scoping for non-empty ones.
|
||
*
|
||
* Using braces unnecessarily for empty cases adds visual noise, while omitting braces in non-empty cases can lead to
|
||
* scoping issues.
|
||
*/
|
||
"unicorn/switch-case-braces": ["deny", "avoid"],
|
||
/**
|
||
* Enforce consistent `break`/`return`/`continue`/`throw` position in `case` clauses.
|
||
*
|
||
* Enforce that terminating statements (`break`, `return`, `continue`, `throw`) appear inside the block statement of a
|
||
* `case` clause, not after it. This can happen when refactoring — for example, removing an if wrapper but leaving the
|
||
* `break` outside the braces.
|
||
*/
|
||
"unicorn/switch-case-break-position": "deny",
|
||
/**
|
||
* This rule enforces consistent casing for text encoding identifiers, specifically:
|
||
*
|
||
* - `'utf8'` instead of `'UTF-8'` or `'utf-8'` (or `'utf-8'` if `withDash` is enabled) ;
|
||
* - `'ascii'` instead of `'ASCII'`.
|
||
*
|
||
* Inconsistent casing of encoding identifiers reduces code readability and can lead to subtle confusion across a
|
||
* codebase. Although casing is not strictly enforced by ECMAScript or Node.js, using lowercase is the conventional
|
||
* and widely recognized style.
|
||
*/
|
||
"unicorn/text-encoding-identifier-case": "deny",
|
||
/**
|
||
* This rule makes sure you always use new when throwing an error.
|
||
*
|
||
* In JavaScript, omitting `new` (e.g., `throw Error('message')`) is allowed, but it does not properly initialize the
|
||
* error object. This can lead to missing stack traces or incorrect prototype chains. Using `new` makes the intent
|
||
* clear, ensures consistent behavior, and helps avoid subtle bugs.
|
||
*/
|
||
"unicorn/throw-new-error": "deny"
|
||
};
|
||
|
||
//#endregion
|
||
//#region ../index.ts
|
||
const config = defineConfig({
|
||
categories: {
|
||
correctness: "off",
|
||
nursery: "off",
|
||
pedantic: "off",
|
||
perf: "off",
|
||
style: "off",
|
||
suspicious: "off"
|
||
},
|
||
env: {
|
||
browser: true,
|
||
builtin: true,
|
||
es2026: true,
|
||
node: true
|
||
},
|
||
ignorePatterns: [
|
||
".astro",
|
||
".cache",
|
||
"dist/**/*"
|
||
],
|
||
jsPlugins: ["eslint-plugin-functional", "eslint-plugin-perfectionist"],
|
||
options: {
|
||
reportUnusedDisableDirectives: "warn",
|
||
typeAware: true,
|
||
typeCheck: false
|
||
},
|
||
overrides: [astroConfig],
|
||
plugins: [
|
||
"import",
|
||
"jsdoc",
|
||
"node",
|
||
"oxc",
|
||
"promise",
|
||
"typescript",
|
||
"unicorn"
|
||
],
|
||
rules: {
|
||
...esLintRules,
|
||
...functionalRules,
|
||
...importRules,
|
||
...jsDocRules,
|
||
...nodeRules,
|
||
...oxcRules,
|
||
...perfectionistRules,
|
||
...promiseRules,
|
||
...typeScriptRules,
|
||
...unicornRules
|
||
},
|
||
settings: {}
|
||
});
|
||
|
||
//#endregion
|
||
export { config as default }; |