Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eslint rules #1039

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ module.exports = {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"semi": "error",
"quotes": "error",
"no-console": "off",
"no-empty": "off",
"no-prototype-builtins": "off",
"no-unused-vars": "warn"
"no-unused-vars": "warn",
"quote-props": ["warn", "consistent"],
"no-multi-spaces": ["warn", { "ignoreEOLComments": true }],
"@typescript-eslint/no-unused-vars": "warn"
// "@typescript-eslint/no-misused-promises": "error",
// "@typescript-eslint/no-floating-promises": 2,
// "@typescript-eslint/explicit-function-return-type": "error"
Comment on lines +28 to +30
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than taking the to resolve the warnings, I opted to disable this rules for now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time

},
"globals": {
"DEFINE_VERSION": "readonly",
Expand Down
29 changes: 0 additions & 29 deletions .ts-eslintrc.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/domain/SessionLoadViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,21 @@ export class SessionLoadViewModel extends ViewModel {
if (client) {
switch (client.loadStatus.get()) {
case LoadStatus.QueryAccount:
return `Querying account encryption setup…`;
return "Querying account encryption setup…";
case LoadStatus.AccountSetup:
return ""; // we'll show a header ing AccountSetupView
case LoadStatus.SessionSetup:
return `Setting up your encryption keys…`;
return "Setting up your encryption keys…";
case LoadStatus.Loading:
return `Loading your conversations…`;
return "Loading your conversations…";
case LoadStatus.FirstSync:
return `Getting your conversations from the server…`;
return "Getting your conversations from the server…";
default:
return this._client.loadStatus.get();
}
}

return `Preparing…`;
return "Preparing…";
}

_getError() {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/SessionPickerViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SessionItemViewModel extends ViewModel {
}

get label() {
const {userId, comment} = this._sessionInfo;
const {userId, comment} = this._sessionInfo;
if (comment) {
return `${userId} (${comment})`;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/session/CreateRoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class CreateRoomViewModel extends ViewModel {
info: this._avatarInfo,
name: this._avatarFileName,
blob: this._avatarScaledBlob
}
};
}
const roomBeingCreated = this._session.createRoom({
type: this.isPublic ? RoomType.Public : RoomType.Private,
Expand Down
4 changes: 2 additions & 2 deletions src/domain/session/leftpanel/InviteTileViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ export class InviteTileViewModel extends BaseTileViewModel {
export function tests() {
return {
"test compare with timestamp": assert => {
const urlRouter = {openRoomActionUrl() { return "";}}
const urlRouter = {openRoomActionUrl() { return "";}};
const vm1 = new InviteTileViewModel({invite: {timestamp: 500, id: "1"}, urlRouter});
const vm2 = new InviteTileViewModel({invite: {timestamp: 250, id: "2"}, urlRouter});
assert(vm1.compare(vm2) < 0);
assert(vm2.compare(vm1) > 0);
assert.equal(vm1.compare(vm1), 0);
},
}
};
}
4 changes: 2 additions & 2 deletions src/domain/session/leftpanel/RoomBeingCreatedTileViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export class RoomBeingCreatedTileViewModel extends BaseTileViewModel {
export function tests() {
return {
"test compare with names": assert => {
const urlRouter = {openRoomActionUrl() { return "";}}
const urlRouter = {openRoomActionUrl() { return "";}};
const vm1 = new RoomBeingCreatedTileViewModel({roomBeingCreated: {name: "A", id: "1"}, urlRouter});
const vm2 = new RoomBeingCreatedTileViewModel({roomBeingCreated: {name: "B", id: "2"}, urlRouter});
assert(vm1.compare(vm2) < 0);
assert(vm2.compare(vm1) > 0);
assert.equal(vm1.compare(vm1), 0);
},
}
};
}
2 changes: 1 addition & 1 deletion src/domain/session/rightpanel/MemberDetailsViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class MemberDetailsViewModel extends ViewModel {
}

get avatarColorNumber() {
return getIdentifierColorNumber(this.userId)
return getIdentifierColorNumber(this.userId);
}

avatarUrl(size) {
Expand Down
4 changes: 2 additions & 2 deletions src/domain/session/rightpanel/MemberTileViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class MemberTileViewModel extends ViewModel {
constructor(options) {
super(options);
this._member = this._options.member;
this._mediaRepository = options.mediaRepository
this._mediaRepository = options.mediaRepository;
this._previousName = null;
this._nameChanged = true;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export class MemberTileViewModel extends ViewModel {
}

get avatarColorNumber() {
return getIdentifierColorNumber(this.userId)
return getIdentifierColorNumber(this.userId);
}

avatarUrl(size) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/session/rightpanel/RoomDetailsViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class RoomDetailsViewModel extends ViewModel {
}

get avatarColorNumber() {
return getIdentifierColorNumber(this._room.avatarColorId)
return getIdentifierColorNumber(this._room.avatarColorId);
}

avatarUrl(size) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/session/rightpanel/members/disambiguator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Disambiguator {
value.push(vm);
return value;
} else if(vm.userId !== value.userId) {
const array = [value, vm]
const array = [value, vm];
this._map.set(name, array);
return array;
}
Expand Down
4 changes: 2 additions & 2 deletions src/domain/session/room/InviteViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class InviteViewModel extends ViewModel {
}

get avatarColorNumber() {
return getIdentifierColorNumber(this._invite.avatarColorId)
return getIdentifierColorNumber(this._invite.avatarColorId);
}

avatarUrl(size) {
Expand All @@ -74,7 +74,7 @@ export class InviteViewModel extends ViewModel {
if (this._invite.canonicalAlias) {
parts.push(this._invite.canonicalAlias);
}
return parts.join(" • ")
return parts.join(" • ");
}

get roomDescription() {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/session/room/LightboxViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class LightboxViewModel extends ViewModel {
}

get date() {
return this._date && this._date.toLocaleDateString({}, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
return this._date && this._date.toLocaleDateString({}, { weekday: "long", year: "numeric", month: "long", day: "numeric" });
}

get time() {
Expand Down
8 changes: 4 additions & 4 deletions src/domain/session/room/RoomViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
*/

import {TimelineViewModel} from "./timeline/TimelineViewModel.js";
import {ComposerViewModel} from "./ComposerViewModel.js"
import {CallViewModel} from "./CallViewModel"
import {ComposerViewModel} from "./ComposerViewModel.js";
import {CallViewModel} from "./CallViewModel";
import {PickMapObservableValue} from "../../../observable/value";
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar";
import {ErrorReportViewModel} from "../../ErrorReportViewModel";
Expand Down Expand Up @@ -107,7 +107,7 @@ export class RoomViewModel extends ErrorReportViewModel {
else {
this._composerVM = this.track(new LowerPowerLevelViewModel(this.childOptions()));
}
this.emitChange("powerLevelObservable")
this.emitChange("powerLevelObservable");
};
this.track(powerLevelObservable.subscribe(() => {
const newCanSendMessage = canSendMessage();
Expand Down Expand Up @@ -175,7 +175,7 @@ export class RoomViewModel extends ErrorReportViewModel {
}

get avatarColorNumber() {
return getIdentifierColorNumber(this._room.avatarColorId)
return getIdentifierColorNumber(this._room.avatarColorId);
}

avatarUrl(size) {
Expand Down
4 changes: 2 additions & 2 deletions src/domain/session/room/timeline/ReactionsViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ReactionViewModel {
_tryUpdate(annotation) {
const oneSetAndOtherNot = !!this._annotation !== !!annotation;
const bothSet = this._annotation && annotation;
const areDifferent = bothSet && (
const areDifferent = bothSet && (
annotation.me !== this._annotation.me ||
annotation.count !== this._annotation.count ||
annotation.firstTimestamp !== this._annotation.firstTimestamp
Expand Down Expand Up @@ -369,5 +369,5 @@ export function tests() {
redactionIndex = index;
}
},
}
};
}
2 changes: 1 addition & 1 deletion src/domain/session/room/timeline/TilesCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,5 +500,5 @@ export function tests() {
assert.equal(tilesArray.length, 2);
assert.equal(removals, 2);
}
}
};
}
34 changes: 17 additions & 17 deletions src/domain/session/room/timeline/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MessageBody, HeaderBlock, TableBlock, ListBlock, CodeBlock, PillPart, FormatPart, NewLinePart, RulePart, TextPart, LinkPart, ImagePart } from "./MessageBody.js"
import { MessageBody, HeaderBlock, TableBlock, ListBlock, CodeBlock, PillPart, FormatPart, NewLinePart, RulePart, TextPart, LinkPart, ImagePart } from "./MessageBody.js";
import {linkify} from "./linkify/linkify";

/* At the time of writing (Jul 1 2021), Matrix Spec recommends
Expand All @@ -30,7 +30,7 @@ import {linkify} from "./linkify/linkify";
const basicInline = ["EM", "STRONG", "CODE", "DEL", "SPAN" ];
const basicBlock = ["DIV", "BLOCKQUOTE"];
const safeSchemas = ["https", "http", "ftp", "mailto", "magnet"].map(name => `${name}://`);
const baseUrl = 'https://matrix.to';
const baseUrl = "https://matrix.to";
const linkPrefix = `${baseUrl}/#/`;

class Deserializer {
Expand All @@ -44,7 +44,7 @@ class Deserializer {
return null;
}
const contents = link.substring(linkPrefix.length);
if (contents[0] === '@') {
if (contents[0] === "@") {
return contents;
}
return null;
Expand Down Expand Up @@ -99,10 +99,10 @@ class Deserializer {
if (!this._ensureElement(codeNode, "CODE")) {
return new CodeBlock(language, this.result.getNodeText(node));
}
const cl = result.getAttributeValue(codeNode, "class") || ""
const cl = result.getAttributeValue(codeNode, "class") || "";
for (const clname of cl.split(" ")) {
if (clname.startsWith("language-") && !clname.startsWith("language-_")) {
language = clname.substring(9) // "language-".length
language = clname.substring(9); // "language-".length
break;
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@ class Deserializer {
case "H5":
case "H6": {
const inlines = this.parseInlineNodes(children);
return new HeaderBlock(parseInt(tag[1]), inlines)
return new HeaderBlock(parseInt(tag[1]), inlines);
}
case "UL":
case "OL":
Expand Down Expand Up @@ -432,7 +432,7 @@ export async function tests() {
test(assert, input, output);
},
"Text with ordered list starting at 3": assert => {
const input = '<ol start="3"><li>Lorem</li><li>Ipsum</li></ol>';
const input = "<ol start=\"3\"><li>Lorem</li><li>Ipsum</li></ol>";
const output = [
new ListBlock(3, [
[ new TextPart("Lorem") ],
Expand All @@ -442,7 +442,7 @@ export async function tests() {
test(assert, input, output);
},
"Text with unordered list": assert => {
const input = '<ul start="3"><li>Lorem</li><li>Ipsum</li></ul>';
const input = "<ul start=\"3\"><li>Lorem</li><li>Ipsum</li></ul>";
const output = [
new ListBlock(null, [
[ new TextPart("Lorem") ],
Expand All @@ -452,22 +452,22 @@ export async function tests() {
test(assert, input, output);
},
"Auto-closed tags": assert => {
const input = '<p>hello<p>world</p></p>';
const input = "<p>hello<p>world</p></p>";
const output = [
new FormatPart("p", [new TextPart("hello")]),
new FormatPart("p", [new TextPart("world")])
];
test(assert, input, output);
},
"Block elements ignored inside inline elements": assert => {
const input = '<span><p><code>Hello</code></p></span>';
const input = "<span><p><code>Hello</code></p></span>";
const output = [
new FormatPart("span", [new FormatPart("code", [new TextPart("Hello")])])
];
test(assert, input, output);
},
"Unknown tags are ignored, but their children are kept": assert => {
const input = '<span><dfn><code>Hello</code></dfn><footer><em>World</em></footer></span>';
const input = "<span><dfn><code>Hello</code></dfn><footer><em>World</em></footer></span>";
const output = [
new FormatPart("span", [
new FormatPart("code", [new TextPart("Hello")]),
Expand All @@ -477,34 +477,34 @@ export async function tests() {
test(assert, input, output);
},
"Unknown and invalid attributes are stripped": assert => {
const input = '<em onmouseover=alert("Bad code!")>Hello</em>';
const input = "<em onmouseover=alert(\"Bad code!\")>Hello</em>";
const output = [
new FormatPart("em", [new TextPart("Hello")])
];
test(assert, input, output);
},
"Text with code block but no <code> tag": assert => {
const code = 'main :: IO ()\nmain = putStrLn "Hello"'
const code = "main :: IO ()\nmain = putStrLn \"Hello\"";
const input = `<pre>${code}</pre>`;
const output = [
new CodeBlock(null, code)
];
test(assert, input, output);
},
"Text with code block and 'unsupported' tag": assert => {
const code = '<em>Hello, world</em>'
const code = "<em>Hello, world</em>";
const input = `<pre>${code}</pre>`;
const output = [
new CodeBlock(null, code)
];
test(assert, input, output);
},
"Reply fallback is always stripped": assert => {
const input = 'Hello, <em><mx-reply>World</mx-reply></em>!';
const input = "Hello, <em><mx-reply>World</mx-reply></em>!";
const output = [
new TextPart('Hello, '),
new TextPart("Hello, "),
new FormatPart("em", []),
new TextPart('!'),
new TextPart("!"),
];
assert.deepEqual(parseHTMLBody(platform, null, input), new MessageBody(input, output));
}
Expand Down
Loading