Skip to content

💡 add ec.config.mjs to entry in Starlight plugin #1450

@sushichan044

Description

@sushichan044

Suggest an idea for Knip

Starlight renders code blocks internally using Expressive Code.
https://starlight.astro.build/guides/authoring-content/#expressive-code-features

Since Expressive Code supports a configuration file named ec.config.mjs,
I believe that ec.config.mjs should be treated as an entryin the Starlight plugin.
https://expressive-code.com/reference/configuration/


NOTE: current implementation of startlight plugin:

import type ts from 'typescript';
import type { IsPluginEnabled, Plugin, ResolveFromAST } from '../../types/config.js';
import { toProductionEntry } from '../../util/input.js';
import { hasDependency } from '../../util/plugin.js';
import { config } from '../astro/index.js';
import { getComponentPathsFromSourceFile } from './resolveFromAST.js';
// https://starlight.astro.build/reference/configuration/
const title = 'Starlight';
const enablers = ['@astrojs/starlight'];
const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const resolveFromAST: ResolveFromAST = (sourceFile: ts.SourceFile) => {
const componentPaths = getComponentPathsFromSourceFile(sourceFile);
return Array.from(componentPaths).map(id => toProductionEntry(id));
};
const plugin: Plugin = {
title,
enablers,
isEnabled,
config,
resolveFromAST,
};
export default plugin;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions