mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-29 18:59:20 +01:00
* chore(deps): update dependency eslint to v9 * chore: migrate eslint to v9 * fix: dependency issues * fix: unit tests not working * chore: disable lint check for Image component that does not work in ci * fix: lint issue --------- Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
91 lines
3.3 KiB
JavaScript
91 lines
3.3 KiB
JavaScript
/// <reference types="./types.d.ts" />
|
|
|
|
import eslint from "@eslint/js";
|
|
import importPlugin from "eslint-plugin-import";
|
|
import tseslint from "typescript-eslint";
|
|
|
|
export default tseslint.config(
|
|
{
|
|
// Globally ignored files
|
|
ignores: ["**/*.config.js"],
|
|
},
|
|
{
|
|
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
|
plugins: {
|
|
import: importPlugin,
|
|
},
|
|
extends: [
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
...tseslint.configs.recommendedTypeChecked,
|
|
...tseslint.configs.stylisticTypeChecked,
|
|
],
|
|
rules: {
|
|
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
"@typescript-eslint/consistent-type-imports": [
|
|
"warn",
|
|
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
|
|
],
|
|
"@typescript-eslint/no-misused-promises": [2, { checksVoidReturn: { attributes: false } }],
|
|
"@typescript-eslint/no-unnecessary-condition": [
|
|
"error",
|
|
{
|
|
allowConstantLoopConditions: true,
|
|
},
|
|
],
|
|
"@typescript-eslint/no-non-null-assertion": "error",
|
|
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
"id-length": [
|
|
"warn",
|
|
{
|
|
min: 3,
|
|
exceptions: ["_", "i", "z", "t", "id", "db"], // _ for unused variables, i for index, z for zod, t for translation
|
|
properties: "never", // This allows for example the use of <Grid.Col span={{ sm: 12, md: 6 }}> as sm and md would be too short
|
|
},
|
|
],
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
{
|
|
selector: "FunctionDeclaration[async=false][id.name=/Async$/]",
|
|
message: "Function ending in 'Async' must be declared async",
|
|
},
|
|
{
|
|
selector:
|
|
"FunctionDeclaration[async=true][id.name=/^[a-z].*$/][id.name=/ ^(?!generateMetadata$)[a-z].*$/][id.name!=/Async$/]",
|
|
message: "Async function name must end in 'Async' (function declaration)",
|
|
},
|
|
{
|
|
selector: "MethodDefinition[value.async=false][key.name=/Async$/]",
|
|
message: "Method ending in 'Async' must be declared async",
|
|
},
|
|
{
|
|
selector: "MethodDefinition[value.async=true][key.name!=/Async$/]",
|
|
message: "Async method name must end in 'Async'",
|
|
},
|
|
{
|
|
selector: "Property[value.type=/FunctionExpression$/][value.async=false][key.name=/Async$/]",
|
|
message: "Function ending in 'Async' must be declared async",
|
|
},
|
|
{
|
|
selector:
|
|
"Property[value.type=/FunctionExpression$/][value.async=true][key.name!=/^on(Success|Settled)$/][key.name!=/Async$/]",
|
|
message: "Async function name must end in 'Async' (property)",
|
|
},
|
|
{
|
|
selector: "VariableDeclarator[init.type=/FunctionExpression$/][init.async=false][id.name=/Async$/]",
|
|
message: "Function ending in 'Async' must be declared async",
|
|
},
|
|
{
|
|
selector:
|
|
"VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name=/^[a-z].*$/][id.name!=/Async$/]",
|
|
message: "Async function name must end in 'Async' (variable declarator)",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
languageOptions: { parserOptions: { project: true } },
|
|
},
|
|
);
|