main
ts 22 lines 680 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 import { Rule } from 'eslint';
9
10 const SETTINGS_KEY = 'react-hooks';
11 const SETTINGS_ADDITIONAL_EFFECT_HOOKS_KEY = 'additionalEffectHooks';
12
13 export function getAdditionalEffectHooksFromSettings(
14 settings: Rule.RuleContext['settings'],
15 ): RegExp | undefined {
16 const additionalHooks = settings[SETTINGS_KEY]?.[SETTINGS_ADDITIONAL_EFFECT_HOOKS_KEY];
17 if (additionalHooks != null && typeof additionalHooks === 'string') {
18 return new RegExp(additionalHooks);
19 }
20
21 return undefined;
22 }