fix: eslintrc to json, added missing eslint plugins

This commit is contained in:
Dmitriy Bratchikov
2024-05-27 16:10:17 +07:00
parent 34217c639f
commit 7e4ab61c34
3 changed files with 199 additions and 197 deletions
-196
View File
@@ -1,196 +0,0 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh", "boundaries"],
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
"boundaries/include": ["src/**/*"],
"boundaries/elements": [
{
type: "app",
pattern: "app",
},
{
type: "pages",
pattern: "src/pages/*",
capture: ["page"],
},
{
type: "widgets",
pattern: "widgets/*",
capture: ["widget"],
},
{
type: "features",
pattern: "features/*",
capture: ["feature"],
},
{
type: "entities",
pattern: "entities/*",
capture: ["entity"],
},
{
type: "shared",
pattern: "shared/*",
capture: ["segment"],
},
],
},
rules: {
"react-refresh/only-export-components": 0,
"boundaries/entry-point": [
2,
{
default: "disallow",
rules: [
{
target: [
[
"shared",
{
segment: "lib",
},
],
],
allow: "*/index.ts",
},
{
target: [
[
"shared",
{
segment: "lib",
},
],
],
allow: "*.(ts|tsx)",
},
{
target: [
[
"shared",
{
segment: "constants",
},
],
],
allow: "index.ts",
},
{
target: [
[
"shared",
{
segment: "ui", // ("ui"|"constants")
},
],
],
allow: "**",
},
{
target: ["app", "pages", "widgets", "features", "entities"],
allow: "index.(ts|tsx)",
},
],
},
],
"boundaries/element-types": [
2,
{
default: "allow",
message: "${file.type} is not allowed to import (${dependency.type})",
rules: [
{
from: ["shared"],
disallow: ["app", "pages", "widgets", "features", "entities"],
message:
"Shared module must not import upper layers (${dependency.type})",
},
{
from: ["entities"],
message: "Entity must not import upper layers (${dependency.type})",
disallow: ["app", "pages", "widgets", "features"],
},
{
from: ["entities"],
message: "Entity must not import other entity",
disallow: [
[
"entities",
{
entity: "!${entity}",
},
],
],
},
{
from: ["features"],
message:
"Feature must not import upper layers (${dependency.type})",
disallow: ["app", "pages", "widgets"],
},
{
from: ["features"],
message: "Feature must not import other feature",
disallow: [
[
"features",
{
feature: "!${feature}",
},
],
],
},
{
from: ["widgets"],
message:
"Feature must not import upper layers (${dependency.type})",
disallow: ["app", "pages"],
},
{
from: ["widgets"],
message: "Widget must not import other widget",
disallow: [
[
"widgets",
{
widget: "!${widget}",
},
],
],
},
{
from: ["pages"],
message: "Page must not import upper layers (${dependency.type})",
disallow: ["app"],
},
{
from: ["pages"],
message: "Page must not import other page",
disallow: [
[
"pages",
{
page: "!${page}",
},
],
],
},
],
},
],
},
};
+196
View File
@@ -0,0 +1,196 @@
{
"root": true,
"env": { "browser": true, "es2020": true },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals",
"plugin:react-hooks/recommended"
],
"ignorePatterns": ["dist", ".eslintrc.ts"],
"parser": "@typescript-eslint/parser",
"plugins": ["react-refresh", "boundaries"],
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
},
"boundaries/include": ["src/**/*"],
"boundaries/elements": [
{
"type": "app",
"pattern": "app"
},
{
"type": "pages",
"pattern": "src/pages/*",
"capture": ["page"]
},
{
"type": "widgets",
"pattern": "widgets/*",
"capture": ["widget"]
},
{
"type": "features",
"pattern": "features/*",
"capture": ["feature"]
},
{
"type": "entities",
"pattern": "entities/*",
"capture": ["entity"]
},
{
"type": "shared",
"pattern": "shared/*",
"capture": ["segment"]
}
]
},
"rules": {
"react-refresh/only-export-components": 0,
"boundaries/entry-point": [
2,
{
"default": "disallow",
"rules": [
{
"target": [
[
"shared",
{
"segment": "lib"
}
]
],
"allow": "*/index.ts"
},
{
"target": [
[
"shared",
{
"segment": "lib"
}
]
],
"allow": "*.(ts|tsx)"
},
{
"target": [
[
"shared",
{
"segment": "constants"
}
]
],
"allow": "index.ts"
},
{
"target": [
[
"shared",
{
"segment": "ui" // ("ui"|"constants")
}
]
],
"allow": "**"
},
{
"target": ["app", "pages", "widgets", "features", "entities"],
"allow": "index.(ts|tsx)"
}
]
}
],
"boundaries/element-types": [
2,
{
"default": "allow",
"message": "${file.type} is not allowed to import (${dependency.type})",
"rules": [
{
"from": ["shared"],
"disallow": ["app", "pages", "widgets", "features", "entities"],
"message":
"Shared module must not import upper layers (${dependency.type})"
},
{
"from": ["entities"],
"message": "Entity must not import upper layers (${dependency.type})",
"disallow": ["app", "pages", "widgets", "features"]
},
{
"from": ["entities"],
"message": "Entity must not import other entity",
"disallow": [
[
"entities",
{
"entity": "!${entity}"
}
]
]
},
{
"from": ["features"],
"message":
"Feature must not import upper layers (${dependency.type})",
"disallow": ["app", "pages", "widgets"]
},
{
"from": ["features"],
"message": "Feature must not import other feature",
"disallow": [
[
"features",
{
"feature": "!${feature}"
}
]
]
},
{
"from": ["widgets"],
"message":
"Feature must not import upper layers (${dependency.type})",
"disallow": ["app", "pages"]
},
{
"from": ["widgets"],
"message": "Widget must not import other widget",
"disallow": [
[
"widgets",
{
"widget": "!${widget}"
}
]
]
},
{
"from": ["pages"],
"message": "Page must not import upper layers (${dependency.type})",
"disallow": ["app"]
},
{
"from": ["pages"],
"message": "Page must not import other page",
"disallow": [
[
"pages",
{
"page": "!${page}"
}
]
]
}
]
}
]
}
}
+3 -1
View File
@@ -29,6 +29,7 @@
"eslint-import-resolver-typescript": "^3.6.1", "eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-boundaries": "^4.2.1", "eslint-plugin-boundaries": "^4.2.1",
"eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"sass": "^1.77.1", "sass": "^1.77.1",
"stylelint": "^16.5.0", "stylelint": "^16.5.0",
@@ -36,6 +37,7 @@
"stylelint-config-standard-scss": "^13.1.0", "stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4", "stylelint-order": "^6.0.4",
"stylelint-order-config-standard": "^0.1.3", "stylelint-order-config-standard": "^0.1.3",
"typescript": "^5" "typescript": "^5",
"typescript-eslint": "^7.10.0"
} }
} }