Skip to content

Commit 9aa56de

Browse files
committed
Add lint support for IPYNB files when MATLAB is connected
1 parent c25ac7c commit 9aa56de

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/providers/linting/LintingSupportProvider.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,16 @@ class LintingSupportProvider {
9292
const matlabConnection = await this.matlabLifecycleManager.getMatlabConnection()
9393
const isMatlabAvailable = matlabConnection != null
9494

95-
const fileName = URI.parse(uri).fsPath
95+
const isIPYNBFile = this.isNotebookFile(uri)
96+
const fileName = isIPYNBFile ? "Notebook.m" : URI.parse(uri).fsPath
9697

9798
let lintData: string[] = []
9899

99100
if (isMatlabAvailable) {
100101
// Use MATLAB-based linting for better results and fixes
101102
const code = textDocument.getText()
102103
lintData = await this.getLintResultsFromMatlab(code, fileName, matlabConnection)
103-
} else {
104+
} else if (!isIPYNBFile) {
104105
// Try to use mlint executable for basic linting
105106
lintData = await this.getLintResultsFromExecutable(fileName)
106107
}
@@ -528,6 +529,16 @@ class LintingSupportProvider {
528529
a.severity === b.severity &&
529530
a.source === b.source
530531
}
532+
533+
/**
534+
* Checks if the given URI corresponds to a Jupyter Notebook file.
535+
*
536+
* @param uri - The URI of the file to check.
537+
* @returns True if the file is a Jupyter Notebook (.ipynb), false otherwise.
538+
*/
539+
private isNotebookFile(uri: string): boolean {
540+
return URI.parse(uri).fsPath.endsWith(".ipynb")
541+
}
531542
}
532543

533544
export default LintingSupportProvider

0 commit comments

Comments
 (0)