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
Copy file name to clipboardExpand all lines: README.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,8 @@ Example of `.eslintrc`:
31
31
"rules": {
32
32
"@lwc/lwc/no-deprecated": "error",
33
33
"@lwc/lwc/valid-api": "error",
34
-
"@lwc/lwc/no-document-query": "error"
34
+
"@lwc/lwc/no-document-query": "error",
35
+
"@lwc/lwc/ssr/no-unsupported-properties": "error"
35
36
}
36
37
}
37
38
```
@@ -85,6 +86,9 @@ To choose from three configuration settings, install the [`eslint-config-lwc`](h
85
86
|[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
87
|[lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md)| disallow access of unsupported properties in SSR ||
87
88
|[lwc/no-node-env-in-ssr](./docs/rules/no-node-env-in-ssr.md)| disallow usage of process.env.NODE_ENV in SSR ||
89
+
|[lwc/ssr/no-restricted-browser-globals](./docs/rules/ssr/no-restricted-browser-globals.md)| disallow access to global browser APIs during SSR ||
90
+
|[lwc/ssr/no-unsupported-properties](./docs/rules/ssr/no-unsupported-properties.md)| disallow access of unsupported properties in SSR ||
91
+
|[lwc/ssr/no-node-env](./docs/rules/ssr/no-node-env.md)| disallow usage of process.env.NODE_ENV in SSR ||
88
92
|[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
93
|[lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md)| disallow the host element mutation in 'connectedCallback' ||
90
94
| Rule ID | Description | Fixable |
@@ -101,13 +105,13 @@ To choose from three configuration settings, install the [`eslint-config-lwc`](h
|[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 ||
108
+
|[lwc/ssr/no-restricted-browser-globals](./docs/rules/ssr/no-restricted-browser-globals.md)| disallow access to global browser APIs during SSR ||
109
+
|[lwc/ssr/no-unsupported-properties](./docs/rules/ssr/no-unsupported-properties.md)| disallow access of unsupported properties in SSR ||
110
+
|[lwc/ssr/no-node-env](./docs/rules/ssr/no-node-env.md)| disallow usage of process.env.NODE_ENV in SSR ||
107
111
|[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 ||
112
+
|[lwc/ssr/no-host-mutation-in-connected-callback](./docs/rules/ssr/no-host-mutation-in-connected-callback.md)| disallow the host element mutation in 'connectedCallback' ||
113
+
|[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 ||
114
+
|[lwc/ssr/no-form-factor](./docs/rules/ssr/no-form-factor.md)| disallow formFactor in SSR-able components ||
111
115
112
116
### Best practices
113
117
@@ -119,7 +123,7 @@ To choose from three configuration settings, install the [`eslint-config-lwc`](h
119
123
|[lwc/no-template-children](./docs/rules/no-template-children.md)| prevent accessing the immediate children of this.template ||
120
124
|[lwc/no-leaky-event-listeners](./docs/rules/no-leaky-event-listeners.md)| prevent event listeners from leaking memory ||
121
125
|[lwc/prefer-custom-event](./docs/rules/prefer-custom-event.md)| suggest usage of `CustomEvent` over `Event` constructor ||
122
-
|[lwc/ssr-no-unsupported-node-api](./docs/rules/ssr-no-unsupported-node-api.md)| disallow unsupported Node API calls in SSR-able components ||
126
+
|[lwc/ssr/no-unsupported-node-api](./docs/rules/ssr/no-unsupported-node-api.md)| disallow unsupported Node API calls in SSR-able components ||
123
127
124
128
### Compat performance
125
129
@@ -133,6 +137,9 @@ Older browsers like IE11 run LWC in compatibility mode. For more information abo
Copy file name to clipboardExpand all lines: docs/rules/no-node-env-in-ssr.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Disallow use of `process.env.NODE_ENV` during SSR (`lwc/no-node-env-in-ssr`)
2
2
3
-
Using process.env.NODE_ENV during server-side rendering in JavaScript is not recommended because it can introduce unexpected behavior and bugs in your application. This environment variable is typically used for conditional logic related to development or production builds, which is more relevant on the client side.
3
+
Using `process.env.NODE_ENV` during server-side rendering in JavaScript is not recommended because it can introduce unexpected behavior and bugs in your application. This environment variable is typically used for conditional logic related to development or production builds, which is more relevant on the client side.
# Disallow use of `process.env.NODE_ENV` during SSR (`lwc/ssr/no-node-env`)
2
+
3
+
Using `process.env.NODE_ENV` during server-side rendering in JavaScript is not recommended because it can introduce unexpected behavior and bugs in your application. This environment variable is typically used for conditional logic related to development or production builds, which is more relevant on the client side.
4
+
5
+
## Rule Details
6
+
7
+
Example of **incorrect** code for this rule:
8
+
9
+
```js
10
+
import { LightningElement } from'lwc';
11
+
12
+
exportdefaultclassFooextendsLightningElement {
13
+
connectedCallback() {
14
+
if (process.env.NODE_ENV!=='production') {
15
+
console.log('Foo:connectedCallback');
16
+
}
17
+
}
18
+
}
19
+
```
20
+
21
+
Examples of **correct** code for this rule:
22
+
23
+
```js
24
+
import { LightningElement } from'lwc';
25
+
26
+
exportdefaultclassFooextendsLightningElement {
27
+
connectedCallback() {
28
+
if (!import.meta.env.SSR && process.env.NODE_ENV !== 'production') {
Copy file name to clipboardExpand all lines: docs/rules/ssr/no-unsupported-node-api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Disallow Node API Calls in SSR Context (`lwc/ssr-no-unsupported-node-api`)
1
+
# Disallow Node API Calls in SSR Context (`lwc/ssr/no-unsupported-node-api`)
2
2
3
3
This rule disallows the use of unsupported Node API calls within components that may run during server-side rendering. These APIs are not available in client-side rendering environments and can lead to serious issues when used without proper safeguards. To avoid unexpected behavior and security vulnerabilities, certain problematic Node APIs should not be used in SSR contexts.
0 commit comments