mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-06 02:49:56 +00:00
* feat: configure prettier with pre-commit hook integration Add prettier, lint-staged, and prettier-plugin-tailwindcss at the repo root with husky pre-commit hook integration. Moves husky from gitnexus/ to root package.json for reliable hook installation. - Root package.json with prepare/format/format:check scripts - .prettierrc with endOfLine:lf and tailwindStylesheet for TW v4 - .prettierignore excluding fixtures, vendor, generated, *.d.ts, *.md - .gitattributes enforcing LF line endings for Windows consistency - Pre-commit hook uses direct node_modules/.bin/ paths (no npx) * style: apply prettier formatting to entire codebase One-time bulk format. No logic changes. Use .git-blame-ignore-revs to skip this commit in git blame. * chore: add .git-blame-ignore-revs for prettier format commit * perf: pre-commit hook runs only tests related to staged files Use vitest --related to scope test execution to tests that import the changed files, instead of running the full suite on every commit. * perf: remove vitest from pre-commit hook, keep in CI only Pre-commit now runs lint-staged + tsc only. Tests run in CI (ci-tests.yml) where they belong — keeps commits fast. * ci: add prettier format check to quality workflow PRs will now fail if code isn't formatted with prettier.
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { resolveDartImport } from '../../src/core/ingestion/import-resolvers/dart.js';
|
|
import type { ResolveCtx } from '../../src/core/ingestion/import-resolvers/types.js';
|
|
|
|
function makeCtx(files: string[]): ResolveCtx {
|
|
const allFileList = files;
|
|
const normalizedFileList = files.map((f) => f.toLowerCase());
|
|
return {
|
|
allFilePaths: new Set(files),
|
|
allFileList,
|
|
normalizedFileList,
|
|
index: undefined as any,
|
|
resolveCache: new Map(),
|
|
configs: {
|
|
tsconfigPaths: null,
|
|
goModule: null,
|
|
composerConfig: null,
|
|
swiftPackageConfig: null,
|
|
csharpConfigs: [],
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('Dart import resolver', () => {
|
|
describe('dart: SDK imports', () => {
|
|
it('skips dart:async', () => {
|
|
const result = resolveDartImport("'dart:async'", 'lib/main.dart', makeCtx([]));
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('skips dart:io', () => {
|
|
const result = resolveDartImport("'dart:io'", 'lib/main.dart', makeCtx([]));
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('package: imports', () => {
|
|
it('resolves local package import to lib/', () => {
|
|
const ctx = makeCtx(['lib/models/user.dart', 'lib/main.dart']);
|
|
const result = resolveDartImport("'package:my_app/models/user.dart'", 'lib/main.dart', ctx);
|
|
expect(result).toEqual({ kind: 'files', files: ['lib/models/user.dart'] });
|
|
});
|
|
|
|
it('returns null for external package imports', () => {
|
|
const ctx = makeCtx(['lib/main.dart']);
|
|
const result = resolveDartImport("'package:http/http.dart'", 'lib/main.dart', ctx);
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('returns null for malformed package import (no slash)', () => {
|
|
const result = resolveDartImport("'package:http'", 'lib/main.dart', makeCtx([]));
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('relative imports', () => {
|
|
it('resolves relative import via standard resolver', () => {
|
|
const ctx = makeCtx(['lib/models/user.dart', 'lib/main.dart']);
|
|
const result = resolveDartImport("'models/user.dart'", 'lib/main.dart', ctx);
|
|
// resolveStandard handles relative path resolution
|
|
// The exact result depends on the standard resolver — we just check it doesn't crash
|
|
expect(result === null || result?.kind === 'files').toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('quote stripping', () => {
|
|
it('strips single quotes', () => {
|
|
const ctx = makeCtx([]);
|
|
const result = resolveDartImport("'dart:core'", 'lib/main.dart', ctx);
|
|
expect(result).toBeNull(); // dart: is skipped, proving quotes were stripped
|
|
});
|
|
|
|
it('strips double quotes', () => {
|
|
const ctx = makeCtx([]);
|
|
const result = resolveDartImport('"dart:core"', 'lib/main.dart', ctx);
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
});
|