about summary refs log tree commit diff
path: root/eslint/use-exact-imports.js
blob: 26e688563ead1fdde8a71c6d46a7243308e2dcb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const BANNED_IMPORTS = [
  '@fortawesome/free-regular-svg-icons',
  '@fortawesome/free-solid-svg-icons',
]

exports.create = function create(context) {
  return {
    ImportDeclaration(node) {
      const source = node.source
      if (typeof source.value !== 'string') {
        return
      }
      if (BANNED_IMPORTS.includes(source.value)) {
        context.report({
          node,
          message:
            'Import the specific thing you want instead of the entire package',
        })
      }
    },
  }
}