Skip to content

Conversation

@weronikaolejniczak
Copy link
Contributor

@weronikaolejniczak weronikaolejniczak commented Nov 24, 2025

Summary

  • added a rule that warns about static z-index

Note

This PR was co-authored with Gemini 3 Pro.

Why are we making this change?

Resolves #9230

It was raised as a suggestion on an internal meeting. If people do not reuse euiTheme tokens it's hard to assure the correct hierarchy.

Screenshots #

Impact to users

🟢 No impact. Just a dev warning.

QA

@weronikaolejniczak weronikaolejniczak self-assigned this Nov 24, 2025
@weronikaolejniczak weronikaolejniczak force-pushed the feat/eslint-z-index-warning branch from 6782d45 to 66ef4bd Compare November 24, 2025 15:21
@weronikaolejniczak weronikaolejniczak force-pushed the feat/eslint-z-index-warning branch 4 times, most recently from 44ecf1e to fe9080c Compare November 28, 2025 14:16
@weronikaolejniczak weronikaolejniczak marked this pull request as ready for review November 28, 2025 14:34
@weronikaolejniczak weronikaolejniczak requested a review from a team as a code owner November 28, 2025 14:34
@weronikaolejniczak weronikaolejniczak force-pushed the feat/eslint-z-index-warning branch from fe9080c to 7b8869b Compare December 9, 2025 10:12
@acstll acstll assigned acstll and unassigned acstll Dec 9, 2025
@acstll acstll self-requested a review December 9, 2025 10:14
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

Copy link
Contributor

@acstll acstll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in Kibana, ran tests locally and it's working nicely, as expected. Added a comment about 2 uses cases I found that hopefully we can also cover. Let me know what you think. Thanks for tackling this one!

`,
languageOptions,
errors: [{ messageId: 'noStaticZIndexSpecific' }],
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while testing in Kibana, I found 2 use cases that are not covered by the rule, the most common one being "nested" style objects, the other are arrays — would that be too tricky to implement?

I tried reproducing these locally, adding these:

    {
      // Invalid: Variable with static value used in css prop (object style, nested)
      filename: 'test.tsx',
      code: dedent`
        import React from 'react';
        import { css } from '@emotion/react';

        const myCss = css({ container: zIndex: 100 }});

        function TestComponent() {
          return <div css={myCss}>test</div>
        }`,
      languageOptions,
      errors: [{ messageId: 'noStaticZIndexSpecificDeclaredVariable' }],
    },
    {
      // Invalid: css array, one with static z-index
      filename: 'test.tsx',
      code: dedent`
            import { css } from '@emotion/react';

            function TestComponent() {
                return <div css={[someStyle, css({ zIndex: 9 })]}>test</div>
            }
        `,
      languageOptions,
      errors: [{ messageId: 'noStaticZIndexSpecific' }],
    },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredible find, thank you, Arturo 🙏🏻 and for adding the test cases, I'll cover these

Comment on lines +87 to +94
if (
(didReport = checkPropertySpecifiesInvalidZIndex(
propertyName,
propertyNode.value.value
))
) {
context.report(messageToReport);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking] I would avoid assignments inside conditions mostly for readability (TIL there's even a rule for that: no-cond-assign 😀)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thank you for catching this!

@@ -0,0 +1 @@
- Add a `no-static-z-index` rule No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add a `no-static-z-index` rule
- Added `no-static-z-index` rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ESLint] Add a warning about static z-index values

3 participants