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

Lines changed: 22 additions & 22 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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: {

0 commit comments

Comments
 (0)