You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@W-15205324 New rule - disallow import of scoped modules (#164)
* New rule - disallow import of scoped modules
* Addressin the comments
* Small correction in the title
* Remove the link for formFactor
* Remove the rule regarding the dynamic imports
* Remove the link to the internal doc
* Update docs/rules/no-form-factor-in-ssrable-components.md
Co-authored-by: Laura <49494194+lpomerleau@users.noreply.github.com>
* Update lib/rules/no-static-imports-of-user-specific-scoped-modules-in-ssrable-components.js
Co-authored-by: Laura <49494194+lpomerleau@users.noreply.github.com>
* Fixing the failing test
* Update lib/rules/no-static-imports-of-user-specific-scoped-modules-in-ssrable-components.js
Co-authored-by: nrobertdehault <nrobertdehault@salesforce.com>
* Addressing feedabck
* Adding the link to the public doc
* rebasing
* Fix the link.
* Renaming
* Removing the config
---------
Co-authored-by: lturanscaia <lturanscaia@salesforce.com>
Co-authored-by: Laura <49494194+lpomerleau@users.noreply.github.com>
Co-authored-by: nrobertdehault <nrobertdehault@salesforce.com>
|[lwc/consistent-component-name](./docs/rules/consistent-component-name.md)| ensure component class name matches file name | 🔧 |
74
-
|[lwc/no-api-reassignments](./docs/rules/no-api-reassignments.md)| prevent public property reassignments ||
75
-
|[lwc/no-deprecated](./docs/rules/no-deprecated.md)| disallow usage of deprecated LWC APIs ||
76
-
|[lwc/no-document-query](./docs/rules/no-document-query.md)| disallow DOM query at the document level ||
77
-
|[lwc/no-attributes-during-construction](./docs/rules/no-attributes-during-construction.md)| disallow setting attributes during construction ||
78
-
|[lwc/no-disallowed-lwc-imports](./docs/rules/no-disallowed-lwc-imports.md)| disallow importing unsupported APIs from the `lwc` package ||
79
-
|[lwc/no-leading-uppercase-api-name](./docs/rules/no-leading-uppercase-api-name.md)| ensure public property doesn't start with an upper-case character ||
80
-
|[lwc/no-unexpected-wire-adapter-usages](./docs/rules/no-unexpected-wire-adapter-usages.md)| enforce wire adapters to be used with `wire` decorator ||
81
-
|[lwc/no-unknown-wire-adapters](./docs/rules/no-unknown-wire-adapters.md)| disallow usage of unknown wire adapters ||
|[lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md)| disallow access to global browser APIs during SSR ||
86
-
|[lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md)| disallow access of unsupported properties in SSR ||
87
-
|[lwc/no-node-env-in-ssr](./docs/rules/no-node-env-in-ssr.md)| disallow usage of process.env.NODE_ENV in SSR ||
88
-
|[lwc/valid-graphql-wire-adapter-callback-parameters](./docs/rules/valid-graphql-wire-adapter-callback-parameters.md)| ensure graphql wire adapters are using 'errors' instead of 'error' ||
89
-
|[lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md)| disallow the host element mutation in 'connectedCallback' ||
|[lwc/consistent-component-name](./docs/rules/consistent-component-name.md)| ensure component class name matches file name | 🔧 |
74
+
|[lwc/no-api-reassignments](./docs/rules/no-api-reassignments.md)| prevent public property reassignments ||
75
+
|[lwc/no-deprecated](./docs/rules/no-deprecated.md)| disallow usage of deprecated LWC APIs ||
76
+
|[lwc/no-document-query](./docs/rules/no-document-query.md)| disallow DOM query at the document level ||
77
+
|[lwc/no-attributes-during-construction](./docs/rules/no-attributes-during-construction.md)| disallow setting attributes during construction ||
78
+
|[lwc/no-disallowed-lwc-imports](./docs/rules/no-disallowed-lwc-imports.md)| disallow importing unsupported APIs from the `lwc` package ||
79
+
|[lwc/no-leading-uppercase-api-name](./docs/rules/no-leading-uppercase-api-name.md)| ensure public property doesn't start with an upper-case character ||
80
+
|[lwc/no-unexpected-wire-adapter-usages](./docs/rules/no-unexpected-wire-adapter-usages.md)| enforce wire adapters to be used with `wire` decorator ||
81
+
|[lwc/no-unknown-wire-adapters](./docs/rules/no-unknown-wire-adapters.md)| disallow usage of unknown wire adapters ||
|[lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md)| disallow access to global browser APIs during SSR ||
86
+
|[lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md)| disallow access of unsupported properties in SSR ||
87
+
|[lwc/no-node-env-in-ssr](./docs/rules/no-node-env-in-ssr.md)| disallow usage of process.env.NODE_ENV in SSR ||
88
+
|[lwc/valid-graphql-wire-adapter-callback-parameters](./docs/rules/valid-graphql-wire-adapter-callback-parameters.md)| ensure graphql wire adapters are using 'errors' instead of 'error' ||
89
+
|[lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md)| disallow the host element mutation in 'connectedCallback' ||
|[lwc/consistent-component-name](./docs/rules/consistent-component-name.md)| ensure component class name matches file name | 🔧 |
93
+
|[lwc/no-api-reassignments](./docs/rules/no-api-reassignments.md)| prevent public property reassignments ||
94
+
|[lwc/no-deprecated](./docs/rules/no-deprecated.md)| disallow usage of deprecated LWC APIs ||
95
+
|[lwc/no-document-query](./docs/rules/no-document-query.md)| disallow DOM query at the document level ||
96
+
|[lwc/no-attributes-during-construction](./docs/rules/no-attributes-during-construction.md)| disallow setting attributes during construction ||
97
+
|[lwc/no-disallowed-lwc-imports](./docs/rules/no-disallowed-lwc-imports.md)| disallow importing unsupported APIs from the `lwc` package ||
98
+
|[lwc/no-leading-uppercase-api-name](./docs/rules/no-leading-uppercase-api-name.md)| ensure public property doesn't start with an upper-case character ||
99
+
|[lwc/no-unexpected-wire-adapter-usages](./docs/rules/no-unexpected-wire-adapter-usages.md)| enforce wire adapters to be used with `wire` decorator ||
100
+
|[lwc/no-unknown-wire-adapters](./docs/rules/no-unknown-wire-adapters.md)| disallow usage of unknown wire adapters ||
|[lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md)| disallow access to global browser APIs during SSR ||
105
+
|[lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md)| disallow access of unsupported properties in SSR ||
106
+
|[lwc/no-node-env-in-ssr](./docs/rules/no-node-env-in-ssr.md)| disallow usage of process.env.NODE_ENV in SSR ||
107
+
|[lwc/valid-graphql-wire-adapter-callback-parameters](./docs/rules/valid-graphql-wire-adapter-callback-parameters.md)| ensure graphql wire adapters are using 'errors' instead of 'error' ||
108
+
|[lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md)| disallow the host element mutation in 'connectedCallback' ||
109
+
|[lwc/ssr-no-static-imports-of-user-specific-scoped-modules](./docs/rules/ssr-no-static-imports-of-user-specific-scoped-modules.md)| disallow static imports of user-specific scoped modules in SSR-able components ||
110
+
|[lwc/ssr-no-form-factor](./docs/rules/ssr-no-form-factor.md)| disallow formFactor in SSR-able components ||
# Using @salesforce/client/formFactor in SSR-able components is not the best practice(`lwc/ssr-no-form-factor`)
2
+
3
+
## Rule details
4
+
5
+
The [`@salesforce/client/formFactor`](https://developer.salesforce.com/docs/platform/lwc/guide/create-client-form-factor.html) module defaults to a value of `"Large"` during SSR, regardless of the device that made the request. This can cause issues where the UI shifts once client-side rendering is complete, particularly when rendering on smaller devices. To avoid this, use **[CSS media queries](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries)** to handle form factors and **[responsive images](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)** for different screen sizes.
# Deprecation Notice for Salesforce Scoped Modules during Server-Side Rendering (SSR)
2
+
3
+
Static imports of user-specific scoped modules, such as `@salesforce/user/*`, are not supported in LWC components marked with `lightning__ServerRenderable` or `lightning__ServerRenderableWithHydration`.
4
+
5
+
## Rule details
6
+
7
+
The following Salesforce scoped modules are deprecated when using Server-Side Rendering (SSR):
8
+
9
+
-`@salesforce/user/*`
10
+
-`@salesforce/userPermission/*`
11
+
-`@salesforce/customPermission/*`
12
+
13
+
To replace these deprecated modules, use dynamic imports to fetch the necessary data on-demand. This ensures that SSR can run without issues and user-specific data is loaded appropriately after hydration on the client-side. For more details, refer to the guide on [Adding Dynamic Data to LWR Sites](https://developer.salesforce.com/docs/atlas.en-us.exp_cloud_lwr.meta/exp_cloud_lwr/advanced_expressions.htm).
14
+
15
+
### Handling Deprecation in components
16
+
17
+
If your component relies on one of these scoped modules, follow these best practices:
18
+
19
+
1.**On the Server (SSR)**:
20
+
21
+
- Render a placeholder during SSR to avoid negatively impacting **[web vitals](https://web.dev/articles/vitals)**.
22
+
23
+
2.**On the Client (after Hydration)**:
24
+
-**[Dynamically import](https://developer.salesforce.com/docs/platform/lwr/guide/lwr-portable-best-practices.html#dynamically-import-non-portable-modules)** the module after hydration to avoid SSR issues.
0 commit comments