Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# be identified in the format @org/team-name. Teams must have
# explicit write access to the repository. In this example,
# the octocats team in the octo-org organization owns all .txt files.
*.txt @octo-org/octocats
*.txt @octo-org/@test_one/octocats

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## 4.2.0 - 2026-03-14

### Added

- Show error diagnostics for invalid CODEOWNERS patterns (#34).

## 4.1.0 - 2024-04-13

### Changed
Expand Down
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Quickly see GitHub Code Owners for the current file. Add syntax highlighting for CODEOWNERS files.",
"publisher": "chdsbd",
"license": "SEE LICENSE IN LICENSE",
"version": "4.1.0",
"version": "4.2.0",
"icon": "images/logo256.png",
"homepage": "https://github.com/chdsbd/vscode-github-code-owners/blob/master/README.md",
"keywords": [
Expand Down Expand Up @@ -229,7 +229,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@snyk/github-codeowners": "github:chdsbd/github-codeowners#chris/line-number-information",
"@snyk/github-codeowners": "github:chdsbd/github-codeowners#da8b03fa3cb4de086f3a564f1af03cc44288e43c",
"lodash": "^4.17.21"
},
"volta": {
Expand Down
49 changes: 49 additions & 0 deletions src/codeowners-diagnostic-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import vscode from "vscode"
import { OwnershipEngine } from "@snyk/github-codeowners/dist/lib/ownership"

function updateDiagnostics(
document: vscode.TextDocument,
collection: vscode.DiagnosticCollection,
): void {
if (document.languageId !== "codeowners") {
return
}

const engine = OwnershipEngine.FromCodeownersFile(document.uri.fsPath)

const diagnostics = engine.errors.map((err) => {
const line = document.lineAt(err.lineno)
return new vscode.Diagnostic(line.range, err.message, vscode.DiagnosticSeverity.Error)
})

collection.set(document.uri, diagnostics)
}

export function registerCodeownersDiagnostics(
context: vscode.ExtensionContext,
): void {
const collection = vscode.languages.createDiagnosticCollection("codeowners")
context.subscriptions.push(collection)

vscode.workspace.textDocuments.forEach((doc) =>
updateDiagnostics(doc, collection),
)

vscode.workspace.onDidOpenTextDocument(
(doc) => updateDiagnostics(doc, collection),
null,
context.subscriptions,
)

vscode.workspace.onDidChangeTextDocument(
(e) => updateDiagnostics(e.document, collection),
null,
context.subscriptions,
)

vscode.workspace.onDidCloseTextDocument(
(doc) => collection.delete(doc.uri),
null,
context.subscriptions,
)
}
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { showOwnersCommandHandler } from "./show-owners-command"
import { CodeownersHoverProvider } from "./codeowners-hover-provider"
import { statusBarTextEditorListener } from "./status-bar-text-editor-listener"
import { AlignOwnersFormattingProvider } from "./align-codeowners"
import { registerCodeownersDiagnostics } from "./codeowners-diagnostic-provider"

const COMMAND_ID = "github-code-owners.show-owners"

Expand Down Expand Up @@ -74,6 +75,8 @@ export function activate(context: vscode.ExtensionContext) {
),
)

registerCodeownersDiagnostics(context)

vscode.workspace.onDidChangeConfiguration(() => {
outputChannel.appendLine("Configuration changed: Reloading link provider")
handles.linkProvider.dispose()
Expand Down
Loading