Commit 56a6b2b5 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs-allow-to-reassign-immer-draft' into 'master'

Remove redundant no-param-reassign from Immer drafts

See merge request gitlab-org/gitlab!56320
parents a378e3b9 4e7c724e
...@@ -43,6 +43,17 @@ rules: ...@@ -43,6 +43,17 @@ rules:
promise/always-return: off promise/always-return: off
promise/no-callback-in-promise: off promise/no-callback-in-promise: off
'@gitlab/no-global-event-off': error '@gitlab/no-global-event-off': error
no-param-reassign:
- error
- props: true
ignorePropertyModificationsFor:
- acc
- accumulator
- el
- element
- state
ignorePropertyModificationsForRegex:
- '^draft'
import/order: import/order:
- error - error
- groups: - groups:
......
...@@ -104,10 +104,8 @@ export default { ...@@ -104,10 +104,8 @@ export default {
const { projects: previousProjects } = previousResult; const { projects: previousProjects } = previousResult;
return produce(previousResult, (draftData) => { return produce(previousResult, (draftData) => {
/* eslint-disable no-param-reassign */
draftData.projects.nodes = [...previousProjects.nodes, ...newProjects.nodes]; draftData.projects.nodes = [...previousProjects.nodes, ...newProjects.nodes];
draftData.projects.pageInfo = newProjects.pageInfo; draftData.projects.pageInfo = newProjects.pageInfo;
/* eslint-enable no-param-reassign */
}); });
}, },
}); });
......
...@@ -27,10 +27,8 @@ const resolvers = { ...@@ -27,10 +27,8 @@ const resolvers = {
const sourceData = cache.readQuery({ query: getCurrentIntegrationQuery }); const sourceData = cache.readQuery({ query: getCurrentIntegrationQuery });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
if (id === null) { if (id === null) {
// eslint-disable-next-line no-param-reassign
draftData.currentIntegration = null; draftData.currentIntegration = null;
} else { } else {
// eslint-disable-next-line no-param-reassign
draftData.currentIntegration = { draftData.currentIntegration = {
id, id,
name, name,
......
...@@ -15,7 +15,6 @@ const deleteIntegrationFromStore = (store, query, { httpIntegrationDestroy }, va ...@@ -15,7 +15,6 @@ const deleteIntegrationFromStore = (store, query, { httpIntegrationDestroy }, va
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = draftData.project.alertManagementIntegrations.nodes.filter( draftData.project.alertManagementIntegrations.nodes = draftData.project.alertManagementIntegrations.nodes.filter(
({ id }) => id !== integration.id, ({ id }) => id !== integration.id,
); );
...@@ -46,7 +45,6 @@ const addIntegrationToStore = ( ...@@ -46,7 +45,6 @@ const addIntegrationToStore = (
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = [ draftData.project.alertManagementIntegrations.nodes = [
integration, integration,
...draftData.project.alertManagementIntegrations.nodes, ...draftData.project.alertManagementIntegrations.nodes,
...@@ -72,7 +70,6 @@ const addHttpIntegrationToStore = (store, query, { httpIntegrationCreate }, vari ...@@ -72,7 +70,6 @@ const addHttpIntegrationToStore = (store, query, { httpIntegrationCreate }, vari
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementHttpIntegrations.nodes = [ draftData.project.alertManagementHttpIntegrations.nodes = [
integration, integration,
...draftData.project.alertManagementHttpIntegrations.nodes, ...draftData.project.alertManagementHttpIntegrations.nodes,
......
...@@ -20,7 +20,6 @@ const resolvers = { ...@@ -20,7 +20,6 @@ const resolvers = {
const sourceData = cache.readQuery({ query: activeDiscussionQuery }); const sourceData = cache.readQuery({ query: activeDiscussionQuery });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.activeDiscussion = { draftData.activeDiscussion = {
__typename: 'ActiveDiscussion', __typename: 'ActiveDiscussion',
id, id,
......
...@@ -41,7 +41,6 @@ const addNewVersionToStore = (store, query, version) => { ...@@ -41,7 +41,6 @@ const addNewVersionToStore = (store, query, version) => {
const sourceData = store.readQuery(query); const sourceData = store.readQuery(query);
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.issue.designCollection.versions.nodes = [ draftData.project.issue.designCollection.versions.nodes = [
version, version,
...draftData.project.issue.designCollection.versions.nodes, ...draftData.project.issue.designCollection.versions.nodes,
...@@ -168,7 +167,6 @@ const addNewDesignToStore = (store, designManagementUpload, query) => { ...@@ -168,7 +167,6 @@ const addNewDesignToStore = (store, designManagementUpload, query) => {
nodes: newVersions, nodes: newVersions,
}, },
}; };
// eslint-disable-next-line no-param-reassign
draftData.project.issue.designCollection = updatedDesigns; draftData.project.issue.designCollection = updatedDesigns;
}); });
...@@ -182,7 +180,6 @@ const moveDesignInStore = (store, designManagementMove, query) => { ...@@ -182,7 +180,6 @@ const moveDesignInStore = (store, designManagementMove, query) => {
const sourceData = store.readQuery(query); const sourceData = store.readQuery(query);
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.issue.designCollection.designs = draftData.project.issue.designCollection.designs =
designManagementMove.designCollection.designs; designManagementMove.designCollection.designs;
}); });
......
...@@ -21,8 +21,7 @@ export const addInProgressImportToStore = (store, jiraImportStart, fullPath) => ...@@ -21,8 +21,7 @@ export const addInProgressImportToStore = (store, jiraImportStart, fullPath) =>
store.writeQuery({ store.writeQuery({
...queryDetails, ...queryDetails,
data: produce(sourceData, (draftData) => { data: produce(sourceData, (draftData) => {
draftData.project.jiraImportStatus = IMPORT_STATE.SCHEDULED; // eslint-disable-line no-param-reassign draftData.project.jiraImportStatus = IMPORT_STATE.SCHEDULED;
// eslint-disable-next-line no-param-reassign
draftData.project.jiraImports.nodes = [ draftData.project.jiraImports.nodes = [
...sourceData.project.jiraImports.nodes, ...sourceData.project.jiraImports.nodes,
jiraImportStart.jiraImport, jiraImportStart.jiraImport,
......
...@@ -86,7 +86,6 @@ export default { ...@@ -86,7 +86,6 @@ export default {
const originalMetricQuery = this.graphData.metrics[0]; const originalMetricQuery = this.graphData.metrics[0];
const metricQuery = produce(originalMetricQuery, (draftQuery) => { const metricQuery = produce(originalMetricQuery, (draftQuery) => {
// eslint-disable-next-line no-param-reassign
draftQuery.result[0].values = draftQuery.result[0].values.map(([x, y]) => [ draftQuery.result[0].values = draftQuery.result[0].values.map(([x, y]) => [
x, x,
y + this.yOffset, y + this.yOffset,
......
...@@ -9,7 +9,6 @@ export const updateGroupPackageSettings = (fullPath) => (client, { data: updated ...@@ -9,7 +9,6 @@ export const updateGroupPackageSettings = (fullPath) => (client, { data: updated
const sourceData = client.readQuery(queryAndParams); const sourceData = client.readQuery(queryAndParams);
const data = produce(sourceData, (draftState) => { const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.group.packageSettings = { draftState.group.packageSettings = {
...updatedData.updateNamespacePackageSettings.packageSettings, ...updatedData.updateNamespacePackageSettings.packageSettings,
}; };
......
...@@ -29,7 +29,6 @@ export default { ...@@ -29,7 +29,6 @@ export default {
}); });
const data = produce(sourceData, (draftState) => { const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.containerRepository.status = draftState.containerRepository.status =
destroyContainerRepository.containerRepository.status; destroyContainerRepository.containerRepository.status;
}); });
......
...@@ -9,7 +9,6 @@ export const updateContainerExpirationPolicy = (projectPath) => (client, { data: ...@@ -9,7 +9,6 @@ export const updateContainerExpirationPolicy = (projectPath) => (client, { data:
const sourceData = client.readQuery(queryAndParams); const sourceData = client.readQuery(queryAndParams);
const data = produce(sourceData, (draftState) => { const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project.containerExpirationPolicy = { draftState.project.containerExpirationPolicy = {
...updatedData.updateContainerExpirationPolicy.containerExpirationPolicy, ...updatedData.updateContainerExpirationPolicy.containerExpirationPolicy,
}; };
......
...@@ -95,7 +95,6 @@ export default { ...@@ -95,7 +95,6 @@ export default {
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.workspace.issuable.confidential = !this.confidential; draftData.workspace.issuable.confidential = !this.confidential;
}); });
......
...@@ -87,11 +87,8 @@ export default { ...@@ -87,11 +87,8 @@ export default {
}); });
const data = produce(sourceData, (draftState) => { const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project.mergeRequest.mergeableDiscussionsState = mergeableDiscussionsState; draftState.project.mergeRequest.mergeableDiscussionsState = mergeableDiscussionsState;
// eslint-disable-next-line no-param-reassign
draftState.project.mergeRequest.workInProgress = workInProgress; draftState.project.mergeRequest.workInProgress = workInProgress;
// eslint-disable-next-line no-param-reassign
draftState.project.mergeRequest.title = title; draftState.project.mergeRequest.title = title;
}); });
......
...@@ -116,7 +116,6 @@ export default { ...@@ -116,7 +116,6 @@ export default {
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementAlerts.nodes[0].todos.nodes = []; draftData.project.alertManagementAlerts.nodes[0].todos.nodes = [];
}); });
......
...@@ -20,7 +20,6 @@ export default (selector) => { ...@@ -20,7 +20,6 @@ export default (selector) => {
toggleSidebarStatus: (_, __, { cache }) => { toggleSidebarStatus: (_, __, { cache }) => {
const sourceData = cache.readQuery({ query: sidebarStatusQuery }); const sourceData = cache.readQuery({ query: sidebarStatusQuery });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.sidebarStatus = !draftData.sidebarStatus; draftData.sidebarStatus = !draftData.sidebarStatus;
}); });
cache.writeQuery({ query: sidebarStatusQuery, data }); cache.writeQuery({ query: sidebarStatusQuery, data });
......
...@@ -7,7 +7,6 @@ export const addSegmentToCache = (store, segment) => { ...@@ -7,7 +7,6 @@ export const addSegmentToCache = (store, segment) => {
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.devopsAdoptionSegments.nodes = [...draftData.devopsAdoptionSegments.nodes, segment]; draftData.devopsAdoptionSegments.nodes = [...draftData.devopsAdoptionSegments.nodes, segment];
}); });
...@@ -23,7 +22,6 @@ export const deleteSegmentFromCache = (store, segmentId) => { ...@@ -23,7 +22,6 @@ export const deleteSegmentFromCache = (store, segmentId) => {
}); });
const updatedData = produce(sourceData, (draftData) => { const updatedData = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.devopsAdoptionSegments.nodes = draftData.devopsAdoptionSegments.nodes.filter( draftData.devopsAdoptionSegments.nodes = draftData.devopsAdoptionSegments.nodes.filter(
({ id }) => id !== segmentId, ({ id }) => id !== segmentId,
); );
......
...@@ -112,7 +112,6 @@ export default { ...@@ -112,7 +112,6 @@ export default {
}, },
updateQuery(previousResult, { fetchMoreResult }) { updateQuery(previousResult, { fetchMoreResult }) {
const results = produce(fetchMoreResult, (draftData) => { const results = produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.group.projects.nodes = [ draftData.group.projects.nodes = [
...previousResult.group.projects.nodes, ...previousResult.group.projects.nodes,
...draftData.group.projects.nodes, ...draftData.group.projects.nodes,
......
...@@ -11,7 +11,6 @@ const resolvers = { ...@@ -11,7 +11,6 @@ const resolvers = {
updateShiftTimeUnitWidth: (_, { shiftTimeUnitWidth = 0 }, { cache }) => { updateShiftTimeUnitWidth: (_, { shiftTimeUnitWidth = 0 }, { cache }) => {
const sourceData = cache.readQuery({ query: getShiftTimeUnitWidthQuery }); const sourceData = cache.readQuery({ query: getShiftTimeUnitWidthQuery });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.shiftTimeUnitWidth = shiftTimeUnitWidth; draftData.shiftTimeUnitWidth = shiftTimeUnitWidth;
}); });
cache.writeQuery({ query: getShiftTimeUnitWidthQuery, data }); cache.writeQuery({ query: getShiftTimeUnitWidthQuery, data });
......
...@@ -47,7 +47,6 @@ const deleteScheduleFromStore = (store, query, { oncallScheduleDestroy }, variab ...@@ -47,7 +47,6 @@ const deleteScheduleFromStore = (store, query, { oncallScheduleDestroy }, variab
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.incidentManagementOncallSchedules.nodes = draftData.project.incidentManagementOncallSchedules.nodes.filter( draftData.project.incidentManagementOncallSchedules.nodes = draftData.project.incidentManagementOncallSchedules.nodes.filter(
({ id }) => id !== schedule.id, ({ id }) => id !== schedule.id,
); );
...@@ -72,7 +71,6 @@ const updateScheduleFromStore = (store, query, { oncallScheduleUpdate }, variabl ...@@ -72,7 +71,6 @@ const updateScheduleFromStore = (store, query, { oncallScheduleUpdate }, variabl
}); });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.incidentManagementOncallSchedules.nodes = draftData.project.incidentManagementOncallSchedules.nodes.map( draftData.project.incidentManagementOncallSchedules.nodes = draftData.project.incidentManagementOncallSchedules.nodes.map(
(scheduleToUpdate) => { (scheduleToUpdate) => {
return scheduleToUpdate.iid === schedule.iid ? schedule : scheduleToUpdate; return scheduleToUpdate.iid === schedule.iid ? schedule : scheduleToUpdate;
......
...@@ -31,7 +31,6 @@ export const removeProfile = ({ profileId, profileType, store, queryBody }) => { ...@@ -31,7 +31,6 @@ export const removeProfile = ({ profileId, profileType, store, queryBody }) => {
const sourceData = store.readQuery(queryBody); const sourceData = store.readQuery(queryBody);
const data = produce(sourceData, (draftState) => { const data = produce(sourceData, (draftState) => {
// eslint-disable-next-line no-param-reassign
draftState.project[profileType].edges = draftState.project[profileType].edges.filter( draftState.project[profileType].edges = draftState.project[profileType].edges.filter(
({ node }) => { ({ node }) => {
return node.id !== profileId; return node.id !== profileId;
......
...@@ -84,7 +84,6 @@ export default { ...@@ -84,7 +84,6 @@ export default {
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
return produce(fetchMoreResult, (draftData) => { return produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.group.vulnerabilities.nodes = [ draftData.group.vulnerabilities.nodes = [
...previousResult.group.vulnerabilities.nodes, ...previousResult.group.vulnerabilities.nodes,
...draftData.group.vulnerabilities.nodes, ...draftData.group.vulnerabilities.nodes,
......
...@@ -82,7 +82,6 @@ export default { ...@@ -82,7 +82,6 @@ export default {
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
return produce(fetchMoreResult, (draftData) => { return produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.vulnerabilities.nodes = [ draftData.vulnerabilities.nodes = [
...previousResult.vulnerabilities.nodes, ...previousResult.vulnerabilities.nodes,
...draftData.vulnerabilities.nodes, ...draftData.vulnerabilities.nodes,
......
...@@ -82,7 +82,6 @@ export default { ...@@ -82,7 +82,6 @@ export default {
const newProject = results.addProjectToSecurityDashboard.project; const newProject = results.addProjectToSecurityDashboard.project;
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.instanceSecurityDashboard.projects.nodes = [ draftData.instanceSecurityDashboard.projects.nodes = [
...draftData.instanceSecurityDashboard.projects.nodes, ...draftData.instanceSecurityDashboard.projects.nodes,
{ {
...@@ -157,7 +156,6 @@ export default { ...@@ -157,7 +156,6 @@ export default {
const sourceData = store.readQuery({ query: projectsQuery }); const sourceData = store.readQuery({ query: projectsQuery });
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.instanceSecurityDashboard.projects.nodes = draftData.instanceSecurityDashboard.projects.nodes.filter( draftData.instanceSecurityDashboard.projects.nodes = draftData.instanceSecurityDashboard.projects.nodes.filter(
(curr) => curr.id !== id, (curr) => curr.id !== id,
); );
......
...@@ -112,7 +112,6 @@ export default { ...@@ -112,7 +112,6 @@ export default {
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
return produce(fetchMoreResult, (draftData) => { return produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.vulnerabilities.nodes = [ draftData.project.vulnerabilities.nodes = [
...previousResult.project.vulnerabilities.nodes, ...previousResult.project.vulnerabilities.nodes,
...draftData.project.vulnerabilities.nodes, ...draftData.project.vulnerabilities.nodes,
......
...@@ -103,7 +103,6 @@ export default { ...@@ -103,7 +103,6 @@ export default {
variables: { nextPageCursor: this.pageInfo.endCursor }, variables: { nextPageCursor: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const results = produce(fetchMoreResult, (draftData) => { const results = produce(fetchMoreResult, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementAlerts.nodes = [ draftData.project.alertManagementAlerts.nodes = [
...previousResult.project.alertManagementAlerts.nodes, ...previousResult.project.alertManagementAlerts.nodes,
...draftData.project.alertManagementAlerts.nodes, ...draftData.project.alertManagementAlerts.nodes,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment