Don't report literal errors on null

This commit is contained in:
Matt Bierner 2020-06-22 15:43:13 -07:00
parent 5c375ef21c
commit c5e1438a6e
2 changed files with 7 additions and 0 deletions

View file

@ -13,6 +13,10 @@ module.exports = new class ApiLiteralOrTypes {
create(context) {
return {
['TSTypeAnnotation TSUnionType TSLiteralType']: (node) => {
var _a;
if (((_a = node.literal) === null || _a === void 0 ? void 0 : _a.type) === 'TSNullKeyword') {
return;
}
context.report({
node: node,
messageId: 'useEnum'

View file

@ -15,6 +15,9 @@ export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule {
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
return {
['TSTypeAnnotation TSUnionType TSLiteralType']: (node: any) => {
if (node.literal?.type === 'TSNullKeyword') {
return;
}
context.report({
node: node,
messageId: 'useEnum'