Skip to content

Commit

Permalink
Update eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Mar 8, 2024
1 parent da16fde commit 8a16681
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 24 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ module.exports = {
jQuery: true,
},
rules: {
'react/jsx-boolean-value': 'error',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'no-nested-ternary': 'off',
'no-unused-expressions': 'off',
'@wordpress/no-unsafe-wp-apis': 'off',
'jsdoc/require-param-type': 0,
'prettier/prettier': [
'error',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function AcceptSuggestionOnEnter() {
}
) }
isToggle
defaultToggle={ true }
defaultToggle
value={ editorOptions.acceptSuggestionOnEnter }
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function EmptySelectionClipboard() {
onChange={ onChange }
title={ title }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/empty-selection-clipboard.gif' }
value={ editorOptions.emptySelectionClipboard }
/>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/editor-config/editor-options/find/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function FindLoop() {
'custom-html-block-extension'
) }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/find/loop.gif' }
value={ editorOptions.find.loop }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function FindSeedSearchStringFromSelection() {
onChange={ onChange }
title={ title }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/find/seed-search-string-from-selection.gif' }
value={ editorOptions.find.seedSearchStringFromSelection }
/>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/editor-config/editor-options/folding.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function Folding() {
'custom-html-block-extension'
) }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/folding.gif' }
value={ editorOptions.folding }
/>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/editor-config/editor-options/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Hover() {
onChange={ onChange }
title={ title }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/hover.gif' }
value={ editorOptions.hover }
/>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/editor-config/editor-options/minimap/enabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function MinimapEnabled() {
'custom-html-block-extension'
) }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/minimap/enabled.gif' }
value={ editorOptions.minimap.enabled }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function QuickSuggestions() {
'custom-html-block-extension'
) }
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-options/quick-suggestions.gif' }
value={ editorOptions.quickSuggestions }
/>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/editor-config/editor-settings/emmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Emmet() {
</>
}
isToggle
defaultToggle={ true }
defaultToggle
image={ 'editor-settings/emmet.gif' }
value={ editorSettings.emmet }
/>
Expand Down
24 changes: 13 additions & 11 deletions src/classic-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ initLoader().then( ( monaco ) => {
textarea.value = editorValue;

// Change editor area height.
// eslint-disable-next-line no-shadow
const contentHeight = Math.max( 300, window.editor.getContentHeight() );
monacoEditorContainer.style.height = `${ contentHeight }px`;
const newContentHeight = Math.max( 300, window.editor.getContentHeight() );
monacoEditorContainer.style.height = `${ newContentHeight }px`;
} );

// Enable Emmet.
Expand All @@ -105,10 +104,14 @@ initLoader().then( ( monaco ) => {
} );

// Catch the Ctrl+S command to save draft or publish post.
// eslint-disable-next-line no-bitwise
window.editor.addCommand( monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, () => {
!! draftButton ? draftButton.click() : publishButton.click();
} );
window.editor.addCommand(
// eslint-disable-next-line no-bitwise
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S,
() => {
// eslint-disable-next-line no-unused-expressions
!! draftButton ? draftButton.click() : publishButton.click();
}
);

// Load webfont.
const font = fontFamily.find( ( data ) => editorOptions.fontFamily === data.name );
Expand Down Expand Up @@ -222,10 +225,9 @@ initLoader().then( ( monaco ) => {
};

// Get cursor position info for the editor.
// eslint-disable-next-line no-shadow
const getEditorPosition = ( textarea ) => {
const linesContent = textarea.value.split( '\n' );
let selectionStart = textarea.selectionStart;
const getEditorPosition = ( element ) => {
const linesContent = element.value.split( '\n' );
let selectionStart = element.selectionStart;
let lineNumber = 1;
let column = 0;

Expand Down
1 change: 1 addition & 0 deletions src/components/monaco-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function MonacoEditor( {
}, 500 );

return () => {
// eslint-disable-next-line no-unused-expressions
editorRef ? disposeEditor() : cancelable.cancel();
clearInterval( interval );
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function makeCancelable( promise ) {
/**
* Custom monaco editor loader which is a customized version of @monaco-editor/loader.
*
* @param targetWindow The window object to load the editor.
* @param {Object} targetWindow The window object to load the editor.
* @see https://github.com/suren-atoyan/monaco-loader
*/
export default function initLoader( targetWindow = window ) {
Expand Down

0 comments on commit 8a16681

Please sign in to comment.