123 lines
2.9 KiB
JavaScript
123 lines
2.9 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/**",
|
|
"tests/fixtures/security/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",
|
|
]),
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.{js,jsx}"],
|
|
rules: {
|
|
"no-eval": "error",
|
|
"no-new-func": "error",
|
|
"no-script-url": "error",
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
{
|
|
selector: "JSXAttribute[name.name='dangerouslySetInnerHTML']",
|
|
message: "Raw HTML injection is prohibited by FE-OC-019.",
|
|
},
|
|
{
|
|
selector:
|
|
"CallExpression[callee.object.name='document'][callee.property.name='createElement'][arguments.0.value='script']",
|
|
message: "Runtime script construction is prohibited by FE-OC-019.",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
];
|