feat: enforce frontend architecture boundaries
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import eslint from "@eslint/js";
|
||||
import globals from "globals";
|
||||
|
||||
const layerPatterns = {
|
||||
domain: [
|
||||
"**/application/**",
|
||||
"**/presentation/**",
|
||||
"**/adapters/**",
|
||||
"**/bootstrap/**",
|
||||
"react",
|
||||
"react-dom",
|
||||
"@tanstack/**",
|
||||
],
|
||||
application: [
|
||||
"**/presentation/**",
|
||||
"**/adapters/**",
|
||||
"**/bootstrap/**",
|
||||
"react",
|
||||
"react-dom",
|
||||
"@tanstack/**",
|
||||
],
|
||||
presentation: ["**/adapters/**", "**/bootstrap/**", "@tanstack/**"],
|
||||
adapters: ["**/presentation/**", "**/bootstrap/**"],
|
||||
};
|
||||
|
||||
function restrictedImports(patterns) {
|
||||
return ["error", { patterns }];
|
||||
}
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: [
|
||||
"dist/**",
|
||||
"node_modules/**",
|
||||
"artifacts/**",
|
||||
"tests/fixtures/typecheck/**",
|
||||
"tests/fixtures/architecture/forbidden/**",
|
||||
],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
{
|
||||
files: ["**/*.{js,jsx,mjs}"],
|
||||
languageOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaFeatures: { jsx: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/domain/**/*.{js,jsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": restrictedImports(layerPatterns.domain),
|
||||
"no-restricted-globals": ["error", "window", "document", "localStorage", "fetch"],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/application/**/*.{js,jsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": restrictedImports(layerPatterns.application),
|
||||
"no-restricted-globals": ["error", "window", "document", "localStorage", "fetch"],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/presentation/**/*.{js,jsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": restrictedImports(layerPatterns.presentation),
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/adapters/**/*.{js,jsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": restrictedImports(layerPatterns.adapters),
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["tests/**/*.{js,jsx}"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["tests/fixtures/architecture/forbidden/**/*.{js,jsx}"],
|
||||
rules: {
|
||||
"no-restricted-imports": restrictedImports([
|
||||
"**/adapters/**",
|
||||
"@tanstack/**",
|
||||
"react",
|
||||
"react-dom",
|
||||
]),
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user