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 +1 -1
- package/package.json +5 -4
- package/workers/oxfmt.mjs +33 -10
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-oxfmt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.12.
|
|
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
|
|
68
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
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.
|
|
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
|
|
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 =
|
|
91
|
+
const fileMatcher = getCachedOverrideMatcher(override.files)
|
|
89
92
|
const matches = !!fileMatcher && fileMatcher(relativePath)
|
|
90
93
|
|
|
91
94
|
const excludeMatcher = override.excludeFiles?.length
|
|
92
|
-
?
|
|
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
|
|
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
|
|
243
|
+
function getCachedOverrideMatcher(patterns) {
|
|
224
244
|
const key = patterns.join('\0')
|
|
225
|
-
const cached =
|
|
245
|
+
const cached = overrideMatcherCache.get(key)
|
|
226
246
|
if (cached) {
|
|
227
247
|
return cached
|
|
228
248
|
}
|
|
229
249
|
|
|
230
|
-
const matcher = picomatch(patterns
|
|
231
|
-
|
|
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 =
|
|
301
|
-
return
|
|
323
|
+
const matcher = getCachedIgnoreMatcher(ignorePatterns)
|
|
324
|
+
return matcher.ignores(relativePath)
|
|
302
325
|
}
|
|
303
326
|
|
|
304
327
|
/**
|