Skip to content

Commit 23520d2

Browse files
feat!: @W-17529338 reformat SSR rules to support eslint v9 (#180)
* fix: reformat ssr rules to support eslint v9 * fix: doc url for ssr rules --------- Co-authored-by: ravi-jayaramappa <[email protected]>
1 parent b702267 commit 23520d2

27 files changed

+57
-59
lines changed

README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Example of `.eslintrc`:
3232
"@lwc/lwc/no-deprecated": "error",
3333
"@lwc/lwc/valid-api": "error",
3434
"@lwc/lwc/no-document-query": "error",
35-
"@lwc/lwc/ssr/no-unsupported-properties": "error"
35+
"@lwc/lwc/ssr-no-unsupported-properties": "error"
3636
}
3737
}
3838
```
@@ -86,9 +86,9 @@ To choose from three configuration settings, install the [`eslint-config-lwc`](h
8686
| [lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md) | disallow access to global browser APIs during SSR | |
8787
| [lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md) | disallow access of unsupported properties in SSR | |
8888
| [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 | |
89+
| [lwc/ssr-no-restricted-browser-globals](./docs/rules/ssr/ssr-no-restricted-browser-globals.md) | disallow access to global browser APIs during SSR | |
90+
| [lwc/ssr-no-unsupported-properties](./docs/rules/ssr/ssr-no-unsupported-properties.md) | disallow access of unsupported properties in SSR | |
91+
| [lwc/ssr-no-node-env](./docs/rules/ssr/ssr-no-node-env.md) | disallow usage of process.env.NODE_ENV in SSR | |
9292
| [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' | |
9393
| [lwc/no-host-mutation-in-connected-callback](./docs/rules/no-host-mutation-in-connected-callback.md) | disallow the host element mutation in 'connectedCallback' | |
9494
| Rule ID | Description | Fixable |
@@ -105,25 +105,25 @@ To choose from three configuration settings, install the [`eslint-config-lwc`](h
105105
| [lwc/valid-api](./docs/rules/valid-api.md) | validate `api` decorator usage | |
106106
| [lwc/valid-track](./docs/rules/valid-track.md) | validate `track` decorator usage | |
107107
| [lwc/valid-wire](./docs/rules/valid-wire.md) | validate `wire` decorator usage | |
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 | |
108+
| [lwc/ssr-no-restricted-browser-globals](./docs/rules/ssr/ssr-no-restricted-browser-globals.md) | disallow access to global browser APIs during SSR | |
109+
| [lwc/ssr-no-unsupported-properties](./docs/rules/ssr/ssr-no-unsupported-properties.md) | disallow access of unsupported properties in SSR | |
110+
| [lwc/ssr-no-node-env](./docs/rules/ssr/ssr-no-node-env.md) | disallow usage of process.env.NODE_ENV in SSR | |
111111
| [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' | |
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 | |
112+
| [lwc/ssr-no-host-mutation-in-connected-callback](./docs/rules/ssr/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/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/ssr-no-form-factor.md) | disallow formFactor in SSR-able components | |
115115

116116
### Best practices
117117

118-
| Rule ID | Description | Fixable |
119-
| ------------------------------------------------------------------------------ | ---------------------------------------------------------- | ------- |
120-
| [lwc/no-async-operation](./docs/rules/no-async-operation.md) | restrict usage of async operations | |
121-
| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md) | disallow duplicate class members | |
122-
| [lwc/no-inner-html](./docs/rules/no-inner-html.md) | disallow usage of `innerHTML` | |
123-
| [lwc/no-template-children](./docs/rules/no-template-children.md) | prevent accessing the immediate children of this.template | |
124-
| [lwc/no-leaky-event-listeners](./docs/rules/no-leaky-event-listeners.md) | prevent event listeners from leaking memory | |
125-
| [lwc/prefer-custom-event](./docs/rules/prefer-custom-event.md) | suggest usage of `CustomEvent` over `Event` constructor | |
126-
| [lwc/ssr/no-unsupported-node-api](./docs/rules/ssr/no-unsupported-node-api.md) | disallow unsupported Node API calls in SSR-able components | |
118+
| Rule ID | Description | Fixable |
119+
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------- |
120+
| [lwc/no-async-operation](./docs/rules/no-async-operation.md) | restrict usage of async operations | |
121+
| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md) | disallow duplicate class members | |
122+
| [lwc/no-inner-html](./docs/rules/no-inner-html.md) | disallow usage of `innerHTML` | |
123+
| [lwc/no-template-children](./docs/rules/no-template-children.md) | prevent accessing the immediate children of this.template | |
124+
| [lwc/no-leaky-event-listeners](./docs/rules/no-leaky-event-listeners.md) | prevent event listeners from leaking memory | |
125+
| [lwc/prefer-custom-event](./docs/rules/prefer-custom-event.md) | suggest usage of `CustomEvent` over `Event` constructor | |
126+
| [lwc/ssr-no-unsupported-node-api](./docs/rules/ssr/ssr-no-unsupported-node-api.md) | disallow unsupported Node API calls in SSR-able components | |
127127

128128
### Compat performance
129129

@@ -140,6 +140,6 @@ Older browsers like IE11 run LWC in compatibility mode. For more information abo
140140
| Rule ID | Replaced by |
141141
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
142142
| [lwc/no-dupe-class-members](./docs/rules/no-dupe-class-members.md) | [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members)(base eslint rule) |
143-
| [lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md) | [lwc/ssr/no-restricted-browser-globals](./docs/rules/ssr/no-restricted-browser-globals.md) |
144-
| [lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md) | [lwc/ssr/no-unsupported-properties](./docs/rules/ssr/no-unsupported-properties.md) |
145-
| [lwc/no-node-env-in-ssr](./docs/rules/no-node-en-in-ssr.md) | [lwc/ssr/no-node-env](./docs/rules/ssr/no-node-env.md) |
143+
| [lwc/no-restricted-browser-globals-during-ssr](./docs/rules/no-restricted-browser-globals-during-ssr.md) | [lwc/ssr-no-restricted-browser-globals](./docs/rules/ssr/ssr-no-restricted-browser-globals.md) |
144+
| [lwc/no-unsupported-ssr-properties](./docs/rules/no-unsupported-ssr-properties.md) | [lwc/ssr-no-unsupported-properties](./docs/rules/ssr/ssr-no-unsupported-properties.md) |
145+
| [lwc/no-node-env-in-ssr](./docs/rules/no-node-en-in-ssr.md) | [lwc/ssr-no-node-env](./docs/rules/ssr/ssr-no-node-env.md) |

docs/rules/ssr/no-form-factor.md renamed to docs/rules/ssr/ssr-no-form-factor.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Using @salesforce/client/formFactor in SSR-able components is not the best practice(`lwc/ssr/no-form-factor`)
1+
# Using @salesforce/client/formFactor in SSR-able components is not the best practice(`lwc/ssr-no-form-factor`)
22

33
## Rule details
44

docs/rules/ssr/no-node-env.md renamed to docs/rules/ssr/ssr-no-node-env.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow use of `process.env.NODE_ENV` during SSR (`lwc/ssr/no-node-env`)
1+
# Disallow use of `process.env.NODE_ENV` during SSR (`lwc/ssr-no-node-env`)
22

33
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.
44

docs/rules/ssr/no-restricted-browser-globals.md renamed to docs/rules/ssr/ssr-no-restricted-browser-globals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow access to global browser APIs during SSR (`lwc/ssr/no-restricted-browser-globals`)
1+
# Disallow access to global browser APIs during SSR (`lwc/ssr-no-restricted-browser-globals`)
22

33
Browser APIs must not be accessed when SSR is being done. This rule prevents usage of browser APIs like `DOMParser`, `DocumentFragment` etc.
44
in `connectedCallback` (and in methods called from `connectedCallback` or anywhere when SSR is being done).

docs/rules/ssr/no-unsupported-node-api.md renamed to docs/rules/ssr/ssr-no-unsupported-node-api.md

+1-1
Original file line numberDiff line numberDiff 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`)
22

