You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`${file.id} uses the v4 API, so it should include \`requiresToken: true\`, or if the token is optional, \`hasToken\` anywhere`,
);
}
Claude generated this rule for a single check:
importtype{Rule}from'eslint';importtype{CallExpression,Node}from'estree';constv4ApiNames=newSet(['getDefaultBranch','getPrInfo']);functionisV4Call(node: CallExpression): boolean{// api.v4(...)return(node.callee.type==='MemberExpression'&&node.callee.object.type==='Identifier'&&node.callee.object.name==='api'&&node.callee.property.type==='Identifier'&&node.callee.property.name==='v4');}functionisV4Helper(node: CallExpression): boolean{// getDefaultBranch(...) / getPrInfo(...)return(node.callee.type==='Identifier'&&v4ApiNames.has(node.callee.name));}functionisObserveCall(node: CallExpression): boolean{return(node.callee.type==='Identifier'&&(node.callee.name==='observe'||node.callee.name==='delegate'));}functiongetFeaturesAddArgs(node: CallExpression): Node[]{// features.add(import.meta.url, ...featureObjects)return(node.callee.type==='MemberExpression'&&node.callee.object.type==='Identifier'&&node.callee.object.name==='features'&&node.callee.property.type==='Identifier'&&node.callee.property.name==='add') ? node.arguments.slice(1) : [];}functionhasTokenProperty(obj: Node): boolean{if(obj.type!=='ObjectExpression')returnfalse;returnobj.properties.some(p=>p.type==='Property'&&p.key.type==='Identifier'&&(p.key.name==='requiresToken'||p.key.name==='hasToken'),);}functionisDescendant(child: Node,ancestor: Node): boolean{
let current: Node|undefined=(childasRule.NodeParentExtension).parent;while(current){if(current===ancestor)returntrue;current=(currentasRule.NodeParentExtension).parent;}returnfalse;}construle: Rule.RuleModule={meta: {type: 'problem',docs: {description: 'features.add() blocks using the v4 API with observers must declare requiresToken or hasToken'},schema: [],messages: {missingToken: 'This features.add() block uses the v4 API, so it should include `requiresToken` in its setup or, if the token is optional, `hasToken` anywhere',},},create(context){constv4Calls=newSet<Node>();constobserveCalls=newSet<Node>();return{CallExpression(node){if(isV4Call(node)||isV4Helper(node))v4Calls.add(node);if(isObserveCall(node))observeCalls.add(node);},'CallExpression:exit'(node){constargs=getFeaturesAddArgs(node);if(args.length===0)return;for(constargofargs){if(arg.type!=='ObjectExpression')continue;if(hasTokenProperty(arg))continue;constusesV4=[...v4Calls].some(c=>isDescendant(c,arg));constusesObserve=[...observeCalls].some(c=>isDescendant(c,arg));if(usesV4&&usesObserve){context.report({node: arg,messageId: 'missingToken'});}}},};},};exportdefault{rules: {'requires-token': rule},}satisfies{rules: Record<string, Rule.RuleModule>};
Activity
fregante commentedon May 22, 2026
Tried this:
refined-github/build/features.test.ts
Lines 177 to 185 in 65aab39
Claude generated this rule for a single check:
Absolutely not worth it.
fregante commentedon May 22, 2026
Too much trouble at this point. This is already somewhat enforced for CSS-only features anyway, where it is 100% required.
fregante commentedon May 22, 2026
Not really needed. These are small features that work best without
observe, at least until they break.