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
But I haven't managed to do it. Specifically, I was trying to add this custom rule just as an example and a starting point:
customPlugin.ts
import{ESLintUtils}from"@typescript-eslint/utils";typeMessageIds="default";typeOptions={functionNames: string[]}[];constcreateRule=ESLintUtils.RuleCreator((name)=>`https://kodix.com.br/rule/${name}`,);constexplicitGenerics=createRule<Options,MessageIds>({name: "explicit-generics",meta: {docs: {description:
"Enforces that certain functions must have their TypeScript generics inputs be provided",},messages: {default: "'{{callee}}' should include generics in function call",},type: "problem",schema: [{type: "object",properties: {functionNames: {type: "array",items: [{type: "string",},],uniqueItems: true,},},},],},defaultOptions: [],create(context){return{CallExpression(node){if(node.callee.type==="Identifier"&&context.options[0]!.functionNames.includes(node.callee.name)){if(!node.typeArguments){context.report({messageId: "default",data: {callee: node.callee.name},node: node.callee,});}}},};},});exportconstcustomPlugin={rules: {"explicit-generics": explicitGenerics,},};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was trying to create custom eslint rules using typescript-eslint's custom rules: https://typescript-eslint.io/developers/custom-rules/
But I haven't managed to do it. Specifically, I was trying to add this custom rule just as an example and a starting point:
customPlugin.ts
eslint/react.js
Does anyone have a working example of how to create such rules?
Beta Was this translation helpful? Give feedback.
All reactions