Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "mocha"
},
"dependencies": {
"@lwc/eslint-plugin-lwc": "~0.11.0",
"@lwc/eslint-plugin-lwc": "~0.12.0",
"babel-eslint": "~10.1.0",
"eslint-plugin-import": "~2.22.1",
"eslint-plugin-jest": "~23.8.2",
Expand Down
1 change: 1 addition & 0 deletions recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = {
// LWC specific rules
'@lwc/lwc/no-api-reassignments': 'error',
'@lwc/lwc/no-async-operation': 'error',
'@lwc/lwc/no-attributes-during-construction': 'error',
'@lwc/lwc/no-document-query': 'error',
'@lwc/lwc/no-dupe-class-members': 'error',
'@lwc/lwc/no-inner-html': 'error',
Expand Down
39 changes: 29 additions & 10 deletions test/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe('recommended config', () => {
const report = cli.executeOnText('document.querySelectorAll("a")');

const { messages } = report.results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/no-document-query');
assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, '@lwc/lwc/no-document-query');
});

it('should forbid mixing uppercase and underscore characters in public properties', () => {
Expand All @@ -50,8 +50,8 @@ describe('recommended config', () => {
`);

const { messages } = report.results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/valid-api');
assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, '@lwc/lwc/valid-api');
});

it('should suggest usage of CustomEvent over Event constructor', () => {
Expand All @@ -60,8 +60,8 @@ describe('recommended config', () => {
const report = cli.executeOnText(`dispatchEvent(new Event('test'));`);

const { messages } = report.results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/prefer-custom-event');
assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, '@lwc/lwc/prefer-custom-event');
});

it('should forbid duplicate class members', () => {
Expand All @@ -72,15 +72,34 @@ describe('recommended config', () => {

export default class App extends LightningElement {
@api foo = 1;

set foo(value) { this._foo = value }
get foo() { return this._foo; }
}
`);

const { messages } = report.results[0];
assert.equal(messages.length, 2);
assert.equal(messages[0].ruleId, '@lwc/lwc/no-dupe-class-members');
assert.equal(messages[1].ruleId, '@lwc/lwc/no-dupe-class-members');
assert.strictEqual(messages.length, 2);
assert.strictEqual(messages[0].ruleId, '@lwc/lwc/no-dupe-class-members');
assert.strictEqual(messages[1].ruleId, '@lwc/lwc/no-dupe-class-members');
});

it('should prevent attributes set during construction', () => {
const cli = getCliEngineWithRecommendedRules();

const report = cli.executeOnText(`
import { LightningElement } from 'lwc';

export default class App extends LightningElement {
constructor() {
super();
this.tabIndex = '-1';
}
}
`);

const { messages } = report.results[0];
assert.strictEqual(messages.length, 1);
assert.strictEqual(messages[0].ruleId, '@lwc/lwc/no-attributes-during-construction');
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@lwc/eslint-plugin-lwc@~0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@lwc/eslint-plugin-lwc/-/eslint-plugin-lwc-0.11.0.tgz#1c69cc673b9798e04e87ececb8529b93eb2215b1"
integrity sha512-wJOD4XWOH91GaZfypMSKfEeMXqMfvKdsb2gSJ/9FEwJVlziKg1aagtRYJh2ln3DyEZV33tBC/p/dWzIeiwa1tg==
"@lwc/eslint-plugin-lwc@~0.12.0":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@lwc/eslint-plugin-lwc/-/eslint-plugin-lwc-0.12.0.tgz#4065c2e9c72f4133f2e6dca5a87ca613b35a4e1d"
integrity sha512-p8PacTcCNg+Txgu7P+sDaLKAs1S/LyKWvbBiE3lZByGkahveISX7VARt8W+bCxUTERoXzoOPDxa7uGmawEfmXQ==
dependencies:
minimatch "^3.0.4"

Expand Down