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
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { defineRule } from '@oxlint/plugins';
|
|
|
|
export default defineRule({
|
|
meta: {
|
|
type: 'problem',
|
|
messages: {
|
|
noHostRulesMock:
|
|
"Do not mock host-rules; configure real rules via the test util instead: import { hostRules } from '~test/host-rules.ts' and call hostRules.add() in the test.",
|
|
},
|
|
},
|
|
createOnce(context) {
|
|
return {
|
|
CallExpression(node) {
|
|
const { callee } = node;
|
|
if (
|
|
callee.type !== 'MemberExpression' ||
|
|
callee.computed ||
|
|
callee.object.type !== 'Identifier' ||
|
|
callee.object.name !== 'vi' ||
|
|
callee.property.type !== 'Identifier' ||
|
|
(callee.property.name !== 'mock' && callee.property.name !== 'doMock')
|
|
) {
|
|
return;
|
|
}
|
|
const [specifier] = node.arguments;
|
|
if (
|
|
specifier?.type === 'Literal' &&
|
|
typeof specifier.value === 'string' &&
|
|
// only the host-rules module itself, not e.g. `host-rules-from-env`
|
|
/(?:^|\/)host-rules(?:\.[cm]?[jt]s)?$/.test(specifier.value)
|
|
) {
|
|
context.report({ node, messageId: 'noHostRulesMock' });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
});
|