[Statsig] Typecheck gates (#3467)
* Typecheck gates * Lint against untyped useGate() * Alphabetic
This commit is contained in:
parent
bf974b147e
commit
427f3a848d
6 changed files with 45 additions and 6 deletions
|
@ -3,5 +3,6 @@
|
|||
module.exports = {
|
||||
rules: {
|
||||
'avoid-unwrapped-text': require('./avoid-unwrapped-text'),
|
||||
'use-typed-gates': require('./use-typed-gates'),
|
||||
},
|
||||
}
|
||||
|
|
31
eslint/use-typed-gates.js
Normal file
31
eslint/use-typed-gates.js
Normal file
|
@ -0,0 +1,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.",
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue