en cours: règles ESLint/Oxlint

- eslint
This commit is contained in:
gcch 2026-03-30 15:50:50 +02:00
commit 1ba4b6c986
4 changed files with 227 additions and 144 deletions

130
dist/index.mjs vendored
View file

@ -82,71 +82,61 @@ const functionalRules = {
//#endregion //#endregion
//#region ../rules/eslint.ts //#region ../rules/eslint.ts
const esLintRules = { const esLintRules = {
"array-callback-return": [ "eslint/accessor-pairs": ["deny", { enforceForTSTypes: true }],
"error", "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",
{ {
allowVoid: true, block: { ignoreConsecutiveComments: true },
checkForEach: true, line: { ignoreConsecutiveComments: true },
}, },
], ],
"for-direction": "error", "eslint/constructor-super": "deny",
"max-params": ["error", { max: 3 }], "eslint/curly": ["deny", "all"],
"no-array-constructor": "error", "eslint/default-case": "deny",
"no-async-promise-executor": "error", "eslint/default-case-last": "deny",
"no-case-declarations": "error", "eslint/default-param-last": "deny",
"no-compare-neg-zero": "error", "eslint/eqeqeq": "deny",
"no-cond-assign": "error", "eslint/for-direction": "deny",
"no-constant-binary-expression": "error", "eslint/func-names": "allow",
"no-constant-condition": "error", "eslint/func-style": ["deny", "expression", { allowArrowFunctions: true }],
"no-control-regex": "error", "eslint/getter-return": "deny",
"no-debugger": "error", "eslint/grouped-accessor-pairs": ["deny", "setBeforeGet", { enforceForTSTypes: true }],
"no-delete-var": "error", "eslint/guard-for-in": "deny",
"no-dupe-else-if": "error", "eslint/id-length": "deny",
"no-duplicate-case": "error", "eslint/init-declarations": ["deny", "always"],
"no-duplicate-imports": ["error", { allowSeparateTypeImports: true }], "eslint/new-cap": [
"no-empty": "error", "deny",
"no-empty-character-class": "error", {
"no-empty-function": "error", capIsNew: false,
"no-empty-pattern": "error", newIsCap: true,
"no-empty-static-block": "error", properties: true,
"no-ex-assign": "error", },
"no-extra-boolean-cast": "error", ],
"no-fallthrough": "error", "eslint/no-alert": "deny",
"no-global-assign": "error", "eslint/no-array-constructor": "deny",
"no-invalid-regexp": "error", "eslint/no-async-promise-executor": "deny",
"no-irregular-whitespace": "error", "eslint/no-await-in-loop": "deny",
"no-loss-of-precision": "error", "eslint/no-bitwise": "deny",
"no-misleading-character-class": "error", "eslint/no-caller": "deny",
"no-nonoctal-decimal-escape": "error", "eslint/no-case-declarations": "deny",
"no-param-reassign": "error", "eslint/no-class-assign": "deny",
"no-prototype-builtins": "error", "eslint/no-compare-neg-zero": "deny",
"no-regex-spaces": "error", "eslint/no-cond-assign": "deny",
"no-self-assign": "error", "eslint/no-console": "allow",
"no-shadow-restricted-names": "error", "eslint/no-const-assign": "deny",
"no-sparse-arrays": "error", "eslint/no-constant-binary-expression": "deny",
"no-unassigned-vars": "error", "eslint/no-constant-condition": ["deny", { checkLoops: "allExceptWhileTrue" }],
"no-unexpected-multiline": "error", "eslint/no-constructor-return": "deny",
"no-unneeded-ternary": ["error", { defaultAssignment: false }], "eslint/no-continue": "allow",
"no-unsafe-finally": "error", "eslint/no-control-regex": "deny",
"no-unsafe-optional-chaining": "error", "eslint/no-debugger": "deny",
"no-unused-expressions": "error", "eslint/no-delete-var": "deny",
"no-unused-labels": "error", "eslint/no-div-regex": "allow",
"no-unused-private-class-members": "error", "eslint/no-dupe-class-members": "deny",
"no-unused-vars": "error",
"no-useless-backreference": "error",
"no-useless-catch": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"preserve-caught-error": "error",
"require-yield": "error",
"sort-imports": "off",
"use-isnan": "error",
"valid-typeof": "error",
yoda: ["error", "never"],
}; };
//#endregion //#endregion
@ -752,7 +742,7 @@ const unicornRules = {
"unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-string-starts-ends-with": "error",
"unicorn/prefer-string-trim-start-end": "error", "unicorn/prefer-string-trim-start-end": "error",
"unicorn/prefer-structured-clone": "error", "unicorn/prefer-structured-clone": "error",
"unicorn/prefer-ternary": "error", "unicorn/prefer-ternary": "off",
"unicorn/prefer-top-level-await": "error", "unicorn/prefer-top-level-await": "error",
"unicorn/prefer-type-error": "error", "unicorn/prefer-type-error": "error",
"unicorn/relative-url-style": "error", "unicorn/relative-url-style": "error",
@ -768,12 +758,12 @@ const unicornRules = {
//#region ../index.ts //#region ../index.ts
const config = defineConfig({ const config = defineConfig({
categories: { categories: {
correctness: "warn", correctness: "off",
nursery: "warn", nursery: "off",
pedantic: "warn", pedantic: "off",
perf: "error", perf: "off",
style: "error", style: "off",
suspicious: "error", suspicious: "off",
}, },
env: { env: {
browser: true, browser: true,
@ -781,7 +771,7 @@ const config = defineConfig({
es2026: true, es2026: true,
node: true, node: true,
}, },
ignorePatterns: ["dist/**/*"], ignorePatterns: [".astro", ".cache", "dist/**/*"],
jsPlugins: ["eslint-plugin-functional", "eslint-plugin-perfectionist", "eslint-plugin-sonarjs"], jsPlugins: ["eslint-plugin-functional", "eslint-plugin-perfectionist", "eslint-plugin-sonarjs"],
options: { options: {
reportUnusedDisableDirectives: "warn", reportUnusedDisableDirectives: "warn",

View file

@ -11,12 +11,12 @@ import unicornRules from "./rules/unicorn";
const config: OxlintConfig = defineConfig({ const config: OxlintConfig = defineConfig({
categories: { categories: {
correctness: "warn", correctness: "off",
nursery: "warn", nursery: "off",
pedantic: "warn", pedantic: "off",
perf: "error", perf: "off",
style: "error", style: "off",
suspicious: "error", suspicious: "off",
}, },
env: { env: {
browser: true, browser: true,

View file

@ -1,87 +1,93 @@
import type { DummyRuleMap } from "oxlint"; import type { DummyRuleMap } from "oxlint";
const esLintRules: DummyRuleMap = { const esLintRules: DummyRuleMap = {
"array-callback-return": [ "eslint/accessor-pairs": ["deny", { enforceForTSTypes: true }],
"error", "eslint/array-callback-return ": [
"deny",
{ {
allowVoid: true,
checkForEach: true, checkForEach: true,
}, },
], ],
"for-direction": "error", "eslint/arrow-body-style": [
"max-params": [ "deny",
"error", "as-needed",
{ {
max: 3, requireReturnForObjectLiteral: false,
}, },
], ],
"no-array-constructor": "error", "eslint/block-scoped-var": "deny",
"no-async-promise-executor": "error", "eslint/capitalized-comments": [
"no-case-declarations": "error", "deny",
"no-compare-neg-zero": "error", "always",
"no-cond-assign": "error",
"no-constant-binary-expression": "error",
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-delete-var": "error",
"no-dupe-else-if": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": [
"error",
{ {
allowSeparateTypeImports: true, block: {
ignoreConsecutiveComments: true,
},
line: {
ignoreConsecutiveComments: true,
},
}, },
], ],
"no-empty": "error", "eslint/constructor-super": "deny",
"no-empty-character-class": "error", "eslint/curly": ["deny", "all"],
"no-empty-function": "error", "eslint/default-case": "deny",
"no-empty-pattern": "error", "eslint/default-case-last": "deny",
"no-empty-static-block": "error", "eslint/default-param-last": "deny",
"no-ex-assign": "error", "eslint/eqeqeq": "deny",
"no-extra-boolean-cast": "error", "eslint/for-direction": "deny",
"no-fallthrough": "error", "eslint/func-names": "allow",
"no-global-assign": "error", "eslint/func-style": [
"no-invalid-regexp": "error", "deny",
"no-irregular-whitespace": "error", "expression",
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
"no-nonoctal-decimal-escape": "error",
"no-param-reassign": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-self-assign": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-unassigned-vars": "error",
"no-unexpected-multiline": "error",
"no-unneeded-ternary": [
"error",
{ {
defaultAssignment: false, allowArrowFunctions: true,
}, },
], ],
"no-unsafe-finally": "error", "eslint/getter-return": "deny",
"no-unsafe-optional-chaining": "error", "eslint/grouped-accessor-pairs": [
"no-unused-expressions": "error", "deny",
"no-unused-labels": "error", "setBeforeGet",
"no-unused-private-class-members": "error", {
"no-unused-vars": "error", enforceForTSTypes: true,
"no-useless-backreference": "error", },
"no-useless-catch": "error", ],
"no-useless-constructor": "error", "eslint/guard-for-in": "deny",
"no-useless-escape": "error", "eslint/id-length": "deny",
"no-var": "error", "eslint/init-declarations": ["deny", "always"],
"prefer-const": "error", "eslint/new-cap": [
"prefer-rest-params": "error", "deny",
"prefer-spread": "error", {
"preserve-caught-error": "error", capIsNew: false,
"require-yield": "error", newIsCap: true,
// Rentre en conflit avec perfectionnist. properties: true,
"sort-imports": "off", },
"use-isnan": "error", ],
"valid-typeof": "error", "eslint/no-alert": "deny",
yoda: ["error", "never"], "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",
}; };
export default esLintRules; export default esLintRules;

87
rules/old-eslint.ts Normal file
View file

@ -0,0 +1,87 @@
import type { DummyRuleMap } from "oxlint";
const esLintRules: DummyRuleMap = {
"array-callback-return": [
"error",
{
allowVoid: true,
checkForEach: true,
},
],
"for-direction": "error",
"max-params": [
"error",
{
max: 3,
},
],
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-case-declarations": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-constant-binary-expression": "error",
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-delete-var": "error",
"no-dupe-else-if": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": [
"error",
{
allowSeparateTypeImports: true,
},
],
"no-empty": "error",
"no-empty-character-class": "error",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-empty-static-block": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": "error",
"no-fallthrough": "error",
"no-global-assign": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
"no-nonoctal-decimal-escape": "error",
"no-param-reassign": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-self-assign": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-unassigned-vars": "error",
"no-unexpected-multiline": "error",
"no-unneeded-ternary": [
"error",
{
defaultAssignment: false,
},
],
"no-unsafe-finally": "error",
"no-unsafe-optional-chaining": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-private-class-members": "error",
"no-unused-vars": "error",
"no-useless-backreference": "error",
"no-useless-catch": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"preserve-caught-error": "error",
"require-yield": "error",
// Rentre en conflit avec perfectionnist.
"sort-imports": "off",
"use-isnan": "error",
"valid-typeof": "error",
yoda: ["error", "never"],
};
export default esLintRules;