forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfallback.ts
More file actions
28 lines (24 loc) · 996 Bytes
/
Copy pathfallback.ts
File metadata and controls
28 lines (24 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import createJITI from 'jiti';
import transform from 'jiti/dist/babel.js';
import { timerify } from '../../util/Performance.js';
import type { TransformOptions } from 'jiti/dist/types.js';
const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
// @ts-expect-error Our package.json has type=module (for globby, chalk, etc), but here it confuses TypeScript
const jiti = createJITI(process.cwd(), {
cache: false,
transform: (opts: TransformOptions) => {
opts.source = opts.source.replace(rushstackMatch, '');
// @ts-expect-error Same as above
return transform(opts);
},
});
/**
* Special ESLint config loader to strip problematic lines from source:
*
* ```js
* require('@rushstack/eslint-config/patch/modern-module-resolution');
* require("@rushstack/eslint-patch/modern-module-resolution");
* ```
*/
const load = (configFilePath: string) => jiti(configFilePath);
export const fallback = timerify(load);