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:
@@ -45,7 +45,7 @@ export const UpdateViewButtonGroup = () => {
|
||||
|
||||
const { setViewPickerMode } = useViewPickerMode();
|
||||
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -58,14 +58,14 @@ export const UpdateViewButtonGroup = () => {
|
||||
);
|
||||
|
||||
const openViewPickerInCreateMode = () => {
|
||||
if (!currentViewId) {
|
||||
if (!contextStoreCurrentViewId) {
|
||||
return;
|
||||
}
|
||||
|
||||
openViewPickerDropdown({
|
||||
dropdownComponentInstanceIdFromProps: VIEW_PICKER_DROPDOWN_ID,
|
||||
});
|
||||
setViewPickerReferenceViewId(currentViewId);
|
||||
setViewPickerReferenceViewId(contextStoreCurrentViewId);
|
||||
setViewPickerMode('create-from-current');
|
||||
|
||||
closeUpdateViewButtonDropdown(UPDATE_VIEW_BUTTON_DROPDOWN_ID);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarAnyFieldFilterEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
useAtomComponentFamilyState(
|
||||
hasInitializedAnyFieldFilterComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
}
|
||||
}, [
|
||||
setAnyFieldFilterValue,
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
hasInitializedAnyFieldFilter,
|
||||
setHasInitializedAnyFieldFilter,
|
||||
currentView,
|
||||
|
||||
@@ -189,7 +189,7 @@ export const ViewBarDetails = ({
|
||||
const shouldShowAdvancedFilterDropdownButton =
|
||||
currentRecordFilterGroups.length > 0;
|
||||
|
||||
const isAnyFieldSearchDropdownOpen = useAtomComponentStateValue(
|
||||
const isDropdownOpen = useAtomComponentStateValue(
|
||||
isDropdownOpenComponentState,
|
||||
ANY_FIELD_SEARCH_DROPDOWN_ID,
|
||||
);
|
||||
@@ -202,7 +202,7 @@ export const ViewBarDetails = ({
|
||||
!hasFiltersQueryParams;
|
||||
|
||||
const shouldShowAnyFieldSearchChip =
|
||||
isNonEmptyString(anyFieldFilterValue) || isAnyFieldSearchDropdownOpen;
|
||||
isNonEmptyString(anyFieldFilterValue) || isDropdownOpen;
|
||||
|
||||
const shouldExpandViewBar =
|
||||
shouldShowAnyFieldSearchChip ||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
|
||||
|
||||
const { t } = useLingui();
|
||||
|
||||
const isSelected = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.ADVANCED_FILTER,
|
||||
);
|
||||
@@ -130,7 +130,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
|
||||
text={t`Advanced filter`}
|
||||
onClick={handleClick}
|
||||
LeftIcon={IconFilter}
|
||||
focused={isSelected}
|
||||
focused={isSelectedItemId}
|
||||
/>
|
||||
{advancedFilterQuerySubFilterCount > 0 && (
|
||||
<StyledPill label={advancedFilterQuerySubFilterCount.toString()} />
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ export const ViewBarFilterDropdownAnyFieldSearchButtonMenuItem = ({
|
||||
objectFilterDropdownSearchInputComponentState,
|
||||
);
|
||||
|
||||
const isSelected = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.SEARCH,
|
||||
);
|
||||
@@ -40,7 +40,7 @@ export const ViewBarFilterDropdownAnyFieldSearchButtonMenuItem = ({
|
||||
onEnter={onClick}
|
||||
>
|
||||
<MenuItem
|
||||
focused={isSelected}
|
||||
focused={isSelectedItemId}
|
||||
onClick={onClick}
|
||||
LeftIcon={IconSearch}
|
||||
text={
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ export const ViewBarFilterDropdownFieldSelectMenuItem = ({
|
||||
}: ViewBarFilterDropdownFieldSelectMenuItemProps) => {
|
||||
const { resetSelectedItem } = useSelectableList(FILTER_FIELD_LIST_ID);
|
||||
|
||||
const isSelectedItem = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
fieldMetadataItemToSelect.id,
|
||||
);
|
||||
@@ -43,7 +43,7 @@ export const ViewBarFilterDropdownFieldSelectMenuItem = ({
|
||||
onEnter={handleClick}
|
||||
>
|
||||
<MenuItem
|
||||
focused={isSelectedItem}
|
||||
focused={isSelectedItemId}
|
||||
onClick={handleClick}
|
||||
LeftIcon={Icon}
|
||||
text={fieldMetadataItemToSelect.label}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFieldEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFieldsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
setHasInitializedCurrentRecordFields(true);
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFields,
|
||||
hasInitializedCurrentRecordFields,
|
||||
setHasInitializedCurrentRecordFields,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFilterEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFiltersComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
setHasInitializedCurrentRecordFilters(true);
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFilters,
|
||||
mapViewFiltersToRecordFilters,
|
||||
hasInitializedCurrentRecordFilters,
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFilterGroupEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFilterGroupsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
}
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFilterGroups,
|
||||
hasInitializedCurrentRecordFilterGroups,
|
||||
setHasInitializedCurrentRecordFilterGroups,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordSortEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const ViewBarRecordSortEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ export const ViewBarRecordSortEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordSortsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ const meta: Meta<typeof ViewBarFilterDropdown> = {
|
||||
|
||||
const mockCoreView = mockedCoreViewsData[0];
|
||||
|
||||
const setCurrentViewId = useSetAtomComponentState(
|
||||
const setContextStoreCurrentViewId = useSetAtomComponentState(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
);
|
||||
@@ -71,12 +71,12 @@ const meta: Meta<typeof ViewBarFilterDropdown> = {
|
||||
|
||||
useEffect(() => {
|
||||
setCoreViews([mockCoreView]);
|
||||
setCurrentViewId(mockCoreView.id);
|
||||
setContextStoreCurrentViewId(mockCoreView.id);
|
||||
setCurrentRecordFields(columns);
|
||||
setIsLoaded(true);
|
||||
}, [
|
||||
setCoreViews,
|
||||
setCurrentViewId,
|
||||
setContextStoreCurrentViewId,
|
||||
setCurrentRecordFields,
|
||||
mockCoreView,
|
||||
columns,
|
||||
|
||||
Reference in New Issue
Block a user