File tree Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,21 @@ Add the `i18n` configuration to the `extends` field in your `.eslintrc` configur
6969 "extends" : [" @salesforce/eslint-config-lwc/recommended" , " @salesforce/eslint-config-lwc/i18n" ]
7070}
7171```
72+
73+ ### ` @salesforce/eslint-config-lwc/ssr ` configuration
74+
75+ ** Goal:**
76+ Promote writing server-side-rendering friendly components. We only recommend using this configuration if your components are running in experiences supporting LWC server-side-rendering.
77+
78+ ** Rules:**
79+ [ SSR specific rules ] ( https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#lwc ) only.
80+
81+ ** Usage:**
82+
83+ Add the ` ssr ` configuration to the ` extends ` field in your ` .eslintrc ` configuration file, for example:
84+
85+ ``` json
86+ {
87+ "extends" : [" @salesforce/eslint-config-lwc/recommended" , " @salesforce/eslint-config-lwc/ssr" ]
88+ }
89+ ```
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2018, salesforce.com, inc.
3+ * All rights reserved.
4+ * SPDX-License-Identifier: MIT
5+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+ */
7+ 'use strict' ;
8+
9+ module . exports = {
10+ extends : [ require . resolve ( './lib/defaults' ) ] ,
11+ plugins : [
12+ '@lwc/eslint-plugin-lwc' , // https://github.com/salesforce/eslint-plugin-lwc
13+ ] ,
14+ rules : {
15+ '@lwc/lwc/no-unsupported-ssr-properties' : 'error' ,
16+ '@lwc/lwc/no-restricted-browser-globals-during-ssr' : 'error' ,
17+ } ,
18+ } ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2021, salesforce.com, inc.
3+ * All rights reserved.
4+ * SPDX-License-Identifier: MIT
5+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+ */
7+ 'use strict' ;
8+
9+ const assert = require ( 'assert' ) ;
10+ const eslint = require ( 'eslint' ) ;
11+
12+ const { linkConfig, unlinkConfig } = require ( './utils' ) ;
13+
14+ describe ( 'ssr configs' , ( ) => {
15+ before ( ( ) => {
16+ linkConfig ( ) ;
17+ } ) ;
18+
19+ after ( ( ) => {
20+ unlinkConfig ( ) ;
21+ } ) ;
22+
23+ it ( 'should load properly' , async ( ) => {
24+ const cli = new eslint . ESLint ( {
25+ useEslintrc : false ,
26+ baseConfig : {
27+ extends : [ '@salesforce/eslint-config-lwc/ssr' ] ,
28+ } ,
29+ } ) ;
30+
31+ const results = await cli . lintText ( `
32+ import { LightningElement } from 'lwc';
33+
34+ export default class Foo extends LightningElement {
35+ connectedCallback() {
36+ document.write("Hello world")
37+ this.dispatchEvent("Hello world")
38+ }
39+ }
40+ ` ) ;
41+
42+ const { messages } = results [ 0 ] ;
43+ assert . equal ( messages . length , 2 ) ;
44+ assert . equal ( messages [ 0 ] . ruleId , '@lwc/lwc/no-restricted-browser-globals-during-ssr' ) ;
45+ assert . equal ( messages [ 1 ] . ruleId , '@lwc/lwc/no-unsupported-ssr-properties' ) ;
46+ } ) ;
47+ } ) ;
You can’t perform that action at this time.
0 commit comments