eslint-plugin-lwc icon indicating copy to clipboard operation
eslint-plugin-lwc copied to clipboard

Only check functions called on first paint

Open gracebrack opened this issue 1 year ago • 0 comments
trafficstars

@lwc/lwc/no-unsupported-ssr-properties and @lwc/lwc/no-restricted-browser-globals-during-ssr check all functions in a component for unsafe SSR practices. However, not all functions need to be SSR safe, only those called on first paint.

Example:

export default class ExampleButton {
    handleFocus() {
        this.dispatchEvent(new CustomEvent('focus')); //@lwc/lwc/no-unsupported-ssr-properties error
        console.log(window.location.href) //@lwc/lwc/no-restricted-browser-globals-during-ssr error
    }
}

Screenshot 2024-07-15 at 3 28 41 PM

Relevant Slack Thread: https://salesforce-internal.slack.com/archives/C5W3E40TC/p1719415297404469

gracebrack avatar Jun 27 '24 17:06 gracebrack