File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,27 @@ const docsUrl = require('./docsUrl');
1010// Rule Definition
1111// ------------------------------------------------------------------------------
1212
13+ function mapTitle ( methodName ) {
14+ const map = {
15+ componentDidMount : 'did-mount' ,
16+ componentDidUpdate : 'did-update' ,
17+ componentWillUpdate : 'will-update'
18+ } ;
19+ const title = map [ methodName ] ;
20+ if ( ! title ) {
21+ throw Error ( `No docsUrl for '${ methodName } '` ) ;
22+ }
23+ return `no-${ title } -set-state` ;
24+ }
25+
1326function makeNoMethodSetStateRule ( methodName , shouldCheckUnsafeCb ) {
1427 return {
1528 meta : {
1629 docs : {
1730 description : `Prevent usage of setState in ${ methodName } ` ,
1831 category : 'Best Practices' ,
1932 recommended : false ,
20- url : docsUrl ( methodName )
33+ url : docsUrl ( mapTitle ( methodName ) )
2134 } ,
2235
2336 schema : [ {
You can’t perform that action at this time.
0 commit comments