Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public constructor(parserData: QuestionsType) {
this.name = parserData.name;
this.normalizedName = normalizeStringByDelimiter(parserData.name, '-');
this.capitalizedName = capitalize(parserData.name);
this.description = escapeSafeString(parserData.description);
// Using `Set` to avoid duplicates.
const eventTypesSet: Set = new Set();
parserData.eventsSelected.forEach((event: EventType) => {
const isElement = event.event === 'element::';
const type: string = events[event.event];
const eventSplit = event.event.split('::');
const handler: string = `on${capitalize(eventSplit[0])}${capitalize(isElement ? event.element : eventSplit[1])}${eventSplit[2] ? capitalize(eventSplit[2]) : ''}`;
const varName: string = `${type.charAt(0).toLowerCase()}${type.substr(1)}`;
this.events.push({
event: isElement ? event.event + event.element : event.event,
handler,
const capitalize = (str: string): string => {
if (str === '*') {
return '';
}
const splittedText: string[] = normalizeStringByDelimiter(str, ' ').split(' ');
const result = splittedText.reduce((total, text) => {
/* istanbul ignore else */
if (!text) {
return total;
}
return `${total}${text.charAt(0).toUpperCase()}${text.slice(1)}`;
}, '');
return result;
};
public constructor(data: inquirer.Answers) {
this.name = data.name;
this.isMulti = data.multi;
this.normalizedName = normalizeStringByDelimiter(data.name, '-');
this.description = escapeSafeString(data.description);
this.official = data.official;
const prefix = this.official ? '@hint/hint' : 'hint'; // package.json#name
this.packageName = `${prefix}-${this.normalizedName}`;
this.hints = [];
if (this.isMulti) {
this.packageMain = `dist/src/index.js`; // package.json#main
(data.hints as inquirer.Answers[]).forEach((hint) => {
this.hints.push(new NewHint(hint, this.normalizedName));
});
} else {
this.packageMain = `dist/src/hint.js`; // package.json#main
public constructor(hintData: inquirer.Answers, parentName?: string) {
this.name = hintData.name;
this.normalizedName = normalizeStringByDelimiter(hintData.name, '-');
this.className = `${parentName ? toPascalCase(parentName) : ''}${toPascalCase(this.normalizedName)}Hint`;
this.category = hintData.category || Category.other;
this.description = escapeSafeString(hintData.description);
this.elementType = hintData.elementType;
this.events = getEventsByUseCase(hintData.useCase);
this.useCase[hintData.useCase] = true;
this.scope = hintData.scope;
this.parentName = parentName || '';
}
}