33
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.
44

docs/rules/ssr/no-unsupported-properties.md renamed to docs/rules/ssr/ssr-no-unsupported-properties.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow access of properties on this during SSR (`lwc/ssr/no-unsupported-properties`)
1+
# Disallow access of properties on this during SSR (`lwc/ssr-no-unsupported-properties`)
22

33
Browser APIs must not be accessed when SSR is being done. This rule prevents usage of browser APIs like `querySelector`,
44
`dispatchEvent`, on `this` in `connectedCallback` (and in methods called from `connectedCallback` or anywhere when

lib/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ const rules = {
3333
'no-unsupported-ssr-properties': require('./rules/no-unsupported-ssr-properties'),
3434
'no-node-env-in-ssr': require('./rules/no-node-env-in-ssr'),
3535
// SSR rules
36-
'ssr/no-host-mutation-in-connected-callback': require('./rules/ssr/no-host-mutation-in-connected-callback'),
37-
'ssr/no-restricted-browser-globals': require('./rules/ssr/no-restricted-browser-globals'),
38-
'ssr/no-unsupported-properties': require('./rules/ssr/no-unsupported-properties'),
39-
'ssr/no-node-env': require('./rules/ssr/no-node-env'),
40-
'ssr/no-unsupported-node-api': require('./rules/ssr/no-unsupported-node-api'),
41-
'ssr/no-static-imports-of-user-specific-scoped-modules': require('./rules/ssr/no-static-imports-of-user-specific-scoped-modules'),
42-
'ssr/no-form-factor': require('./rules/ssr/no-form-factor'),
36+
'ssr-no-host-mutation-in-connected-callback': require('./rules/ssr/ssr-no-host-mutation-in-connected-callback'),
37+
'ssr-no-restricted-browser-globals': require('./rules/ssr/ssr-no-restricted-browser-globals'),
38+
'ssr-no-unsupported-properties': require('./rules/ssr/ssr-no-unsupported-properties'),
39+
'ssr-no-node-env': require('./rules/ssr/ssr-no-node-env'),
40+
'ssr-no-unsupported-node-api': require('./rules/ssr/ssr-no-unsupported-node-api'),
41+
'ssr-no-static-imports-of-user-specific-scoped-modules': require('./rules/ssr/ssr-no-static-imports-of-user-specific-scoped-modules'),
42+
'ssr-no-form-factor': require('./rules/ssr/ssr-no-form-factor'),
4343
};
4444

4545
module.exports = {

lib/rules/no-node-env-in-ssr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
description: 'disallow access of process.env.NODE_ENV in SSR',
1919
deprecated: true,
2020
suggestion:
21-
'Please avoid using this rule and use this alternative @lwc/lwc/ssr/no-node-env.',
21+
'Please avoid using this rule and use this alternative @lwc/lwc/ssr-no-node-env.',
2222
},
2323
schema: [],
2424
messages: {

lib/rules/no-restricted-browser-globals-during-ssr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
description: 'disallow access to global browser APIs during SSR',
2525
deprecated: true,
2626
suggestion:
27-
'Please avoid using this rule and use this alternative : @lwc/lwc/ssr/no-restricted-browser-globals',
27+
'Please avoid using this rule and use this alternative : @lwc/lwc/ssr-no-restricted-browser-globals',
2828
},
2929
schema: [
3030
{

lib/rules/no-unsupported-ssr-properties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
description: 'disallow access of unsupported properties in SSR',
3434
deprecated: true,
3535
suggestion:
36-
'Please avoid using this rule and use this alternative : @lwc/lwc/ssr/no-unsupported-ssr-properties',
36+
'Please avoid using this rule and use this alternative : @lwc/ssr-no-unsupported-ssr-properties',
3737
},
3838
schema: [],
3939
messages: {

lib/rules/ssr/no-form-factor.js renamed to lib/rules/ssr/ssr-no-form-factor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
docs: {
1717
description: 'Discourage use of formFactor.',
1818
category: 'LWC',
19-
url: docUrl('ssr/no-form-factor'),
19+
url: docUrl('ssr/ssr-no-form-factor'),
2020
recommended: true,
2121
},
2222
messages: {

lib/rules/ssr/no-host-mutation-in-connected-callback.js renamed to lib/rules/ssr/ssr-no-host-mutation-in-connected-callback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
description: 'Disallow mutations to the host element in connectedCallback',
1717
category: 'LWC',
1818
recommended: true,
19-
url: docUrl('docs/rules/ssr/no-host-mutation-in-connected-callback'),
19+
url: docUrl('docs/rules/ssr-no-host-mutation-in-connected-callback'),
2020
},
2121
messages: {
2222
noHostMutation: 'Mutations to the host element in connectedCallback are not allowed.',

lib/rules/ssr/no-node-env.js renamed to lib/rules/ssr/ssr-no-node-env.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
meta: {
1414
type: 'problem',
1515
docs: {
16-
url: docUrl('ssr/no-node-env'),
16+
url: docUrl('ssr/ssr-no-node-env'),
1717
category: 'LWC',
1818
description: 'disallow access of process.env.NODE_ENV in SSR',
1919
},

lib/rules/ssr/no-restricted-browser-globals.js renamed to lib/rules/ssr/ssr-no-restricted-browser-globals.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
meta: {
2020
type: 'problem',
2121
docs: {
22-
url: docUrl('ssr/no-restricted-browser-globals'),
22+
url: docUrl('ssr/ssr-no-restricted-browser-globals'),
2323
category: 'LWC',
2424
description: 'disallow access to global browser APIs during SSR',
2525
},

lib/rules/ssr/no-static-imports-of-user-specific-scoped-modules.js renamed to lib/rules/ssr/ssr-no-static-imports-of-user-specific-scoped-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
description:
2626
'Disallow static imports of user-specific scoped modules in SSR-able components',
2727
category: 'LWC',
28-
url: docUrl('ssr/no-static-imports-of-user-specific-scoped-modules'),
28+
url: docUrl('ssr/ssr-no-static-imports-of-user-specific-scoped-modules'),
2929
recommended: true,
3030
},
3131
messages: {

lib/rules/ssr/no-unsupported-node-api.js renamed to lib/rules/ssr/ssr-no-unsupported-node-api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
docs: {
1616
description: 'Disallow unsupported Node.js API calls in SSR-able components.',
1717
category: 'LWC',
18-
url: docUrl('ssr/no-unsupported-node-api'),
18+
url: docUrl('ssr/ssr-no-unsupported-node-api'),
1919
recommended: true,
2020
},
2121
messages: {

lib/rules/ssr/no-unsupported-properties.js renamed to lib/rules/ssr/ssr-no-unsupported-properties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
meta: {
2929
type: 'problem',
3030
docs: {
31-
url: docUrl('ssr/no-unsupported-properties'),
31+
url: docUrl('ssr/ssr-no-unsupported-properties'),
3232
category: 'LWC',
3333
description: 'disallow access of unsupported properties in SSR',
3434
},

0 commit comments

Comments
 (0)