mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
7df11ed734
* refactor(lint): extract custom oxlint rules into separate files Split `tools/lint/rules.js` into one file per rule under `tools/lint/rules/`. Also simplify `test-root-describe` with early-exit guard clauses. * feat(lint): add `enforce-ts-extension` oxlint rule Add a custom JS-based oxlint rule that enforces `.ts` extensions on local imports. The rule catches two problems: - `.js` extension used instead of `.ts` (auto-fixable) - missing file extension entirely (report only) Checked locations: - static import/export declarations - dynamic `import()` expressions - vitest module APIs: `vi.mock`, `vi.doMock`, `vi.unmock`, `vi.doUnmock`, `vi.importActual`, `vi.importMock` Both relative paths (`./`, `../`) and path aliases (`~test/`) are treated as local. Package imports are ignored. Also fixes 26 pre-existing violations across 18 spec files. * Update tools/lint/rules/enforce-ts-extension.js Co-authored-by: Anne Stellingwerf <1637358+astellingwerf@users.noreply.github.com> --------- Co-authored-by: Anne Stellingwerf <1637358+astellingwerf@users.noreply.github.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { git } from '~test/util.ts';
|
|
import { PLATFORM_NOT_FOUND } from '../../constants/error-messages.ts';
|
|
import type { PlatformId } from '../../constants/index.ts';
|
|
import { scm, setPlatformScmApi } from './scm.ts';
|
|
|
|
vi.unmock('./scm.ts'); //mocked from test/setup
|
|
|
|
describe('modules/platform/scm', () => {
|
|
it('no platform chosen', () => {
|
|
expect(() => scm.branchExists('branchName')).toThrow(PLATFORM_NOT_FOUND);
|
|
});
|
|
|
|
it('unknown platform', () => {
|
|
expect(() => setPlatformScmApi('unknown' as PlatformId)).toThrow(
|
|
PLATFORM_NOT_FOUND,
|
|
);
|
|
});
|
|
|
|
it.each([
|
|
'azure',
|
|
'github',
|
|
'codecommit',
|
|
'bitbucket',
|
|
'bitbucket-server',
|
|
'forgejo',
|
|
'gitea',
|
|
'github',
|
|
'gitlab',
|
|
] as PlatformId[])(
|
|
'use util/git module as default implementation for platform %s',
|
|
async (platform: PlatformId) => {
|
|
git.isBranchBehindBase.mockResolvedValueOnce(true);
|
|
setPlatformScmApi(platform);
|
|
await scm.isBranchBehindBase('abc', 'main');
|
|
expect(git.isBranchBehindBase).toHaveBeenCalledTimes(1);
|
|
},
|
|
);
|
|
});
|