sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #08670
[Merge] ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main.
Commit message:
test: add eslint-plugin-unused-imports
- fix: remove unused error arg
Requested reviews:
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443547
This will automatically remove unused imports on save or when running eslint with --fix
## QA steps
- Checkout this branch locally
- Go to App.tsx
- Add `import { copyToClipboard } from "@/utils";` at the top of the file
- If you have autofix enabled on save in your code editor:
- save the file and the import should be removed
- If you do not have autofix enabled in your code editor:
- Run yarn lint --fix and once done the import should be removed
--
Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main.
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
index 870950e..3a95201 100644
--- a/frontend/.eslintrc.js
+++ b/frontend/.eslintrc.js
@@ -2,7 +2,7 @@ const path = require("path");
module.exports = {
root: true,
- plugins: ["prettier", "no-relative-import-paths"],
+ plugins: ["unused-imports", "no-relative-import-paths", "prettier"],
extends: [
"./.eslintrc-auto-import.json",
"react-app", // Use the recommended rules from CRA.
@@ -60,11 +60,16 @@ module.exports = {
},
rules: {
"prettier/prettier": "error",
- "@typescript-eslint/no-unused-vars": [
- "error",
+ "@typescript-eslint/no-unused-vars": "off",
+ "unused-imports/no-unused-imports": "error",
+ "unused-imports/no-unused-vars": [
+ "warn",
{
- args: "none",
+ vars: "all",
+ varsIgnorePattern: "^_",
+ args: "after-used",
ignoreRestSiblings: true,
+ argsIgnorePattern: "^_",
},
],
"no-restricted-syntax": [
diff --git a/frontend/package.json b/frontend/package.json
index e28adf0..231006e 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -66,6 +66,7 @@
"eslint-plugin-no-relative-import-paths": "1.5.2",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.32.2",
+ "eslint-plugin-unused-imports": "2.0.0",
"fishery": "2.2.2",
"i18n-iso-countries": "7.6.0",
"jsdom": "21.1.2",
diff --git a/frontend/src/components/RemoveRegions/RemoveRegions.tsx b/frontend/src/components/RemoveRegions/RemoveRegions.tsx
index 303f7a2..d5a9357 100644
--- a/frontend/src/components/RemoveRegions/RemoveRegions.tsx
+++ b/frontend/src/components/RemoveRegions/RemoveRegions.tsx
@@ -27,7 +27,7 @@ const createHandleValidate =
({ expectedConfirmTextValue }: { expectedConfirmTextValue: string }) =>
async (values: RemoveRegionsFormValues) => {
let errors = {};
- await RemoveRegionsFormSchema.validate(values, { context: { expectedConfirmTextValue } }).catch((error) => {
+ await RemoveRegionsFormSchema.validate(values, { context: { expectedConfirmTextValue } }).catch(() => {
errors = { confirmText: `Confirmation string is not correct. Expected ${expectedConfirmTextValue}` };
});
return errors;
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index f05b88c..10570bd 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -3539,6 +3539,18 @@ eslint-plugin-testing-library@^5.0.1:
dependencies:
"@typescript-eslint/utils" "^5.43.0"
+eslint-plugin-unused-imports@2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz#d8db8c4d0cfa0637a8b51ce3fd7d1b6bc3f08520"
+ integrity sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==
+ dependencies:
+ eslint-rule-composer "^0.3.0"
+
+eslint-rule-composer@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"
+ integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==
+
eslint-scope@5.1.1, eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Follow ups