forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.module-boundaries.mjs
More file actions
108 lines (101 loc) · 2.88 KB
/
Copy patheslint.config.module-boundaries.mjs
File metadata and controls
108 lines (101 loc) · 2.88 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Standalone eslint config for running only module boundary linting.
//
// Usage: bunx eslint --config eslint.config.module-boundaries.mjs "frontend/src/**/*.{js,jsx,ts,tsx}" "enterprise/frontend/src/**/*.{js,jsx,ts,tsx}"
import path from "path";
import { fileURLToPath } from "url";
import boundaries from "eslint-plugin-boundaries";
import react from "eslint-plugin-react";
import tseslint from "typescript-eslint";
import { globalIgnores, defineConfig } from "eslint/config";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
import {
elements as boundaryElements,
rules as boundaryRules,
} from "./frontend/lint/module-boundaries.mjs";
// dummy plugins to keep eslint from complaining about missing plugins and settings
const alwaysPassingRule = {
meta: {
type: "problem",
docs: {
description: "stub for ttag/no-module-declaration - always passes",
},
schema: [],
},
create() {
// Return an empty visitor object - this rule does nothing and always passes
return {};
},
};
// Resolve any rule name to the always-passing stub, so eslint-disable
// directives don't error with "Definition for rule ... was not found".
const alwaysPassingPlugin = {
rules: new Proxy(
{},
{
get: () => alwaysPassingRule,
has: () => true,
},
),
};
export default defineConfig([
globalIgnores(["**/e2e/**", "test/**"]),
{
linterOptions: {
reportUnusedDisableDirectives: "off",
},
files: [
"frontend/src/**/*.{js,jsx,ts,tsx}",
"enterprise/frontend/src/**/*.{js,jsx,ts,tsx}",
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
ttag: alwaysPassingPlugin,
metabase: alwaysPassingPlugin,
import: alwaysPassingPlugin,
i18next: alwaysPassingPlugin,
"react-hooks": alwaysPassingPlugin,
"@typescript-eslint": alwaysPassingPlugin,
"testing-library": alwaysPassingPlugin,
jest: alwaysPassingPlugin,
"jest-dom": alwaysPassingPlugin,
boundaries,
react,
},
settings: {
"boundaries/elements": boundaryElements,
"boundaries/ignore": ["**/e2e/**", "test/**"],
"import-x/resolver": {
node: true,
webpack: {
config: path.resolve(__dirname, "./rspack.main.config.js"),
typescript: true,
},
},
"import/resolver": {
node: true,
webpack: {
config: path.resolve(__dirname, "./rspack.main.config.js"),
typescript: true,
},
},
},
rules: {
"boundaries/element-types": [
"error",
{
default: "disallow",
rules: boundaryRules,
},
],
// Every file frontend/src/ and enterprise/frontend/src/ must belong to a declared module.
"boundaries/no-unknown-files": "error",
},
},
]);