check() — astro Function Reference
Architecture documentation for the check() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD f0311e94_e870_5023_248c_ac95f34ef8e2["check()"] ec2c5796_49f3_c23d_04c9_a07265587893["index.ts"] f0311e94_e870_5023_248c_ac95f34ef8e2 -->|defined in| ec2c5796_49f3_c23d_04c9_a07265587893 style f0311e94_e870_5023_248c_ac95f34ef8e2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/astro-check/src/index.ts lines 25–122
export async function check(flags: Partial<Flags>): Promise<boolean | void> {
const workspaceRoot = path.resolve(flags.root ?? process.cwd());
const require = createRequire(import.meta.url);
const checker = new AstroCheck(workspaceRoot, require.resolve('typescript'), flags.tsconfig);
let req = 0;
if (flags.watch) {
function createWatcher(rootPath: string, extensions: string[]) {
return watch(rootPath, {
ignored(pathStr, stats) {
if (pathStr.includes('node_modules') || pathStr.includes('.git')) return true;
if (stats?.isFile() && !extensions.includes(path.extname(pathStr))) return true;
return false;
},
ignoreInitial: true,
});
}
// Dynamically get the list of extensions to watch from the files already included in the project
const checkedExtensions = Array.from(
new Set(checker.linter.getRootFileNames().map((fileName) => path.extname(fileName))),
);
createWatcher(workspaceRoot, checkedExtensions)
.on('add', (fileName) => {
checker.linter.fileCreated(fileName);
update();
})
.on('unlink', (fileName) => {
checker.linter.fileDeleted(fileName);
update();
})
.on('change', (fileName) => {
checker.linter.fileUpdated(fileName);
update();
});
}
async function update() {
if (!flags.preserveWatchOutput) process.stdout.write('\x1Bc');
await lint();
}
async function lint() {
const currentReq = ++req;
await new Promise((resolve) => setTimeout(resolve, 100));
const isCanceled = () => currentReq !== req;
if (isCanceled()) return;
const minimumSeverity = flags.minimumSeverity || 'hint';
const result = await checker.lint({
logErrors: {
level: minimumSeverity,
},
cancel: isCanceled,
});
console.info(
[
bold(`Result (${result.fileChecked} file${result.fileChecked === 1 ? '' : 's'}): `),
['error', 'warning', 'hint'].includes(minimumSeverity)
? result.errors > 0
? bold(red(`${result.errors} ${result.errors === 1 ? 'error' : 'errors'}`))
: dim('0 errors')
: undefined,
['warning', 'hint'].includes(minimumSeverity)
? result.warnings > 0
? bold(yellow(`${result.warnings} ${result.warnings === 1 ? 'warning' : 'warnings'}`))
: dim('0 warnings')
: undefined,
['hint'].includes(minimumSeverity)
? dim(`${result.hints} ${result.hints === 1 ? 'hint' : 'hints'}\n`)
: undefined,
]
.filter(Boolean)
.join(`\n${dim('-')} `),
);
if (flags.watch) {
console.info('Watching for changes...');
} else {
switch (flags.minimumFailingSeverity) {
Domain
Subdomains
Source
Frequently Asked Questions
What does check() do?
check() is a function in the astro codebase, defined in packages/language-tools/astro-check/src/index.ts.
Where is check() defined?
check() is defined in packages/language-tools/astro-check/src/index.ts at line 25.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free