eslint-plugin-oxfmt 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -79,7 +79,7 @@ const configs = {
79
79
  //#region src/meta.ts
80
80
  const meta = {
81
81
  name: "eslint-plugin-oxfmt",
82
- version: "0.12.0"
82
+ version: "0.12.1"
83
83
  };
84
84
  //#endregion
85
85
  //#region src/dir.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-oxfmt",
3
3
  "type": "module",
4
- "version": "0.12.0",
4
+ "version": "0.12.1",
5
5
  "description": "An ESLint plugin for formatting code with oxfmt.",
6
6
  "keywords": [
7
7
  "eslint",
@@ -57,6 +57,7 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "generate-differences": "^0.1.1",
60
+ "ignore": "^7.0.5",
60
61
  "load-oxfmt-config": "^0.13.0",
61
62
  "picomatch": "^4.0.4",
62
63
  "synckit": "^0.11.13"
@@ -64,8 +65,8 @@
64
65
  "devDependencies": {
65
66
  "@ntnyq/eslint-config": "^6.1.5",
66
67
  "@types/json-schema": "^7.0.15",
67
- "@types/node": "^26.0.1",
68
- "@typescript/native-preview": "^7.0.0-dev.20260629.1",
68
+ "@types/node": "^26.1.0",
69
+ "@typescript/native-preview": "^7.0.0-dev.20260701.1",
69
70
  "bumpp": "^11.1.0",
70
71
  "eslint": "^10.6.0",
71
72
  "eslint-parser-plain": "^0.1.1",
@@ -83,7 +84,7 @@
83
84
  "tsx": "^4.22.4",
84
85
  "typescript": "^6.0.3",
85
86
  "vitest": "^4.1.9",
86
- "eslint-plugin-oxfmt": "0.12.0"
87
+ "eslint-plugin-oxfmt": "0.12.1"
87
88
  },
88
89
  "engines": {
89
90
  "node": "^20.19.0 || >=22.12.0"
package/workers/oxfmt.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  import { dirname, extname, relative } from 'node:path'
4
+ import ignore from 'ignore'
4
5
  import { isOxfmtIgnored, loadOxfmtConfig } from 'load-oxfmt-config'
5
6
  import { format } from 'oxfmt'
6
7
  import picomatch from 'picomatch'
@@ -65,7 +66,9 @@ const PLUGIN_ONLY_OPTIONS = new Set([
65
66
  'withNodeModules',
66
67
  ])
67
68
  /** @type {Map<string, import('picomatch').Matcher>} */
68
- const matcherCache = new Map()
69
+ const overrideMatcherCache = new Map()
70
+ /** @type {Map<string, import('ignore').Ignore>} */
71
+ const ignoreMatcherCache = new Map()
69
72
 
70
73
  /**
71
74
  * Apply override entries to a base options object.
@@ -85,11 +88,11 @@ function applyOverrides(relativePath, baseOptions, overrides) {
85
88
  continue
86
89
  }
87
90
 
88
- const fileMatcher = getCachedMatcher(override.files)
91
+ const fileMatcher = getCachedOverrideMatcher(override.files)
89
92
  const matches = !!fileMatcher && fileMatcher(relativePath)
90
93
 
91
94
  const excludeMatcher = override.excludeFiles?.length
92
- ? getCachedMatcher(override.excludeFiles)
95
+ ? getCachedOverrideMatcher(override.excludeFiles)
93
96
  : undefined
94
97
  const excluded = excludeMatcher ? excludeMatcher(relativePath) : false
95
98
 
@@ -216,19 +219,39 @@ async function formatViaOxfmt(filename, sourceText, options = {}) {
216
219
  }
217
220
 
218
221
  /**
219
- * Get or create a cached picomatch matcher.
222
+ * Get or create a cached ignore matcher for oxfmt ignorePatterns.
223
+ * @param {string[]} patterns - Gitignore-style patterns.
224
+ * @returns {import('ignore').Ignore} Compiled ignore matcher.
225
+ */
226
+ function getCachedIgnoreMatcher(patterns) {
227
+ const key = patterns.join('\0')
228
+ const cached = ignoreMatcherCache.get(key)
229
+ if (cached) {
230
+ return cached
231
+ }
232
+
233
+ const matcher = ignore().add(patterns)
234
+ setCacheEntry(ignoreMatcherCache, key, matcher)
235
+ return matcher
236
+ }
237
+
238
+ /**
239
+ * Get or create a cached picomatch matcher for oxfmt override globs.
220
240
  * @param {string[]} patterns - Glob patterns.
221
241
  * @returns {import('picomatch').Matcher} Compiled matcher.
222
242
  */
223
- function getCachedMatcher(patterns) {
243
+ function getCachedOverrideMatcher(patterns) {
224
244
  const key = patterns.join('\0')
225
- const cached = matcherCache.get(key)
245
+ const cached = overrideMatcherCache.get(key)
226
246
  if (cached) {
227
247
  return cached
228
248
  }
229
249
 
230
- const matcher = picomatch(patterns)
231
- setCacheEntry(matcherCache, key, matcher)
250
+ const matcher = picomatch(patterns, {
251
+ dot: true,
252
+ noextglob: true,
253
+ })
254
+ setCacheEntry(overrideMatcherCache, key, matcher)
232
255
  return matcher
233
256
  }
234
257
 
@@ -297,8 +320,8 @@ function shouldIgnoreFile(relativePath, ignorePatterns) {
297
320
  return false
298
321
  }
299
322
 
300
- const matcher = getCachedMatcher(ignorePatterns)
301
- return !!matcher && matcher(relativePath)
323
+ const matcher = getCachedIgnoreMatcher(ignorePatterns)
324
+ return matcher.ignores(relativePath)
302
325
  }
303
326
 
304
327
  /**