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/unbound-method': 'off',
|
||||||
'@typescript-eslint/no-explicit-any': '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
|
// These rules enabled by the preset configs don't work well for us
|
||||||
'@typescript-eslint/await-thenable': 'off',
|
'@typescript-eslint/await-thenable': 'off',
|
||||||
'prefer-const': '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 chai from 'chai';
|
||||||
import chaiPromises from 'chai-as-promised';
|
import chaiPromises from 'chai-as-promised';
|
||||||
import chaiXml from 'chai-xml';
|
import chaiXml from 'chai-xml';
|
||||||
|
import rss, { getRssString } from '../dist/index.js';
|
||||||
|
import { rssSchema } from '../dist/schema.js';
|
||||||
import {
|
import {
|
||||||
title,
|
|
||||||
description,
|
description,
|
||||||
site,
|
|
||||||
phpFeedItem,
|
phpFeedItem,
|
||||||
phpFeedItemWithContent,
|
phpFeedItemWithContent,
|
||||||
phpFeedItemWithCustomData,
|
phpFeedItemWithCustomData,
|
||||||
|
site,
|
||||||
|
title,
|
||||||
web1FeedItem,
|
web1FeedItem,
|
||||||
web1FeedItemWithContent,
|
|
||||||
web1FeedItemWithAllData,
|
web1FeedItemWithAllData,
|
||||||
|
web1FeedItemWithContent,
|
||||||
} from './test-utils.js';
|
} from './test-utils.js';
|
||||||
|
|
||||||
chai.use(chaiPromises);
|
chai.use(chaiPromises);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { dim, green } from 'kleur/colors';
|
import { dim, green } from 'kleur/colors';
|
||||||
import fs, { readFileSync } from 'node:fs';
|
import fs, { readFileSync } from 'node:fs';
|
||||||
import { basename, join } from 'node:path/posix';
|
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 { AstroConfig } from '../../@types/astro.js';
|
||||||
import type { BuildPipeline } from '../../core/build/buildPipeline.js';
|
import type { BuildPipeline } from '../../core/build/buildPipeline.js';
|
||||||
import { getOutDirWithinCwd } from '../../core/build/common.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 { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js';
|
||||||
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||||
import type { SSRManifest } from '../app/types.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 { Pipeline } from '../pipeline.js';
|
||||||
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';
|
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';
|
||||||
import { createEnvironment } from '../render/index.js';
|
import { createEnvironment } from '../render/index.js';
|
||||||
|
|
|
@ -10,7 +10,6 @@ import type {
|
||||||
GetStaticPathsItem,
|
GetStaticPathsItem,
|
||||||
RouteData,
|
RouteData,
|
||||||
RouteType,
|
RouteType,
|
||||||
SSRElement,
|
|
||||||
SSRError,
|
SSRError,
|
||||||
SSRLoadedRenderer,
|
SSRLoadedRenderer,
|
||||||
SSRManifest,
|
SSRManifest,
|
||||||
|
|
|
@ -24,7 +24,8 @@ import { resolveConfig } from '../config/config.js';
|
||||||
import { createNodeLogger } from '../config/logging.js';
|
import { createNodeLogger } from '../config/logging.js';
|
||||||
import { createSettings } from '../config/settings.js';
|
import { createSettings } from '../config/settings.js';
|
||||||
import { createVite } from '../create-vite.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 { apply as applyPolyfill } from '../polyfill.js';
|
||||||
import { RouteCache } from '../render/route-cache.js';
|
import { RouteCache } from '../render/route-cache.js';
|
||||||
import { createRouteManifest } from '../routing/index.js';
|
import { createRouteManifest } from '../routing/index.js';
|
||||||
|
|
|
@ -5,7 +5,8 @@ import type { AstroConfig } from '../../@types/astro.js';
|
||||||
import { transform } from '@astrojs/compiler';
|
import { transform } from '@astrojs/compiler';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { normalizePath } from 'vite';
|
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 { AstroErrorData } from '../errors/index.js';
|
||||||
import { resolvePath } from '../util.js';
|
import { resolvePath } from '../util.js';
|
||||||
import { createStylePreprocessor } from './style.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 { fileURLToPath } from 'node:url';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
|
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import debugPackage from 'debug';
|
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';
|
import { getEventPrefix, levels, type LogMessage, type LogWritable } from './core.js';
|
||||||
|
|
||||||
type ConsoleStream = Writable & {
|
type ConsoleStream = Writable & {
|
||||||
|
|
|
@ -4,7 +4,8 @@ import type { Logger } from '../logger/core.js';
|
||||||
import { routeIsFallback } from '../redirects/helpers.js';
|
import { routeIsFallback } from '../redirects/helpers.js';
|
||||||
import { routeIsRedirect } from '../redirects/index.js';
|
import { routeIsRedirect } from '../redirects/index.js';
|
||||||
import { getParams } from '../routing/params.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 {
|
interface GetParamsAndPropsOptions {
|
||||||
mod: ComponentInstance | undefined;
|
mod: ComponentInstance | undefined;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import type {
|
||||||
RouteData,
|
RouteData,
|
||||||
RuntimeMode,
|
RuntimeMode,
|
||||||
} from '../../@types/astro.js';
|
} from '../../@types/astro.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
|
||||||
import type { Logger } from '../logger/core.js';
|
import type { Logger } from '../logger/core.js';
|
||||||
|
|
||||||
import { stringifyParams } from '../routing/params.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 type { PageBuildData } from '../core/build/types.js';
|
||||||
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
||||||
import { mergeConfig } from '../core/config/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 { isServerLikeOutput } from '../prerender/utils.js';
|
||||||
import { validateSupportedFeatures } from './astroFeaturesValidation.js';
|
import { validateSupportedFeatures } from './astroFeaturesValidation.js';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@types/astro.js';
|
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';
|
import { settings } from './settings.js';
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { loadDevOverlayPlugins } from 'astro:dev-overlay';
|
import { loadDevOverlayPlugins } from 'astro:dev-overlay';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import type { SSRResult } from '../../../@types/astro.js';
|
import type { SSRResult } from '../../../@types/astro.js';
|
||||||
import type { RenderInstruction } from './instruction.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 {
|
import {
|
||||||
determineIfNeedsHydrationScript,
|
determineIfNeedsHydrationScript,
|
||||||
determinesIfNeedsDirectiveScript,
|
determinesIfNeedsDirectiveScript,
|
||||||
|
|
|
@ -8,7 +8,8 @@ import { createRenderInstruction, type RenderInstruction } from './instruction.j
|
||||||
|
|
||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import { AstroError, AstroErrorData } from '../../../core/errors/index.js';
|
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 { extractDirectives, generateHydrateScript } from '../hydration.js';
|
||||||
import { serializeProps } from '../serialize.js';
|
import { serializeProps } from '../serialize.js';
|
||||||
import { shorthash } from '../shorthash.js';
|
import { shorthash } from '../shorthash.js';
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import {
|
import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from './events.js';
|
||||||
TRANSITION_AFTER_SWAP,
|
import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from './events.js';
|
||||||
TransitionBeforeSwapEvent,
|
|
||||||
doPreparation,
|
|
||||||
doSwap,
|
|
||||||
type TransitionBeforePreparationEvent,
|
|
||||||
} from './events.js';
|
|
||||||
import type { Direction, Fallback, Options } from './types.js';
|
import type { Direction, Fallback, Options } from './types.js';
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import type { HmrContext, ModuleNode } from 'vite';
|
import type { HmrContext, ModuleNode } from 'vite';
|
||||||
import type { AstroConfig } from '../@types/astro.js';
|
import type { AstroConfig } from '../@types/astro.js';
|
||||||
import {
|
import type { cachedCompilation } from '../core/compile/index.js';
|
||||||
cachedCompilation,
|
import { invalidateCompilation, isCached, type CompileResult } from '../core/compile/index.js';
|
||||||
invalidateCompilation,
|
|
||||||
isCached,
|
|
||||||
type CompileResult,
|
|
||||||
} from '../core/compile/index.js';
|
|
||||||
import type { Logger } from '../core/logger/core.js';
|
import type { Logger } from '../core/logger/core.js';
|
||||||
import { isAstroSrcFile } from '../core/logger/vite.js';
|
import { isAstroSrcFile } from '../core/logger/vite.js';
|
||||||
import { isAstroScript } from './query.js';
|
import { isAstroScript } from './query.js';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { loadFixture } from './test-utils.js';
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import testAdapter from './test-adapter.js';
|
import testAdapter from './test-adapter.js';
|
||||||
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
describe('astro:i18n virtual module', () => {
|
describe('astro:i18n virtual module', () => {
|
||||||
/** @type {import('./test-utils').Fixture} */
|
/** @type {import('./test-utils').Fixture} */
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import type { AstroInstance } from 'astro';
|
|
||||||
import type { RenderableTreeNode } from '@markdoc/markdoc';
|
import type { RenderableTreeNode } from '@markdoc/markdoc';
|
||||||
import Markdoc from '@markdoc/markdoc';
|
import Markdoc from '@markdoc/markdoc';
|
||||||
|
import type { AstroInstance } from 'astro';
|
||||||
|
import type { HTMLString } from 'astro/runtime/server/index.js';
|
||||||
import {
|
import {
|
||||||
createComponent,
|
createComponent,
|
||||||
renderComponent,
|
|
||||||
render,
|
|
||||||
renderScriptElement,
|
|
||||||
renderUniqueStylesheet,
|
|
||||||
createHeadAndContent,
|
createHeadAndContent,
|
||||||
unescapeHTML,
|
|
||||||
renderTemplate,
|
|
||||||
HTMLString,
|
|
||||||
isHTMLString,
|
isHTMLString,
|
||||||
|
render,
|
||||||
|
renderComponent,
|
||||||
|
renderScriptElement,
|
||||||
|
renderTemplate,
|
||||||
|
renderUniqueStylesheet,
|
||||||
|
unescapeHTML,
|
||||||
} from 'astro/runtime/server/index.js';
|
} from 'astro/runtime/server/index.js';
|
||||||
|
|
||||||
export type TreeNode =
|
export type TreeNode =
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IncomingMessage, ServerResponse } from 'node:http';
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||||
|
|
||||||
export interface UserOptions {
|
export interface UserOptions {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import type { AstroConfig, AstroIntegration } from 'astro';
|
import type { AstroConfig, AstroIntegration } from 'astro';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import {
|
import type { EnumChangefreq, LinkItem as LinkItemBase, SitemapItemLoose } from 'sitemap';
|
||||||
EnumChangefreq,
|
import { simpleSitemapAndIndex } from 'sitemap';
|
||||||
simpleSitemapAndIndex,
|
|
||||||
type LinkItem as LinkItemBase,
|
|
||||||
type SitemapItemLoose,
|
|
||||||
} from 'sitemap';
|
|
||||||
import { ZodError } from 'zod';
|
import { ZodError } from 'zod';
|
||||||
|
|
||||||
import { generateSitemap } from './generate-sitemap.js';
|
import { generateSitemap } from './generate-sitemap.js';
|
||||||
|
|
Loading…
Reference in a new issue