From 6c723baa4c36b8a3bf33ccb63214141a84553b3b Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Sat, 21 Sep 2024 00:57:57 +0530 Subject: [PATCH] fix linting errors --- .../classification/classification-button.js | 23 ++++++++++--------- src/js/features/classification/index.js | 9 +++----- .../classification/taxonomy-controls.js | 6 ++--- .../excerpt-generation/classic/index.js | 8 +++++-- src/js/features/slot-fill/index.js | 11 ++++----- src/js/features/text-to-speech/index.js | 20 ++++++++-------- .../title-generation/classic/index.js | 18 +++++++++++---- src/js/features/title-generation/index.js | 4 +++- 8 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/js/features/classification/classification-button.js b/src/js/features/classification/classification-button.js index 4b13fc4aa..82dc164b8 100644 --- a/src/js/features/classification/classification-button.js +++ b/src/js/features/classification/classification-button.js @@ -1,10 +1,10 @@ /** * External dependencies. */ -import { select, dispatch, useSelect } from '@wordpress/data'; +import { dispatch, useSelect } from '@wordpress/data'; import { useState } from '@wordpress/element'; import { Button, Modal } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies. @@ -26,10 +26,11 @@ export const ClassificationButton = () => { ) ); - const postId = select( 'core/editor' ).getCurrentPostId(); - const postType = select( 'core/editor' ).getCurrentPostType(); + const postId = wp.data.select( 'core/editor' ).getCurrentPostId(); + const postType = wp.data.select( 'core/editor' ).getCurrentPostType(); const postTypeLabel = - select( 'core/editor' ).getPostTypeLabel() || __( 'Post', 'classifai' ); + wp.data.select( 'core/editor' ).getPostTypeLabel() || + __( 'Post', 'classifai' ); const [ isLoading, setLoading ] = useState( false ); const [ resultReceived, setResultReceived ] = useState( false ); @@ -60,11 +61,9 @@ export const ClassificationButton = () => { const taxTermsExisting = {}; // get current terms of the post - const currentTerms = select( 'core' ).getEntityRecord( - 'postType', - postType, - postId - ); + const currentTerms = wp.data + .select( 'core' ) + .getEntityRecord( 'postType', postType, postId ); Object.keys( taxonomies ).forEach( ( taxonomy ) => { let tax = taxonomy; @@ -159,7 +158,9 @@ export const ClassificationButton = () => { ); // If no edited values in post trigger save. - const isDirty = await select( 'core/editor' ).isEditedPostDirty(); + const isDirty = await wp.data + .select( 'core/editor' ) + .isEditedPostDirty(); if ( ! isDirty ) { await dispatch( 'core' ).saveEditedEntityRecord( 'postType', diff --git a/src/js/features/classification/index.js b/src/js/features/classification/index.js index b714d049c..abce612e7 100644 --- a/src/js/features/classification/index.js +++ b/src/js/features/classification/index.js @@ -57,9 +57,6 @@ const ClassificationPlugin = () => { ); }; -registerPlugin( - 'classifai-plugin-classification', - { - render: ClassificationPlugin - } -); +registerPlugin( 'classifai-plugin-classification', { + render: ClassificationPlugin, +} ); diff --git a/src/js/features/classification/taxonomy-controls.js b/src/js/features/classification/taxonomy-controls.js index c7e20dcfd..089699b06 100644 --- a/src/js/features/classification/taxonomy-controls.js +++ b/src/js/features/classification/taxonomy-controls.js @@ -11,7 +11,7 @@ import { getEntitiesInfo, useTaxonomies, } from '../../../../includes/Classifai/Blocks/recommended-content-block/utils'; -import { useState } from '@wordpress/element'; +import { useState, Fragment } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; const termsPerPage = -1; @@ -274,7 +274,7 @@ const TaxonomyControls = ( { onChange, query } ) => { } return ( - + { ) }
-
+ ); } ) } diff --git a/src/js/features/excerpt-generation/classic/index.js b/src/js/features/excerpt-generation/classic/index.js index 7ad7d528d..c032c3700 100644 --- a/src/js/features/excerpt-generation/classic/index.js +++ b/src/js/features/excerpt-generation/classic/index.js @@ -43,7 +43,9 @@ const classifaiExcerptData = window.classifaiGenerateExcerpt || {}; $( '

', { class: 'classifai-excerpt-generation__excerpt-generate-error', } ).insertAfter( - document.getElementById( 'classifai-excerpt-generation__excerpt-generate-btn' ) + document.getElementById( + 'classifai-excerpt-generation__excerpt-generate-btn' + ) ); // Append disable feature link. @@ -85,7 +87,9 @@ const classifaiExcerptData = window.classifaiGenerateExcerpt || {}; const spinnerEl = $( '.classifai-excerpt-generation__excerpt-generate-btn--spinner' ); - const errorEl = $( '.classifai-excerpt-generation__excerpt-generate-error' ); + const errorEl = $( + '.classifai-excerpt-generation__excerpt-generate-error' + ); generateTextEl.css( 'opacity', '0' ); spinnerEl.show(); diff --git a/src/js/features/slot-fill/index.js b/src/js/features/slot-fill/index.js index 0b1260756..b37d14639 100644 --- a/src/js/features/slot-fill/index.js +++ b/src/js/features/slot-fill/index.js @@ -1,5 +1,5 @@ import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; -import { Icon, SlotFillProvider, Slot, Fill, } from '@wordpress/components'; +import { Icon, SlotFillProvider, Slot, Fill } from '@wordpress/components'; import { PluginArea, registerPlugin } from '@wordpress/plugins'; import { __ } from '@wordpress/i18n'; @@ -22,12 +22,9 @@ const ClassifAIPluginArea = () => { ); }; -registerPlugin( - 'classifai-plugin-area', - { - render: ClassifAIPluginArea - } -); +registerPlugin( 'classifai-plugin-area', { + render: ClassifAIPluginArea, +} ); window.ClassifaiEditorSettingPanel = ( { children } ) => { return { children }; diff --git a/src/js/features/text-to-speech/index.js b/src/js/features/text-to-speech/index.js index 9747c890a..6e1d807d7 100644 --- a/src/js/features/text-to-speech/index.js +++ b/src/js/features/text-to-speech/index.js @@ -1,12 +1,16 @@ - /** * External dependencies. */ import { useState, useEffect, useRef } from '@wordpress/element'; -import { ToggleControl, BaseControl, Button, Icon } from '@wordpress/components'; +import { + ToggleControl, + BaseControl, + Button, + Icon, +} from '@wordpress/components'; import { useSelect, subscribe } from '@wordpress/data'; import { registerPlugin } from '@wordpress/plugins'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies. @@ -223,13 +227,9 @@ const TextToSpeechPlugin = () => { ); }; -registerPlugin( - 'classifai-plugin-text-to-speech', - { - render: TextToSpeechPlugin - } -); - +registerPlugin( 'classifai-plugin-text-to-speech', { + render: TextToSpeechPlugin, +} ); let saveHappened = false; let showingNotice = false; diff --git a/src/js/features/title-generation/classic/index.js b/src/js/features/title-generation/classic/index.js index eee17c358..647b8156b 100644 --- a/src/js/features/title-generation/classic/index.js +++ b/src/js/features/title-generation/classic/index.js @@ -125,7 +125,9 @@ const scriptData = classifaiChatGPTData.enabledFeatures.reduce( class: 'button classifai-title-generation__select-title', } ) ) - .appendTo( '#classifai-title-generation__results-content' ); + .appendTo( + '#classifai-title-generation__results-content' + ); } ); // Append disable feature link. @@ -162,8 +164,12 @@ const scriptData = classifaiChatGPTData.enabledFeatures.reduce( $( '' ) .text( error?.message ) - .wrap( `

` ) - .appendTo( '#classifai-title-generation__results-content' ); + .wrap( + `
` + ) + .appendTo( + '#classifai-title-generation__results-content' + ); $( '#classifai-title-generation__results' ) .show() @@ -179,7 +185,11 @@ const scriptData = classifaiChatGPTData.enabledFeatures.reduce( ); // Event handler registration to hide the popup. - $( document ).on( 'click', '#classifai-title-generation__overlay', hidePopup ); + $( document ).on( + 'click', + '#classifai-title-generation__overlay', + hidePopup + ); $( document ).on( 'click', '#classifai-title-generation__close-modal-button', diff --git a/src/js/features/title-generation/index.js b/src/js/features/title-generation/index.js index 33f95f8bf..c3860dea2 100644 --- a/src/js/features/title-generation/index.js +++ b/src/js/features/title-generation/index.js @@ -152,4 +152,6 @@ const TitleGenerationPlugin = () => { ); }; -registerPlugin( 'classifai-plugin-title-generation', { render: TitleGenerationPlugin } ); +registerPlugin( 'classifai-plugin-title-generation', { + render: TitleGenerationPlugin, +} );