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:
+3
-3
@@ -140,7 +140,7 @@ describe('useActivityTargetObjectRecords', () => {
|
||||
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const setRecordFromStore = useSetAtomFamilyState(
|
||||
const setRecordStore = useSetAtomFamilyState(
|
||||
recordStoreFamilyState,
|
||||
task.id,
|
||||
);
|
||||
@@ -151,14 +151,14 @@ describe('useActivityTargetObjectRecords', () => {
|
||||
|
||||
return {
|
||||
activityTargetObjectRecords,
|
||||
setRecordFromStore,
|
||||
setRecordStore,
|
||||
};
|
||||
},
|
||||
{ wrapper: Wrapper },
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.setRecordFromStore(task);
|
||||
result.current.setRecordStore(task);
|
||||
});
|
||||
|
||||
const activityTargetObjectRecords =
|
||||
|
||||
+3
-3
@@ -66,7 +66,7 @@ export const useUpdateActivityTargetFromCell = ({
|
||||
: isNoteTargetMigrated;
|
||||
|
||||
const store = useStore();
|
||||
const setActivityFromStore = useSetAtomFamilyState(
|
||||
const setRecordStore = useSetAtomFamilyState(
|
||||
recordStoreFamilyState,
|
||||
activityId,
|
||||
);
|
||||
@@ -194,7 +194,7 @@ export const useUpdateActivityTargetFromCell = ({
|
||||
await createOneActivityTarget(activityTargetInput);
|
||||
}
|
||||
|
||||
setActivityFromStore((currentActivity) => {
|
||||
setRecordStore((currentActivity) => {
|
||||
if (!isDefined(currentActivity)) {
|
||||
return null;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ export const useUpdateActivityTargetFromCell = ({
|
||||
createOneActivityTarget,
|
||||
deleteOneActivityTarget,
|
||||
isMorphRelation,
|
||||
setActivityFromStore,
|
||||
setRecordStore,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
+3
-6
@@ -103,10 +103,7 @@ export const EventRow = ({
|
||||
|
||||
const { recordId } = useContext(TimelineActivityContext);
|
||||
|
||||
const recordFromStore = useAtomFamilyStateValue(
|
||||
recordStoreFamilyState,
|
||||
recordId,
|
||||
);
|
||||
const recordStore = useAtomFamilyStateValue(recordStoreFamilyState, recordId);
|
||||
|
||||
const beautifiedCreatedAt = beautifyPastDateRelativeToNow(
|
||||
event.createdAt,
|
||||
@@ -120,7 +117,7 @@ export const EventRow = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isUndefinedOrNull(recordFromStore)) {
|
||||
if (isUndefinedOrNull(recordStore)) {
|
||||
return null;
|
||||
}
|
||||
if (isUndefinedOrNull(mainObjectMetadataItem)) {
|
||||
@@ -129,7 +126,7 @@ export const EventRow = ({
|
||||
|
||||
const labelIdentifier = getObjectRecordIdentifier({
|
||||
objectMetadataItem: mainObjectMetadataItem,
|
||||
record: recordFromStore,
|
||||
record: recordStore,
|
||||
allowRequestsToTwentyIcons,
|
||||
});
|
||||
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ export const EventFieldDiffValueEffect = ({
|
||||
mainObjectMetadataItem: ObjectMetadataItem;
|
||||
fieldMetadataItem: FieldMetadataItem;
|
||||
}) => {
|
||||
const setEntity = useSetAtomFamilyState(
|
||||
const setRecordStore = useSetAtomFamilyState(
|
||||
recordStoreFamilyState,
|
||||
diffArtificialRecordStoreId,
|
||||
);
|
||||
@@ -31,13 +31,13 @@ export const EventFieldDiffValueEffect = ({
|
||||
[fieldMetadataItem.name]: diffRecord,
|
||||
};
|
||||
|
||||
setEntity(forgedObjectRecord);
|
||||
setRecordStore(forgedObjectRecord);
|
||||
}, [
|
||||
diffRecord,
|
||||
diffArtificialRecordStoreId,
|
||||
fieldMetadataItem.name,
|
||||
mainObjectMetadataItem.nameSingular,
|
||||
setEntity,
|
||||
setRecordStore,
|
||||
]);
|
||||
|
||||
return <></>;
|
||||
|
||||
Reference in New Issue
Block a user