citation-work/eslint.config.js

72 lines
2.1 KiB
JavaScript
Raw Normal View History

import js from "@eslint/js";
import tseslint from "typescript-eslint";
import boundaries from "eslint-plugin-boundaries";
import importPlugin from "eslint-plugin-import";
import globals from "globals";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const engineSrc = resolve(__dirname, "../citation-engine/src");
const anchorSrc = resolve(__dirname, "../evidence-anchor/src");
const sourceSrc = resolve(__dirname, "../citation-evidence/src/source");
export default tseslint.config(
{
ignores: ["dist/", "node_modules/", "coverage/", "**/*.d.ts"],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ["src/**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: { ...globals.browser, ...globals.node },
},
plugins: {
boundaries,
import: importPlugin,
},
settings: {
"import/resolver": {
typescript: { project: "./tsconfig.json" },
},
"boundaries/elements": [
{ type: "shared", pattern: `${engineSrc}/shared/**` },
{ type: "engine", pattern: `${engineSrc}/engine/**` },
{ type: "anchor", pattern: `${anchorSrc}/**` },
{ type: "source", pattern: `${sourceSrc}/**` },
{ type: "work", pattern: "src/work/**" },
],
},
rules: {
"boundaries/element-types": [
2,
{
default: "disallow",
rules: [
{ from: "shared", allow: [] },
{ from: "engine", allow: ["shared"] },
{ from: "anchor", allow: ["shared", "engine"] },
{ from: "source", allow: ["shared", "engine"] },
{ from: "work", allow: ["shared", "engine", "anchor", "source", "work"] },
],
},
],
"no-restricted-imports": [
2,
{
patterns: [
"@binder/*",
"@app/*",
"../citation-evidence/src/app/*",
"../citation-evidence/src/binder/*",
"../citation-evidence/src/work/*",
],
},
],
},
},
);