Skip to content

Commit

Permalink
ESLint: Bump eslint-plugin-react-compiler to latest beta (#67106)
Browse files Browse the repository at this point in the history
* Bump eslint-plugin-react-compiler to 19.0.0-beta-0dec889-20241115

* Use ref for prev heading level in DocumentOutline

Co-authored-by: tyxla <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent 180211c commit 62704a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"eslint-plugin-jest": "27.2.3",
"eslint-plugin-jest-dom": "5.0.2",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react-compiler": "19.0.0-beta-8a03594-20241020",
"eslint-plugin-react-compiler": "19.0.0-beta-0dec889-20241115",
"eslint-plugin-ssr-friendly": "1.0.6",
"eslint-plugin-storybook": "0.6.13",
"eslint-plugin-testing-library": "6.0.2",
Expand Down
10 changes: 6 additions & 4 deletions packages/editor/src/components/document-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';
import { useRef } from '@wordpress/element';
import { create, getTextContent } from '@wordpress/rich-text';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';
Expand Down Expand Up @@ -125,6 +126,8 @@ export default function DocumentOutline( {
};
} );

const prevHeadingLevelRef = useRef( 1 );

const headings = computeOutlineHeadings( blocks );
if ( headings.length < 1 ) {
return (
Expand All @@ -139,8 +142,6 @@ export default function DocumentOutline( {
);
}

let prevHeadingLevel = 1;

// Not great but it's the simplest way to locate the title right now.
const titleNode = document.querySelector( '.editor-post-title__input' );
const hasTitle = isTitleSupported && title && titleNode;
Expand Down Expand Up @@ -170,15 +171,16 @@ export default function DocumentOutline( {
{ headings.map( ( item, index ) => {
// Headings remain the same, go up by one, or down by any amount.
// Otherwise there are missing levels.
const isIncorrectLevel = item.level > prevHeadingLevel + 1;
const isIncorrectLevel =
item.level > prevHeadingLevelRef.current + 1;

const isValid =
! item.isEmpty &&
! isIncorrectLevel &&
!! item.level &&
( item.level !== 1 ||
( ! hasMultipleH1 && ! hasTitle ) );
prevHeadingLevel = item.level;
prevHeadingLevelRef.current = item.level;

return (
<DocumentOutlineItem
Expand Down

0 comments on commit 62704a0

Please sign in to comment.