You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have three suggestions to propose, and wanted feedback prior to opening a PR. Do you recommend placing this function at the top, under the 'Rule Definition' header? And then I would call the function directly within the docs object: url: docsUrl(getDocsTitle(methodName))
functiongetDocsTitle1(methodName){lettitle;switch(methodName){case'componentDidMount':
title='did-mount';break;case'componentDidUpdate':
title='did-update';break;case'componentWillUpdate':
title='will-update';break;default:
throwError(`No docsUrl for '${methodName}'`);}return`no-${title}-set-state`;}functiongetDocsTitle2(methodName){return`${methodName.match(/[A-Z][a-z]+/g).reduce((res,e)=>`${res}-${e.toLowerCase()}`,'no')}-set-state`;}functiongetDocsTitle3(methodName){returnmethodName.match(/[A-Z][a-z]+/g).reduce((x,y)=>`no-${x.toLowerCase()}-${y.toLowerCase()}-set-state`);}functiongetDocsTitle4(methodName){constmap={componentDidMount: 'did-mount',componentDidUpdate: 'did-update',componentWillUpdate: 'will-update',};consttitle=map[methodName];if(!title)throwError(`No docsUrl for '${methodName}'`);return`no-${title}-set-state`;}console.log(getDocsTitle1('componentWillUpdate'));// no-will-update-set-stateconsole.log(getDocsTitle2('componentWillUpdate'));// no-will-update-set-stateconsole.log(getDocsTitle3('componentWillUpdate'));// no-will-update-set-stateconsole.log(getDocsTitle4('componentWillUpdate'));// no-will-update-set-state
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
@Arcanemagus's docsUrl commit didn't account for the rule naming conventions of the different method names in /lib/util/makeNoMethodSetStateRule.
Currently
componentWillUpdate
links to /docs/rules/componentWillUpdate (doesn't exist, 404) when it should be linking to /docs/rules/no-will-update-set-state:I'm proposing to create a function that gets the proper url within /lib/util/makeNoMethodSetStateRule.
I have three suggestions to propose, and wanted feedback prior to opening a PR. Do you recommend placing this function at the top, under the 'Rule Definition' header? And then I would call the function directly within the
docs
object:url: docsUrl(getDocsTitle(methodName))
The text was updated successfully, but these errors were encountered: