In a few cases, we have to add the case suffix e.g. (pascalCase)
after certain slots in our files, because it is an improper syntax, the code editor (I am using VS Code) is barking at the improper syntax:
// templates/.../__name__(pascalCase).js
class __name__(pascalCase) { ... } // <-- code editor does not like this, obviously
I certainly could update the settings of the editor to ignore those files, but we have a lot of contributors and would prefer not to have everyone have to do that. Do you know of a workaround? In the interim we decided to add a .template
suffix to each filename (__name__(pascalCase).js.template
) so the editor does not lint it. We then remove that extension in the onComplete
callback. This works fine, but I'd prefer to retain the original extension so that I can take advantage of the project linting, formatting, etc.
I thought of a very simple, potential solution; If the dynamicReplacers
were just replaced before the stringReplacers
they could be used to dynamically add the non-editor-friendly syntax. For example:
stringReplacers: [
{
question: 'Insert component name',
slot: '__name__',
}
],
dynamicReplacers: [
{
slot: 'ComponentName', // <-- this slot gets replaced first...
slotValue: '__name__(pascalCase)', // <-- ...with this syntax for the stringReplacers
},
]
// templates/.../__name__(pascalCase).js
class ComponentName { ... } // <-- code editor does not mind this :)
Just an idea, not sure if it would work, or if that is a feature you want to enable. However, it does seem simple enough. I haven't looked at the source code yet, but would image a simple change to the order of operations could accomplish this.
Also, are you open to contributions? I am interested in taking a stab at this update and submitting a PR.