about summary refs log tree commit diff
path: root/eslint/use-exact-imports.js
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-06-18 15:37:08 +0300
committerGitHub <noreply@github.com>2024-06-18 15:37:08 +0300
commite30575c0dc3b2d81694a8a08543c6348e0c27322 (patch)
tree7cc8b19e29a7aeefd98d574fd984c8154009324b /eslint/use-exact-imports.js
parente6213d7aa56faa6994a27bf127c63ded69e67d6f (diff)
downloadvoidsky-e30575c0dc3b2d81694a8a08543c6348e0c27322.tar.zst
Use exact imports for icons (#4549)
* Use exact imports for icons

* Add a lint rule
Diffstat (limited to 'eslint/use-exact-imports.js')
-rw-r--r--eslint/use-exact-imports.js22
1 files changed, 22 insertions, 0 deletions
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',
+        })
+      }
+    },
+  }
+}