mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-22 00:13:45 -05:00
* Apply import sorting with perfectionist/sort-named-imports rule - Add perfectionist/sort-named-imports oxlint rule - Sort named imports: value imports before type imports - Update component-library and desktop-client files to match new rule * Add release notes for linting updates on named imports
27 lines
873 B
JavaScript
27 lines
873 B
JavaScript
import { existsSync } from 'node:fs';
|
|
import { dirname, extname, resolve as nodeResolve } from 'node:path';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
const extensions = ['.ts', '.js', '.mts', '.mjs'];
|
|
|
|
export async function resolve(specifier, context, nextResolve) {
|
|
// Only handle relative imports without extensions
|
|
if (specifier.startsWith('.') && !extname(specifier)) {
|
|
const parentURL = context.parentURL;
|
|
if (parentURL) {
|
|
const parentPath = new URL(parentURL).pathname;
|
|
const parentDir = dirname(parentPath);
|
|
|
|
// Try extensions in order
|
|
for (const ext of extensions) {
|
|
const resolvedPath = nodeResolve(parentDir, `${specifier}${ext}`);
|
|
if (existsSync(resolvedPath)) {
|
|
return nextResolve(pathToFileURL(resolvedPath).href, context);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return nextResolve(specifier, context);
|
|
}
|