Use exact imports for icons (#4549)

* Use exact imports for icons

* Add a lint rule
This commit is contained in:
dan 2024-06-18 15:37:08 +03:00 committed by GitHub
parent e6213d7aa5
commit e30575c0dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 3 deletions

View file

@ -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'),
},
}

View file

@ -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',
})
}
},
}
}