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');
10
10
// Rule Definition
11
11
// ------------------------------------------------------------------------------
12
12
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
+
13
26
function makeNoMethodSetStateRule ( methodName , shouldCheckUnsafeCb ) {
14
27
return {
15
28
meta : {
16
29
docs : {
17
30
description : `Prevent usage of setState in ${ methodName } ` ,
18
31
category : 'Best Practices' ,
19
32
recommended : false ,
20
- url : docsUrl ( methodName )
33
+ url : docsUrl ( mapTitle ( methodName ) )
21
34
} ,
22
35
23
36
schema : [ {
You can’t perform that action at this time.
0 commit comments