Skip to content

Commit

Permalink
Merge pull request #27177 from mshima/import-type
Browse files Browse the repository at this point in the history
enable consistent-type-imports rule
  • Loading branch information
DanielFran authored Sep 4, 2024
2 parents 2fae076 + b8f06fc commit 5d8b3f0
Show file tree
Hide file tree
Showing 155 changed files with 305 additions and 278 deletions.
2 changes: 1 addition & 1 deletion cli/cli-command.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Environment from 'yeoman-environment';
import EnvironmentBuilder from './environment-builder.mjs';
import type EnvironmentBuilder from './environment-builder.mjs';

/**
* @param args - positional arguments, a varidic argument is an array at last position.
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default ts.config(
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
Expand Down
4 changes: 2 additions & 2 deletions generators/angular/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* limitations under the License.
*/

import CoreGenerator from '../base-core/index.js';
import type CoreGenerator from '../base-core/index.js';
import { CLIENT_WEBPACK_DIR } from '../generator-constants.js';
import { GeneratorDefinition } from '../base-application/generator.js';
import type { GeneratorDefinition } from '../base-application/generator.js';

/**
* Removes files that where generated in previous JHipster versions and therefore
Expand Down
4 changes: 2 additions & 2 deletions generators/angular/entity-files-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import type { GeneratorDefinition } from '../base-application/generator.js';
import { clientApplicationTemplatesBlock } from '../client/support/files.js';
import CoreGenerator from '../base-core/index.js';
import { WriteFileSection } from '../base/api.js';
import type CoreGenerator from '../base-core/index.js';
import type { WriteFileSection } from '../base/api.js';
import { asWritingEntitiesTask } from '../base-application/support/task-type-inference.js';

const entityModelFiles = clientApplicationTemplatesBlock({
Expand Down
2 changes: 1 addition & 1 deletion generators/angular/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import { writeEslintClientRootConfigFile } from '../javascript/generators/eslint
import { cleanupEntitiesFiles, postWriteEntitiesFiles, writeEntitiesFiles } from './entity-files-angular.js';
import { writeFiles } from './files-angular.js';
import cleanupOldFilesTask from './cleanup.js';
import type { addItemToMenu } from './support/index.js';
import {
addEntitiesRoute,
addIconImport,
addItemToAdminMenu,
addItemToMenu,
addRoute,
addToEntitiesMenu,
buildAngularFormPath as angularFormPath,
Expand Down
10 changes: 5 additions & 5 deletions generators/base-application/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import type { ComposeOptions, Storage } from 'yeoman-generator';

import BaseGenerator from '../base/index.js';
import { JHIPSTER_CONFIG_DIR } from '../generator-constants.js';
import { GenericSourceTypeDefinition, GenericTaskGroup } from '../base/tasks.js';
import { SpringBootSourceType } from '../server/types.js';
import { ClientSourceType } from '../client/types.js';
import { I18nApplication } from '../languages/types.js';
import { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js';
import type { GenericSourceTypeDefinition, GenericTaskGroup } from '../base/tasks.js';
import type { SpringBootSourceType } from '../server/types.js';
import type { ClientSourceType } from '../client/types.js';
import type { I18nApplication } from '../languages/types.js';
import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js';
import { mutateData } from '../base/support/config.js';
import {
GENERATOR_BOOTSTRAP_APPLICATION,
Expand Down
2 changes: 1 addition & 1 deletion generators/base-application/support/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { upperFirst } from 'lodash-es';
import { JSONEntity } from '../../../jdl/converters/types.js';
import type { JSONEntity } from '../../../jdl/converters/types.js';

export const findEntityInEntities = (entityName: string, entities: JSONEntity[]) =>
entities.find(entity => upperFirst(entity.name) === upperFirst(entityName));
2 changes: 1 addition & 1 deletion generators/base-application/support/prepare-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { getEntityParentPathAddition, getTypescriptKeyType } from '../../client/
import { applicationTypes, databaseTypes, entityOptions, fieldTypes, searchEngineTypes } from '../../../jdl/jhipster/index.js';
import { binaryOptions } from '../../../jdl/built-in-options/index.js';

import { Entity } from '../types/index.js';
import type { Entity } from '../types/index.js';
import type CoreGenerator from '../../base-core/generator.js';
import { fieldIsEnum } from './field-utils.js';
import { fieldToReference } from './prepare-field.js';
Expand Down
4 changes: 2 additions & 2 deletions generators/base-application/support/relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import { lowerFirst, upperFirst } from 'lodash-es';

import { JSONEntity, JSONRelationship } from '../../../jdl/converters/types.js';
import { ValidationResult } from '../../base/api.js';
import type { JSONEntity, JSONRelationship } from '../../../jdl/converters/types.js';
import type { ValidationResult } from '../../base/api.js';
import { stringifyApplicationData } from './debug.js';
import { findEntityInEntities } from './entity.js';

Expand Down
6 changes: 3 additions & 3 deletions generators/base-application/support/task-type-inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import CoreGenerator from '../../base-core/generator.js';
import { WriteFileBlock, WriteFileSection } from '../../base/api.js';
import { GeneratorDefinition } from '../generator.js';
import type CoreGenerator from '../../base-core/generator.js';
import type { WriteFileBlock, WriteFileSection } from '../../base/api.js';
import type { GeneratorDefinition } from '../generator.js';

export function asWriteFilesSection<Data = GeneratorDefinition['writingTaskParam']['application']>(
section: WriteFileSection<CoreGenerator, Data>,
Expand Down
10 changes: 5 additions & 5 deletions generators/base-application/tasks.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Storage } from 'yeoman-generator';
import { BaseGeneratorDefinition, ControlTaskParam, GenericSourceTypeDefinition, SourceTaskParam } from '../base/tasks.js';
import { ClientSourceType } from '../client/types.js';
import { BaseChangelog } from '../base-entity-changes/types.js';
import { CommonClientServerApplication } from './types.js';
import { Entity, Field, Relationship } from './types/index.js';
import type { BaseGeneratorDefinition, ControlTaskParam, GenericSourceTypeDefinition, SourceTaskParam } from '../base/tasks.js';
import type { ClientSourceType } from '../client/types.js';
import type { BaseChangelog } from '../base-entity-changes/types.js';
import type { CommonClientServerApplication } from './types.js';
import type { Entity, Field, Relationship } from './types/index.js';

export type GenericApplicationDefinition<ApplicationType = CommonClientServerApplication> = {
applicationType: ApplicationType;
Expand Down
10 changes: 5 additions & 5 deletions generators/base-application/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CoreGenerator from '../base-core/generator.ts';
import { ClientApplication } from '../client/types.js';
import { I18nApplication } from '../languages/types.js';
import { SpringBootApplication } from '../server/types.js';
import { DeterministicOptionWithDerivedProperties, OptionWithDerivedProperties } from './application-options.js';
import type CoreGenerator from '../base-core/generator.ts';
import type { ClientApplication } from '../client/types.js';
import type { I18nApplication } from '../languages/types.js';
import type { SpringBootApplication } from '../server/types.js';
import type { DeterministicOptionWithDerivedProperties, OptionWithDerivedProperties } from './application-options.js';

export type BaseApplication = {
jhipsterVersion: string;
Expand Down
6 changes: 3 additions & 3 deletions generators/base-application/types/entity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* limitations under the License.
*/

