Constant Factory
Stop rewriting the constant name in each entry use a factory for this job
Install
npm
npm install constant-factory --save-dev
yarn
yarn add constant-factory --dev
Usage
// normal // advanced
Example
Before:
const MY_CONSTANT = TODO: 'MY_CONSTANT_TODO' ISSUES: 'MY_CONSTANT_ISSUES'
Now:
const MY_CONSTANT = // returns// {// TODO: 'MY_CONSTANT_TODO',// ISSUES: 'MY_CONSTANT_ISSUES'// }
Advanced:
const MY_CONSTANT ANOTHER_CONSTANT = // returns// {// MY_CONSTANT: {// TODO: 'MY_CONSTANT_TODO',// ISSUES: 'MY_CONSTANT_ISSUES'// },// ANOTHER_CONSTANT: {// DATES: 'ANOTHER_CONSTANT_DATES'// }// }
Expert:
Add additional subs in subs
const MY_CONSTANT ANOTHER_CONSTANT = // returns// {// MY_CONSTANT: {// TODO: 'MY_CONSTANT_TODO',// STATUS: [// 'MY_CONSTANT_STATUS_DONE',// 'MY_CONSTANT_STATUS_OPEN'// ]// }// }