Skip to content

Commit 67e8f04

Browse files
Using the standalone "zeptomatch-is-static" utility
1 parent 93231ea commit 67e8f04

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

package-lock.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"tiny-spinner": "^2.0.3",
5252
"worktank": "^2.6.1",
5353
"zeptomatch": "^2.0.0",
54-
"zeptomatch-escape": "^1.0.0"
54+
"zeptomatch-escape": "^1.0.0",
55+
"zeptomatch-is-static": "^1.0.0"
5556
},
5657
"devDependencies": {
5758
"@types/js-yaml": "^4.0.9",

src/utils.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import url from "node:url";
88
import { exit } from "specialist";
99
import readdir from "tiny-readdir-glob";
1010
import zeptomatchEscape from "zeptomatch-escape";
11+
import zeptomatchIsStatic from "zeptomatch-is-static";
1112
import type { ContextOptions, FormatOptions, FunctionMaybe, Key, LogLevel, Options, PrettierConfigWithOverrides, PrettierPlugin } from "./types.js";
1213
import type { PluginsOptions, PromiseMaybe } from "./types.js";
1314

@@ -239,11 +240,6 @@ function isFunction(value: unknown): value is Function {
239240
return typeof value === "function";
240241
}
241242

242-
function isGlobStatic(glob: string): boolean {
243-
//TODO: Make this perfect, grammar-based, rather than letting some glob-looking paths slip through
244-
return /^(?:\\.|[ a-zA-Z0-9/._-])*$/.test(glob);
245-
}
246-
247243
function isInteger(value: unknown): value is number {
248244
return Number.isInteger(value);
249245
}
@@ -309,7 +305,7 @@ function normalizeOptions(options: unknown, targets: unknown[]): Options {
309305
const cache = "cache" in options ? !!options.cache : true;
310306
const cacheLocation = "cacheLocation" in options && isString(options.cacheLocation) ? options.cacheLocation : undefined;
311307
const errorOnUnmatchedPattern = "errorOnUnmatchedPattern" in options ? !!options.errorOnUnmatchedPattern : true;
312-
const ignoreUnknown = "ignoreUnknown" in options && isBoolean(options.ignoreUnknown) ? !!options.ignoreUnknown : globs.some(isGlobStatic);
308+
const ignoreUnknown = "ignoreUnknown" in options && isBoolean(options.ignoreUnknown) ? !!options.ignoreUnknown : globs.some(zeptomatchIsStatic);
313309

314310
const logLevel = "logLevel" in options ? ((options.logLevel || "log") as LogLevel) : "log";
315311
const parallel = "parallel" in options && !!options.parallel;

0 commit comments

Comments
 (0)