about summary refs log tree commit diff
path: root/eslint/use-typed-gates.js
blob: 6c0331afee69ef4676f2eb08e0d69b8d07b6b4ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict'

exports.create = function create(context) {
  return {
    ImportSpecifier(node) {
      if (
        !node.local ||
        node.local.type !== 'Identifier' ||
        node.local.name !== 'useGate'
      ) {
        return
      }
      if (
        node.parent.type !== 'ImportDeclaration' ||
        !node.parent.source ||
        node.parent.source.type !== 'Literal'
      ) {
        return
      }
      const source = node.parent.source.value
      if (source.startsWith('statsig') || source.startsWith('@statsig')) {
        context.report({
          node,
          message:
            "Use useGate() from '#/lib/statsig/statsig' instead of the one on npm.",
        })
      }
    },
  }
}