mirror of
https://github.com/bitwarden/browser
synced 2026-02-22 12:24:01 +00:00
* rename bit-icon to bit-svg; create new bit-icon for font icons Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * find and replace current usage Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * add custom eslint warning Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix incorrect usage * fix tests * fix tests * Update libs/components/src/svg/index.ts Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * Update libs/eslint/components/no-bwi-class-usage.spec.mjs Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * update component api * update class name * use icon type in iconButton component * update type Icon --> BitSvg * fix bad renames * fix more renames * fix bad input * revert iconButton type * fix lint * fix more inputs * misc fixes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix test * add eslint ignore * fix lint * add comparison story --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
export const errorMessage =
|
|
"Use <bit-icon> component instead of applying 'bwi' classes directly. Example: <bit-icon name=\"bwi-lock\"></bit-icon>";
|
|
|
|
export default {
|
|
meta: {
|
|
type: "suggestion",
|
|
docs: {
|
|
description:
|
|
"Discourage using 'bwi' font icon classes directly in favor of the <bit-icon> component",
|
|
category: "Best Practices",
|
|
recommended: true,
|
|
},
|
|
schema: [],
|
|
},
|
|
create(context) {
|
|
return {
|
|
Element(node) {
|
|
// Get all class-related attributes
|
|
const classAttrs = [
|
|
...(node.attributes?.filter((attr) => attr.name === "class") ?? []),
|
|
...(node.inputs?.filter((input) => input.name === "class") ?? []),
|
|
...(node.templateAttrs?.filter((attr) => attr.name === "class") ?? []),
|
|
];
|
|
|
|
for (const classAttr of classAttrs) {
|
|
const classValue = classAttr.value || "";
|
|
|
|
// Check if the class value contains 'bwi' or 'bwi-'
|
|
// This handles both string literals and template expressions
|
|
const hasBwiClass =
|
|
typeof classValue === "string" && /\bbwi(?:-[\w-]+)?\b/.test(classValue);
|
|
|
|
if (hasBwiClass) {
|
|
context.report({
|
|
node,
|
|
message: errorMessage,
|
|
});
|
|
// Only report once per element
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|