eslint-plugin-oxfmt 0.11.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/README.md CHANGED
@@ -22,6 +22,7 @@
22
22
 
23
23
  - **ESLint**: `>= 9.0.0` (Only supports ESLint flat config)
24
24
  - **Node.js**: `^20.19.0 || >=22.12.0`
25
+ - **oxfmt**: `>= 0.57.0`
25
26
 
26
27
  ## Installation
27
28
 
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.11.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.11.0",
4
+ "version": "0.12.1",
5
5
  "description": "An ESLint plugin for formatting code with oxfmt.",
6
6
  "keywords": [
7
7
  "eslint",
@@ -47,7 +47,7 @@
47
47
  "sideEffects": false,
48
48
  "peerDependencies": {
49
49
  "eslint": "^9.5.0 || ^10.0.0",
50
- "oxfmt": ">=0.56.0",
50
+ "oxfmt": ">=0.57.0",
51
51
  "svelte": "*"
52
52
  },
53
53
  "peerDependenciesMeta": {
@@ -57,17 +57,18 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "generate-differences": "^0.1.1",
60
- "load-oxfmt-config": "^0.12.1",
60
+ "ignore": "^7.0.5",
61
+ "load-oxfmt-config": "^0.13.0",
61
62
  "picomatch": "^4.0.4",
62
63
  "synckit": "^0.11.13"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@ntnyq/eslint-config": "^6.1.5",
66
67
  "@types/json-schema": "^7.0.15",
67
- "@types/node": "^26.0.0",
68
- "@typescript/native-preview": "^7.0.0-dev.20260622.1",
68
+ "@types/node": "^26.1.0",
69
+ "@typescript/native-preview": "^7.0.0-dev.20260701.1",
69
70
  "bumpp": "^11.1.0",
70
- "eslint": "^10.5.0",
71
+ "eslint": "^10.6.0",
71
72
  "eslint-parser-plain": "^0.1.1",
72
73
  "eslint-typegen": "^2.3.1",
73
74
  "eslint-vitest-rule-tester": "^3.1.0",
@@ -75,15 +76,15 @@
75
76
  "jsonc-eslint-parser": "^3.1.0",
76
77
  "nano-staged": "^1.0.2",
77
78
  "npm-run-all2": "^9.0.2",
78
- "oxfmt": "^0.56.0",
79
+ "oxfmt": "^0.57.0",
79
80
  "show-invisibles": "^0.0.2",
80
- "svelte": "^5.56.3",
81
+ "svelte": "^5.56.4",
81
82
  "tinyglobby": "^0.2.17",
82
83
  "tsdown": "^0.22.3",
83
84
  "tsx": "^4.22.4",
84
85
  "typescript": "^6.0.3",
85
86
  "vitest": "^4.1.9",
86
- "eslint-plugin-oxfmt": "0.11.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
- import { dirname, relative } from 'node:path'
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
 
@@ -118,6 +121,7 @@ async function formatViaOxfmt(filename, sourceText, options = {}) {
118
121
 
119
122
  const cwd = pluginOptions.cwd
120
123
  const useConfig = pluginOptions.useConfig !== false
124
+ const useCache = getUseCacheOption(pluginOptions)
121
125
 
122
126
  const ruleIgnorePatterns = isStringArray(inlineFormatOptions.ignorePatterns)
123
127
  ? inlineFormatOptions.ignorePatterns
@@ -143,7 +147,7 @@ async function formatViaOxfmt(filename, sourceText, options = {}) {
143
147
  ignorePath: pluginOptions.ignorePath,
144
148
  includeConfigIgnorePatterns: useConfig,
145
149
  loadConfigForIgnorePatterns: useConfig,
146
- useCache: pluginOptions.useCache,
150
+ useCache,
147
151
  withNodeModules: pluginOptions.withNodeModules,
148
152
  }
149
153
  const ignored = await isOxfmtIgnored(ignoredOptions)
@@ -178,7 +182,7 @@ async function formatViaOxfmt(filename, sourceText, options = {}) {
178
182
  disableNestedConfig: pluginOptions.disableNestedConfig,
179
183
  editorconfig: pluginOptions.editorconfig,
180
184
  filepath: filename,
181
- useCache: pluginOptions.useCache,
185
+ useCache,
182
186
  })
183
187
  const { overrides: configOverrides, ...loadedConfig } = loaded.config
184
188
  const { overrides: ruleOverrides, ...inlineOptionsWithoutOverrides } =
@@ -215,19 +219,39 @@ async function formatViaOxfmt(filename, sourceText, options = {}) {
215
219
  }
216
220
 
217
221
  /**
218
- * 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.
219
240
  * @param {string[]} patterns - Glob patterns.
220
241
  * @returns {import('picomatch').Matcher} Compiled matcher.
221
242
  */
222
- function getCachedMatcher(patterns) {
243
+ function getCachedOverrideMatcher(patterns) {
223
244
  const key = patterns.join('\0')
224
- const cached = matcherCache.get(key)
245
+ const cached = overrideMatcherCache.get(key)
225
246
  if (cached) {
226
247
  return cached
227
248
  }
228
249
 
229
- const matcher = picomatch(patterns)
230
- setCacheEntry(matcherCache, key, matcher)
250
+ const matcher = picomatch(patterns, {
251
+ dot: true,
252
+ noextglob: true,
253
+ })
254
+ setCacheEntry(overrideMatcherCache, key, matcher)
231
255
  return matcher
232
256
  }
233
257
 
@@ -241,6 +265,24 @@ function getRelativePath(baseDir, filename) {
241
265
  return relative(baseDir, filename).replace(/\\/g, '/')
242
266
  }
243
267
 
268
+ /**
269
+ * Resolve the cache setting passed to load-oxfmt-config.
270
+ * Explicit CommonJS config files need the loader's non-cached CJS path so
271
+ * `module.exports = {}` configs are read as config objects.
272
+ * @param {PluginOnlyOptions} pluginOptions - Plugin orchestration options.
273
+ * @returns {boolean | undefined} Cache setting for config/ignore loading.
274
+ */
275
+ function getUseCacheOption(pluginOptions) {
276
+ if (
277
+ pluginOptions.configPath &&
278
+ extname(pluginOptions.configPath) === '.cjs'
279
+ ) {
280
+ return false
281
+ }
282
+
283
+ return pluginOptions.useCache
284
+ }
285
+
244
286
  /**
245
287
  * Check whether a value is an array of strings.
246
288
  * @param {unknown} value - Value to validate.
@@ -278,8 +320,8 @@ function shouldIgnoreFile(relativePath, ignorePatterns) {
278
320
  return false
279
321
  }
280
322
 
281
- const matcher = getCachedMatcher(ignorePatterns)
282
- return !!matcher && matcher(relativePath)
323
+ const matcher = getCachedIgnoreMatcher(ignorePatterns)
324
+ return matcher.ignores(relativePath)
283
325
  }
284
326
 
285
327
  /**