mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-31 12:47:58 +00:00 
			
		
		
		
	![gitstart-app[bot]](/assets/img/avatar_default.png) 60598bf235
			
		
	
	60598bf235
	
	
	
		
			
			Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { ESLintUtils } from '@typescript-eslint/utils';
 | |
| 
 | |
| // NOTE: The rule will be available in ESLint configs as "@nx/workspace-useRecoilCallback-has-dependency-array"
 | |
| export const RULE_NAME = 'useRecoilCallback-has-dependency-array';
 | |
| 
 | |
| export const rule = ESLintUtils.RuleCreator(() => __filename)({
 | |
|   name: RULE_NAME,
 | |
|   meta: {
 | |
|     type: 'problem',
 | |
|     docs: {
 | |
|       description: 'Ensure `useRecoilCallback` is used with a dependency array',
 | |
|       recommended: 'recommended',
 | |
|     },
 | |
|     schema: [],
 | |
|     messages: {
 | |
|       isNecessaryDependencyArray:
 | |
|         'Is necessary dependency array with useRecoilCallback',
 | |
|     },
 | |
|     fixable: 'code',
 | |
|   },
 | |
|   defaultOptions: [],
 | |
|   create: (context) => {
 | |
|     return {
 | |
|       CallExpression: (node) => {
 | |
|         const { callee } = node;
 | |
|         if (
 | |
|           callee.type === 'Identifier' &&
 | |
|           callee.name === 'useRecoilCallback'
 | |
|         ) {
 | |
|           const depsArg = node.arguments;
 | |
|           if (depsArg.length === 1) {
 | |
|             context.report({
 | |
|               node: callee,
 | |
|               messageId: 'isNecessaryDependencyArray',
 | |
|               data: {
 | |
|                 callee,
 | |
|                 deps: depsArg[0],
 | |
|               },
 | |
|               fix: (fixer) => fixer.insertTextAfter(depsArg[0], ', []'),
 | |
|             });
 | |
|           }
 | |
|         }
 | |
|       },
 | |
|     };
 | |
|   },
 | |
| });
 |