Files
renovate/tools/lint/rules/no-new-url.spec.ts
Sebastian Poxhofer e44c9a2070 ci(oxlint): move custom oxlint rules to typescript and alternative API (#45337)
* ci: move custom oxlint rules to typescript and alternative API

* ci: add  to test sharding
2026-08-19 05:37:56 +00:00

35 lines
869 B
TypeScript

import { RuleTester } from 'oxlint/plugins-dev';
import rule from './no-new-url.ts';
RuleTester.describe = describe;
RuleTester.it = it;
const ruleTester = new RuleTester({
languageOptions: { parserOptions: { lang: 'ts' } },
});
ruleTester.run('no-new-url', rule, {
valid: [
// parseUrl cannot express a base, so two-argument calls are allowed
`new URL('/foo', base);`,
// no arguments
`new URL();`,
// other constructors
`new URLSearchParams('a=b');`,
// member expression callee
`new global.URL('https://example.com');`,
// plain call, not a construction
`URL('https://example.com');`,
],
invalid: [
{
code: `new URL('https://example.com');`,
errors: [{ messageId: 'noNewUrl' }],
},
{
code: `const url = new URL(someString);`,
errors: [{ messageId: 'noNewUrl' }],
},
],
});