81 lines
3.5 KiB
TypeScript
81 lines
3.5 KiB
TypeScript
/* eslint-disable unicorn/no-null -- Le null est nécessaire ici. */
|
|
|
|
import type { 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";
|
|
|
|
export const astroRules: ReadonlyArray<Linter.Config> = [
|
|
{
|
|
files: ["**/*.astro"],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.astro,
|
|
},
|
|
parser: astroEsLintParser,
|
|
parserOptions: {
|
|
extraFileExtensions: [".astro"],
|
|
parser: typeScriptEsLint.parser,
|
|
project: true,
|
|
projectService: null,
|
|
tsconfigRootDir: null,
|
|
},
|
|
sourceType: "module",
|
|
},
|
|
name: "Astro",
|
|
plugins: {
|
|
astro: astro.configs.base[0]?.plugins.astro ?? {},
|
|
},
|
|
processor: "astro/client-side-ts",
|
|
rules: {
|
|
// 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: Sélectionner manuellement les règles.
|
|
...astro.configs["jsx-a11y-strict"][4]?.rules,
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.astro/*.ts"],
|
|
languageOptions: {
|
|
globals: { ...globals.browser },
|
|
parser: typeScriptEsLint.parser,
|
|
parserOptions: {
|
|
project: null,
|
|
},
|
|
sourceType: "module",
|
|
},
|
|
name: "Astro/TypeScript",
|
|
},
|
|
];
|