wip
This commit is contained in:
parent
d14e999d04
commit
380fb54e4e
9 changed files with 618 additions and 649 deletions
6
dist/index.d.mts
vendored
6
dist/index.d.mts
vendored
|
|
@ -1,6 +0,0 @@
|
||||||
import { Linter } from "eslint";
|
|
||||||
|
|
||||||
//#region index.d.ts
|
|
||||||
declare const configTypescriptNavigateur: ReadonlyArray<Linter.Config>;
|
|
||||||
//#endregion
|
|
||||||
export { configTypescriptNavigateur };
|
|
||||||
188
dist/index.mjs
vendored
188
dist/index.mjs
vendored
|
|
@ -1,188 +0,0 @@
|
||||||
import { Linter } from "eslint";
|
|
||||||
import { defineConfig, globalIgnores } from "eslint/config";
|
|
||||||
import globals from "globals";
|
|
||||||
import javascript from "@eslint/js";
|
|
||||||
import jsdoc from "eslint-plugin-jsdoc";
|
|
||||||
import oxlint from "eslint-plugin-oxlint";
|
|
||||||
import functional from "eslint-plugin-functional";
|
|
||||||
import typescriptEslint from "typescript-eslint";
|
|
||||||
import sonarJs from "eslint-plugin-sonarjs";
|
|
||||||
import perfectionist from "eslint-plugin-perfectionist";
|
|
||||||
import unicorn from "eslint-plugin-unicorn";
|
|
||||||
|
|
||||||
//#region règles/javascript.ts
|
|
||||||
const règlesJavaScript = {
|
|
||||||
name: "JavaScript",
|
|
||||||
rules: {
|
|
||||||
...javascript.configs.recommended.rules,
|
|
||||||
"array-callback-return": ["error", {
|
|
||||||
allowVoid: true,
|
|
||||||
checkForEach: true
|
|
||||||
}],
|
|
||||||
"no-nested-ternary": "off",
|
|
||||||
"no-unassigned-vars": "error",
|
|
||||||
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
||||||
"no-unreachable-loop": "error",
|
|
||||||
"no-use-before-define": "off",
|
|
||||||
"no-useless-assignment": "error",
|
|
||||||
yoda: ["error", "never"]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/jsdoc.ts
|
|
||||||
const flatRecommended = jsdoc.configs["flat/recommended-typescript"];
|
|
||||||
const flatStylistic = jsdoc.configs["flat/stylistic-typescript"];
|
|
||||||
const règlesJsDoc = {
|
|
||||||
name: "JSDoc",
|
|
||||||
plugins: flatRecommended.plugins ?? {},
|
|
||||||
rules: {
|
|
||||||
...flatRecommended.rules,
|
|
||||||
...flatStylistic.rules,
|
|
||||||
"jsdoc/check-indentation": "warn",
|
|
||||||
"jsdoc/check-line-alignment": "warn",
|
|
||||||
"jsdoc/check-tag-names": ["warn", { definedTags: ["link"] }],
|
|
||||||
"jsdoc/lines-before-block": "off",
|
|
||||||
"jsdoc/no-blank-block-descriptions": "warn",
|
|
||||||
"jsdoc/no-blank-blocks": "warn",
|
|
||||||
"jsdoc/require-hyphen-before-param-description": ["warn", "never"],
|
|
||||||
"jsdoc/require-throws": "warn",
|
|
||||||
"jsdoc/sort-tags": "warn",
|
|
||||||
"jsdoc/tag-lines": "off"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/oxlint.ts
|
|
||||||
const règlesOxlint = {
|
|
||||||
name: "Oxlint",
|
|
||||||
...oxlint.configs["flat/recommended"][0]
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/programmation-fonctionnelle.ts
|
|
||||||
const règlesProgrammationFonctionnelle = {
|
|
||||||
name: "Programmation fonctionnelle",
|
|
||||||
plugins: { functional },
|
|
||||||
rules: {
|
|
||||||
...functional.configs.noExceptions.rules,
|
|
||||||
...functional.configs.noMutations.rules,
|
|
||||||
...functional.configs.externalTypeScriptRecommended.rules,
|
|
||||||
...functional.configs.stylistic.rules,
|
|
||||||
"@typescript-eslint/array-type": ["error", {
|
|
||||||
default: "generic",
|
|
||||||
readonly: "generic"
|
|
||||||
}],
|
|
||||||
"functional/prefer-immutable-types": "off",
|
|
||||||
"functional/prefer-tacit": "off",
|
|
||||||
"functional/readonly-type": ["error", "generic"],
|
|
||||||
"functional/type-declaration-immutability": "off"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/sonarjs.ts
|
|
||||||
const règlesSonarJs = {
|
|
||||||
name: "SonarJS",
|
|
||||||
plugins: sonarJs.configs.recommended.plugins ?? {},
|
|
||||||
rules: {
|
|
||||||
...sonarJs.configs.recommended.rules,
|
|
||||||
"sonarjs/arguments-usage": "error",
|
|
||||||
"sonarjs/no-collapsible-if": "error",
|
|
||||||
"sonarjs/no-duplicate-string": "error",
|
|
||||||
"sonarjs/no-inconsistent-returns": "error",
|
|
||||||
"sonarjs/no-nested-switch": "error",
|
|
||||||
"sonarjs/prefer-immediate-return": "error"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/tri.ts
|
|
||||||
const règlesTri = {
|
|
||||||
name: "Tri",
|
|
||||||
plugins: perfectionist.configs["recommended-natural"].plugins ?? {},
|
|
||||||
rules: perfectionist.configs["recommended-natural"].rules ?? {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/typescript.ts
|
|
||||||
const trouveConfiguration = (configuration, nom) => configuration.find((v) => v.name === nom) ?? {};
|
|
||||||
const base = trouveConfiguration(typescriptEslint.configs.strictTypeChecked, "typescript-eslint/base");
|
|
||||||
const desactivationsJavaScript = trouveConfiguration(typescriptEslint.configs.strictTypeChecked, "typescript-eslint/eslint-recommended");
|
|
||||||
const strictTypeChecked = trouveConfiguration(typescriptEslint.configs.strictTypeChecked, "typescript-eslint/strict-type-checked");
|
|
||||||
const stylisticTypeChecked = trouveConfiguration(typescriptEslint.configs.stylisticTypeChecked, "typescript-eslint/stylistic-type-checked");
|
|
||||||
const règlesTypeScript = {
|
|
||||||
languageOptions: base.languageOptions ?? {},
|
|
||||||
name: "TypeScript",
|
|
||||||
plugins: base.plugins ?? {},
|
|
||||||
rules: {
|
|
||||||
...desactivationsJavaScript.rules,
|
|
||||||
...strictTypeChecked.rules,
|
|
||||||
...stylisticTypeChecked.rules,
|
|
||||||
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
||||||
"@typescript-eslint/max-params": ["error", { max: 3 }],
|
|
||||||
"@typescript-eslint/method-signature-style": ["off", "property"],
|
|
||||||
"@typescript-eslint/no-magic-numbers": "off",
|
|
||||||
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
||||||
"@typescript-eslint/no-unnecessary-type-parameters": "off"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region règles/unicorn.ts
|
|
||||||
const règlesUnicorn = {
|
|
||||||
name: "Unicorn",
|
|
||||||
plugins: { unicorn },
|
|
||||||
rules: {
|
|
||||||
...unicorn.configs.unopinionated.rules,
|
|
||||||
"unicorn/catch-error-name": "error",
|
|
||||||
"unicorn/consistent-empty-array-spread": "error",
|
|
||||||
"unicorn/custom-error-definition": "error",
|
|
||||||
"unicorn/explicit-length-check": ["error", { "non-zero": "not-equal" }],
|
|
||||||
"unicorn/no-array-for-each": "off",
|
|
||||||
"unicorn/no-array-reduce": "off",
|
|
||||||
"unicorn/no-negated-condition": "error",
|
|
||||||
"unicorn/no-nested-ternary": "error",
|
|
||||||
"unicorn/no-null": "error",
|
|
||||||
"unicorn/prefer-dom-node-dataset": "off"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
//#region index.ts
|
|
||||||
const configTypescriptNavigateur = defineConfig([
|
|
||||||
globalIgnores(["dist/**/*"], "Ignore le dossier de compilation"),
|
|
||||||
{
|
|
||||||
files: ["**/*.js", "**/*.ts"],
|
|
||||||
name: "Fichiers à analyser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
ecmaVersion: "latest",
|
|
||||||
globals: {
|
|
||||||
...globals.browser,
|
|
||||||
...globals.builtin,
|
|
||||||
...globals.es2026,
|
|
||||||
...globals.node
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: "latest",
|
|
||||||
projectService: true,
|
|
||||||
sourceType: "module",
|
|
||||||
tsconfigRootDir: import.meta.dirname
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: "Configuration du projet"
|
|
||||||
},
|
|
||||||
règlesJavaScript,
|
|
||||||
règlesTypeScript,
|
|
||||||
règlesProgrammationFonctionnelle,
|
|
||||||
règlesUnicorn,
|
|
||||||
règlesSonarJs,
|
|
||||||
règlesJsDoc,
|
|
||||||
règlesTri,
|
|
||||||
règlesOxlint
|
|
||||||
]);
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
export { configTypescriptNavigateur };
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "node_modules/@gcch/configuration-dprint/dprint.json"
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineConfig } from "eslint/config";
|
import { defineConfig } from "eslint/config";
|
||||||
|
|
||||||
import { configTypescriptNavigateur } from ".";
|
import { configAstro } from ".";
|
||||||
|
|
||||||
export default defineConfig([...configTypescriptNavigateur]);
|
export default defineConfig([...configAstro]);
|
||||||
|
|
|
||||||
10
index.ts
10
index.ts
|
|
@ -4,12 +4,13 @@ import globals from "globals";
|
||||||
|
|
||||||
import { règlesJavaScript } from "./règles/javascript.ts";
|
import { règlesJavaScript } from "./règles/javascript.ts";
|
||||||
import { règlesJsDoc } from "./règles/jsdoc.ts";
|
import { règlesJsDoc } from "./règles/jsdoc.ts";
|
||||||
import { règlesOxlint } from "./règles/oxlint.ts";
|
|
||||||
import { règlesProgrammationFonctionnelle } from "./règles/programmation-fonctionnelle.ts";
|
import { règlesProgrammationFonctionnelle } from "./règles/programmation-fonctionnelle.ts";
|
||||||
import { règlesSonarJs } from "./règles/sonarjs.ts";
|
import { règlesSonarJs } from "./règles/sonarjs.ts";
|
||||||
import { règlesTri } from "./règles/tri.ts";
|
import { règlesTri } from "./règles/tri.ts";
|
||||||
import { règlesTypeScript } from "./règles/typescript.ts";
|
import { règlesTypeScript } from "./règles/typescript.ts";
|
||||||
import { règlesUnicorn } from "./règles/unicorn.ts";
|
import { règlesUnicorn } from "./règles/unicorn.ts";
|
||||||
|
import astro from "eslint-plugin-astro";
|
||||||
|
import { règlesAstro } from "./règles/astro.ts";
|
||||||
|
|
||||||
export const configTypescriptNavigateur: ReadonlyArray<Linter.Config> = defineConfig([
|
export const configTypescriptNavigateur: ReadonlyArray<Linter.Config> = defineConfig([
|
||||||
globalIgnores(["dist/**/*"], "Ignore le dossier de compilation"),
|
globalIgnores(["dist/**/*"], "Ignore le dossier de compilation"),
|
||||||
|
|
@ -42,5 +43,10 @@ export const configTypescriptNavigateur: ReadonlyArray<Linter.Config> = defineCo
|
||||||
règlesSonarJs,
|
règlesSonarJs,
|
||||||
règlesJsDoc,
|
règlesJsDoc,
|
||||||
règlesTri,
|
règlesTri,
|
||||||
règlesOxlint,
|
]);
|
||||||
|
|
||||||
|
export const configAstro: ReadonlyArray<Linter.Config> = defineConfig([
|
||||||
|
...configTypescriptNavigateur,
|
||||||
|
règlesAstro
|
||||||
|
// astro.configs["flat/recommended"],
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
47
package.json
47
package.json
|
|
@ -10,39 +10,34 @@
|
||||||
".": "./dist/index.mjs",
|
".": "./dist/index.mjs",
|
||||||
"./package.json": "./package.json"
|
"./package.json": "./package.json"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["dist"],
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^9.36.0",
|
"eslint": "^9.36.0",
|
||||||
"oxlint": "^1.28.0",
|
"oxlint": "^1.55.0",
|
||||||
"typescript": "^6.0.0-dev.20251111"
|
"typescript": "^6.0.1-rc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/js": "^9.39.1",
|
"@eslint/js": "^10.0.1",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^10.0.3",
|
||||||
"eslint-plugin-functional": "^9.0.2",
|
"eslint-plugin-astro": "^1.6.0",
|
||||||
"eslint-plugin-jsdoc": "^61.1.12",
|
"eslint-plugin-functional": "^9.0.4",
|
||||||
"eslint-plugin-oxlint": "^1.28.0",
|
"eslint-plugin-jsdoc": "^62.8.0",
|
||||||
"eslint-plugin-perfectionist": "^4.15.1",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-sonarjs": "^3.0.5",
|
"eslint-plugin-perfectionist": "^5.6.0",
|
||||||
"eslint-plugin-unicorn": "^62.0.0",
|
"eslint-plugin-sonarjs": "^4.0.2",
|
||||||
"globals": "^16.5.0",
|
"eslint-plugin-unicorn": "^63.0.0",
|
||||||
"typescript-eslint": "^8.46.4"
|
"globals": "^17.4.0",
|
||||||
|
"typescript-eslint": "^8.57.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@arethetypeswrong/core": "^0.18.2",
|
"@arethetypeswrong/core": "^0.18.2",
|
||||||
"@gcch/configuration-dprint": "^0.0.2",
|
"knip": "^5.86.0",
|
||||||
"@gcch/configuration-prettier": "^0.0.10",
|
"prettier": "^4.0.0-alpha.13",
|
||||||
"knip": "^5.69.0",
|
"prettier-plugin-curly": "^0.4.1",
|
||||||
"prettier": "^4.0.0-alpha.12",
|
"prettier-plugin-jsdoc": "^1.8.0",
|
||||||
"prettier-plugin-curly": "^0.4.0",
|
|
||||||
"prettier-plugin-jsdoc": "^1.5.0",
|
|
||||||
"prettier-plugin-sh": "^0.18.0",
|
"prettier-plugin-sh": "^0.18.0",
|
||||||
"publint": "^0.3.15",
|
"publint": "^0.3.18",
|
||||||
"tsdown": "^0.16.2"
|
"tsdown": "^0.21.2"
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": ["oxc-resolver"]
|
||||||
"oxc-resolver"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
règles/astro.ts
Normal file
31
règles/astro.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import type { Linter } from "eslint";
|
||||||
|
|
||||||
|
import astro from "eslint-plugin-astro";
|
||||||
|
|
||||||
|
export const règlesAstro: Readonly<Linter.Config> = {
|
||||||
|
files: ["**/*.astro"],
|
||||||
|
plugins: {
|
||||||
|
astro: astro.configs["flat/base"][0]?.plugins.astro ?? {},
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
parser: "astro-eslint-parser",
|
||||||
|
sourceType: "module",
|
||||||
|
parserOptions: {
|
||||||
|
parser: {
|
||||||
|
version: "8.57.0",
|
||||||
|
meta: {
|
||||||
|
name: "typescript-eslint/parser",
|
||||||
|
version: "8.57.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extraFileExtensions: [".astro"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...astro.configs["flat/recommended"][4]?.rules,
|
||||||
|
...astro.configs["jsx-a11y-strict"][4]?.rules,
|
||||||
|
},
|
||||||
|
name: "Astro",
|
||||||
|
};
|
||||||
|
|
||||||
|
console.debug(règlesAstro);
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import type { Linter } from "eslint";
|
|
||||||
|
|
||||||
import oxlint from "eslint-plugin-oxlint";
|
|
||||||
|
|
||||||
export const règlesOxlint: Readonly<Linter.Config> = {
|
|
||||||
name: "Oxlint",
|
|
||||||
...oxlint.configs["flat/recommended"][0],
|
|
||||||
};
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue