microsoft/tslint-microsoft-contrib

React UNSAFE_ methods not passing

JohnPhamous opened this issue · 1 comments

Bug Report

  • tslint-microsoft-contrib version: 6.2.0
  • TSLint version: 5.10.0
  • TypeScript version: 3.5.3
  • Running TSLint via: CLI webpack prod build, VS Code

TypeScript code being linted

public UNSAFE_componentWillReceiveProps(nextProps: IOnboardReleaseFormProps): void {
   ...
  }

Actual behavior

Throws this error: Method name does not match /^[a-z][\w\d]+$/: UNSAFE_componentWillReceiveProps (function-name)

Expected behavior

React 16.9.0 added UNSAFE_* methods. The regex currently being used doesn't allow for the UNSAFE_ prefix.

Proposed Changes

Not sure how yall want to handle this since it's a library dependent change. What do yall think of changing the regex to ([a-z]|UNSAFE)[\w\d]+?

👋 @JohnPhamous good idea! Fortunately, the function-name rule supports overriding the regular expressions used already:

private parseOptions(options: Lint.IOptions): Options {