import assert from 'node:assert/strict'; import { createRequire } from 'node:module'; import test from 'node:test'; const require = createRequire(import.meta.url); const estreeRequire = createRequire(require.resolve('@typescript-eslint/typescript-estree')); const { Minimatch } = estreeRequire('minimatch'); test('TypeScript ESLint glob preprocessing respects its expansion budget', () => { // Eight repetitions keep the affected-version reproduction bounded to 256 patterns. const pattern = Array(8).fill('**/../a/b').join('/'); assert.throws( () => new Minimatch(pattern, { optimizationLevel: 2, braceExpandMax: 64 }), { name: 'RangeError', message: "optimizationLevel 2: too many patterns from '**/..'" }, ); }); test('TypeScript ESLint glob matching preserves ordinary path behavior', () => { const matcher = new Minimatch('**/../a/b/**/../c/d', { optimizationLevel: 2 }); assert.equal(matcher.match('../a/b/../c/d'), true); assert.equal(matcher.match('x/a/b/y/c/d'), true); assert.equal(new Minimatch('src/**/*.tsx').match('src/components/Example.tsx'), true); assert.equal(new Minimatch('src/**/*.tsx').match('src/components/Example.js'), false); });