102 lines
2.2 KiB
JavaScript
102 lines
2.2 KiB
JavaScript
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",
|
|
]),
|
|
},
|
|
},
|
|
];
|