diff options
author | dan <dan.abramov@gmail.com> | 2024-04-10 19:36:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 19:36:37 +0100 |
commit | 427f3a848d3bdc2e9c4b6b7cb2b8699511339ee2 (patch) | |
tree | e50dd6fc56e45170730223c53180389cfab676cf /eslint | |
parent | bf974b147ec8ba2b84803d17f8ca1f9291726ed2 (diff) | |
download | voidsky-427f3a848d3bdc2e9c4b6b7cb2b8699511339ee2.tar.zst |
[Statsig] Typecheck gates (#3467)
* Typecheck gates * Lint against untyped useGate() * Alphabetic
Diffstat (limited to 'eslint')
-rw-r--r-- | eslint/index.js | 1 | ||||
-rw-r--r-- | eslint/use-typed-gates.js | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/eslint/index.js b/eslint/index.js index daf5bd81d..bb31a942d 100644 --- a/eslint/index.js +++ b/eslint/index.js @@ -3,5 +3,6 @@ module.exports = { rules: { 'avoid-unwrapped-text': require('./avoid-unwrapped-text'), + 'use-typed-gates': require('./use-typed-gates'), }, } diff --git a/eslint/use-typed-gates.js b/eslint/use-typed-gates.js new file mode 100644 index 000000000..3625a7da3 --- /dev/null +++ b/eslint/use-typed-gates.js @@ -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.", + }) + }, + } +} |