Rework atom naming (#18240)
## Summary - **Enhanced the `matching-state-variable` ESLint rule** to enforce consistent naming for `ComponentState`, `FamilyState`, and `ComponentFamilyState` hooks — previously it only covered `useAtomState` and `useAtomStateValue` - **The rule now checks 12 hooks** across three categories: value hooks (`useAtomComponentStateValue`, `useAtomFamilyStateValue`, etc.), state hooks (`useAtomComponentState`, `useAtomComponentFamilyState`), and setter hooks (`useSetAtomState`, `useSetAtomComponentState`, `useSetAtomFamilyState`, `useSetAtomComponentFamilyState`) - **Fixed all 225 resulting lint violations** across 151 files, renaming variables to match their state atom names (e.g. `currentViewId` → `contextStoreCurrentViewId`, `selectedRecord` → `recordStore`). Cases where the same state is accessed with different family keys/instance IDs are suppressed with `eslint-disable-next-line`. ## Naming convention | Hook | State argument | Valid | Invalid | |------|---------------|-------|---------| | `useAtomStateValue` | `fooState` | `const foo = ...` | `const bar = ...` | | `useAtomComponentStateValue` | `fooComponentState` | `const foo = ...` | `const bar = ...` | | `useAtomFamilyStateValue` | `fooFamilyState` | `const foo = ...` | `const bar = ...` | | `useAtomComponentFamilyStateValue` | `fooComponentFamilyState` | `const foo = ...` | `const bar = ...` | | `useAtomState` | `fooState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useAtomComponentState` | `fooComponentState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useAtomComponentFamilyState` | `fooComponentFamilyState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useSetAtomState` | `fooState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomComponentState` | `fooComponentState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomFamilyState` | `fooFamilyState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomComponentFamilyState` | `fooComponentFamilyState` | `const setFoo = ...` | `const setBar = ...` |
This commit is contained in:
+2
-2
@@ -174,13 +174,13 @@ describe('useCreatePageLayoutTab', () => {
|
||||
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const getActiveTabId = useAtomComponentStateValue(
|
||||
const activeTabId = useAtomComponentStateValue(
|
||||
activeTabIdComponentState,
|
||||
`${PAGE_LAYOUT_TEST_INSTANCE_ID}-tab-list`,
|
||||
);
|
||||
return {
|
||||
createTab: useCreatePageLayoutTab(PAGE_LAYOUT_TEST_INSTANCE_ID),
|
||||
activeTabId: getActiveTabId,
|
||||
activeTabId: activeTabId,
|
||||
};
|
||||
},
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
|
||||
tabListInstanceId,
|
||||
);
|
||||
|
||||
const setTabSettingsOpenTabId = useSetAtomComponentState(
|
||||
const setPageLayoutTabSettingsOpenTabId = useSetAtomComponentState(
|
||||
pageLayoutTabSettingsOpenTabIdComponentState,
|
||||
pageLayoutId,
|
||||
);
|
||||
@@ -128,7 +128,7 @@ export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
|
||||
|
||||
setActiveTabId(newTabId);
|
||||
|
||||
setTabSettingsOpenTabId(newTabId);
|
||||
setPageLayoutTabSettingsOpenTabId(newTabId);
|
||||
|
||||
navigatePageLayoutCommandMenu({
|
||||
commandMenuPage: CommandMenuPages.PageLayoutTabSettings,
|
||||
@@ -144,7 +144,7 @@ export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
|
||||
pageLayoutCurrentLayouts,
|
||||
pageLayoutDraft,
|
||||
setActiveTabId,
|
||||
setTabSettingsOpenTabId,
|
||||
setPageLayoutTabSettingsOpenTabId,
|
||||
store,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ export const useDuplicatePageLayoutWidget = (
|
||||
pageLayoutId,
|
||||
);
|
||||
|
||||
const setEditingWidgetId = useSetAtomComponentState(
|
||||
const setPageLayoutEditingWidgetId = useSetAtomComponentState(
|
||||
pageLayoutEditingWidgetIdComponentState,
|
||||
pageLayoutId,
|
||||
);
|
||||
@@ -115,7 +115,7 @@ export const useDuplicatePageLayoutWidget = (
|
||||
tabs: addWidgetToTab(prev.tabs, sourceTab.id, clonedWidget),
|
||||
}));
|
||||
|
||||
setEditingWidgetId(newWidgetId);
|
||||
setPageLayoutEditingWidgetId(newWidgetId);
|
||||
|
||||
const { scrollWrapperElement } = getScrollWrapperElement();
|
||||
|
||||
@@ -139,7 +139,7 @@ export const useDuplicatePageLayoutWidget = (
|
||||
[
|
||||
pageLayoutCurrentLayoutsState,
|
||||
pageLayoutDraftState,
|
||||
setEditingWidgetId,
|
||||
setPageLayoutEditingWidgetId,
|
||||
getScrollWrapperElement,
|
||||
store,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user