1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Migrate to eslint-plugin-matrix-org

This migrates to the new plugin form of our custom ESLint configs. As part of
this, some packages are de-duplicated, configs streamlined, etc.
This commit is contained in:
J. Ryan Stinnett
2021-03-12 16:31:11 +00:00
parent c5fb351baa
commit 102704e91a
8 changed files with 158 additions and 734 deletions

View File

@@ -1,13 +1,12 @@
module.exports = { module.exports = {
extends: ["matrix-org"],
plugins: [ plugins: [
"babel", "matrix-org",
], ],
extends: ["plugin:matrix-org/javascript"],
env: { env: {
browser: true, browser: true,
node: true, node: true,
}, },
rules: { rules: {
"no-var": ["warn"], "no-var": ["warn"],
"prefer-rest-params": ["warn"], "prefer-rest-params": ["warn"],
@@ -33,7 +32,7 @@ module.exports = {
}, },
overrides: [{ overrides: [{
"files": ["src/**/*.ts"], "files": ["src/**/*.ts"],
"extends": ["matrix-org/ts"], "extends": ["plugin:matrix-org/typescript"],
"rules": { "rules": {
// We're okay being explicit at the moment // We're okay being explicit at the moment
"@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-empty-interface": "off",

View File

@@ -61,6 +61,8 @@
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.12.10", "@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/eslint-parser": "^7.12.10",
"@babel/eslint-plugin": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1", "@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.7", "@babel/plugin-proposal-numeric-separator": "^7.12.7",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1", "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
@@ -72,15 +74,16 @@
"@types/jest": "^26.0.20", "@types/jest": "^26.0.20",
"@types/node": "12", "@types/node": "12",
"@types/request": "^2.48.5", "@types/request": "^2.48.5",
"babel-eslint": "^10.1.0", "@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"babel-jest": "^26.6.3", "babel-jest": "^26.6.3",
"babelify": "^10.0.0", "babelify": "^10.0.0",
"better-docs": "^2.3.2", "better-docs": "^2.3.2",
"browserify": "^17.0.0", "browserify": "^17.0.0",
"docdash": "^1.2.0", "docdash": "^1.2.0",
"eslint": "7.18.0", "eslint": "7.18.0",
"eslint-config-matrix-org": "^0.2.0", "eslint-config-google": "^0.14.0",
"eslint-plugin-babel": "^5.3.1", "eslint-plugin-matrix-org": "github:matrix-org/eslint-plugin-matrix-org#main",
"exorcist": "^1.0.1", "exorcist": "^1.0.1",
"fake-indexeddb": "^3.1.2", "fake-indexeddb": "^3.1.2",
"jest": "^26.6.3", "jest": "^26.6.3",

View File

@@ -30,7 +30,7 @@ export async function makeTestClients(userInfos, options) {
for (const [deviceId, msg] of Object.entries(devMap)) { for (const [deviceId, msg] of Object.entries(devMap)) {
if (deviceId in clientMap[userId]) { if (deviceId in clientMap[userId]) {
const event = new MatrixEvent({ const event = new MatrixEvent({
sender: this.getUserId(), // eslint-disable-line babel/no-invalid-this sender: this.getUserId(), // eslint-disable-line @babel/no-invalid-this
type: type, type: type,
content: msg, content: msg,
}); });
@@ -49,9 +49,9 @@ export async function makeTestClients(userInfos, options) {
}; };
const sendEvent = function(room, type, content) { const sendEvent = function(room, type, content) {
// make up a unique ID as the event ID // make up a unique ID as the event ID
const eventId = "$" + this.makeTxnId(); // eslint-disable-line babel/no-invalid-this const eventId = "$" + this.makeTxnId(); // eslint-disable-line @babel/no-invalid-this
const rawEvent = { const rawEvent = {
sender: this.getUserId(), // eslint-disable-line babel/no-invalid-this sender: this.getUserId(), // eslint-disable-line @babel/no-invalid-this
type: type, type: type,
content: content, content: content,
room_id: room, room_id: room,
@@ -61,13 +61,13 @@ export async function makeTestClients(userInfos, options) {
const event = new MatrixEvent(rawEvent); const event = new MatrixEvent(rawEvent);
const remoteEcho = new MatrixEvent(Object.assign({}, rawEvent, { const remoteEcho = new MatrixEvent(Object.assign({}, rawEvent, {
unsigned: { unsigned: {
transaction_id: this.makeTxnId(), // eslint-disable-line babel/no-invalid-this transaction_id: this.makeTxnId(), // eslint-disable-line @babel/no-invalid-this
}, },
})); }));
setImmediate(() => { setImmediate(() => {
for (const tc of clients) { for (const tc of clients) {
if (tc.client === this) { // eslint-disable-line babel/no-invalid-this if (tc.client === this) { // eslint-disable-line @babel/no-invalid-this
logger.log("sending remote echo!!"); logger.log("sending remote echo!!");
tc.client.emit("Room.timeline", remoteEcho); tc.client.emit("Room.timeline", remoteEcho);
} else { } else {

View File

@@ -46,8 +46,8 @@ describe("realtime-callbacks", function() {
it("should set 'this' to the global object", function() { it("should set 'this' to the global object", function() {
let passed = false; let passed = false;
const callback = function() { const callback = function() {
expect(this).toBe(global); // eslint-disable-line babel/no-invalid-this expect(this).toBe(global); // eslint-disable-line @babel/no-invalid-this
expect(this.console).toBeTruthy(); // eslint-disable-line babel/no-invalid-this expect(this.console).toBeTruthy(); // eslint-disable-line @babel/no-invalid-this
passed = true; passed = true;
}; };
callbacks.setTimeout(callback); callbacks.setTimeout(callback);

View File

@@ -36,11 +36,11 @@ const DEFAULT_NAMESPACE = "matrix";
// when logging so we always get the current value of console methods. // when logging so we always get the current value of console methods.
log.methodFactory = function(methodName, logLevel, loggerName) { log.methodFactory = function(methodName, logLevel, loggerName) {
return function(...args) { return function(...args) {
/* eslint-disable babel/no-invalid-this */ /* eslint-disable @babel/no-invalid-this */
if (this.prefix) { if (this.prefix) {
args.unshift(this.prefix); args.unshift(this.prefix);
} }
/* eslint-enable babel/no-invalid-this */ /* eslint-enable @babel/no-invalid-this */
const supportedByConsole = methodName === "error" || const supportedByConsole = methodName === "error" ||
methodName === "warn" || methodName === "warn" ||
methodName === "trace" || methodName === "trace" ||

View File

@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/* eslint-disable babel/no-invalid-this */ /* eslint-disable @babel/no-invalid-this */
import {MemoryStore} from "./memory"; import {MemoryStore} from "./memory";
import * as utils from "../utils"; import * as utils from "../utils";

View File

@@ -206,9 +206,9 @@ export function getDesktopCapturerSources(): Promise<Array<DesktopCapturerSource
} }
export class CallError extends Error { export class CallError extends Error {
code : string; code: string;
constructor(code : CallErrorCode, msg: string, err: Error) { constructor(code: CallErrorCode, msg: string, err: Error) {
// Stil ldon't think there's any way to have proper nested errors // Stil ldon't think there's any way to have proper nested errors
super(msg + ": " + err); super(msg + ": " + err);
@@ -450,7 +450,7 @@ export class MatrixCall extends EventEmitter {
* video will be rendered to it immediately. * video will be rendered to it immediately.
* @param {Element} element The <code>&lt;video&gt;</code> DOM element. * @param {Element} element The <code>&lt;video&gt;</code> DOM element.
*/ */
public async setLocalVideoElement(element : HTMLVideoElement) { public async setLocalVideoElement(element: HTMLVideoElement) {
this.localVideoElement = element; this.localVideoElement = element;
if (element && this.localAVStream && this.type === CallType.Video) { if (element && this.localAVStream && this.type === CallType.Video) {
@@ -471,7 +471,7 @@ export class MatrixCall extends EventEmitter {
* the first received video-capable stream will be rendered to it immediately. * the first received video-capable stream will be rendered to it immediately.
* @param {Element} element The <code>&lt;video&gt;</code> DOM element. * @param {Element} element The <code>&lt;video&gt;</code> DOM element.
*/ */
public setRemoteVideoElement(element : HTMLVideoElement) { public setRemoteVideoElement(element: HTMLVideoElement) {
if (element === this.remoteVideoElement) return; if (element === this.remoteVideoElement) return;
element.autoplay = true; element.autoplay = true;
@@ -1199,7 +1199,7 @@ export class MatrixCall extends EventEmitter {
} }
} }
private callHasEnded() : boolean { private callHasEnded(): boolean {
// This exists as workaround to typescript trying to be clever and erroring // This exists as workaround to typescript trying to be clever and erroring
// when putting if (this.state === CallState.Ended) return; twice in the same // when putting if (this.state === CallState.Ended) return; twice in the same
// function, even though that function is async. // function, even though that function is async.

846
yarn.lock

File diff suppressed because it is too large Load Diff