From e30575c0dc3b2d81694a8a08543c6348e0c27322 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Jun 2024 15:37:08 +0300 Subject: Use exact imports for icons (#4549) * Use exact imports for icons * Add a lint rule --- eslint/index.js | 1 + eslint/use-exact-imports.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 eslint/use-exact-imports.js (limited to 'eslint') diff --git a/eslint/index.js b/eslint/index.js index 955103d8c..cb6291d79 100644 --- a/eslint/index.js +++ b/eslint/index.js @@ -4,6 +4,7 @@ module.exports = { rules: { 'keep-i18n-patch-in-sync': require('./keep-i18n-patch-in-sync'), 'avoid-unwrapped-text': require('./avoid-unwrapped-text'), + 'use-exact-imports': require('./use-exact-imports'), 'use-typed-gates': require('./use-typed-gates'), }, } diff --git a/eslint/use-exact-imports.js b/eslint/use-exact-imports.js new file mode 100644 index 000000000..06723043f --- /dev/null +++ b/eslint/use-exact-imports.js @@ -0,0 +1,22 @@ +/* eslint-disable bsky-internal/use-exact-imports */ +const BANNED_IMPORTS = [ + '@fortawesome/free-regular-svg-icons', + '@fortawesome/free-solid-svg-icons', +] + +exports.create = function create(context) { + return { + Literal(node) { + if (typeof node.value !== 'string') { + return + } + if (BANNED_IMPORTS.includes(node.value)) { + context.report({ + node, + message: + 'Import the specific thing you want instead of the entire package', + }) + } + }, + } +} -- cgit 1.4.1