0.0.11
This commit is contained in:
parent
d14e999d04
commit
3e409c2b95
27 changed files with 1235 additions and 997 deletions
78
rules/typescript.ts
Normal file
78
rules/typescript.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import type { Linter } from "eslint";
|
||||
|
||||
import typescriptEslint from "typescript-eslint";
|
||||
|
||||
type EsLintConfig = Readonly<Linter.Config>;
|
||||
|
||||
const findConfiguration = (configuration: ReadonlyArray<Linter.Config>, nom: string): EsLintConfig =>
|
||||
configuration.find((v: EsLintConfig) => v.name === nom) ?? {};
|
||||
|
||||
const base = findConfiguration(typescriptEslint.configs.strictTypeChecked, "typescript-eslint/base");
|
||||
const desactivationsJavaScript = findConfiguration(
|
||||
typescriptEslint.configs.strictTypeChecked,
|
||||
"typescript-eslint/eslint-recommended",
|
||||
);
|
||||
const strictTypeChecked = findConfiguration(
|
||||
typescriptEslint.configs.strictTypeChecked,
|
||||
"typescript-eslint/strict-type-checked",
|
||||
);
|
||||
const stylisticTypeChecked = findConfiguration(
|
||||
typescriptEslint.configs.stylisticTypeChecked,
|
||||
"typescript-eslint/stylistic-type-checked",
|
||||
);
|
||||
|
||||
export const typeScriptRules: Readonly<Linter.Config> = {
|
||||
languageOptions: base.languageOptions ?? {},
|
||||
name: "TypeScript",
|
||||
plugins: base.plugins ?? {},
|
||||
rules: {
|
||||
...desactivationsJavaScript.rules,
|
||||
...strictTypeChecked.rules,
|
||||
...stylisticTypeChecked.rules,
|
||||
/**
|
||||
* Impose un usage consistant entre interfaces et types. Ici préfère les déclarations de types.
|
||||
*
|
||||
* @link [typescript-eslint](https://typescript-eslint.io/rules/consistent-type-definitions)
|
||||
*/
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
||||
/**
|
||||
* Interdit la définition de fonctions avec plus de 3 paramètres.
|
||||
*
|
||||
* @link [typescript-eslint](https://eslint.org/docs/latest/rules/max-params)
|
||||
*/
|
||||
"@typescript-eslint/max-params": ["error", { max: 3 }],
|
||||
/**
|
||||
* Impose une syntaxe particulière pour les signatures de méthodes au sein d'interfaces et types. Ici utilise la
|
||||
* syntaxe « propriété ».
|
||||
*
|
||||
* ```typescript
|
||||
* interface Exemple {
|
||||
* func: (arg: string) => number;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @link [typescript-eslint](https://typescript-eslint.io/rules/method-signature-style/)
|
||||
*/
|
||||
"@typescript-eslint/method-signature-style": ["off", "property"],
|
||||
/**
|
||||
* Interdit l'usage de nombres magiques. Cette règle étend
|
||||
* [no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers) de la configuration de base _ESLint_.
|
||||
*
|
||||
* @link [typescript-eslint](https://eslint.org/docs/latest/rules/no-magic-numbers)
|
||||
*/
|
||||
"@typescript-eslint/no-magic-numbers": "off",
|
||||
/**
|
||||
* Autorise ici la comparaison avec des littéraux booléens. La désactivation de cette règle permet des comparaisons
|
||||
* plus claires qu'avec l'opérateur de négation `!`.
|
||||
*
|
||||
* @link [typescript-eslint](https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare)
|
||||
*/
|
||||
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
||||
/**
|
||||
* Interdit l'usage de paramètres de types non utilisés plusieurs fois. Désactivé ici à cause de faux positifs.
|
||||
*
|
||||
* @link [typescript-eslint](https://typescript-eslint.io/rules/no-unnecessary-type-parameters)
|
||||
*/
|
||||
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue