Shopify / tslint-config-shopify

Shopify’s TypeScript rules and configs.
https://www.npmjs.com/package/tslint-config-shopify
37 stars 3 forks source link

Custom rule: Enforce a style on ternary operators with multiline tsx markup #46

Open ismail-syed opened 7 years ago

ismail-syed commented 7 years ago

Enforce consistent styling for ternary operators with multi line tsx.

Good

    return onClick
      ? (
        <button onClick={onClick} className={className} disabled={disabled}>
          {children}
        </button>
      )
      : (
        <UnstyledLink className={className} to={to} target={external ? '_blank' : ''} disabled={disabled}>
          {children}
        </UnstyledLink>
      );

Bad

    return onClick
      ? (
        <button onClick={onClick} className={className} disabled={disabled}>
          {children}
        </button>
      ) : (
        <UnstyledLink className={className} to={to} target={external ? '_blank' : ''} disabled={disabled}>
          {children}
        </UnstyledLink>
      );