diff --git a/.vscodeignore b/.vscodeignore index ceabf0d..8f5e030 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -16,3 +16,4 @@ vsc-extension-quickstart.md **/*.map **/*.ts node_modules/ +examples/** diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e568c..f6e0484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## 4.3.0 - 2026-11-04 + +### Changed + +- Improve syntax highlighting (#39). + ## 4.2.0 - 2026-03-14 ### Added diff --git a/README.md b/README.md index ec3296a..9ec9476 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Shows the first code owner. Click to see matching line in CODEOWNERS file. syntax highlighting +Escapes, wildcards, comments and owners are highlighted the way GitHub reads them, and patterns or owners that make GitHub skip a line are marked invalid. [`examples/CODEOWNERS`](examples/CODEOWNERS) has a rule for each case. + #### Formatting > Enable formatting by setting `github-code-owners.format.enabled` to `true`. diff --git a/examples/CODEOWNERS b/examples/CODEOWNERS new file mode 100644 index 0000000..8f332b2 --- /dev/null +++ b/examples/CODEOWNERS @@ -0,0 +1,188 @@ +# An example CODEOWNERS file: the usual rules first, then a rule for each +# way GitHub matches that's easy to get wrong, or that other CODEOWNERS +# libraries get wrong. Each behavior here was checked on GitHub. +# +# GitHub doesn't use this file. It reads CODEOWNERS from .github/, the +# repository root, or docs/, in that order, and ignores one over 3 MiB. +# +# The last rule matching a file sets its owners, so later rules override +# earlier ones. A line GitHub rejects is skipped, as if it weren't there. +# +# "Other libraries" notes compare codeowners-rs (Rust), hmarr/codeowners +# (Go), snyk/github-codeowners (Node) and sbdchd/codeowners (Python). See +# https://github.com/chdsbd/codeowners-comparison for every case where each +# disagrees with GitHub. + + +# ---- The usual rules ---- + +# Default owners, for every file no later rule matches. +* @acme/everyone + +# Every .js file, at any depth. +*.js @acme/frontend + +# An email address works as an owner, for the account that uses it. +*.go gopher@example.com + +# A leading slash anchors a pattern to the repository root, so this owns +# `build/x` but not `src/build/x`. A trailing slash matches a directory, +# and everything in it however deeply nested. +/build/ @acme/release + +# Without a leading slash, a directory matches at any depth: `apps/` owns +# `apps/x` and `src/apps/x`. +apps/ @acme/apps + +# A slash in the middle anchors a pattern too, and `*` doesn't cross +# slashes: `docs/*` owns `docs/a.md`, but not `docs/guides/a.md`. +docs/* @acme/docs + +# `**` between slashes matches any number of directories: `**/logs` owns +# `logs/x`, `build/logs/x` and `a/b/logs/x`. +**/logs @acme/sre + +# A rule with no owners leaves its files without any, even though earlier +# rules match them. +/apps/legacy/ + + +# ---- Negation ---- + +# `!` doesn't negate. Without a slash, GitHub drops it and matches files +# named like the rest of the pattern, but not directories: `!secrets` owns +# `secrets` and `config/secrets`, but not `secrets/key`. +# Other libraries: all four match nothing, or reject the line. +!secrets @acme/security + +# With a slash, `!` is an ordinary character: this owns the file +# `!important/notes.md`, nothing else. +# Other libraries: hmarr rejects the line, and snyk matches nothing. +!important/notes.md @acme/notes + + +# ---- Wildcards ---- + +# `?` matches one byte, not one character. `é` is two bytes in UTF-8, so +# `?.txt` owns `a.txt` but not `é.txt`, and `??.txt` owns `é.txt`. +# Other libraries: all four match one character. +?.txt @acme/one-byte +??.txt @acme/two-bytes + +# A trailing `/**/` matches files too, like a trailing `/**`: +# `/vendor/**/` owns `vendor/x`, not just directories in vendor/. +# Other libraries: sbdchd matches only directories. hmarr and snyk do too +# for a bare `**/` or `/**/`, which on GitHub own every file. +/vendor/**/ @acme/vendor + +# `**` that isn't between slashes is the same as `*`: `test**data` owns +# `testdata` and `test-data/x`, but not `test/data`. +test**data @acme/fixtures + +# `***` makes GitHub skip the line. +# Other libraries: codeowners-rs, snyk and sbdchd treat `***` like `*`. +/tmp/*** @acme/tmp + +# Braces aren't special: this owns files and directories named `{a,b}`, +# not `a` or `b`. +# Other libraries: hmarr rejects the line. +{a,b} @acme/braces + + +# ---- Brackets ---- + +# GitHub has no character ranges, so an unescaped `[` or `]` makes it skip +# the line. That catches route directories like Next.js's `[id]`. +# Other libraries: codeowners-rs and hmarr treat this as owning +# `app/[id]/page.tsx`. +/app/[id]/ @acme/web + +# Escape them instead: this owns `app/[id]/page.tsx`. Escaped brackets also +# match a path with the backslashes in it, like `app/\[id\]/page.tsx`, but +# not a mix of the two, like `app/\[id]/page.tsx`. +# Other libraries: none match that second path. +/app/\[id\]/ @acme/web + +# Without a slash, a pattern starting with `\[` matches nothing: this +# doesn't own `[draft]notes.md`. Start it with `**/` instead. +# Other libraries: all four match it. +\[draft\]* @acme/drafts +**/\[draft\]* @acme/drafts + +# Escaped brackets must pair up by count, or the pattern matches nothing: +# this doesn't own `notes[1`. +# Other libraries: all four match it. +notes\[1 @acme/notes + + +# ---- Escapes and comments ---- + +# `\` only escapes a space, a tab, `#`, `[`, `]` or `\`. Escaping anything +# else makes GitHub skip the line. +# Other libraries: all four read `\*` as a literal `*`. +\*.bak @acme/backups + +# A `\` at the end of a pattern escapes nothing and is dropped. Since a `\` +# before a space or tab escapes it, the pattern has to end the line, so the +# rule never has owners. Without a slash, this leaves `x/drafts` with no +# owner, but not `drafts\`. +drafts\ + +# With a slash, the pattern also matches the `\` literally: this leaves +# both `notes` and `notes\` with no owner. +/notes\ + +# A pattern of nothing but slashes is accepted but matches nothing. +/ @acme/root + +# So is one with a `.` or `..` segment, since git paths never have one: +# this doesn't own `src/x`. +./src/ @acme/src + +# An escaped space is part of the pattern. +# Other libraries: snyk rejects the line. +My\ Documents/ @acme/docs + +# `\\` is a literal backslash: this owns `win\path`. +# Other libraries: codeowners-rs matches nothing. +win\\path @acme/windows + +# An unescaped `#` starts a comment anywhere, even inside a pattern. This +# line is the pattern `/src/C` with no owners: it leaves `src/C/x` with no +# owner, and doesn't match `src/C#/x`. +# Other libraries: sbdchd reads `/src/C#/` as the pattern. +/src/C#/ @acme/csharp + +# Escape `#` to match it: this owns `src/C#/x`, and `#notes` anywhere. +# GitHub's docs say this escape doesn't work, but it does. +# Other libraries: hmarr and snyk match nothing. +/src/C\#/ @acme/csharp +\#notes @acme/notes + + +# ---- Case and non-ASCII ---- + +# Patterns are case-sensitive: this owns `README.MD`, not `README.md`. +# Other libraries: snyk ignores case. +*.MD @acme/docs + +# Non-ASCII patterns work: this owns everything in directories named `日本語`. +# Other libraries: hmarr rejects the line. +日本語/ @acme/i18n + + +# ---- Owners ---- + +# GitHub skips a line if any owner isn't an @user, an @org/team, or an +# email address with a dot in its domain. Each of these lines is skipped, +# so their files keep the owners of earlier rules. +/owners/one/ @first.last +/owners/two/ @acme/team/sub +/owners/three/ admin@localhost +/owners/four/ @acme/ok not-an-owner + +# A user or team that doesn't exist, or can't access the repository, +# doesn't make GitHub skip the line. The line still applies to its files, +# but GitHub has no one to request a review from, so in practice they have +# no owner. +/owners/five/ @no-such-user diff --git a/package-lock.json b/package-lock.json index 2eaf70d..8dd59e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "github-code-owners", - "version": "4.2.0", + "version": "4.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "github-code-owners", - "version": "4.2.0", + "version": "4.3.0", "license": "SEE LICENSE IN LICENSE", "dependencies": { "@snyk/github-codeowners": "github:chdsbd/github-codeowners#bb24c2adb022a88e03f25a3680a23934a281a5c3", @@ -15,12 +15,12 @@ "devDependencies": { "@types/lodash": "^4.14.195", "@types/mocha": "^10.0.4", - "@types/node": "^18.14.2", + "@types/node": "^24.19.2", "@types/vscode": "^1.53.0", "@typescript-eslint/eslint-plugin": "^5.54.1", "@typescript-eslint/parser": "^5.54.1", "@vscode/test-cli": "^0.0.9", - "@vscode/test-electron": "^2.3.9", + "@vscode/test-electron": "^3.1.0", "esbuild": "^0.17.10", "eslint": "^8.35.0", "glob": "^10.3.10", @@ -655,15 +655,6 @@ "node": ">= 6" } }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -689,10 +680,14 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.14.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.2.tgz", - "integrity": "sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==", - "dev": true + "version": "24.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz", + "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": ">=7.24.0 <7.24.7" + } }, "node_modules/@types/semver": { "version": "7.3.13", @@ -995,18 +990,20 @@ } }, "node_modules/@vscode/test-electron": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.9.tgz", - "integrity": "sha512-z3eiChaCQXMqBnk2aHHSEkobmC2VRalFQN0ApOAtydL172zXGxTwGrRtviT5HnUB+Q+G3vtEYFtuQkYqBzYgMA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-3.1.0.tgz", + "integrity": "sha512-CRqv5u+YYoseuNVJ6Tyo4k0sF0mx4qnKMihRB0PjsUF8Dc0WKtCXo6CNL6nWWm5esfFQsQA/pejMj4ZbpJVLTw==", "dev": true, + "license": "MIT", "dependencies": { - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "^5.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.5", "jszip": "^3.10.1", - "semver": "^7.5.2" + "ora": "^8.1.0", + "semver": "^7.6.2" }, "engines": { - "node": ">=16" + "node": ">=22" } }, "node_modules/acorn": { @@ -1031,15 +1028,13 @@ } }, "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", "dev": true, - "dependencies": { - "debug": "4" - }, + "license": "MIT", "engines": { - "node": ">= 6.0.0" + "node": ">= 14" } }, "node_modules/aggregate-error": { @@ -1384,6 +1379,35 @@ "node": ">=6" } }, + "node_modules/cli-cursor": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "restore-cursor": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -2138,6 +2162,19 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-intrinsic": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", @@ -2404,30 +2441,31 @@ "dev": true }, "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", "dev": true, + "license": "MIT", "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" + "agent-base": "^7.1.0", + "debug": "^4.3.4" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", "dev": true, + "license": "MIT", "dependencies": { - "agent-base": "6", + "agent-base": "^7.1.2", "debug": "4" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/ignore": { @@ -2636,6 +2674,19 @@ "node": ">=0.10.0" } }, + "node_modules/is-interactive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", + "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -2984,18 +3035,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -3042,6 +3081,19 @@ "node": ">=8.6" } }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3451,6 +3503,22 @@ "wrappy": "1" } }, + "node_modules/onetime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-function": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -3468,6 +3536,140 @@ "node": ">= 0.8.0" } }, + "node_modules/ora": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", + "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "cli-cursor": "^5.0.0", + "cli-spinners": "^2.9.2", + "is-interactive": "^2.0.0", + "is-unicode-supported": "^2.0.0", + "log-symbols": "^6.0.0", + "stdin-discarder": "^0.2.2", + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ora/node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/ora/node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, + "license": "MIT" + }, + "node_modules/ora/node_modules/is-unicode-supported": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", + "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/log-symbols": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", + "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "is-unicode-supported": "^1.3.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/log-symbols/node_modules/is-unicode-supported": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", + "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -3837,6 +4039,23 @@ "node": ">=4" } }, + "node_modules/restore-cursor": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -3964,13 +4183,11 @@ } }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -4119,6 +4336,19 @@ "integrity": "sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==", "dev": true }, + "node_modules/stdin-discarder": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", + "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -4494,6 +4724,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "7.24.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", + "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -4648,12 +4885,6 @@ "node": ">=10" } }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index ca2b3e4..50933b1 100644 --- a/package.json +++ b/package.json @@ -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.2.0", + "version": "4.3.0", "icon": "images/logo256.png", "homepage": "https://github.com/chdsbd/vscode-github-code-owners/blob/master/README.md", "keywords": [ @@ -214,12 +214,12 @@ "devDependencies": { "@types/lodash": "^4.14.195", "@types/mocha": "^10.0.4", - "@types/node": "^18.14.2", + "@types/node": "^24.19.2", "@types/vscode": "^1.53.0", "@typescript-eslint/eslint-plugin": "^5.54.1", "@typescript-eslint/parser": "^5.54.1", "@vscode/test-cli": "^0.0.9", - "@vscode/test-electron": "^2.3.9", + "@vscode/test-electron": "^3.1.0", "esbuild": "^0.17.10", "eslint": "^8.35.0", "glob": "^10.3.10", @@ -233,6 +233,6 @@ "lodash": "^4.17.21" }, "volta": { - "node": "18.14.2" + "node": "24.22.1" } } diff --git a/syntaxes/codeowners.tmLanguage.json b/syntaxes/codeowners.tmLanguage.json index 7c66d4c..6d48eb7 100644 --- a/syntaxes/codeowners.tmLanguage.json +++ b/syntaxes/codeowners.tmLanguage.json @@ -5,31 +5,102 @@ "include": "#comment" }, { - "include": "#absolute-path-matcher" + "include": "#absolute-rule" }, { - "include": "#pattern-matcher" - }, - { - "include": "#owner-matcher" + "include": "#rule" } ], "repository": { "comment": { - "match": "\\s*(#.*)", - "name": "comment.line.codeowners" + "match": "(#).*$", + "name": "comment.line.number-sign.codeowners", + "captures": { + "1": { + "name": "punctuation.definition.comment.codeowners" + } + } + }, + "absolute-rule": { + "begin": "^\\s*(/(?:[^\\s#\\\\]|\\\\.|\\\\$)*)", + "beginCaptures": { + "1": { + "name": "entity.name.function.codeowners", + "patterns": [ + { + "include": "#pattern-tokens" + } + ] + } + }, + "end": "$", + "patterns": [ + { + "include": "#owners" + } + ] }, - "absolute-path-matcher": { - "match": "^\\s*(/\\S+)", - "name": "entity.name.function.codeowners" + "rule": { + "begin": "^\\s*((?:[^\\s#\\\\]|\\\\.|\\\\$)+)", + "beginCaptures": { + "1": { + "name": "entity.name.type.codeowners", + "patterns": [ + { + "include": "#pattern-tokens" + } + ] + } + }, + "end": "$", + "patterns": [ + { + "include": "#owners" + } + ] }, - "pattern-matcher": { - "match": "^\\s*(\\S+)", - "name": "entity.name.type.codeowners" + "pattern-tokens": { + "patterns": [ + { + "match": "\\\\[ \\t#\\[\\]\\\\]", + "name": "constant.character.escape.codeowners" + }, + { + "match": "\\\\.", + "name": "invalid.illegal.escape.codeowners" + }, + { + "match": "[\\[\\]]", + "name": "invalid.illegal.bracket.codeowners" + }, + { + "match": "\\*{3,}", + "name": "invalid.illegal.wildcard.codeowners" + }, + { + "match": "\\*\\*|\\*|\\?", + "name": "keyword.operator.wildcard.codeowners" + } + ] }, - "owner-matcher": { - "match": "\\S*\\s\\S*@\\S*", - "name": "storage.type.function.codeowners" + "owners": { + "patterns": [ + { + "include": "#comment" + }, + { + "match": "@[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)?(?=\\s|#|$)", + "name": "storage.type.function.codeowners" + }, + { + "match": "[^\\s#@]+@[^\\s#@]+\\.[A-Za-z]{2,}(?=\\s|#|$)", + "name": "storage.type.function.codeowners" + }, + { + "match": "[^\\s#]+", + "name": "invalid.illegal.owner.codeowners" + } + ] } }, "scopeName": "text.codeowners" diff --git a/test/runTest.ts b/test/runTest.ts index d52f161..90af2ff 100644 --- a/test/runTest.ts +++ b/test/runTest.ts @@ -1,3 +1,5 @@ +import fs from "fs" +import os from "os" import path from "path" import { runTests } from "@vscode/test-electron" @@ -12,8 +14,16 @@ async function main() { // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, "./suite/index") + // VS Code puts its IPC socket in the user data directory. The default, + // inside the checkout, can pass the macOS limit of 103 characters. + const userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), "vscode-test-")) + // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }) + await runTests({ + extensionDevelopmentPath, + extensionTestsPath, + launchArgs: ["--user-data-dir", userDataDir], + }) } catch (err) { console.error("Failed to run tests", err) process.exit(1) diff --git a/test/suite/index.ts b/test/suite/index.ts index 97ca559..5e105ca 100644 --- a/test/suite/index.ts +++ b/test/suite/index.ts @@ -6,7 +6,9 @@ export async function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', - color: true + color: true, + // Writing settings can take a few seconds while VS Code is starting up. + timeout: 20000 }); const testsRoot = path.resolve(__dirname, '..'); diff --git a/tsconfig.json b/tsconfig.json index 3a765ed..e3f0e95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, + "skipLibCheck": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUnusedParameters": false,