Skip to content

Commit ae8ba13

Browse files
authored
Merge pull request element-hq#14673 from vector-im/joriks/eslint-config
Configure eslint package and fix lint issues
2 parents 6c50aa1 + 9bb1f99 commit ae8ba13

File tree

9 files changed

+634
-112
lines changed

9 files changed

+634
-112
lines changed

.eslintrc.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
module.exports = {
2-
extends: ["./node_modules/matrix-react-sdk/.eslintrc.js"],
2+
"extends": ["matrix-org", "matrix-org/react"],
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
},
7+
"rules": {
8+
"quotes": "off",
9+
},
10+
"overrides": [{
11+
"files": ["src/**/*.{ts, tsx}"],
12+
"extends": ["matrix-org/ts", "matrix-org/react"],
13+
"env": {
14+
"browser": true,
15+
},
16+
"rules": {
17+
"quotes": "off",
18+
// While converting to ts we allow this
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"prefer-promise-reject-errors": "off",
21+
},
22+
}],
323
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@
4949
"start": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n reskindex,reskindex-react,res,riot-js \"yarn reskindex:watch\" \"yarn reskindex:watch-react\" \"yarn start:res\" \"yarn start:js\"",
5050
"start:res": "yarn build:jitsi && node scripts/copy-res.js -w",
5151
"start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --progress --mode development",
52-
"lint": "yarn lint:types && yarn lint:ts && yarn lint:js && yarn lint:style",
52+
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
5353
"lint:js": "eslint src",
54-
"lint:ts": "echo 'We don't actually have a typescript linter at this layer because tslint is being removed from our stack. Presumably your TS is fine.'",
5554
"lint:types": "tsc --noEmit --jsx react",
5655
"lint:style": "stylelint 'res/css/**/*.scss'",
5756
"test": "jest"
@@ -101,8 +100,9 @@
101100
"concurrently": "^4.0.1",
102101
"cpx": "^1.3.2",
103102
"css-loader": "^3.3.2",
104-
"eslint": "^5.8.0",
103+
"eslint": "7.3.1",
105104
"eslint-config-google": "^0.7.1",
105+
"eslint-config-matrix-org": "^0.1.2",
106106
"eslint-plugin-babel": "^4.1.2",
107107
"eslint-plugin-flowtype": "^2.50.3",
108108
"eslint-plugin-jest": "^23.0.4",

src/components/structures/VectorEmbeddedPage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default class VectorEmbeddedPage extends EmbeddedPage {
2929
translate(s) {
3030
s = sanitizeHtml(_t(s));
3131
// ugly fix for https://github.com/vector-im/riot-web/issues/4243
32+
// eslint-disable-next-line max-len
3233
s = s.replace(/\[matrix\]/, '<a href="https://matrix.org" target="_blank" rel="noreferrer noopener"><img width="79" height="34" alt="[matrix]" style="padding-left: 1px;vertical-align: middle" src="welcome/images/matrix.svg"/></a>');
3334
return s;
3435
}

src/favicon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class Favicon {
5252
private context: CanvasRenderingContext2D;
5353
private icons: HTMLLinkElement[];
5454

55-
private isReady: boolean = false;
55+
private isReady = false;
5656
// callback to run once isReady is asserted, allows for a badge to be queued for when it can be shown
5757
private readyCb = () => {};
5858

src/vector/getconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import request from 'browser-request';
1818

1919
// Load the config file. First try to load up a domain-specific config of the
2020
// form "config.$domain.json" and if that fails, fall back to config.json.
21-
export async function getVectorConfig(relativeLocation: string='') {
21+
export async function getVectorConfig(relativeLocation='') {
2222
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
2323

2424
const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`);

src/vector/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ async function start() {
175175
if (error.err && error.err instanceof SyntaxError) {
176176
// This uses the default brand since the app config is unavailable.
177177
return showError(_t("Your Element is misconfigured"), [
178-
_t("Your Element configuration contains invalid JSON. Please correct the problem and reload the page."),
179-
_t("The message from the parser is: %(message)s", { message: error.err.message || _t("Invalid JSON")}),
178+
_t("Your Element configuration contains invalid JSON. " +
179+
"Please correct the problem and reload the page."),
180+
_t(
181+
"The message from the parser is: %(message)s",
182+
{ message: error.err.message || _t("Invalid JSON") },
183+
),
180184
]);
181185
}
182186
return showError(_t("Unable to load config file: please refresh the page to try again."));
@@ -210,6 +214,7 @@ start().catch(err => {
210214
// with some basic styling to make the iframe full page
211215
delete document.body.style.height;
212216
const iframe = document.createElement("iframe");
217+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
213218
// @ts-ignore - typescript seems to only like the IE syntax for iframe sandboxing
214219
iframe["sandbox"] = "";
215220
iframe.src = supportedBrowser ? "static/unable-to-load.html" : "static/incompatible-browser.html";

src/vector/jitsi/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Capability, WidgetApi } from "matrix-react-sdk/src/widgets/WidgetApi";
2323
// Dev note: we use raw JS without many dependencies to reduce bundle size.
2424
// We do not need all of React to render a Jitsi conference.
2525

26-
declare var JitsiMeetExternalAPI: any;
26+
declare let JitsiMeetExternalAPI: any;
2727

2828
let inConference = false;
2929

@@ -36,7 +36,7 @@ let userId: string;
3636

3737
let widgetApi: WidgetApi;
3838

39-
(async function () {
39+
(async function() {
4040
try {
4141
// The widget's options are encoded into the fragment to avoid leaking info to the server. The widget
4242
// spec on the other hand requires the widgetId and parentUrl to show up in the regular query string.

src/vector/mobile_guide/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function renderConfigError(message) {
2929
async function initPage() {
3030
document.getElementById('back_to_element_button').onclick = onBackToElementClick;
3131

32-
let config = await getVectorConfig('..');
32+
const config = await getVectorConfig('..');
3333

3434
// We manually parse the config similar to how validateServerConfig works because
3535
// calling that function pulls in roughly 4mb of JS we don't use.

0 commit comments

Comments
 (0)