about summary refs log tree commit diff
path: root/eslint/use-typed-gates.js
blob: 3625a7da37055c69ff7ae1c243ed72166ad687c0 (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
31
'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('.') || source.startsWith('#')) {
        return
      }
      context.report({
        node,
        message:
          "Use useGate() from '#/lib/statsig/statsig' instead of the one on npm.",
      })
    },
  }
}