Skip to content

Commit

Permalink
Braces and parentheses should be used consistently with arrow functio…
Browse files Browse the repository at this point in the history
…ns (#28365)
  • Loading branch information
qmonmert authored Jan 1, 2025
1 parent 57f1079 commit 1b2c980
Show file tree
Hide file tree
Showing 33 changed files with 56 additions and 137 deletions.
4 changes: 1 addition & 3 deletions generators/angular/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ export default class AngularGenerator extends BaseApplicationGenerator<DefaultTa
...(entity.entityReadAuthority?.split(',') ?? []),
]),
});
entity.generateEntityClientEnumImports = fields => {
return getClientEnumImportsFormat(fields, ANGULAR);
};
entity.generateEntityClientEnumImports = fields => getClientEnumImportsFormat(fields, ANGULAR);
},
});
}
Expand Down
4 changes: 1 addition & 3 deletions generators/angular/support/reserved-keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ export const angularReservedKeywords = [
'ROUTER',
];

export const isReservedAngularKeyword = (keyword: string) => {
return angularReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedAngularKeyword = (keyword: string) => angularReservedKeywords.includes(keyword.toUpperCase());
4 changes: 1 addition & 3 deletions generators/base-application/support/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
* @param text the text to check, which should not begin with the closing wrapper character '<'
* @return {boolean} true if the text is considered wrapped, false otherwise
*/
const isSimpleText = (previousLine, text) => {
return !previousLine.endsWith('>') && !text.startsWith('<');
};
const isSimpleText = (previousLine, text) => !previousLine.endsWith('>') && !text.startsWith('<');

/**
* Format As Liquibase Remarks
Expand Down
8 changes: 2 additions & 6 deletions generators/base-application/support/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import { lowerFirst } from 'lodash-es';
import { formatDocAsJavaDoc } from '../../java/support/doc.js';

const doesTheEnumValueHaveACustomValue = enumValue => {
return enumValue.includes('(');
};
const doesTheEnumValueHaveACustomValue = enumValue => enumValue.includes('(');

const getCustomValuesState = enumValues => {
const state = {
Expand Down Expand Up @@ -73,9 +71,7 @@ const extractEnumInstance = field => {
return lowerFirst(fieldType);
};

const extractEnumEntries = field => {
return field.fieldValues.split(',').map(fieldValue => fieldValue.trim());
};
const extractEnumEntries = field => field.fieldValues.split(',').map(fieldValue => fieldValue.trim());

/**
* Build an enum object
Expand Down
4 changes: 1 addition & 3 deletions generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
* Merge value to an existing json and write to destination
*/
mergeDestinationJson(filepath: string, value: Record<string | number, any>) {
this.editFile(filepath, { create: true }, content => {
return JSON.stringify(merge(content ? JSON.parse(content) : {}, value), null, 2);
});
this.editFile(filepath, { create: true }, content => JSON.stringify(merge(content ? JSON.parse(content) : {}, value), null, 2));
}

/**
Expand Down
5 changes: 2 additions & 3 deletions generators/base/support/basename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ export const getFrontendAppName = ({ baseName }: { baseName: string }) => {
return /^\d/.exec(name) ? 'App' : name;
};

export const getMicroserviceAppName = ({ microserviceName }: { microserviceName: string }) => {
return camelCase(microserviceName) + (microserviceName.endsWith('App') ? '' : 'App');
};
export const getMicroserviceAppName = ({ microserviceName }: { microserviceName: string }) =>
camelCase(microserviceName) + (microserviceName.endsWith('App') ? '' : 'App');
4 changes: 1 addition & 3 deletions generators/base/support/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class RandexpWithFaker extends Randexp {
throw new Error('Faker is required');
}
// In order to have consistent results with RandExp, the RNG is seeded.
this.randInt = (from: number, to?: number): number => {
return faker.number.int({ min: from, max: to });
};
this.randInt = (from: number, to?: number): number => faker.number.int({ min: from, max: to });
}
}

Expand Down
12 changes: 3 additions & 9 deletions generators/base/support/jhipster7-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,9 @@ const createHandler = ({ log }: { log: (msg: string) => void } = { log: msg => c
'set',
].map(method => [method, (...args) => console.log(`Fixme: template data called ${method}(${args?.pop() ?? ''})`)]),
),
ownKeys: ({ data }) => {
return Reflect.ownKeys(data);
},
getPrototypeOf: ({ data }) => {
return Object.getPrototypeOf(data);
},
getOwnPropertyDescriptor: ({ data }, prop) => {
return Object.getOwnPropertyDescriptor(data, prop);
},
ownKeys: ({ data }) => Reflect.ownKeys(data),
getPrototypeOf: ({ data }) => Object.getPrototypeOf(data),
getOwnPropertyDescriptor: ({ data }, prop) => Object.getOwnPropertyDescriptor(data, prop),
has: (context, prop) => {
if (ejsBuiltInProperties.includes(prop)) {
return false;
Expand Down
4 changes: 1 addition & 3 deletions generators/base/support/write-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export function addSectionsCondition(files: Record<string, any[]>, commonConditi
const { condition } = block;
let newCondition = commonCondition;
if (typeof condition === 'function') {
newCondition = (...args) => {
return commonCondition(...args) && condition(...args);
};
newCondition = (...args) => commonCondition(...args) && condition(...args);
} else if (condition !== undefined) {
newCondition = (...args) => commonCondition(...args) && condition;
}
Expand Down
5 changes: 2 additions & 3 deletions generators/bootstrap/support/sort-config-files-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import sortKeys from 'sort-keys';
import { transformContents } from '@yeoman/transform';
import type { MemFsEditorFile } from 'mem-fs-editor';

const sortJsonFileContent = (contents: Exclude<File['contents'], null>) => {
return Buffer.from(`${JSON.stringify(sortKeys(JSON.parse(contents.toString('utf8')), { deep: true }), null, 2)}\n`);
};
const sortJsonFileContent = (contents: Exclude<File['contents'], null>) =>
Buffer.from(`${JSON.stringify(sortKeys(JSON.parse(contents.toString('utf8')), { deep: true }), null, 2)}\n`);

export default function createSortConfigFilesTransform(pattern = '**/{.yo-rc.json,.jhipster/*.json}') {
return transformContents<MemFsEditorFile>(contents => sortJsonFileContent(contents!), {
Expand Down
5 changes: 2 additions & 3 deletions generators/client/support/template-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ const { ANGULAR, VUE } = clientFrameworkTypes;
* @param {Array|Object} relationships - array of relationships
* @returns {Array|Object} filtered relationships
*/
export const filterRelevantRelationships = relationships => {
return relationships.filter(rel => rel.persistableRelationship || rel.relationshipEagerLoad);
};
export const filterRelevantRelationships = relationships =>
relationships.filter(rel => rel.persistableRelationship || rel.relationshipEagerLoad);

/**
* @private
Expand Down
4 changes: 1 addition & 3 deletions generators/client/support/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,4 @@ export const typescriptReservedKeywords = [
'YIELD',
];

export const isReservedTypescriptKeyword = (keyword: string) => {
return typescriptReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedTypescriptKeyword = (keyword: string) => typescriptReservedKeywords.includes(keyword.toUpperCase());
7 changes: 1 addition & 6 deletions generators/entity/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ const prompts = {

export default prompts;

const getFieldNameUndercored = fields =>
['id'].concat(
fields.map(field => {
return snakeCase(field.fieldName);
}),
);
const getFieldNameUndercored = fields => ['id'].concat(fields.map(field => snakeCase(field.fieldName)));

function askForMicroserviceJson(this: EntityGenerator) {
const context = this.entityData;
Expand Down
12 changes: 3 additions & 9 deletions generators/entity/support/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,20 @@ const filterNumber = (input: any, isSigned = false, isDecimal = false) => {
* @param {any} input input
* @returns {boolean} true if input is number; false otherwise
*/
const isNumber = (input: any): input is number => {
return !isNaN(filterNumber(input));
};
const isNumber = (input: any): input is number => !isNaN(filterNumber(input));

/**
* @private
* @param {any} input input
* @returns {boolean} true if input is a signed number; false otherwise
*/
const isSignedNumber = (input: any): boolean => {
return !isNaN(filterNumber(input, true));
};
const isSignedNumber = (input: any): boolean => !isNaN(filterNumber(input, true));

/**
* @private
* @param {any} input input
* @returns {boolean} true if input is a signed decimal number; false otherwise
*/
const isSignedDecimalNumber = (input: any): boolean => {
return !isNaN(filterNumber(input, true, true));
};
const isSignedDecimalNumber = (input: any): boolean => !isNaN(filterNumber(input, true, true));

export { isNumber, isSignedNumber, isSignedDecimalNumber };
4 changes: 1 addition & 3 deletions generators/java/support/reserved-keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ export const javaReservedKeywords = [
'WHILE',
];

export const isReservedJavaKeyword = (keyword: string) => {
return javaReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedJavaKeyword = (keyword: string) => javaReservedKeywords.includes(keyword.toUpperCase());
8 changes: 2 additions & 6 deletions generators/languages/support/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ export function languageToJavaLanguage(language) {
return languageSnakeCase(languageUpperCaseCountry(language));
}

const languageToFakerjsLanguage = (languageTag: string): string => {
return languageUpperCaseCountry(languageTag);
};
const languageToFakerjsLanguage = (languageTag: string): string => languageUpperCaseCountry(languageTag);

const languageToAngularLanguage = (languageTag: string): string => {
return languageUpperCaseCountry(languageTag);
};
const languageToAngularLanguage = (languageTag: string): string => languageUpperCaseCountry(languageTag);

const languageToDayjsLanguage = (languageTag: string): string => {
const split = splitLanguageTag(languageTag);
Expand Down
4 changes: 1 addition & 3 deletions generators/languages/translation-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const createTranslationsFilter = ({ clientSrcDir, nativeLanguage, fallbac
? `**/${clientSrcDir}i18n/${nativeLanguage}/*.json`
: `**/${clientSrcDir}i18n/{${nativeLanguage},${fallbackLanguage}}/*.json`;
const minimatch = new Minimatch(pattern);
return filePath => {
return minimatch.match(filePath);
};
return filePath => minimatch.match(filePath);
};

export const createTranslationsFileFilter = opts => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,4 @@ export const cassandraReservedKeywords = [
'BITSTRING',
];

export const isReservedCassandraKeyword = (keyword: string) => {
return cassandraReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedCassandraKeyword = (keyword: string) => cassandraReservedKeywords.includes(keyword.toUpperCase());
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,4 @@ export const couchbaseReservedKeywords = [
'WRITE',
];

export const isReservedCouchbaseKeyword = (keyword: string) => {
return couchbaseReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedCouchbaseKeyword = (keyword: string) => couchbaseReservedKeywords.includes(keyword.toUpperCase());
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { it } from 'esmocha';
import { JAVA_DOCKER_DIR, SERVER_MAIN_SRC_DIR } from '../../generator-constants.js';
import { matchWrittenConfig, matchWrittenFiles, runResult } from '../../../lib/testing/index.js';

const expectedElasticsearchFiles = () => {
return [`${JAVA_DOCKER_DIR}elasticsearch.yml`];
};
const expectedElasticsearchFiles = () => [`${JAVA_DOCKER_DIR}elasticsearch.yml`];

const expectedElasticsearchUserFiles = () => {
const application = runResult.generator.sharedData.getApplication();
Expand Down
4 changes: 1 addition & 3 deletions generators/spring-data-neo4j/support/reserved-keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,4 @@ export const neo4jReservedKeywords = [
'SCALAR',
];

export const isReservedNeo4jKeyword = (keyword: string) => {
return neo4jReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedNeo4jKeyword = (keyword: string) => neo4jReservedKeywords.includes(keyword.toUpperCase());
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,4 @@ export const mssqlReservedKeywords = [
'WRITETEXT',
];

export const isReservedMssqlKeyword = (keyword: string) => {
return mssqlReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedMssqlKeyword = (keyword: string) => mssqlReservedKeywords.includes(keyword.toUpperCase());
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,4 @@ export const mysqlReservedKeywords = [
'WINDOW',
];

export const isReservedMysqlKeyword = (keyword: string) => {
return mysqlReservedKeywords.includes(keyword.toUpperCase());
};
export const isReservedMysqlKeyword = (keyword: string) => mysqlReservedKeywords.includes(keyword.toUpperCase());
4 changes: 1 addition & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export const isDistFolder = () => {
return basename(dirname(__dirname)) === 'dist';
};
export const isDistFolder = () => basename(dirname(__dirname)) === 'dist';

export const getPackageRoot = (relativePath?: string) => {
const sourceRoot = dirname(__dirname);
Expand Down
10 changes: 4 additions & 6 deletions lib/jdl/converters/exporters/jhipster-entity-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ function init(passedConfiguration: JhipsterJSONJDLExporterWrapper) {
* @param subFolder the folder (to create) in which the JHipster entity folder will be.
*/
function updateEntities(applicationPath: string): JSONEntity[] {
return configuration.entities.map((entity: JSONEntity) => {
return updateEntityToGenerateWithExistingOne(applicationPath, entity);
});
return configuration.entities.map((entity: JSONEntity) => updateEntityToGenerateWithExistingOne(applicationPath, entity));
}

function updateEntityToGenerateWithExistingOne(applicationPath: string, entity: JSONEntity): JSONEntity {
Expand All @@ -86,7 +84,7 @@ function shouldFilterOutEntitiesBasedOnMicroservice(): string {
}

function filterOutEntitiesByMicroservice(): JSONEntity[] {
return configuration.entities.filter(entity => {
return !(entity.microserviceName && entity.microserviceName.toLowerCase() !== configuration.application.name.toLowerCase());
});
return configuration.entities.filter(
entity => !(entity.microserviceName && entity.microserviceName.toLowerCase() !== configuration.application.name.toLowerCase()),
);
}
10 changes: 2 additions & 8 deletions lib/jdl/core/linters/enum-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ function checkForDuplicatedEnums(enumDeclarations: EnumDeclaration[]) {
}

function checkForUnusedEnums(enumDeclarations: EnumDeclaration[], fieldDeclarations: FieldDeclaration[]) {
const fieldTypes = fieldDeclarations.map(fieldDeclaration => {
return fieldDeclaration.children.type[0].children.NAME[0].image;
});
const declaredEnums = new Set(
enumDeclarations.map(enumDeclaration => {
return enumDeclaration.children.NAME[0].image;
}),
);
const fieldTypes = fieldDeclarations.map(fieldDeclaration => fieldDeclaration.children.type[0].children.NAME[0].image);
const declaredEnums = new Set(enumDeclarations.map(enumDeclaration => enumDeclaration.children.NAME[0].image));
fieldTypes.forEach(usedEnum => {
declaredEnums.delete(usedEnum);
});
Expand Down
4 changes: 1 addition & 3 deletions lib/jdl/core/parsing/lexer/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,4 @@ export const buildTokens = (tokens: { applicationTokens: TokenParam; deploymentT
// with 'ensureOptimizations' the lexer initialization will throw a descriptive error
// instead of silently reverting to an unoptimized algorithm.
// This will avoid performance regressions.
export const createJDLLexer = (tokens: Record<string, TokenType>) => {
return new Lexer(Object.values(tokens), { ensureOptimizations: true });
};
export const createJDLLexer = (tokens: Record<string, TokenType>) => new Lexer(Object.values(tokens), { ensureOptimizations: true });
5 changes: 2 additions & 3 deletions lib/jdl/core/utils/entity-table-name-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ export const getTableNameFromEntityNameFallback = (entityName: string): string |
/**
* @deprecated TODO v9 drop this function and always write entityTableName if exists.
*/
export const shouldWriteEntityTableName = (entityName: string, entityTableName: string): boolean => {
return entityTableName !== snakeCase(entityName) || entityTableName !== hibernateSnakeCase(entityName);
};
export const shouldWriteEntityTableName = (entityName: string, entityTableName: string): boolean =>
entityTableName !== snakeCase(entityName) || entityTableName !== hibernateSnakeCase(entityName);
4 changes: 1 addition & 3 deletions lib/testing/get-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export const getGeneratorRelativeFolder = (generatorName: string) => {
return join('generators', generatorName.split(':').join('/generators/'));
};

export const getGeneratorFolder = (generatorName: string) => {
return resolve(__dirname, '../..', getGeneratorRelativeFolder(generatorName));
};
export const getGeneratorFolder = (generatorName: string) => resolve(__dirname, '../..', getGeneratorRelativeFolder(generatorName));

const getGenerator = (generatorName: string) => {
const generatorFolder = getGeneratorFolder(generatorName);
Expand Down
5 changes: 2 additions & 3 deletions lib/testing/github-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ export type GitHubMatrixOutput = {
include: GitHubMatrix[];
};

export const getUnknownGitHubMatrixProperties = (matrix: Partial<GitHubMatrix>): string[] => {
return Object.keys(matrix).filter(key => !knwonGitHubMatrixProperties.includes(key));
};
export const getUnknownGitHubMatrixProperties = (matrix: Partial<GitHubMatrix>): string[] =>
Object.keys(matrix).filter(key => !knwonGitHubMatrixProperties.includes(key));

export const getUnknownGitHubMatrixGroupProperties = (matrixRecord: GitHubMatrixGroup): string[] => {
let unknownProperties: string[] = [];
Expand Down
4 changes: 1 addition & 3 deletions lib/testing/support/matrix-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ const applyExtendedMatrix = (matrixEntries, configMatrix) => {
* // 'initialMatrix(false)-toBeMerged(false)': { initialMatrix: false, toBeMerged: false },
* // }
*/
export const extendMatrix = (matrix, configMatrix) => {
return Object.fromEntries(applyExtendedMatrix(Object.entries(matrix), configMatrix));
};
export const extendMatrix = (matrix, configMatrix) => Object.fromEntries(applyExtendedMatrix(Object.entries(matrix), configMatrix));

export const extendFilteredMatrix = (matrix, filter, extendedConfig) => {
const matrixEntries = Object.entries(matrix);
Expand Down
5 changes: 2 additions & 3 deletions lib/testing/support/server-samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,5 @@ export const buildServerMatrix = (matrix: Record<string, unknown> = {}) => {
return serverMatrix;
};

export const buildServerSamples = (commonConfig?: Record<string, unknown>, matrix?: Record<string, unknown>) => {
return buildSamplesFromMatrix(buildServerMatrix(matrix), { commonConfig });
};
export const buildServerSamples = (commonConfig?: Record<string, unknown>, matrix?: Record<string, unknown>) =>
buildSamplesFromMatrix(buildServerMatrix(matrix), { commonConfig });
Loading

0 comments on commit 1b2c980

Please sign in to comment.