From 39bb7f3ddcb8a60d1a75223d0ea89fd3531c508b Mon Sep 17 00:00:00 2001 From: Dfdez Date: Tue, 15 Jul 2025 22:25:39 +0200 Subject: [PATCH] feat: linter passed --- .../src/actions/__tests__/entries.spec.js | 46 ++++++------- .../src/components/App/StackToolbar.js | 2 +- .../src/components/Editor/Editor.js | 10 ++- .../Editor/EditorControlPane/EditorControl.js | 2 +- .../Editor/EditorControlPane/Widget.js | 5 +- .../src/components/Editor/EditorToolbar.js | 66 ++++++++----------- .../src/components/Editor/withWorkflow.js | 2 +- .../src/components/Workflow/WorkflowList.js | 6 +- packages/decap-cms-core/src/lib/registry.js | 3 +- packages/decap-cms-locales/src/en/index.js | 10 +-- .../src/__tests__/DateTimeControl.spec.js | 2 +- .../decap-cms-widget-list/src/ListControl.js | 6 +- .../src/StringControl.js | 4 +- 13 files changed, 83 insertions(+), 81 deletions(-) diff --git a/packages/decap-cms-core/src/actions/__tests__/entries.spec.js b/packages/decap-cms-core/src/actions/__tests__/entries.spec.js index 1827cc588590..9fa3cfac1b37 100644 --- a/packages/decap-cms-core/src/actions/__tests__/entries.spec.js +++ b/packages/decap-cms-core/src/actions/__tests__/entries.spec.js @@ -73,30 +73,32 @@ describe('entries', () => { fields: [{ name: 'title' }, { name: 'boolean' }], }); - return store.dispatch(createLocalEmptyDraft(collection, '?title=title&boolean=True')).then(() => { - const actions = store.getActions(); - expect(actions).toHaveLength(1); + return store + .dispatch(createLocalEmptyDraft(collection, '?title=title&boolean=True')) + .then(() => { + const actions = store.getActions(); + expect(actions).toHaveLength(1); - expect(actions[0]).toEqual({ - payload: { - author: '', - collection: undefined, - data: { title: 'title', boolean: true }, - meta: {}, - i18n: {}, - isModification: null, - label: null, - mediaFiles: [], - partial: false, - path: '', - raw: '', - slug: '', - status: '', - updatedOn: '', - }, - type: 'DRAFT_CREATE_EMPTY', + expect(actions[0]).toEqual({ + payload: { + author: '', + collection: undefined, + data: { title: 'title', boolean: true }, + meta: {}, + i18n: {}, + isModification: null, + label: null, + mediaFiles: [], + partial: false, + path: '', + raw: '', + slug: '', + status: '', + updatedOn: '', + }, + type: 'DRAFT_CREATE_EMPTY', + }); }); - }); }); it('should html escape URL params', () => { diff --git a/packages/decap-cms-core/src/components/App/StackToolbar.js b/packages/decap-cms-core/src/components/App/StackToolbar.js index f7653fe2bc1f..c33925176923 100644 --- a/packages/decap-cms-core/src/components/App/StackToolbar.js +++ b/packages/decap-cms-core/src/components/App/StackToolbar.js @@ -95,7 +95,7 @@ const StatusButton = styled(DropdownButton)` css` background-color: ${colors.processingBackground}; color: ${colors.processingText}; - `} + `} ${props => props.label === 'stale' && diff --git a/packages/decap-cms-core/src/components/Editor/Editor.js b/packages/decap-cms-core/src/components/Editor/Editor.js index 7e6a39ab8f2b..d0d00935a033 100644 --- a/packages/decap-cms-core/src/components/Editor/Editor.js +++ b/packages/decap-cms-core/src/components/Editor/Editor.js @@ -232,7 +232,7 @@ export class Editor extends React.Component { // deleteLocalBackup(collection, !newEntry && slug); // } - createHookContext = (context) => { + createHookContext = context => { const defaultContext = { editor: { props: this.props, @@ -253,7 +253,12 @@ export class Editor extends React.Component { persistUnpublishedEntry: async (collection, existingUnpublishedEntry, entry, opts = {}) => { const context = this.createHookContext(opts); const entryDraft = entry || this.props.createEmptyDraft(collection); - return this.props.persistUnpublishedEntry(collection, existingUnpublishedEntry, context, entryDraft); + return this.props.persistUnpublishedEntry( + collection, + existingUnpublishedEntry, + context, + entryDraft, + ); }, publishUnpublishedEntry: async (collection, slug, entry, opts = {}) => { const context = this.createHookContext(opts); @@ -417,7 +422,6 @@ export class Editor extends React.Component { } } - await deleteUnpublishedEntry(collection.get('name'), slug); // this.deleteBackup(); diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index a577cc1ccad9..90fef3de7b48 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -72,7 +72,7 @@ const styleStrings = { `, flat: ` margin-top: 0 !important; - ` + `, }; const ControlContainer = styled.div` diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js index 7e8980da8423..f7811ebe1169 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js @@ -301,7 +301,10 @@ export default class Widget extends Component { setInactiveStyle = () => { this.props.setInactiveStyle(); - if ((this.props.field.has('pattern') || this.props.field.has('negative_pattern')) && !isEmpty(this.getValidateValue())) { + if ( + (this.props.field.has('pattern') || this.props.field.has('negative_pattern')) && + !isEmpty(this.getValidateValue()) + ) { this.validate(); } }; diff --git a/packages/decap-cms-core/src/components/Editor/EditorToolbar.js b/packages/decap-cms-core/src/components/Editor/EditorToolbar.js index 13456f6045a0..c9b3f5d83a21 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorToolbar.js +++ b/packages/decap-cms-core/src/components/Editor/EditorToolbar.js @@ -224,7 +224,7 @@ const StatusButton = styled(DropdownButton)` css` background-color: ${colors.processingBackground}; color: ${colors.processingText}; - `} + `} ${props => props.label === 'stale' && @@ -390,34 +390,29 @@ export class EditorToolbar extends React.Component { ); }; - handleStatusChange = (newStatusName) => { - const { - currentStatus, - onChangeStatus, - t - } = this.props; + handleStatusChange = newStatusName => { + const { currentStatus, onChangeStatus, t } = this.props; if (currentStatus === status.get('PROCESSING')) { const newStatusLabel = t(`editor.editorToolbar.${newStatusName.toLowerCase()}`); - if (!window.confirm(t('editor.editor.onProcessingStatusChange', { - newStatus: newStatusLabel - }))) { + if ( + !window.confirm( + t('editor.editor.onProcessingStatusChange', { + newStatus: newStatusLabel, + }), + ) + ) { return; } } onChangeStatus(newStatusName); - } + }; handleDelete = () => { - const { - currentStatus, - hasUnpublishedChanges, - onDeleteUnpublishedChanges, - onDelete, - t - } = this.props; + const { currentStatus, hasUnpublishedChanges, onDeleteUnpublishedChanges, onDelete, t } = + this.props; if (currentStatus === status.get('PROCESSING')) { const translationKey = hasUnpublishedChanges ? 'editor.editor.onProcessingDeleteUnpublishedChanges' @@ -427,7 +422,7 @@ export class EditorToolbar extends React.Component { } } return hasUnpublishedChanges ? onDeleteUnpublishedChanges() : onDelete(); - } + }; renderWorkflowStatusControls = () => { const { isUpdatingStatus, currentStatus, t, useOpenAuthoring } = this.props; @@ -681,26 +676,23 @@ export class EditorToolbar extends React.Component { , currentStatus ? [ - - {this.renderWorkflowStatusControls()} - {currentStatus === status.get('PENDING_PUBLISH') && - this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })} - , - ] + + {this.renderWorkflowStatusControls()} + {currentStatus === status.get('PENDING_PUBLISH') && + this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })} + , + ] : !isNewEntry && ( - - {this.renderExistingEntryWorkflowPublishControls({ - canCreate, - canPublish, - canDelete, - })} - - ), + + {this.renderExistingEntryWorkflowPublishControls({ + canCreate, + canPublish, + canDelete, + })} + + ), !hasUnpublishedChanges && !isModification ? null : ( - + {isDeleting ? t('editor.editorToolbar.discarding') : deleteLabel} ), diff --git a/packages/decap-cms-core/src/components/Editor/withWorkflow.js b/packages/decap-cms-core/src/components/Editor/withWorkflow.js index 1766beefc08a..4555a4598e6a 100644 --- a/packages/decap-cms-core/src/components/Editor/withWorkflow.js +++ b/packages/decap-cms-core/src/components/Editor/withWorkflow.js @@ -38,7 +38,7 @@ function mergeProps(stateProps, dispatchProps, ownProps) { returnObj.persistEntry = (collection, context, entryDraft) => { const { unpublished = stateProps.unpublishedEntry } = context; return dispatch(persistUnpublishedEntry(collection, unpublished, context, entryDraft)); - } + }; } return { diff --git a/packages/decap-cms-core/src/components/Workflow/WorkflowList.js b/packages/decap-cms-core/src/components/Workflow/WorkflowList.js index 87b6b8a9266f..bf7e5f446cbb 100644 --- a/packages/decap-cms-core/src/components/Workflow/WorkflowList.js +++ b/packages/decap-cms-core/src/components/Workflow/WorkflowList.js @@ -110,7 +110,7 @@ const ColumnHeader = styled.h2` css` background-color: ${colors.processingBackground}; color: ${colors.processingText}; - `} + `} ${props => props.name === 'stale' && @@ -162,7 +162,7 @@ class WorkflowList extends React.Component { const collection = dragProps.collection; const oldStatus = dragProps.ownStatus; if (oldStatus === 'processing') { - window.alert(this.props.t('workflow.workflowList.onProcessingUpdate')) + window.alert(this.props.t('workflow.workflowList.onProcessingUpdate')); return; } if (newStatus === 'stale') { @@ -174,7 +174,7 @@ class WorkflowList extends React.Component { requestDelete = (collection, slug, ownStatus) => { if (ownStatus === 'processing') { - window.alert(this.props.t('workflow.workflowList.onProcessingUpdate')) + window.alert(this.props.t('workflow.workflowList.onProcessingUpdate')); return; } if (window.confirm(this.props.t('workflow.workflowList.onDeleteEntry'))) { diff --git a/packages/decap-cms-core/src/lib/registry.js b/packages/decap-cms-core/src/lib/registry.js index ef094fe37a57..bec212806b43 100644 --- a/packages/decap-cms-core/src/lib/registry.js +++ b/packages/decap-cms-core/src/lib/registry.js @@ -20,7 +20,7 @@ allowedEvents.forEach(e => { const lib = { immutable, -} +}; /** * Global Registry Object @@ -321,4 +321,3 @@ export function getCustomFormatsFormatters() { export function getFormatter(name) { return registry.formats[name]?.formatter; } - diff --git a/packages/decap-cms-locales/src/en/index.js b/packages/decap-cms-locales/src/en/index.js index 261f09fdf1b3..9cae3ba21591 100644 --- a/packages/decap-cms-locales/src/en/index.js +++ b/packages/decap-cms-locales/src/en/index.js @@ -80,7 +80,7 @@ const en = { widget: { required: '%{fieldLabel} is required.', regexPattern: "%{fieldLabel} didn't match the pattern: %{pattern}.", - regexNegativePattern: "%{fieldLabel} should not contain pattern: %{pattern}.", + regexNegativePattern: '%{fieldLabel} should not contain pattern: %{pattern}.', processing: '%{fieldLabel} is processing.', range: '%{fieldLabel} must be between %{minValue} and %{maxValue}.', min: '%{fieldLabel} must be at least %{minValue}.', @@ -115,9 +115,11 @@ const en = { 'All changes to this entry will be deleted.\n\n Do you still want to delete?', loadingEntry: 'Loading entry...', confirmLoadBackup: 'A local backup was recovered for this entry, would you like to use it?', - onProcessingStatusChange: "Are you sure you want to change the status to %{newStatus} while the entry is processing?", - onProcessingDeleteUnpublishedChanges: "Are you sure you want to delete unpublished changes while the entry is processing?", - onProcessingDeleteEntry: "Are you sure you want to delete this entry while it is processing?", + onProcessingStatusChange: + 'Are you sure you want to change the status to %{newStatus} while the entry is processing?', + onProcessingDeleteUnpublishedChanges: + 'Are you sure you want to delete unpublished changes while the entry is processing?', + onProcessingDeleteEntry: 'Are you sure you want to delete this entry while it is processing?', onStackPublishing: 'Are you sure you want to publish all changes?', onStackClosing: 'Are you sure you want to discard all changes?', }, diff --git a/packages/decap-cms-widget-datetime/src/__tests__/DateTimeControl.spec.js b/packages/decap-cms-widget-datetime/src/__tests__/DateTimeControl.spec.js index 14eed45dccdc..9e1e021d9bf7 100644 --- a/packages/decap-cms-widget-datetime/src/__tests__/DateTimeControl.spec.js +++ b/packages/decap-cms-widget-datetime/src/__tests__/DateTimeControl.spec.js @@ -67,7 +67,7 @@ describe('DateTimeControl', () => { }); test('sets value in custom format (local timezone) when input value changes', () => { - const { input, props } = setup({ field: new Map() }) + const { input, props } = setup({ field: new Map() }); const testDate = '2024-03-15T10:30:00'; diff --git a/packages/decap-cms-widget-list/src/ListControl.js b/packages/decap-cms-widget-list/src/ListControl.js index ee19b5650b53..f70f5af1459d 100644 --- a/packages/decap-cms-widget-list/src/ListControl.js +++ b/packages/decap-cms-widget-list/src/ListControl.js @@ -446,7 +446,7 @@ export default class ListControl extends React.Component { const { value, onChange } = this.props; const listValue = value.get(index); - if (!listValue) return + if (!listValue) return; const { itemsCollapsed } = this.state; @@ -459,7 +459,7 @@ export default class ListControl extends React.Component { this.setState({ itemsCollapsed: newItemsCollapsed, - keys: newKeys + keys: newKeys, }); onChange(value.insert(index + 1, listValue)); @@ -690,7 +690,7 @@ export default class ListControl extends React.Component { } } - const ObjectControl = (this.props.getWidget('object')).control; + const ObjectControl = this.props.getWidget('object').control; return (