mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix: enforce separate type imports (#9288)
This commit is contained in:
parent
bd9907867b
commit
4aa8091582
21 changed files with 47 additions and 47 deletions
|
@ -58,6 +58,16 @@ module.exports = {
|
|||
'@typescript-eslint/unbound-method': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
|
||||
// Enforce separate type imports for type-only imports to avoid bundling unneeded code
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
'error',
|
||||
{
|
||||
prefer: 'type-imports',
|
||||
fixStyle: 'separate-type-imports',
|
||||
disallowTypeAnnotations: false,
|
||||
},
|
||||
],
|
||||
|
||||
// These rules enabled by the preset configs don't work well for us
|
||||
'@typescript-eslint/await-thenable': 'off',
|
||||
'prefer-const': 'off',
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import rss, { getRssString } from '../dist/index.js';
|
||||
import { rssSchema } from '../dist/schema.js';
|
||||
import chai from 'chai';
|
||||
import chaiPromises from 'chai-as-promised';
|
||||
import chaiXml from 'chai-xml';
|
||||
import rss, { getRssString } from '../dist/index.js';
|
||||
import { rssSchema } from '../dist/schema.js';
|
||||
import {
|
||||
title,
|
||||
description,
|
||||
site,
|
||||
phpFeedItem,
|
||||
phpFeedItemWithContent,
|
||||
phpFeedItemWithCustomData,
|
||||
site,
|
||||
title,
|
||||
web1FeedItem,
|
||||
web1FeedItemWithContent,
|
||||
web1FeedItemWithAllData,
|
||||
web1FeedItemWithContent,
|
||||
} from './test-utils.js';
|
||||
|
||||
chai.use(chaiPromises);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { dim, green } from 'kleur/colors';
|
||||
import fs, { readFileSync } from 'node:fs';
|
||||
import { basename, join } from 'node:path/posix';
|
||||
import PQueue from 'p-queue';
|
||||
import type PQueue from 'p-queue';
|
||||
import type { AstroConfig } from '../../@types/astro.js';
|
||||
import type { BuildPipeline } from '../../core/build/buildPipeline.js';
|
||||
import { getOutDirWithinCwd } from '../../core/build/common.js';
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { AstroConfig, AstroSettings, SSRLoadedRenderer } from '../../@types
|
|||
import { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js';
|
||||
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||
import type { SSRManifest } from '../app/types.js';
|
||||
import { Logger } from '../logger/core.js';
|
||||
import type { Logger } from '../logger/core.js';
|
||||
import { Pipeline } from '../pipeline.js';
|
||||
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';
|
||||
import { createEnvironment } from '../render/index.js';
|
||||
|
|
|
@ -10,7 +10,6 @@ import type {
|
|||
GetStaticPathsItem,
|
||||
RouteData,
|
||||
RouteType,
|
||||
SSRElement,
|
||||
SSRError,
|
||||
SSRLoadedRenderer,
|
||||
SSRManifest,
|
||||
|
|
|
@ -24,7 +24,8 @@ import { resolveConfig } from '../config/config.js';
|
|||
import { createNodeLogger } from '../config/logging.js';
|
||||
import { createSettings } from '../config/settings.js';
|
||||
import { createVite } from '../create-vite.js';
|
||||
import { Logger, levels, timerMessage } from '../logger/core.js';
|
||||
import type { Logger } from '../logger/core.js';
|
||||
import { levels, timerMessage } from '../logger/core.js';
|
||||
import { apply as applyPolyfill } from '../polyfill.js';
|
||||
import { RouteCache } from '../render/route-cache.js';
|
||||
import { createRouteManifest } from '../routing/index.js';
|
||||
|
|
|
@ -5,7 +5,8 @@ import type { AstroConfig } from '../../@types/astro.js';
|
|||
import { transform } from '@astrojs/compiler';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { normalizePath } from 'vite';
|
||||
import { AggregateError, AstroError, CompilerError } from '../errors/errors.js';
|
||||
import type { AstroError } from '../errors/errors.js';
|
||||
import { AggregateError, CompilerError } from '../errors/errors.js';
|
||||
import { AstroErrorData } from '../errors/index.js';
|
||||
import { resolvePath } from '../util.js';
|
||||
import { createStylePreprocessor } from './style.js';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import nodeFs from 'node:fs';
|
||||
import type nodeFs from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import * as vite from 'vite';
|
||||
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import debugPackage from 'debug';
|
||||
import { Writable } from 'node:stream';
|
||||
import type { Writable } from 'node:stream';
|
||||
import { getEventPrefix, levels, type LogMessage, type LogWritable } from './core.js';
|
||||
|
||||
type ConsoleStream = Writable & {
|
||||
|
|
|
@ -4,7 +4,8 @@ import type { Logger } from '../logger/core.js';
|
|||
import { routeIsFallback } from '../redirects/helpers.js';
|
||||
import { routeIsRedirect } from '../redirects/index.js';
|
||||
import { getParams } from '../routing/params.js';
|
||||
import { RouteCache, callGetStaticPaths, findPathItemByKey } from './route-cache.js';
|
||||
import type { RouteCache } from './route-cache.js';
|
||||
import { callGetStaticPaths, findPathItemByKey } from './route-cache.js';
|
||||
|
||||
interface GetParamsAndPropsOptions {
|
||||
mod: ComponentInstance | undefined;
|
||||
|
|
|
@ -8,7 +8,6 @@ import type {
|
|||
RouteData,
|
||||
RuntimeMode,
|
||||
} from '../../@types/astro.js';
|
||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
||||
import type { Logger } from '../logger/core.js';
|
||||
|
||||
import { stringifyParams } from '../routing/params.js';
|
||||
|
|
|
@ -18,7 +18,7 @@ import type { SerializedSSRManifest } from '../core/app/types.js';
|
|||
import type { PageBuildData } from '../core/build/types.js';
|
||||
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
||||
import { mergeConfig } from '../core/config/index.js';
|
||||
import { AstroIntegrationLogger, type Logger } from '../core/logger/core.js';
|
||||
import type { AstroIntegrationLogger, Logger } from '../core/logger/core.js';
|
||||
import { isServerLikeOutput } from '../prerender/utils.js';
|
||||
import { validateSupportedFeatures } from './astroFeaturesValidation.js';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@types/astro.js';
|
||||
import { type AstroDevOverlay, type DevOverlayPlugin } from './overlay.js';
|
||||
import type { AstroDevOverlay, DevOverlayPlugin } from './overlay.js';
|
||||
import { settings } from './settings.js';
|
||||
// @ts-expect-error
|
||||
import { loadDevOverlayPlugins } from 'astro:dev-overlay';
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import type { SSRResult } from '../../../@types/astro.js';
|
||||
import type { RenderInstruction } from './instruction.js';
|
||||
|
||||
import { HTMLBytes, HTMLString, markHTMLString } from '../escape.js';
|
||||
import type { HTMLBytes, HTMLString } from '../escape.js';
|
||||
import { markHTMLString } from '../escape.js';
|
||||
import {
|
||||
determineIfNeedsHydrationScript,
|
||||
determinesIfNeedsDirectiveScript,
|
||||
|
|
|
@ -8,7 +8,8 @@ import { createRenderInstruction, type RenderInstruction } from './instruction.j
|
|||
|
||||
import { clsx } from 'clsx';
|
||||
import { AstroError, AstroErrorData } from '../../../core/errors/index.js';
|
||||
import { HTMLBytes, markHTMLString } from '../escape.js';
|
||||
import type { HTMLBytes } from '../escape.js';
|
||||
import { markHTMLString } from '../escape.js';
|
||||
import { extractDirectives, generateHydrateScript } from '../hydration.js';
|
||||
import { serializeProps } from '../serialize.js';
|
||||
import { shorthash } from '../shorthash.js';
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
import {
|
||||
TRANSITION_AFTER_SWAP,
|
||||
TransitionBeforeSwapEvent,
|
||||
doPreparation,
|
||||
doSwap,
|
||||
type TransitionBeforePreparationEvent,
|
||||
} from './events.js';
|
||||
import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from './events.js';
|
||||
import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from './events.js';
|
||||
import type { Direction, Fallback, Options } from './types.js';
|
||||
|
||||
type State = {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import type { HmrContext, ModuleNode } from 'vite';
|
||||
import type { AstroConfig } from '../@types/astro.js';
|
||||
import {
|
||||
cachedCompilation,
|
||||
invalidateCompilation,
|
||||
isCached,
|
||||
type CompileResult,
|
||||
} from '../core/compile/index.js';
|
||||
import type { cachedCompilation } from '../core/compile/index.js';
|
||||
import { invalidateCompilation, isCached, type CompileResult } from '../core/compile/index.js';
|
||||
import type { Logger } from '../core/logger/core.js';
|
||||
import { isAstroSrcFile } from '../core/logger/vite.js';
|
||||
import { isAstroScript } from './query.js';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { loadFixture } from './test-utils.js';
|
||||
import { expect } from 'chai';
|
||||
import * as cheerio from 'cheerio';
|
||||
import testAdapter from './test-adapter.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('astro:i18n virtual module', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import type { AstroInstance } from 'astro';
|
||||
import type { RenderableTreeNode } from '@markdoc/markdoc';
|
||||
import Markdoc from '@markdoc/markdoc';
|
||||
import type { AstroInstance } from 'astro';
|
||||
import type { HTMLString } from 'astro/runtime/server/index.js';
|
||||
import {
|
||||
createComponent,
|
||||
renderComponent,
|
||||
render,
|
||||
renderScriptElement,
|
||||
renderUniqueStylesheet,
|
||||
createHeadAndContent,
|
||||
unescapeHTML,
|
||||
renderTemplate,
|
||||
HTMLString,
|
||||
isHTMLString,
|
||||
render,
|
||||
renderComponent,
|
||||
renderScriptElement,
|
||||
renderTemplate,
|
||||
renderUniqueStylesheet,
|
||||
unescapeHTML,
|
||||
} from 'astro/runtime/server/index.js';
|
||||
|
||||
export type TreeNode =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IncomingMessage, ServerResponse } from 'node:http';
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
|
||||
export interface UserOptions {
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
import type { AstroConfig, AstroIntegration } from 'astro';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
EnumChangefreq,
|
||||
simpleSitemapAndIndex,
|
||||
type LinkItem as LinkItemBase,
|
||||
type SitemapItemLoose,
|
||||
} from 'sitemap';
|
||||
import type { EnumChangefreq, LinkItem as LinkItemBase, SitemapItemLoose } from 'sitemap';
|
||||
import { simpleSitemapAndIndex } from 'sitemap';
|
||||
import { ZodError } from 'zod';
|
||||
|
||||
import { generateSitemap } from './generate-sitemap.js';
|
||||
|
|
Loading…
Reference in a new issue