MCPcopy
hub / github.com/deepnote/deepnote / createLintAction

Function createLintAction

packages/cli/src/commands/lint.ts:131–167  ·  view source on GitHub ↗
(_program: Command)

Source from the content-addressed store, hash-verified

129 * Creates the lint action - checks for issues in a .deepnote file or integrations yaml file.
130 */
131export function createLintAction(_program: Command): (path: string | undefined, options: LintOptions) => Promise<void> {
132 return async (path, options) => {
133 try {
134 debug(`Linting: ${path}`)
135 let result: LintFileResult
136 if (path != null && isYamlPath(path)) {
137 // The YAML file itself is the integrations file, so --integrations-file has no meaning here.
138 if (options.integrationsFile) {
139 warn('Warning: --integrations-file is ignored when linting an integrations YAML file directly')
140 }
141 result = await lintIntegrationsFile(path)
142 } else {
143 result = await lintFile(path, options)
144 }
145 outputLintResult(result, options)
146
147 // Exit with error code if there are notebook errors or configuration errors
148 const hasErrors = result.issueCount.errors > 0 || result.integrationsFile.issues.length > 0
149 if (hasErrors) {
150 process.exit(ExitCode.Error)
151 }
152 } catch (error) {
153 const message = error instanceof Error ? error.message : String(error)
154 const exitCode =
155 error instanceof FileResolutionError || error instanceof InitNotebookResolutionError
156 ? ExitCode.InvalidUsage
157 : ExitCode.Error
158
159 if (options.output === 'json') {
160 outputJson({ success: false, error: message })
161 } else {
162 logError(message)
163 }
164 process.exit(exitCode)
165 }
166 }
167}
168
169async function lintFile(path: string | undefined, options: LintOptions): Promise<LintFileResult> {
170 // Loading `.env` and injecting integration env vars mutates `process.env`; restore it afterwards

Callers 2

registerCommandsFunction · 0.90
lint.test.tsFile · 0.90

Calls 7

debugFunction · 0.90
warnFunction · 0.90
outputJsonFunction · 0.90
isYamlPathFunction · 0.85
lintIntegrationsFileFunction · 0.85
lintFileFunction · 0.85
outputLintResultFunction · 0.85

Tested by

no test coverage detected