import { SpringEntity } from '../../server/types.js';
import Field from './field.js';
import Relationship from './relationship.js';
import type { SpringEntity } from '../../server/types.js';
import type Field from './field.js';
import type Relationship from './relationship.js';

export type BaseEntity = {
name: string;
Expand Down
13 changes: 4 additions & 9 deletions generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { fileURLToPath } from 'url';
import { existsSync, readFileSync, rmSync, statSync } from 'fs';
import assert from 'assert';
import { requireNamespace } from '@yeoman/namespace';
import { GeneratorMeta } from '@yeoman/types';
import type { GeneratorMeta } from '@yeoman/types';
import chalk from 'chalk';
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
import { defaults, get, kebabCase, merge, mergeWith, set, snakeCase } from 'lodash-es';
Expand All @@ -36,13 +36,8 @@ import type Environment from 'yeoman-environment';
import latestVersion from 'latest-version';
import SharedData from '../base/shared-data.js';
import { CUSTOM_PRIORITIES, PRIORITY_NAMES, PRIORITY_PREFIX, QUEUES } from '../base/priorities.js';
import {
Logger,
createJHipster7Context,
formatDateForChangelog,
joinCallbacks,
removeFieldsWithNullishValues,
} from '../base/support/index.js';
import type { Logger } from '../base/support/index.js';
import { createJHipster7Context, formatDateForChangelog, joinCallbacks, removeFieldsWithNullishValues } from '../base/support/index.js';

import type {
CascatedEditFileCallback,
Expand All @@ -61,7 +56,7 @@ import {
convertConfigToOption,
} from '../../lib/command/index.js';
import { packageJson } from '../../lib/index.js';
import { type BaseApplication, CommonClientServerApplication } from '../base-application/types.js';
import type { BaseApplication, CommonClientServerApplication } from '../base-application/types.js';
import { GENERATOR_BOOTSTRAP } from '../generator-list.js';
import NeedleApi from '../needle-api.js';
import command from '../base/command.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/base/blueprints.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { before, describe, esmocha, expect, it } from 'esmocha';
import { RunResult } from 'yeoman-test';
import type { RunResult } from 'yeoman-test';
import { toHaveBeenCalledAfter } from 'jest-extended';

import { basicHelpers as helpers } from '../../testing/index.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/base/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { loadStoredAppOptions } from '../app/support/index.js';
import { packageNameToNamespace } from './support/index.js';
import { loadBlueprintsFromConfiguration, mergeBlueprints, normalizeBlueprintName, parseBluePrints } from './internal/index.js';
import { PRIORITY_NAMES } from './priorities.js';
import { BaseGeneratorDefinition, GenericTaskGroup } from './tasks.js';
import type { BaseGeneratorDefinition, GenericTaskGroup } from './tasks.js';
import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from './api.js';
import { LOCAL_BLUEPRINT_PACKAGE_NAMESPACE } from './support/constants.js';

Expand Down
3 changes: 2 additions & 1 deletion generators/base/shared-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { rm } from 'fs/promises';
import { isAbsolute, join, relative } from 'path';
import { lt as semverLessThan } from 'semver';
import { defaults } from 'lodash-es';
import { MemFsEditor, create } from 'mem-fs-editor';
import type { MemFsEditor } from 'mem-fs-editor';
import { create } from 'mem-fs-editor';
import { type BaseApplication } from '../base-application/types.js';
import { GENERATOR_JHIPSTER } from '../generator-constants.js';
import { type Control } from './types.js';
Expand Down
3 changes: 2 additions & 1 deletion generators/base/support/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/
import chalk from 'chalk';
import type { Logger as LoggerApi } from '@yeoman/types';
import { Logger as DefaultLogger, LoggerOptions, createLogger } from '@yeoman/adapter';
import type { Logger as DefaultLogger, LoggerOptions } from '@yeoman/adapter';
import { createLogger } from '@yeoman/adapter';
import createDebug from 'debug';

/**
Expand Down
4 changes: 2 additions & 2 deletions generators/base/support/needles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
import assert from 'assert';
import { escapeRegExp, kebabCase } from 'lodash-es';
import CoreGenerator from '../../base-core/index.js';
import { CascatedEditFileCallback, EditFileCallback } from '../api.js';
import type CoreGenerator from '../../base-core/index.js';
import type { CascatedEditFileCallback, EditFileCallback } from '../api.js';
import { joinCallbacks } from './write-files.js';

export type NeedleInsertion = {
Expand Down
2 changes: 1 addition & 1 deletion generators/base/support/write-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { describe, esmocha, expect, it } from 'esmocha';
import { EditFileCallback } from '../api.js';
import type { EditFileCallback } from '../api.js';
import { joinCallbacks } from './write-files.js';

describe('generator - base - support - writeFiles', () => {
Expand Down
2 changes: 1 addition & 1 deletion generators/base/types-export.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Generator from './index.js';
import type Generator from './index.js';

// Remove generics support
export type BaseGenerator = Generator;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Minimatch } from 'minimatch';
import { setModifiedFileState } from 'mem-fs-editor/state';
import { GENERATOR_JHIPSTER } from '../../generator-constants.js';
import { getJDLObjectFromSingleApplication } from '../../../jdl/converters/json-to-jdl-converter.js';
import { JSONEntity } from '../../../jdl/converters/types.js';
import type { JSONEntity } from '../../../jdl/converters/types.js';

export const exportJDLTransform = ({
destinationPath,
Expand Down
2 changes: 1 addition & 1 deletion generators/bootstrap/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { createConflicterTransform, createYoResolveTransform, forceYoFiles } fro
import type { MemFsEditorFile } from 'mem-fs-editor';
import { isFilePending, isFileStateModified } from 'mem-fs-editor/state';
import { createCommitTransform } from 'mem-fs-editor/transform';
import { Options as PrettierOptions } from 'prettier';
import type { Options as PrettierOptions } from 'prettier';
import type { FileTransform, PipelineOptions } from 'mem-fs';

import BaseGenerator from '../base/index.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/bootstrap/support/eslint-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { isFileStateModified } from 'mem-fs-editor/state';
import { Minimatch } from 'minimatch';
import { Piscina } from 'piscina';

import BaseGenerator from '../../base-core/index.js';
import type BaseGenerator from '../../base-core/index.js';
import { addLineNumbers } from '../internal/transform-utils.js';

type PoolOptions = Exclude<ConstructorParameters<typeof Piscina>[0], undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { transformFileField } from '@yeoman/transform';
import { ConflicterFile } from '@yeoman/conflicter';
import type { ConflicterFile } from '@yeoman/conflicter';

const createForceWriteConfigFilesTransform = () =>
transformFileField<'conflicter', ConflicterFile>('conflicter', 'force', { pattern: '**/.jhipster/*.json' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extname } from 'path';
import { passthrough } from 'p-transform';
import { isFileStateModified } from 'mem-fs-editor/state';
import { VinylMemFsEditorFile } from 'mem-fs-editor';
import type { VinylMemFsEditorFile } from 'mem-fs-editor';
import { Piscina } from 'piscina';

import type CoreGenerator from '../../base-core/index.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/bootstrap/support/multi-step-transform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { type DuplexWithDebug, transform } from 'p-transform';
import type { MemFsEditorFile } from 'mem-fs-editor';
import TemplateFileFs from './template-file-fs.js';
import TemplateFile from './template-file.js';
import type TemplateFile from './template-file.js';

export const createMultiStepTransform = () => {
const templateFileFs = new TemplateFileFs({});
Expand Down
4 changes: 2 additions & 2 deletions generators/bootstrap/support/sort-config-files-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import File from 'vinyl';
import type File from 'vinyl';
import sortKeys from 'sort-keys';
import { transformContents } from '@yeoman/transform';
import { MemFsEditorFile } from 'mem-fs-editor';
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`);
Expand Down
2 changes: 1 addition & 1 deletion generators/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { GeneratorDefinition } from '../base-application/generator.js';
import type { GeneratorDefinition } from '../base-application/generator.js';

export { default } from './generator.js';
export { default as command } from './command.js';
Expand Down
4 changes: 2 additions & 2 deletions generators/client/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CommonClientServerApplication } from '../../base-application/types.js';
import BaseGenerator from '../../base/index.js';
import type { CommonClientServerApplication } from '../../base-application/types.js';
import type BaseGenerator from '../../base/index.js';

export type UpdateClientLanguagesTaskParam = { application: CommonClientServerApplication & { enableTranslation: true }; control?: any };

Expand Down
4 changes: 2 additions & 2 deletions generators/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BaseApplicationGeneratorDefinition } from '../base-application/tasks.js';
import type { BaseApplicationGeneratorDefinition } from '../base-application/tasks.js';
import { type Entity } from '../base-application/index.js';
import { ClientServerApplication } from './types.js';
import type { ClientServerApplication } from './types.js';

export { default } from './generator.js';
export { default as command } from './command.js';
Expand Down
6 changes: 3 additions & 3 deletions generators/cucumber/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
import { moveToJavaPackageTestDir } from '../server/support/index.js';
import { GRADLE_BUILD_SRC_MAIN_DIR, SERVER_TEST_RES_DIR, SERVER_TEST_SRC_DIR } from '../generator-constants.js';
import { WriteFileSection } from '../base/api.js';
import { CommonClientServerApplication } from '../base-application/types.js';
import Generator from './generator.js';
import type { WriteFileSection } from '../base/api.js';
import type { CommonClientServerApplication } from '../base-application/types.js';
import type Generator from './generator.js';

const cucumberFiles: WriteFileSection<Generator, CommonClientServerApplication> = {
cucumberFiles: [
Expand Down
2 changes: 1 addition & 1 deletion generators/gatling/entity-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { TEST_DIR } from '../generator-constants.js';
import Generator from './generator.js';
import type Generator from './generator.js';

export const gatlingFiles = {
gatlingFiles: [
Expand Down
6 changes: 3 additions & 3 deletions generators/gatling/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* limitations under the License.
*/
import { GRADLE_BUILD_SRC_MAIN_DIR, TEST_DIR } from '../generator-constants.js';
import { WriteFileSection } from '../base/api.js';
import { SpringBootApplication } from '../server/types.js';
import Generator from './generator.js';
import type { WriteFileSection } from '../base/api.js';
import type { SpringBootApplication } from '../server/types.js';
import type Generator from './generator.js';

const gatlingFiles: WriteFileSection<Generator, SpringBootApplication> = {
gatlingFiles: [
Expand Down
2 changes: 1 addition & 1 deletion generators/gradle/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
gradleNeedleOptionsWithDefaults,
sortDependencies,
} from './internal/needles.js';
import { GradleDependency } from './types.js';
import type { GradleDependency } from './types.js';

const { PRE_CONFLICTS_QUEUE } = QUEUES;

Expand Down
2 changes: 1 addition & 1 deletion generators/gradle/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequireOneOrNone } from 'type-fest';
import type { RequireOneOrNone } from 'type-fest';

export type GradleComment = { comment?: string };

Expand Down
Loading

0 comments on commit 5d8b3f0

Please sign in to comment.