mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-29 02:19:51 +00:00
https://github.com/the-draupnir-project/planning/issues/104 I don't know what the fuck they are doing with the typings in the vector bot-sdk repository but whatever. https://github.com/the-draupnir-project/Draupnir/issues/1053
139 lines
4.8 KiB
JavaScript
139 lines
4.8 KiB
JavaScript
// SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
|
|
//
|
|
// SPDX-License-Identifier: 0BSD
|
|
|
|
import eslint from "@eslint/js";
|
|
import tseslint from "typescript-eslint";
|
|
import tsplugin from "@typescript-eslint/eslint-plugin";
|
|
|
|
// this configuration file stilli includes random shite from these directories
|
|
// and I do not understand why. It is one of the most frustraiting things
|
|
// my guess is that there is some hidden ambient config that is included
|
|
// full of eslint defaults that we can't intercept??
|
|
// I don't know, but it's one of the most frustraiting things ever.
|
|
const ignores = [
|
|
"**/docs/**",
|
|
"**/.husky/**",
|
|
"**/coverage/**",
|
|
"**/dist/**",
|
|
"**/lib/**",
|
|
"**/node_modules/**",
|
|
"**/*.js",
|
|
"**/*.jsx"
|
|
];
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores
|
|
},
|
|
{
|
|
// This is a typescript-eslint configurartion for typescript files.
|
|
// This will not work against js files.
|
|
files: [
|
|
"packages/**/src/**/*.ts",
|
|
"packages/**/src/**/*.tsx",
|
|
"packages/**/test/**/*.ts",
|
|
"packages/**/test/**/*.tsx",
|
|
"apps/**/src/**/*.ts",
|
|
"apps/**/src/**/*.tsx",
|
|
"apps/**/test/**/*.ts",
|
|
"apps/**/test/**/*.tsx",
|
|
],
|
|
extends: [
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.strictTypeChecked,
|
|
],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
project: [
|
|
"./apps/*/tsconfig.test.json",
|
|
"./apps/*/tsconfig.json",
|
|
"./packages/*/tsconfig.test.json",
|
|
"./packages/*/tsconfig.json",
|
|
],
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
// This is needed in order to specify the desired behavior for its rules
|
|
plugins: {
|
|
"@typescript-eslint": tsplugin,
|
|
},
|
|
rules: {
|
|
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
|
|
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
|
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{ argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
|
|
],
|
|
// we implement a lot of interfaces that return promises with synchronous functions.
|
|
"require-await": "off",
|
|
"@typescript-eslint/require-await": "off",
|
|
// we need never because our code can be wrong!
|
|
"@typescript-eslint/restrict-template-expressions": [
|
|
"error",
|
|
{ allowNever: true },
|
|
],
|
|
// stylistic recommendation that doesn't play well with event emitter interfaces.
|
|
"@typescript-eslint/unified-signatures": "off",
|
|
// There are some compelling arguments for including this rule,
|
|
// but other than using namespaces, we don't have granular enough modules
|
|
// to be able to depend on their behaviour. This should be revisited.
|
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
"@typescript-eslint/unbound-method": [
|
|
"error",
|
|
{ ignoreStatic: true }
|
|
],
|
|
// We want to be able to create infinite loops.
|
|
"@typescript-eslint/no-unnecessary-condition": [
|
|
"error",
|
|
{ allowConstantLoopConditions: true },
|
|
],
|
|
// This rule is unstable as hell and tries to apply itself to interfaces.
|
|
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
"@typescript-eslint/no-empty-object-type": [
|
|
"error",
|
|
{ allowInterfaces: "with-single-extends" },
|
|
],
|
|
"@typescript-eslint/no-deprecated": [
|
|
"error",
|
|
{
|
|
allow: [
|
|
// Idk why they did this but whatever https://github.com/element-hq/matrix-bot-sdk/pull/66/changes#r2965217095
|
|
{ from: "package", name: "getRoomStateEvent", package: "@vector-im/matrix-bot-sdk" },
|
|
],
|
|
},
|
|
],
|
|
// We intentionally use enums to compare against non enum values, but no doubt this one will bite us in the ass later
|
|
},
|
|
ignores,
|
|
},
|
|
{
|
|
files: ["packages/matrix-protection-suite/**/*.{ts,tsx}"],
|
|
rules: {
|
|
// We intentionally compare enums to non enum values but no doubt it will bite us in the ass later
|
|
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
},
|
|
ignores,
|
|
},
|
|
{
|
|
files: ["apps/draupnir/**/*.{ts,tsx}"],
|
|
rules: {
|
|
"@typescript-eslint/no-deprecated": [
|
|
"error",
|
|
{
|
|
allow: [
|
|
{ from: "file", name: "logMessage" },
|
|
{ from: "file", name: "allocateProtection" },
|
|
// Idk why they did this but whatever https://github.com/element-hq/matrix-bot-sdk/pull/66/changes#r2965217095
|
|
{ from: "package", name: "getRoomStateEvent", package: "@vector-im/matrix-bot-sdk" },
|
|
],
|
|
},
|
|
],
|
|
// We intentionally compare enums to non enum values but no doubt it will bite us in the ass later
|
|
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
},
|
|
ignores,
|
|
}
|
|
);
|