0.0.11
This commit is contained in:
parent
d14e999d04
commit
62ee424274
27 changed files with 1290 additions and 996 deletions
116
rules/astro.ts
Normal file
116
rules/astro.ts
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/* eslint-disable unicorn/no-null -- Le null est nécessaire ici. */
|
||||
/* eslint-disable functional/no-throw-statements -- L'exécution d'ESLint doit pouvoir s'arrêter en cas d'échec critique. */
|
||||
|
||||
import type { ESLint, Linter } from "eslint";
|
||||
|
||||
import * as astroEsLintParser from "astro-eslint-parser";
|
||||
import astro from "eslint-plugin-astro";
|
||||
import globals from "globals";
|
||||
import typeScriptEsLint from "typescript-eslint";
|
||||
|
||||
const getAstroPlugin = (): ESLint.Plugin => {
|
||||
const firstBaseConfig = astro.configs.base.at(0);
|
||||
|
||||
if (firstBaseConfig === undefined) {
|
||||
throw new Error("Impossible de récupérer la configuration de base du plugin Astro.");
|
||||
}
|
||||
|
||||
const astroPlugin = firstBaseConfig.plugins?.["astro"];
|
||||
|
||||
if (astroPlugin === undefined) {
|
||||
throw new Error("Impossible de récupérer le plugin Astro.");
|
||||
}
|
||||
|
||||
return astroPlugin;
|
||||
};
|
||||
|
||||
export const astroRules: ReadonlyArray<Linter.Config> = [
|
||||
{
|
||||
files: ["**/*.astro"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.astro,
|
||||
},
|
||||
parser: astroEsLintParser,
|
||||
parserOptions: {
|
||||
extraFileExtensions: [".astro"],
|
||||
parser: typeScriptEsLint.parser,
|
||||
/// Ces lignes sont nécessaires pour surcharger la configuration pour les fichiers TS.
|
||||
project: true,
|
||||
projectService: null,
|
||||
tsconfigRootDir: null,
|
||||
},
|
||||
sourceType: "module",
|
||||
},
|
||||
name: "Astro",
|
||||
plugins: {
|
||||
astro: getAstroPlugin(),
|
||||
},
|
||||
processor: "astro/client-side-ts",
|
||||
rules: {
|
||||
//
|
||||
// Enforce that all elements that require alternative text have meaningful information to relay back to the end user.
|
||||
"astro/jsx-a11y/alt-text": "error",
|
||||
// Enforces <a> values are not exact matches for the phrases “click here”, “here”, “link”, “a link”, or “learn more”.
|
||||
"astro/jsx-a11y/anchor-ambiguous-text": "error",
|
||||
// Enforce that anchors have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden prop.
|
||||
"astro/jsx-a11y/anchor-has-content": "error",
|
||||
// Ennforces that <a> elements avec valid hyperlinks (and not buttons).
|
||||
"astro/jsx-a11y/anchor-is-valid": "error",
|
||||
// Enforces good aria-activedescendant handling.
|
||||
"astro/jsx-a11y/aria-activedescendant-has-tabindex": "error",
|
||||
// Elements cannot use an invalid ARIA attribute. This will fail if it finds an aria-* property that is not listed in WAI-ARIA States and Properties spec.
|
||||
"astro/jsx-a11y/aria-props": "error",
|
||||
// ARIA state and property values must be valid.
|
||||
"astro/jsx-a11y/aria-proptypes": "error",
|
||||
// Elements with ARIA roles must use a valid, non-abstract ARIA role. A reference to role definitions can be found at
|
||||
"astro/jsx-a11y/aria-role": "error",
|
||||
// This rule reports not setting a value for the client:only directive.
|
||||
"astro/missing-client-only-directive-value": "error",
|
||||
// This rule reports conflicting set:text, set:html, and child content.
|
||||
"astro/no-conflict-set-directives": "error",
|
||||
// This rule reports use of deprecated Astro.canonicalURL.
|
||||
"astro/no-deprecated-astro-canonicalurl": "error",
|
||||
// This rule reports use of deprecated Astro.fetchContent().
|
||||
"astro/no-deprecated-astro-fetchcontent": "error",
|
||||
// This rule reports use of deprecated Astro.resolve().
|
||||
"astro/no-deprecated-astro-resolve": "error",
|
||||
// This rule reports use of deprecated getEntryBySlug().
|
||||
"astro/no-deprecated-getentrybyslug": "error",
|
||||
// This rule reports value exports from Astro components. The use of typed exports are still allowed.
|
||||
"astro/no-exports-from-components": "error",
|
||||
// This rule reports all uses of set:html in order to reduce the risk of injecting potentially unsafe / unescaped html into the browser leading to Cross-Site Scripting (XSS) attacks.
|
||||
"astro/no-set-html-directive": "error",
|
||||
// This rule reports all uses of set:text directive.
|
||||
"astro/no-set-text-directive": "error",
|
||||
// This rule aims to remove unused CSS selectors.
|
||||
"astro/no-unused-css-selector": "error",
|
||||
// This rule is aimed at eliminating unused defined variables in define:vars={...} in style tag.
|
||||
"astro/no-unused-define-vars-in-style": "error",
|
||||
// This rule aims to replace the class attribute with expression with the class:list directive.
|
||||
"astro/prefer-class-list-directive": "error",
|
||||
// This rule aims to replace the class attribute with expression with the class:list directive.
|
||||
"astro/prefer-object-class-list": "error",
|
||||
// This rule aims to use split array elements than string concatenation in class:list.
|
||||
"astro/prefer-split-class-list": ["error", { splitLiteral: false }],
|
||||
// This rule ensures that attributes are sorted, making the structure of your elements more predictable and easier to manage.
|
||||
"astro/sort-attributes": ["error", { ignoreCase: false, order: "asc", type: "alphabetical" }],
|
||||
// This rule uses @astrojs/compiler to check the source code.
|
||||
"astro/valid-compile": "error",
|
||||
// TODO: Finir.
|
||||
},
|
||||
},
|
||||
{
|
||||
/// Cette configuration permet de vérfier les blocs TS dans les fichiers Astro.
|
||||
files: ["**/*.astro/*.ts"],
|
||||
languageOptions: {
|
||||
globals: { ...globals.browser },
|
||||
parser: typeScriptEsLint.parser,
|
||||
parserOptions: {
|
||||
project: null,
|
||||
},
|
||||
sourceType: "module",
|
||||
},
|
||||
name: "Astro/TypeScript",
|
||||
},
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue