mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-02 10:33:39 +00:00
e44c9a2070
* ci: move custom oxlint rules to typescript and alternative API * ci: add to test sharding
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { defineRule } from '@oxlint/plugins';
|
|
|
|
// Regex used instead of String#includes() to avoid CodeQL's js/incomplete-url-substring-sanitization false positive.
|
|
const DOCS_URL_RE = /https:\/\/docs\.renovatebot\.com/;
|
|
|
|
export default defineRule({
|
|
meta: {
|
|
type: 'suggestion',
|
|
messages: {
|
|
noHardcodedDocsUrl:
|
|
"Use config.productLinks.documentation instead of hardcoding 'docs.renovatebot.com' URLs.",
|
|
},
|
|
},
|
|
createOnce(context) {
|
|
return {
|
|
Literal(node) {
|
|
// oxlint-disable-next-line typescript/prefer-includes -- regex avoids CodeQL js/incomplete-url-substring-sanitization
|
|
if (typeof node.value === 'string' && DOCS_URL_RE.test(node.value)) {
|
|
context.report({ node, messageId: 'noHardcodedDocsUrl' });
|
|
}
|
|
},
|
|
TemplateElement(node) {
|
|
// oxlint-disable-next-line typescript/prefer-includes -- regex avoids CodeQL js/incomplete-url-substring-sanitization
|
|
if (node.value.raw && DOCS_URL_RE.test(node.value.raw)) {
|
|
context.report({ node, messageId: 'noHardcodedDocsUrl' });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
});
|