lint() — astro Function Reference
Architecture documentation for the lint() function in check.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 408ef090_33c2_8dd2_356f_d3ded1591f4b["lint()"] 97a48377_0e57_a94f_8ce7_cd934868bb42["AstroCheck"] 408ef090_33c2_8dd2_356f_d3ded1591f4b -->|defined in| 97a48377_0e57_a94f_8ce7_cd934868bb42 style 408ef090_33c2_8dd2_356f_d3ded1591f4b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/check.ts lines 51–133
public async lint({
fileNames = undefined,
cancel = () => false,
logErrors = undefined,
}: {
fileNames?: string[] | undefined;
cancel?: () => boolean;
logErrors?:
| {
level: 'error' | 'warning' | 'hint';
}
| undefined;
}): Promise<CheckResult> {
let files = (fileNames !== undefined ? fileNames : this.linter.getRootFileNames()).filter(
(file) => {
// We don't have the same understanding of Svelte and Vue files as their own respective tools (vue-tsc, svelte-check)
// So we don't want to check them here
return !file.endsWith('.vue') && !file.endsWith('.svelte');
},
);
const result: CheckResult = {
status: undefined,
fileChecked: 0,
errors: 0,
warnings: 0,
hints: 0,
fileResult: [],
};
for (const file of files) {
if (cancel()) {
result.status = 'cancelled';
return result;
}
const fileDiagnostics = await this.linter.check(file);
// Filter diagnostics based on the logErrors level
const fileDiagnosticsToPrint = fileDiagnostics.filter((diag) => {
const severity = diag.severity ?? DiagnosticSeverity.Error;
switch (logErrors?.level ?? 'hint') {
case 'error':
return severity <= DiagnosticSeverity.Error;
case 'warning':
return severity <= DiagnosticSeverity.Warning;
case 'hint':
return severity <= DiagnosticSeverity.Hint;
}
});
if (fileDiagnostics.length > 0) {
const errorText = this.linter.printErrors(file, fileDiagnosticsToPrint);
if (logErrors !== undefined && errorText) {
console.info(errorText);
}
const fileSnapshot = this.linter.language.scripts.get(URI.file(file))?.snapshot;
const fileContent = fileSnapshot?.getText(0, fileSnapshot.getLength());
result.fileResult.push({
errors: fileDiagnostics,
fileContent: fileContent ?? '',
fileUrl: pathToFileURL(file),
text: errorText,
});
result.errors += fileDiagnostics.filter(
(diag) => diag.severity === DiagnosticSeverity.Error,
).length;
result.warnings += fileDiagnostics.filter(
(diag) => diag.severity === DiagnosticSeverity.Warning,
).length;
result.hints += fileDiagnostics.filter(
(diag) => diag.severity === DiagnosticSeverity.Hint,
).length;
}
result.fileChecked += 1;
}
result.status = 'completed';
Domain
Subdomains
Source
Frequently Asked Questions
What does lint() do?
lint() is a function in the astro codebase, defined in packages/language-tools/language-server/src/check.ts.
Where is lint() defined?
lint() is defined in packages/language-tools/language-server/src/check.ts at line 51.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free