- corvée: met à jour les dépendances
- corvée: utilise treefmt pour le formatage
- corvée: nettoie les règles
This commit is contained in:
gcch 2026-04-08 08:43:12 +02:00
commit 32ed83d772
8 changed files with 222 additions and 115 deletions

View file

@ -301,6 +301,14 @@ const esLintRules: DummyRuleMap = {
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",

View file

@ -40,7 +40,8 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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",
@ -109,7 +110,8 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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. */
@ -150,24 +152,32 @@ const unicornRules: DummyRuleMap = {
/**
* Prefer using `Array#toReversed()` over `Array#reverse()`.
*
* `Array#reverse()` modifies the original array in place, which can lead to unintended side effectsespecially when the original array is used elsewhere in the code.
* `Array#reverse()` modifies the original array in place, which can lead to unintended side effectsespecially 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. */
/**
* 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 effectsespecially when the original array is used elsewhere in the code.
* `Array#sort()` modifies the original array in place, which can lead to unintended side effectsespecially 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. */
/**
* 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,
},
],
@ -190,7 +200,6 @@ const unicornRules: DummyRuleMap = {
/** 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. */
/** 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",
@ -201,28 +210,34 @@ const unicornRules: DummyRuleMap = {
/**
* 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`, ).
* - 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.
* `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. */
/**
* 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.
* - `"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.
* When `true`, checks `instanceof Error` and suggests using `Error.isError()` instead. Requires the
* `Error.isError()` function to be available.
*/
useErrorIsError: true,
},
@ -333,8 +348,22 @@ const unicornRules: DummyRuleMap = {
* the `Error` constructor calls it automatically.
*/
"unicorn/no-useless-error-capture-stack-trace": "deny",
/** Disallow useless fallback when spreading in object litterals. */
/** 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",
/**
@ -350,10 +379,10 @@ const unicornRules: DummyRuleMap = {
/**
* 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
* - 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. */
@ -363,19 +392,21 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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 lower case, it can be hard to differentiate between them.
* 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.
* 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",
@ -402,9 +433,11 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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.
* 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",
/**
@ -417,9 +450,11 @@ const unicornRules: DummyRuleMap = {
/** 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.
* 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.
* 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",
/**
@ -448,7 +483,8 @@ const unicornRules: DummyRuleMap = {
},
],
/**
* Requires using `BigInt` literals (e.g. `123n`) instead of calling the `BigInt()` constructor with literal arguments such as numbers or numeric strings.
* 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.
*/
@ -461,13 +497,15 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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()`.
* The `toggle()` method is more concise and expressive than using conditional logic to switch between `add()` and
* `remove()`.
*/
"unicorn/prefer-classlist-toggle": "deny",
/**
@ -478,11 +516,16 @@ const unicornRules: DummyRuleMap = {
/** 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.
* 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.
* 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.
* Using default parameters makes it clear that a parameter has a default value, improving code readability and
* maintainability.
*/
"unicorn/prefer-default-parameters": "deny",
/**
@ -502,9 +545,9 @@ const unicornRules: DummyRuleMap = {
*
* 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.
* - `.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",
/**
@ -514,17 +557,31 @@ const unicornRules: DummyRuleMap = {
*/
"unicorn/prefer-event-target": "deny",
/**
* Enforces the use of `globalThis` instead of environmentspecific global object aliases `(window,` `self,` or `global`).
* Enforces the use of `globalThis` instead of environmentspecific 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.
* 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 Nodespecific. Choosing the wrong alias causes runtime crashes when the code is executed outside of its original environment.
* `window` is only defined in browser main threads, `self` is used in Web Workers, and `global` is Nodespecific.
* 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.
* `globalThis` clearly communicates that you are referring to the global object itself rather than a particular
* platform.
*/
"unicorn/prefer-global-this": "deny",
/**
* Prefer `includes()` over `indexOf()` when checking for existence or non-existence. All built-ins have `.includes()` in addition to `.indexOf()`.
* 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()`.
*/
@ -532,9 +589,10 @@ const unicornRules: DummyRuleMap = {
/**
* Enforces the use of `KeyboardEvent#key` over `KeyboardEvent#keyCode`, which is deprecated.
*
*The `.key` property is also more semantic and readable.
* 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.
* The `keyCode,` `which`, and `charCode` properties are deprecated and should be avoided in favor of the `key`
* property.
*/
"unicorn/prefer-keyboard-event-key": "deny",
/**
@ -574,7 +632,7 @@ const unicornRules: DummyRuleMap = {
* migrate and can block ESM-only features.
*/
"unicorn/prefer-module": "deny",
/** Prefers built in functions, over custom ones with the same functionality. */
/** 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.
@ -614,7 +672,9 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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",
/**
@ -636,7 +696,8 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* `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()`. */
@ -644,7 +705,9 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* `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. */
@ -670,7 +733,8 @@ const unicornRules: DummyRuleMap = {
/** 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.
* `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.
*/
@ -706,7 +770,8 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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",
/**
@ -719,7 +784,8 @@ const unicornRules: DummyRuleMap = {
/**
* 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.
* 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()`. */
@ -727,9 +793,13 @@ const unicornRules: DummyRuleMap = {
/**
* 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`).
* 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.
* When calling `window.postMessage()` without the `targetOrigin` argument, the message cannot be received by any
* window.
*/
"unicorn/require-post-message-target-origin": "deny",
/**
@ -745,9 +815,11 @@ const unicornRules: DummyRuleMap = {
"avoid",
],
/**
* Enforce consistent `break`/`return`/`continue`/`throw` position in case clauses.
* 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.
* 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",
/**