mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 17:51:49 +00:00
e44c9a2070
* ci: move custom oxlint rules to typescript and alternative API * ci: add to test sharding
35 lines
869 B
TypeScript
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' }],
|
|
},
|
|
],
|
|
});
|