Skip to content

Commit

Permalink
manual eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Aug 7, 2024
1 parent 8cb1c33 commit e82b83a
Show file tree
Hide file tree
Showing 33 changed files with 46 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { jdlEntitiesSamplesFolder } from '../../constants.js';
const isDirectory = dir => {
try {
return statSync(dir).isDirectory();
} catch (error) {
} catch {
return false;
}
};
Expand Down
1 change: 1 addition & 0 deletions .blueprint/generate-sample/support/generate-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const generateSample = async (
process.chdir(destProjectFolder);

if (!sample) {
// eslint-disable-next-line no-console
console.log(`Sample ${sampleName} was not found`);
}

Expand Down
2 changes: 2 additions & 0 deletions .blueprint/update-vscode/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class extends BaseGenerator {
request: 'launch',
internalConsoleOptions: 'neverOpen',
name: 'update vscode launch.json',
// eslint-disable-next-line no-template-curly-in-string
program: '${workspaceFolder}/test-integration/scripts/99-update-vscode.js',
console: 'integratedTerminal',
},
Expand All @@ -41,6 +42,7 @@ export default class extends BaseGenerator {
request: 'launch',
internalConsoleOptions: 'neverOpen',
name: `generate sample from ${workflowName} workflow`,
// eslint-disable-next-line no-template-curly-in-string
program: '${workspaceFolder}/bin/jhipster.cjs',
args: ['generate-sample', `\${input:${workflowName}Sample}`, '--global'],
console: 'integratedTerminal',
Expand Down
1 change: 1 addition & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Module = require('module');
const process = require('process');

if (!Module.register) {
// eslint-disable-next-line no-console
console.log('JHipster test requires node >=18.19.0 || >= 20.6.0\n');
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/environment-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export default class EnvironmentBuilder {
commandSpec.blueprint = commandSpec.blueprint || blueprint;
});
result = { ...result, ...blueprintCommands };
} catch (e) {
} catch {
const msg = `Error parsing custom commands found within blueprint: ${blueprint} at ${blueprintCommandsUrl}`;
/* eslint-disable no-console */
console.info(`${chalk.green.bold('INFO!')} ${msg}`);
Expand Down
1 change: 0 additions & 1 deletion cli/program.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ export const buildJHipster = async ({
defaultCommand,
entrypointGenerator,
} = {}) => {
// eslint-disable-next-line chai-friendly/no-unused-expressions
createEnvBuilder =
createEnvBuilder ?? (async options => EnvironmentBuilder.create(options).prepare({ blueprints, lookups, devBlueprintPath }));
envBuilder = envBuilder ?? (await createEnvBuilder());
Expand Down
2 changes: 1 addition & 1 deletion generators/base-application/support/prepare-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function prepareCommonFieldForTemplates(entityWithConfig, field, generator) {
// check if regex is valid. If not, issue warning and we skip fake data generation.
try {
new RegExp(field.fieldValidateRulesPattern);
} catch (e) {
} catch {
generator.log.warn(`${field.fieldName} pattern is not valid: ${field.fieldValidateRulesPattern}. Skipping generating fake data. `);
return undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ You can ignore this error by passing '--skip-checks' to jhipster command.`);
let existingGenerator: string;
try {
existingGenerator = this._jhipsterGenerator ?? requireNamespace(this.options.namespace).generator;
} catch (error) {
} catch {
if (this.options.namespace) {
const split = this.options.namespace.split(':', 2);
existingGenerator = split.length === 1 ? split[0] : split[1];
Expand Down Expand Up @@ -771,7 +771,7 @@ You can ignore this error by passing '--skip-checks' to jhipster command.`);
this.log.info(`Removing legacy folder ${relativePath}`);
rmSync(destinationFolder, { recursive: true });
}
} catch (error) {
} catch {
this.log.log(`Could not remove folder ${destinationFolder}`);
}
}
Expand Down Expand Up @@ -1151,7 +1151,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
let originalContent;
try {
originalContent = this.readDestination(filePath);
} catch (_error) {
} catch {
// null return should be treated like an error.
}

Expand Down
2 changes: 1 addition & 1 deletion generators/base/internal/blueprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function normalizeBlueprintName(blueprint) {
}
return ns.with({ unscoped: `generator-jhipster-${ns.unscoped}` }).toString();
// eslint-disable-next-line no-empty
} catch (e) {}
} catch {}
if (blueprint && blueprint.startsWith('@')) {
return blueprint;
}
Expand Down
2 changes: 1 addition & 1 deletion generators/base/support/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function createFaker(nativeLanguage = 'en') {
// See https://github.com/faker-js/faker/pull/642
try {
locale = (await import(`@faker-js/faker`))[nativeLanguage];
} catch (error) {
} catch {
// Faker not implemented for the native language, fallback to en.

locale = (await import('@faker-js/faker')).en;
Expand Down
5 changes: 2 additions & 3 deletions generators/base/support/jhipster7-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const jhipster7deprecatedProperties = {
devDatabaseType: {
behaviorOnlyReason: 'v8: devDatabaseType is only used in jhipster:spring-data-relational generator',
get: ({ data }) => {
if (data.devDatabaseType === undefined) return data.devDatabaseType;
if (data.devDatabaseType !== undefined) return data.devDatabaseType;
const fallbackValue = data.prodDatabaseType ?? data.databaseType;

console.log(
Expand All @@ -32,9 +32,8 @@ export const jhipster7deprecatedProperties = {
},
prodDatabaseType: {
behaviorOnlyReason: 'v8: prodDatabaseType is only used in jhipster:spring-data-relational generator',
get: ({ data }) => data.prodDatabaseType ?? data.databaseType,
get: ({ data }) => {
if (data.prodDatabaseType === undefined) return data.prodDatabaseType;
if (data.prodDatabaseType !== undefined) return data.prodDatabaseType;

console.log(
`JHipster v8 behavior change(prodDatabaseType is only used in jhipster:spring-data-relational generator): devDatabaseType is not set, using fallback: ${data.databaseType}`,
Expand Down
2 changes: 1 addition & 1 deletion generators/bootstrap-application-base/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { snakeCase } from 'lodash-es';

import { defaultHelpers as helpers, runResult } from '../../testing/index.js';
import { shouldSupportFeatures } from '../../test/support/tests.js';
import { parseChangelog } from '../base/support/timestamp.ts';
import { parseChangelog } from '../base/support/timestamp.js';
import Generator from './index.js';

const __filename = fileURLToPath(import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion generators/client/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function _retrieveBootswatchThemes(generator, useApi) {
}));

resolve(bootswatchChoices);
} catch (err) {
} catch {
reject(errorMessage);
}
},
Expand Down
1 change: 0 additions & 1 deletion generators/cypress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
*/
export { default } from './generator.js';
export { default as command } from './command.js';
export * from './generator.js';
export { cypressFiles, cypressEntityFiles } from './files.js';
2 changes: 1 addition & 1 deletion generators/info/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class InfoGenerator extends BaseApplicationGenerator {
) {
try {
printInfo(await this.spawn(command, args, { stdio: 'pipe' }));
} catch (_error) {
} catch {
console.log(chalk.red(`'${command}' command could not be found`));
}
}
Expand Down
16 changes: 9 additions & 7 deletions generators/java/generators/domain/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ describe(`generator - ${generator}`, () => {
});

it('should have options defaults set', () => {
expect(result.generator.generateEntities).toBe(true);
expect(result.generator.generateEnums).toBe(true);
expect(result.generator.useJakartaValidation).toBe(true);
const generator: any = result.generator;
expect(generator.generateEntities).toBe(true);
expect(generator.generateEnums).toBe(true);
expect(generator.useJakartaValidation).toBe(true);
});
});

Expand Down Expand Up @@ -118,17 +119,18 @@ describe(`generator - ${generator}`, () => {
await helpers
.runJHipster(generator)
.withJHipsterConfig({})
.onGenerator(generator => {
.onGenerator((generator: any) => {
generator.generateEntities = false;
generator.generateEnums = false;
generator.useJakartaValidation = false;
});
});

it('should not override custom values', () => {
expect(result.generator.generateEntities).toBe(false);
expect(result.generator.generateEnums).toBe(false);
expect(result.generator.useJakartaValidation).toBe(false);
const generator: any = result.generator;
expect(generator.generateEntities).toBe(false);
expect(generator.generateEnums).toBe(false);
expect(generator.useJakartaValidation).toBe(false);
});
});
});
1 change: 1 addition & 0 deletions generators/java/generators/openapi-generator/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class OpenapiGeneratorGenerator extends BaseApplicationGenerator
{
groupId: 'org.openapitools',
artifactId: 'openapi-generator-maven-plugin',
// eslint-disable-next-line no-template-curly-in-string
version: '${openapi-generator-maven-plugin.version}',
additionalContent: ` <executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion generators/kubernetes-helm/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class KubernetesHelmGenerator extends BaseWorkspacesGenerator {
try {
fs.chmodSync('helm-apply.sh', '755');
fs.chmodSync('helm-upgrade.sh', '755');
} catch (err) {
} catch {
this.log.warn(
"Failed to make 'helm-apply.sh', 'helm-upgrade.sh' executable, you may need to run 'chmod +x helm-apply.sh helm-upgrade.sh",
);
Expand Down
6 changes: 3 additions & 3 deletions generators/kubernetes-knative/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class KubernetesKnativeGenerator extends BaseWorkspacesGenerator
await this.spawnCommand(
'kubectl get deploy -n knative-serving --label-columns=serving.knative.dev/release | grep -E "v0\\.[8-9]{1,3}\\.[0-9]*',
);
} catch (error) {
} catch {
this.log.warn(
'Knative 0.8.* or later is not installed on your computer.\n' +
'Make sure you have Knative and Istio installed. Read https://knative.dev/docs/install/\n',
Expand Down Expand Up @@ -218,7 +218,7 @@ export default class KubernetesKnativeGenerator extends BaseWorkspacesGenerator
// Make the apply script executable
try {
fs.chmodSync('kubectl-knative-apply.sh', '755');
} catch (err) {
} catch {
this.log.warn("Failed to make 'kubectl-knative-apply.sh' executable, you may need to run 'chmod +x kubectl-knative-apply.sh'");
}
} else {
Expand All @@ -229,7 +229,7 @@ export default class KubernetesKnativeGenerator extends BaseWorkspacesGenerator
try {
fs.chmodSync('helm-knative-apply.sh', '755');
fs.chmodSync('helm-knative-upgrade.sh', '755');
} catch (err) {
} catch {
this.log.warn(
"Failed to make 'helm-knative-apply.sh', 'helm-knative-upgrade.sh' executable, you may need to run 'chmod +x helm-knative-apply.sh helm-knative-upgrade.sh",
);
Expand Down
2 changes: 1 addition & 1 deletion generators/kubernetes/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default class KubernetesGenerator extends BaseWorkspacesGenerator {
// Make the apply script executable
try {
fs.chmodSync('kubectl-apply.sh', '755');
} catch (err) {
} catch {
this.log.warn("Failed to make 'kubectl-apply.sh' executable, you may need to run 'chmod +x kubectl-apply.sh'");
}
},
Expand Down
2 changes: 1 addition & 1 deletion generators/kubernetes/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export async function askForIngressDomain() {
try {
const { stdout: istioIngressIp } = this.spawnCommandSync(istioIpCommand, { stdio: 'pipe' });
defaultValue = `${istioIngressIp}.nip.io`;
} catch (ex) {
} catch {
istioMessage = `Unable to determine Istio Ingress IP address. You can find the Istio Ingress IP address by running the command line:\n ${istioIpCommand}`;
}
} else if (this.ingressType === NGINX) {
Expand Down
2 changes: 1 addition & 1 deletion generators/server/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MavenSourceType } from '../maven/types.js';
import { LiquibaseSourceType } from '../liquibase/types.js';
import { SpringCacheSourceType } from '../spring-cache/types.js';
import type { DeterministicOptionWithDerivedProperties, OptionWithDerivedProperties } from '../base-application/application-options.js';
import { GatewayApplication } from '../spring-cloud/generators/gateway/types.ts';
import { GatewayApplication } from '../spring-cloud/generators/gateway/types.js';
import { JavaAnnotation } from '../java/support/add-java-annotation.ts';
import { ApplicationPropertiesNeedles } from './support/needles.ts';
import { MessageBrokerApplicationType } from './options/message-broker.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import JSONEntity from '../../jhipster/json-entity.js';
import formatComment from '../../utils/format-utils.js';
import { formatComment } from '../../utils/format-utils.js';
import { getTableNameFromEntityNameFallback } from '../../jhipster/entity-table-name-creator.js';
import { JDLEntity } from '../../models/index.js';

Expand Down
2 changes: 1 addition & 1 deletion jdl/converters/jdl-to-json/jdl-to-json-field-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { capitalize } from 'lodash-es';

import { validations } from '../../jhipster/index.js';
import formatComment from '../../utils/format-utils.js';
import { formatComment } from '../../utils/format-utils.js';
import { camelCase } from '../../utils/string-utils.js';
import fieldTypes from '../../jhipster/field-types.js';
import JDLObject from '../../models/jdl-object.js';
Expand Down
2 changes: 1 addition & 1 deletion jdl/converters/json-to-jdl-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function convertToJDL(directory = '.', output: string | false = 'app.jdl'
} else {
try {
jdlObject = getJDLObjectFromMultipleApplications(directory);
} catch (error) {
} catch {
return undefined;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function init(passedConfiguration: ParsedJDLRoot) {
function fillApplications(): void {
// TODO: Function which expects two arguments is called with three.

// @ts-expect-error
// @ts-expect-error TODO
const jdlApplications: JDLApplication[] = convertApplications(parsedContent.applications, configuration, entityNames);
jdlApplications.forEach((jdlApplication: JDLApplication) => {
jdlObject.addApplication(jdlApplication);
Expand Down
2 changes: 1 addition & 1 deletion jdl/jhipster/field-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function getIsType(databaseType?: string, callback?: any): (type: any) =>
isType = () => true;
break;
default:
callback && callback();
callback?.();
throw new Error(
"The passed database type must either be 'sql', 'mysql', 'mariadb', 'postgresql'," +
" 'oracle', 'mssql', 'mongodb', 'couchbase', 'neo4j' or 'cassandra'",
Expand Down
2 changes: 1 addition & 1 deletion jdl/parsing/self-checks/parsing-system-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getUselessTokens(usedTokens: any[], allDefinedTokens: any[]) {
const usedCategories = uniq(flatMap(usedTokens, 'CATEGORIES'));
// TODO: Calling uniq with two parameters is probably a bug.

// @ts-expect-error
// @ts-expect-error TODO
const notDirectlyUsedTokens = difference(allDefinedTokens, uniq(usedTokens, usedCategories));
const redundant = reject(notDirectlyUsedTokens, token => {
const tokCategories = token.CATEGORIES;
Expand Down
2 changes: 1 addition & 1 deletion jdl/readers/json-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function parseFromDir(dir: string): JDLObject {
});
const applicationOptions = readJSONFile(`${dir}/.yo-rc.json`)['generator-jhipster'];

// @ts-expect-error
// @ts-expect-error TODO
const jdlObject = convertServerOptionsToJDL(applicationOptions);
const convertedJDLObject = convertEntitiesToJDL(entities);
return mergeJDLObjects(jdlObject, convertedJDLObject);
Expand Down
2 changes: 1 addition & 1 deletion jdl/utils/format-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { it, describe } from 'esmocha';
import { expect } from 'chai';
import formatComment from '../utils/format-utils.js';
import { formatComment } from '../utils/format-utils.js';

describe('jdl - FormatUtils', () => {
describe('formatComment', () => {
Expand Down
1 change: 1 addition & 0 deletions test-integration/scripts/99-write-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let existing = {};
try {
existing = JSON.parse(readFileSync(MATRIX_FILE));
} catch {
// eslint-disable-next-line no-console
console.log(`File ${MATRIX_FILE} not found`);
existing = { include: [] };
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('integration-test', () => {
});

describe('::entities samples reproducibility', () => {
const changelogDates = [];
const changelogDates: string[] = [];
for (const [name, entitySample] of itEntitiesSamplesEntries) {
let entityJson = readJsonSync(entitySample);
before(() => {
Expand Down
4 changes: 2 additions & 2 deletions testing/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ plugins {
Object.entries(this.sharedSource).map(([name, fn]) => [name, fn.mock.calls.map(args => args[0])]),
);
if (sourceCallsArg.addEntitiesToClient) {
sourceCallsArg.addEntitiesToClient = (sourceCallsArg.addEntitiesToClient as any).map(({ application, entities }) => ({
sourceCallsArg.addEntitiesToClient = sourceCallsArg.addEntitiesToClient.map(({ application, entities }) => ({
application: `Application[${application.baseName}]`,
entities: entities.map(entity => `Entity[${entity.name}]`),
}));
}
if (sourceCallsArg.addEntityToCache) {
sourceCallsArg.addEntityToCache = (sourceCallsArg.addEntityToCache as any).map(({ relationships, ...fields }) => ({
sourceCallsArg.addEntityToCache = sourceCallsArg.addEntityToCache.map(({ relationships, ...fields }) => ({
...fields,
relationships: relationships.map(rel => `Relationship[${rel.relationshipName}]`),
}));
Expand Down

0 comments on commit e82b83a

Please sign in to comment.