From d6a0ca9c59e0a97aba5f7988ec7fbbf175967bc4 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 30 Jun 2024 13:22:42 +0300 Subject: [PATCH 1/4] chore: 320 - add FSD eslint config --- eslint.config.js | 21 +++++ package-lock.json | 203 +++++++++++++++++++++++++++++++++++++++++----- package.json | 5 +- 3 files changed, 209 insertions(+), 20 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index a5a20186a..95d23785d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,4 +1,5 @@ import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; import stylistic from '@stylistic/eslint-plugin'; import tsPlugin from '@typescript-eslint/eslint-plugin'; import tsParser from '@typescript-eslint/parser'; @@ -11,6 +12,13 @@ import sortExports from 'eslint-plugin-sort-exports'; import vitestPlugin from 'eslint-plugin-vitest'; import globals from 'globals'; +const DIRNAME = import.meta.dirname; +const compat = new FlatCompat({ baseDirectory: DIRNAME }); +const fsdConfig = compat.extends('@feature-sliced/eslint-config'); + +// Pop is needed to remove 'ecmaVersion: 2015' to fix the error 💫 +fsdConfig.pop(); + export default [ { ignores: [ @@ -26,6 +34,7 @@ export default [ ], }, stylistic.configs['recommended-flat'], + ...fsdConfig, { files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], languageOptions: { @@ -90,6 +99,18 @@ export default [ 'import/no-namespace': ['error', { ignore: ['*.ext'] }], 'import/newline-after-import': 'error', 'import/no-duplicates': 'error', + 'import/no-internal-modules': [ 'error', + { + 'allow': [ + '**/app/*', + '**/pages/*', + '**/widgets/*', + '**/features/*', + '**/entities/*', + '**/shared/**/*', + ], + } + ], 'import/order': [ 'error', { diff --git a/package-lock.json b/package-lock.json index 858902a3d..1a6a845c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,9 @@ "react-router-dom": "^6.23.1" }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.6.0", + "@feature-sliced/eslint-config": "^0.1.1", "@playwright/test": "^1.44.1", "@stylistic/eslint-plugin": "^2.1.0", "@testing-library/jest-dom": "^6.4.2", @@ -1022,15 +1025,16 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, + "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -1038,7 +1042,7 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -1054,16 +1058,45 @@ "concat-map": "0.0.1" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "type-fest": "^0.20.2" + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" }, "engines": { - "node": ">=8" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -1082,12 +1115,24 @@ } }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.6.0.tgz", + "integrity": "sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A==", "dev": true, + "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@feature-sliced/eslint-config": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@feature-sliced/eslint-config/-/eslint-config-0.1.1.tgz", + "integrity": "sha512-6g2xgY3TVv24N1828U5gnfT7/R2aNiRghhCs45j6mbltLQik0CR7puKJhZSmhLqczMDM8TRqLVNhaCdvdgZpWw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint-plugin-boundaries": ">=2", + "eslint-plugin-import": ">=2" } }, "node_modules/@humanwhocodes/config-array": { @@ -3057,10 +3102,11 @@ "dev": true }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -4777,6 +4823,91 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-boundaries": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-boundaries/-/eslint-plugin-boundaries-4.2.1.tgz", + "integrity": "sha512-BPkpaSh4jC3T+O3vTz77o3UFp/5t5eY8Kcl9em7VphfxdHv+sdZCzU82YIkv81T4ZJsKhfshaJJAjYmd6UBIrQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "chalk": "4.1.2", + "eslint-import-resolver-node": "0.3.9", + "eslint-module-utils": "2.8.1", + "is-core-module": "2.13.1", + "micromatch": "4.0.5" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-plugin-boundaries/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/eslint-plugin-boundaries/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/eslint-plugin-boundaries/node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/eslint-plugin-boundaries/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/eslint-plugin-css-import-order": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-css-import-order/-/eslint-plugin-css-import-order-1.1.0.tgz", @@ -5046,6 +5177,40 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", diff --git a/package.json b/package.json index 2f8ac6c88..ff341aa17 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,9 @@ "react-router-dom": "^6.23.1" }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.6.0", + "@feature-sliced/eslint-config": "^0.1.1", "@playwright/test": "^1.44.1", "@stylistic/eslint-plugin": "^2.1.0", "@testing-library/jest-dom": "^6.4.2", @@ -71,4 +74,4 @@ "vite": "^5.2.12", "vitest": "^1.5.0" } -} \ No newline at end of file +} From b94dae71a9a91ee5d68465b8e0268ab5db792165 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 3 Jul 2024 22:21:20 +0300 Subject: [PATCH 2/4] refactor: 320 - change FSD errors to warns --- eslint.config.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 95d23785d..a61059a16 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -85,6 +85,7 @@ export default [ ...vitestPlugin.configs['recommended'].rules, ...cssImportOrder.configs['recommended'].rules, + 'boundaries/element-types': 'warn', 'no-undef': 'off', 'react/prop-types': 'off', 'react/react-in-jsx-scope': 'off', @@ -99,18 +100,7 @@ export default [ 'import/no-namespace': ['error', { ignore: ['*.ext'] }], 'import/newline-after-import': 'error', 'import/no-duplicates': 'error', - 'import/no-internal-modules': [ 'error', - { - 'allow': [ - '**/app/*', - '**/pages/*', - '**/widgets/*', - '**/features/*', - '**/entities/*', - '**/shared/**/*', - ], - } - ], + 'import/no-internal-modules': 'warn', 'import/order': [ 'error', { From 958bdc763c7c8105e3fe73416a6a1bf982140304 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 3 Jul 2024 22:51:12 +0300 Subject: [PATCH 3/4] chore: 320 - increase max warnings value from 10 to 360 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 228e0b381..ad7968348 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "optimizeImages": "npx cross-env VITE_TABLET=768 VITE_MOBILE=425 VITE_COMPRESS_QUALITY=80 node optimizeImages/optimizeImages.js", "stylelint": "npx stylelint \"**/*.scss\"", "stylelint:fix": "npx stylelint \"**/*.scss\" --fix", - "lint": "npx eslint . --report-unused-disable-directives --max-warnings 10", - "lint:fix": "npx eslint . --fix --report-unused-disable-directives --max-warnings 10", + "lint": "npx eslint . --report-unused-disable-directives --max-warnings 360", + "lint:fix": "npx eslint . --fix --report-unused-disable-directives --max-warnings 360", "preview": "vite preview", "test": "vitest --run", "test:playWright": "npx playwright test", From 22ea83ef587db32b92e679db7f0714f96e4beedf Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 6 Jul 2024 11:30:07 +0300 Subject: [PATCH 4/4] fix: 320 - increase max warns value --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 549bc38cd..fb1c1aad7 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "optimizeImages": "npx cross-env VITE_TABLET=768 VITE_MOBILE=425 VITE_COMPRESS_QUALITY=80 node optimizeImages/optimizeImages.js", "stylelint": "npx stylelint \"**/*.scss\"", "stylelint:fix": "npx stylelint \"**/*.scss\" --fix", - "lint": "npx eslint . --report-unused-disable-directives --max-warnings 360", - "lint:fix": "npx eslint . --fix --report-unused-disable-directives --max-warnings 360", + "lint": "npx eslint . --report-unused-disable-directives --max-warnings 400", + "lint:fix": "npx eslint . --fix --report-unused-disable-directives --max-warnings 400", "preview": "vite preview", "test": "vitest --run", "test:playWright": "npx playwright test",