-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add `ssr` config * doc: add to README * Update README.md Co-authored-by: Pierre-Marie Dartus <p.dartus@salesforce.com> * doc: add missing title --------- Co-authored-by: Pierre-Marie Dartus <p.dartus@salesforce.com>
- Loading branch information
1 parent
bfe9fba
commit 46372df
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
'use strict'; | ||
|
||
module.exports = { | ||
extends: [require.resolve('./lib/defaults')], | ||
plugins: [ | ||
'@lwc/eslint-plugin-lwc', // https://github.com/salesforce/eslint-plugin-lwc | ||
], | ||
rules: { | ||
'@lwc/lwc/no-unsupported-ssr-properties': 'error', | ||
'@lwc/lwc/no-restricted-browser-globals-during-ssr': 'error', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2021, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const eslint = require('eslint'); | ||
|
||
const { linkConfig, unlinkConfig } = require('./utils'); | ||
|
||
describe('ssr configs', () => { | ||
before(() => { | ||
linkConfig(); | ||
}); | ||
|
||
after(() => { | ||
unlinkConfig(); | ||
}); | ||
|
||
it('should load properly', async () => { | ||
const cli = new eslint.ESLint({ | ||
useEslintrc: false, | ||
baseConfig: { | ||
extends: ['@salesforce/eslint-config-lwc/ssr'], | ||
}, | ||
}); | ||
|
||
const results = await cli.lintText(` | ||
import { LightningElement } from 'lwc'; | ||
export default class Foo extends LightningElement { | ||
connectedCallback() { | ||
document.write("Hello world") | ||
this.dispatchEvent("Hello world") | ||
} | ||
} | ||
`); | ||
|
||
const { messages } = results[0]; | ||
assert.equal(messages.length, 2); | ||
assert.equal(messages[0].ruleId, '@lwc/lwc/no-restricted-browser-globals-during-ssr'); | ||
assert.equal(messages[1].ruleId, '@lwc/lwc/no-unsupported-ssr-properties'); | ||
}); | ||
}); |