mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
e44c9a2070
* ci: move custom oxlint rules to typescript and alternative API * ci: add to test sharding
26 lines
677 B
TypeScript
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' });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
});
|