Skip to content

Commit

Permalink
Move the options check before isTypeFlagSet() check
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichb committed Apr 14, 2020
1 parent f2fab58 commit 9ebb323
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/eslint-plugin/src/rules/restrict-template-expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,30 @@ export default util.createRule<Options, MessageId>({
}

if (
util.isTypeFlagSet(
type,
ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike,
) &&
options.allowNumber
options.allowNullable &&
util.isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined)
) {
return true;
}

if (
util.isTypeFlagSet(type, ts.TypeFlags.BooleanLike) &&
options.allowBoolean
options.allowNumber &&
util.isTypeFlagSet(
type,
ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike,
)
) {
return true;
}

if (
util.isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined) &&
options.allowNullable
options.allowBoolean &&
util.isTypeFlagSet(type, ts.TypeFlags.BooleanLike)
) {
return true;
}

if (util.isTypeFlagSet(type, ts.TypeFlags.Any) && options.allowAny) {
if (options.allowAny && util.isTypeFlagSet(type, ts.TypeFlags.Any)) {
return true;
}

Expand Down

0 comments on commit 9ebb323

Please sign in to comment.