From 7e4ab61c3445d9b2c46ecaf4512fc2e570d078ab Mon Sep 17 00:00:00 2001 From: Dmitriy Bratchikov Date: Mon, 27 May 2024 16:10:17 +0700 Subject: [PATCH] fix: eslintrc to json, added missing eslint plugins --- .eslintrc.cjs | 196 ------------------------------------------------- .eslintrc.json | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- 3 files changed, 199 insertions(+), 197 deletions(-) delete mode 100644 .eslintrc.cjs create mode 100644 .eslintrc.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 9a53b97..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -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}", - }, - ], - ], - }, - ], - }, - ], - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..53bca78 --- /dev/null +++ b/.eslintrc.json @@ -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}" + } + ] + ] + } + ] + } + ] + } +} diff --git a/package.json b/package.json index 8dc68ed..5ebb56f 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-boundaries": "^4.2.1", "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.7", "prettier": "^3.2.5", "sass": "^1.77.1", "stylelint": "^16.5.0", @@ -36,6 +37,7 @@ "stylelint-config-standard-scss": "^13.1.0", "stylelint-order": "^6.0.4", "stylelint-order-config-standard": "^0.1.3", - "typescript": "^5" + "typescript": "^5", + "typescript-eslint": "^7.10.0" } }