-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
61 lines (52 loc) · 1.96 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import boundaries from "eslint-plugin-boundaries";
import checkFile from "eslint-plugin-check-file";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
const projectFolders = ["assets", "components", "config", "hooks", "lib", "stores", "testing", "types", "utils"];
const settings = {
"boundaries/include": ["src/**/*"],
"boundaries/elements": [
{ mode: "full", type: "shared", pattern: projectFolders.map((folder) => `src/${folder}/**/*`) },
{ mode: "full", type: "feature", capture: ["featureName"], pattern: ["src/features/*/**/*"] },
{ mode: "full", type: "app", capture: ["_", "fileName"], pattern: ["src/app/**/*"] },
],
};
const boundariesRules = {
default: "disallow",
rules: [
{ from: "shared", allow: ["shared"] },
{ from: "feature", allow: ["shared", ["feature", { featureName: "${from.featureName}" }]] },
{ from: "app", allow: ["app", "shared", "feature"] },
],
};
const rules = {
"prefer-arrow-callback": "error",
"prefer-template": "error",
"prefer-const": "error",
semi: ["error", "always"],
quotes: ["error", "double"],
"check-file/filename-naming-convention": [
"error",
{ "**/*.{ts,tsx}": "KEBAB_CASE" },
{ ignoreMiddleExtensions: true },
],
"check-file/folder-naming-convention": ["error", { "src/**": "KEBAB_CASE" }],
"boundaries/no-unknown": "error",
"boundaries/no-unknown-files": "error",
"boundaries/element-types": ["error", boundariesRules],
};
const config = [
...compat.extends("next/core-web-vitals", "next/typescript", "prettier"),
{ plugins: { "check-file": checkFile, boundaries }, ...{ settings, rules } },
js.configs.recommended,
];
export default config;