Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support calling a function to get the config #5126

Merged
merged 3 commits into from
Dec 29, 2023
Merged

Conversation

Jason3S
Copy link
Collaborator

@Jason3S Jason3S commented Dec 29, 2023

With the release of v8.3.0 it will be possible to return a function from cspell.config.js files. This function will be called to get the configuration. It can return a Config Object or Promise that resolves to a Config Object.

Example:

cspell.config.mjs

import { readFile } from 'node:fs/promises';

/**
 * @returns {Promise<import('@cspell/cspell-types').CSpellUserSettings>}
 */
export default async function getConfig() {
    const words = (await readFile(new URL('requirements.txt', import.meta.url), 'utf8'))
        .replace(/[.,]|([=<>].*)/g, ' ')
        .split(/\s+/g);
    return { id: 'python-imports', words };
}

@Jason3S Jason3S marked this pull request as ready for review December 29, 2023 15:53
@Jason3S Jason3S merged commit 6d083a3 into main Dec 29, 2023
81 checks passed
@Jason3S Jason3S deleted the dev-js-config branch December 29, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant