Files
renovate/tools/lint/rules/no-new-url.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

26 lines
677 B
TypeScript

import { defineRule } from '@oxlint/plugins';
export default defineRule({
meta: {
type: 'problem',
messages: {
noNewUrl:
"Use parseUrl() from 'lib/util/url.ts' instead of 'new URL()' to avoid unhandled exceptions on invalid URLs.",
},
},
createOnce(context) {
return {
NewExpression(node) {
if (
node.callee.type === 'Identifier' &&
node.callee.name === 'URL' &&
// only consider new URL(arg) and not new URL(arg, base) as parseUrl does not allow this
node.arguments.length === 1
) {
context.report({ node, messageId: 'noNewUrl' });
}
},
};
},
});