From 578c8ce5dd4ed76e6734fa16076947afda8e58ba Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:10:20 +1100 Subject: [PATCH] feat(ui): enforce absolute import paths - add & configure `eslint-plug-path` --- invokeai/frontend/web/.eslintrc.js | 2 ++ invokeai/frontend/web/package.json | 3 ++- invokeai/frontend/web/yarn.lock | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/.eslintrc.js b/invokeai/frontend/web/.eslintrc.js index 1777729b67..2062de2cc7 100644 --- a/invokeai/frontend/web/.eslintrc.js +++ b/invokeai/frontend/web/.eslintrc.js @@ -25,9 +25,11 @@ module.exports = { '@typescript-eslint', 'eslint-plugin-react-hooks', 'i18next', + 'path', ], root: true, rules: { + 'path/no-relative-imports': ['error', { maxDepth: 0 }], curly: 'error', 'i18next/no-literal-string': 2, 'react/jsx-no-bind': ['error', { allowBind: true }], diff --git a/invokeai/frontend/web/package.json b/invokeai/frontend/web/package.json index 6e6c919b09..6f160bae46 100644 --- a/invokeai/frontend/web/package.json +++ b/invokeai/frontend/web/package.json @@ -29,7 +29,7 @@ "lint:prettier": "prettier --check .", "lint:tsc": "tsc --noEmit", "lint": "concurrently -g -n eslint,prettier,tsc,madge -c cyan,green,magenta,yellow \"yarn run lint:eslint\" \"yarn run lint:prettier\" \"yarn run lint:tsc\" \"yarn run lint:madge\"", - "fix": "eslint --fix . && prettier --loglevel warn --write .", + "fix": "eslint --fix . && prettier --log-level warn --write .", "lint-staged": "lint-staged", "postinstall": "patch-package && yarn run theme", "theme": "chakra-cli tokens src/theme/theme.ts", @@ -132,6 +132,7 @@ "eslint": "^8.53.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-i18next": "^6.0.3", + "eslint-plugin-path": "^1.2.2", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "husky": "^8.0.3", diff --git a/invokeai/frontend/web/yarn.lock b/invokeai/frontend/web/yarn.lock index 2b5beeac76..e0a9db1c5e 100644 --- a/invokeai/frontend/web/yarn.lock +++ b/invokeai/frontend/web/yarn.lock @@ -3525,6 +3525,13 @@ eslint-plugin-i18next@^6.0.3: lodash "^4.17.21" requireindex "~1.1.0" +eslint-plugin-path@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-path/-/eslint-plugin-path-1.2.2.tgz#5306f46036907ffe1abca6f6e21dc2c2bf869ad5" + integrity sha512-RJ5e/DXRUj7cFD6y3xX5r2syU0uKEkjo9sU8lpayxV/H2plNKPjWv/oRSrWv+XibWV1Qvsu7VELobBFFSPb1UQ== + dependencies: + load-tsconfig "^0.2.5" + eslint-plugin-react-hooks@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" @@ -4662,6 +4669,11 @@ listr2@7.0.2: rfdc "^1.3.0" wrap-ansi "^8.1.0" +load-tsconfig@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/load-tsconfig/-/load-tsconfig-0.2.5.tgz#453b8cd8961bfb912dea77eb6c168fe8cca3d3a1" + integrity sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg== + locate-path@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"