ci: add eslint
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { includeIgnoreFile } from "@eslint/compat";
|
||||
import js from "@eslint/js";
|
||||
import vitest from "@vitest/eslint-plugin";
|
||||
import prettier from "eslint-config-prettier";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import globals from "globals";
|
||||
import path from "node:path";
|
||||
import ts from "typescript-eslint";
|
||||
|
||||
const gitignorePath = path.resolve(import.meta.dirname, ".gitignore");
|
||||
|
||||
export default defineConfig(
|
||||
includeIgnoreFile(gitignorePath),
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
prettier,
|
||||
{
|
||||
languageOptions: { globals: { ...globals.node } },
|
||||
rules: {
|
||||
"no-undef": "off",
|
||||
// base rule is for JS; TS interfaces/ctors need the typed version below
|
||||
"no-unused-vars": "off",
|
||||
"no-console": ["error", { allow: ["warn", "error"] }],
|
||||
"@typescript-eslint/no-magic-numbers": [
|
||||
"error",
|
||||
{
|
||||
enforceConst: true,
|
||||
ignoreDefaultValues: true,
|
||||
ignore: [0, 1, 2],
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
caughtErrorsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["**/constants.ts", "**/constants/*.ts"],
|
||||
rules: {
|
||||
"no-magic-numbers": "off",
|
||||
"@typescript-eslint/no-magic-numbers": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["scripts/**"],
|
||||
rules: {
|
||||
"no-magic-numbers": "off",
|
||||
"@typescript-eslint/no-magic-numbers": "off",
|
||||
"no-console": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.test.ts", "src/**/*.spec.ts", "tests/**/*.test.ts"],
|
||||
plugins: { vitest },
|
||||
rules: {
|
||||
...vitest.configs.recommended.rules,
|
||||
|
||||
"vitest/no-focused-tests": "error",
|
||||
"vitest/no-disabled-tests": "warn",
|
||||
"vitest/expect-expect": "error",
|
||||
"vitest/no-conditional-expect": "error",
|
||||
"vitest/require-hook": "warn",
|
||||
"vitest/consistent-test-it": [
|
||||
"error",
|
||||
{ fn: "it", withinDescribe: "it" },
|
||||
],
|
||||
"vitest/require-top-level-describe": "error",
|
||||
"vitest/no-identical-title": "error",
|
||||
|
||||
"no-magic-numbers": "off",
|
||||
"@typescript-eslint/no-magic-numbers": "off",
|
||||
},
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user