Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add eslint checks for literal SVG usages to use item component instead (#2464)

Leendert de Borstc04f40eef24f
diff --git a/apps/browser-extension/eslint.config.js b/apps/browser-extension/eslint.config.js
index 93c54ec84..3e3dee6d2 100644
--- a/apps/browser-extension/eslint.config.js
+++ b/apps/browser-extension/eslint.config.js
@@ -161,6 +161,18 @@ export default [
},
},
},
+ {
+ // Icons come from the shared catalog in core/models/src/icons (the Icon component, uiIconSvg), never inline SVG markup.
+ files: ["src/**/*.{ts,tsx}"],
+ ignores: ["src/entrypoints/popup/components/Icons/Icon.tsx", "src/entrypoints/popup/components/Logo.tsx", "src/utils/constants/logo.ts", "src/**/__tests__/**"],
+ rules: {
+ "no-restricted-syntax": ["error",
+ { selector: "JSXOpeningElement[name.name='svg']", message: "Use the Icon component with an icon from core/models/src/icons instead of inline SVG." },
+ { selector: "TemplateElement[value.raw=/<svg/]", message: "Use uiIconSvg() from @aliasvault/models/icons instead of inline SVG markup." },
+ { selector: "Literal[value=/<svg/]", message: "Use uiIconSvg() from @aliasvault/models/icons instead of inline SVG markup." },
+ ],
+ },
+ },
{
// The dev-only trace channel is the only module allowed to reach the console directly.
files: ["src/utils/devLogger/DevLogger.ts"],
diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js
index 876858d26..e45e1cae1 100644
--- a/apps/web/eslint.config.js
+++ b/apps/web/eslint.config.js
@@ -148,6 +148,18 @@ export default [
},
},
},
+ {
+ // Icons come from the shared catalog in core/models/src/icons (the Icon component, uiIconSvg), never inline SVG markup.
+ files: ["src/**/*.{ts,tsx}"],
+ ignores: ["src/components/shared/Icon.tsx", "src/**/__tests__/**"],
+ rules: {
+ "no-restricted-syntax": ["error",
+ { selector: "JSXOpeningElement[name.name='svg']", message: "Use the Icon component with an icon from core/models/src/icons instead of inline SVG." },
+ { selector: "TemplateElement[value.raw=/<svg/]", message: "Use uiIconSvg() from @aliasvault/models/icons instead of inline SVG markup." },
+ { selector: "Literal[value=/<svg/]", message: "Use uiIconSvg() from @aliasvault/models/icons instead of inline SVG markup." },
+ ],
+ },
+ },
{
// Playwright fixtures call their `use` callback, which the React hooks rule mistakes for a hook.
files: ["tests/**/*.ts"],