Skip to content

Commit 3903e86

Browse files
authored
Upgrade our eslint config to the latest (element-hq#24647)
* Fix lint error in test-utils.ts * Upgrade eslint config (and separate projects to support it) * Handle possibility that req.error could be null
1 parent 460f3d2 commit 3903e86

File tree

5 files changed

+106
-25
lines changed

5 files changed

+106
-25
lines changed

.eslintrc-module_system.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
module.exports = {
2+
plugins: ["matrix-org"],
3+
extends: ["./.eslintrc.js"],
4+
parserOptions: {
5+
project: ["./tsconfig.module_system.json"],
6+
},
7+
overrides: [
8+
{
9+
files: ["module_system/**/*.{ts,tsx}"],
10+
extends: ["plugin:matrix-org/typescript", "plugin:matrix-org/react"],
11+
// NOTE: These rules are frozen and new rules should not be added here.
12+
// New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/
13+
rules: {
14+
// Things we do that break the ideal style
15+
"prefer-promise-reject-errors": "off",
16+
"quotes": "off",
17+
18+
// We disable this while we're transitioning
19+
"@typescript-eslint/no-explicit-any": "off",
20+
// We're okay with assertion errors when we ask for them
21+
"@typescript-eslint/no-non-null-assertion": "off",
22+
23+
// Ban matrix-js-sdk/src imports in favour of matrix-js-sdk/src/matrix imports to prevent unleashing hell.
24+
"no-restricted-imports": [
25+
"error",
26+
{
27+
paths: [
28+
{
29+
name: "matrix-js-sdk",
30+
message: "Please use matrix-js-sdk/src/matrix instead",
31+
},
32+
{
33+
name: "matrix-js-sdk/",
34+
message: "Please use matrix-js-sdk/src/matrix instead",
35+
},
36+
{
37+
name: "matrix-js-sdk/src",
38+
message: "Please use matrix-js-sdk/src/matrix instead",
39+
},
40+
{
41+
name: "matrix-js-sdk/src/",
42+
message: "Please use matrix-js-sdk/src/matrix instead",
43+
},
44+
{
45+
name: "matrix-js-sdk/src/index",
46+
message: "Please use matrix-js-sdk/src/matrix instead",
47+
},
48+
{
49+
name: "matrix-react-sdk",
50+
message: "Please use matrix-react-sdk/src/index instead",
51+
},
52+
{
53+
name: "matrix-react-sdk/",
54+
message: "Please use matrix-react-sdk/src/index instead",
55+
},
56+
],
57+
patterns: [
58+
{
59+
group: ["matrix-js-sdk/lib", "matrix-js-sdk/lib/", "matrix-js-sdk/lib/**"],
60+
message: "Please use matrix-js-sdk/src/* instead",
61+
},
62+
{
63+
group: ["matrix-react-sdk/lib", "matrix-react-sdk/lib/", "matrix-react-sdk/lib/**"],
64+
message: "Please use matrix-react-sdk/src/* instead",
65+
},
66+
],
67+
},
68+
],
69+
},
70+
},
71+
],
72+
};

.eslintrc.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
22
plugins: ["matrix-org"],
33
extends: ["plugin:matrix-org/babel", "plugin:matrix-org/react"],
4+
parserOptions: {
5+
project: ["./tsconfig.json"],
6+
},
47
env: {
58
browser: true,
69
node: true,
@@ -16,7 +19,7 @@ module.exports = {
1619
},
1720
overrides: [
1821
{
19-
files: ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}", "module_system/**/*.{ts,tsx}"],
22+
files: ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}"],
2023
extends: ["plugin:matrix-org/typescript", "plugin:matrix-org/react"],
2124
// NOTE: These rules are frozen and new rules should not be added here.
2225
// New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/

package.json

+14-8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@
4646
"start:res": "yarn build:jitsi && node scripts/copy-res.js -w",
4747
"start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot",
4848
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
49-
"lint:js": "eslint --max-warnings 0 src module_system test && prettier --check .",
50-
"lint:js-fix": "prettier --write . && eslint --fix src module_system test",
51-
"lint:types": "tsc --noEmit --jsx react && tsc --noEmit --project ./tsconfig.module_system.json",
49+
"lint:js": "yarn lint:js:src && yarn lint:js:module_system",
50+
"lint:js:src": "eslint --max-warnings 0 src test && prettier --check .",
51+
"lint:js:module_system": "eslint --max-warnings 0 --config .eslintrc-module_system.js module_system",
52+
"lint:js-fix": "yarn lint:js-fix:src && yarn lint:js-fix:module_system",
53+
"lint:js-fix:src": "prettier --write . && eslint --fix src test",
54+
"lint:js-fix:module_system": "eslint --fix --config .eslintrc-module_system.js module_system",
55+
"lint:types": "yarn lint:types:src && yarn lint:types:module_system",
56+
"lint:types:src": "tsc --noEmit --jsx react",
57+
"lint:types:module_system": "tsc --noEmit --project ./tsconfig.module_system.json",
5258
"lint:style": "stylelint \"res/css/**/*.pcss\"",
5359
"test": "jest",
5460
"coverage": "yarn test --coverage",
@@ -103,8 +109,8 @@
103109
"@types/react-dom": "17.0.19",
104110
"@types/sanitize-html": "^2.3.1",
105111
"@types/ua-parser-js": "^0.7.36",
106-
"@typescript-eslint/eslint-plugin": "^5.6.0",
107-
"@typescript-eslint/parser": "^5.6.0",
112+
"@typescript-eslint/eslint-plugin": "^5.45.0",
113+
"@typescript-eslint/parser": "^5.45.0",
108114
"allchange": "^1.0.6",
109115
"babel-jest": "^29.0.0",
110116
"babel-loader": "^8.2.2",
@@ -113,12 +119,12 @@
113119
"cpx": "^1.5.0",
114120
"css-loader": "^4",
115121
"dotenv": "^16.0.2",
116-
"eslint": "8.28.0",
122+
"eslint": "8.33.0",
117123
"eslint-config-google": "^0.14.0",
118124
"eslint-config-prettier": "^8.5.0",
119125
"eslint-plugin-deprecate": "^0.7.0",
120-
"eslint-plugin-import": "^2.25.4",
121-
"eslint-plugin-matrix-org": "^0.9.0",
126+
"eslint-plugin-import": "^2.26.0",
127+
"eslint-plugin-matrix-org": "^1.0.0",
122128
"eslint-plugin-react": "^7.28.0",
123129
"eslint-plugin-react-hooks": "^4.3.0",
124130
"eslint-plugin-unicorn": "^45.0.0",

test/test-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function deleteIndexedDB(dbName: string): Promise<void> {
3434
};
3535

3636
req.onerror = (ev): void => {
37-
reject(new Error(`${Date.now()}: unable to delete indexeddb ${dbName}: ${req.error}`));
37+
reject(new Error(`${Date.now()}: unable to delete indexeddb ${dbName}: ${req.error?.message}`));
3838
};
3939

4040
req.onsuccess = (): void => {

yarn.lock

+15-15
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@
11181118
dependencies:
11191119
eslint-visitor-keys "^3.3.0"
11201120

1121-
"@eslint/eslintrc@^1.3.3":
1121+
"@eslint/eslintrc@^1.4.1":
11221122
version "1.4.1"
11231123
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e"
11241124
integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==
@@ -1138,7 +1138,7 @@
11381138
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
11391139
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==
11401140

1141-
"@humanwhocodes/config-array@^0.11.6":
1141+
"@humanwhocodes/config-array@^0.11.8":
11421142
version "0.11.8"
11431143
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9"
11441144
integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==
@@ -5019,7 +5019,7 @@ eslint-plugin-deprecate@^0.7.0:
50195019
resolved "https://registry.yarnpkg.com/eslint-plugin-deprecate/-/eslint-plugin-deprecate-0.7.0.tgz#04805d2f2884800c580d59933b9c895f31b02437"
50205020
integrity sha512-MylhCqoH/SJ2MwzVgX0we6oE+lKPVwhOu9hAJ98vMCmbz3FNwqJ8XipdI23bCF7NHxUbhd6mdxFjywKE52pt7A==
50215021

5022-
eslint-plugin-import@^2.25.4:
5022+
eslint-plugin-import@^2.26.0:
50235023
version "2.27.5"
50245024
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65"
50255025
integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==
@@ -5040,10 +5040,10 @@ eslint-plugin-import@^2.25.4:
50405040
semver "^6.3.0"
50415041
tsconfig-paths "^3.14.1"
50425042

5043-
eslint-plugin-matrix-org@^0.9.0:
5044-
version "0.9.0"
5045-
resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-0.9.0.tgz#b2a5186052ddbfa7dc9878779bafa5d68681c7b4"
5046-
integrity sha512-+j6JuMnFH421Z2vOxc+0YMt5Su5vD76RSatviy3zHBaZpgd+sOeAWoCLBHD5E7mMz5oKae3Y3wewCt9LRzq2Nw==
5043+
eslint-plugin-matrix-org@^1.0.0:
5044+
version "1.0.0"
5045+
resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-1.0.0.tgz#cead71391e2a36d63cb8f8018a38305ecf81b4b8"
5046+
integrity sha512-JSjw+hswEcFR+N4N2JXZttK65cK6huykZKkbnwcITxPTelsaOfZ8qXG0Az9BfmVADaLgY3MGmHK1YYKbykUfBQ==
50475047

50485048
eslint-plugin-react-hooks@^4.3.0:
50495049
version "4.6.0"
@@ -5139,13 +5139,13 @@ eslint-visitor-keys@^3.3.0:
51395139
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
51405140
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
51415141

5142-
eslint@8.28.0:
5143-
version "8.28.0"
5144-
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.28.0.tgz#81a680732634677cc890134bcdd9fdfea8e63d6e"
5145-
integrity sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==
5142+
eslint@8.33.0:
5143+
version "8.33.0"
5144+
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.33.0.tgz#02f110f32998cb598c6461f24f4d306e41ca33d7"
5145+
integrity sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA==
51465146
dependencies:
5147-
"@eslint/eslintrc" "^1.3.3"
5148-
"@humanwhocodes/config-array" "^0.11.6"
5147+
"@eslint/eslintrc" "^1.4.1"
5148+
"@humanwhocodes/config-array" "^0.11.8"
51495149
"@humanwhocodes/module-importer" "^1.0.1"
51505150
"@nodelib/fs.walk" "^1.2.8"
51515151
ajv "^6.10.0"
@@ -5164,7 +5164,7 @@ [email protected]:
51645164
file-entry-cache "^6.0.1"
51655165
find-up "^5.0.0"
51665166
glob-parent "^6.0.2"
5167-
globals "^13.15.0"
5167+
globals "^13.19.0"
51685168
grapheme-splitter "^1.0.4"
51695169
ignore "^5.2.0"
51705170
import-fresh "^3.0.0"
@@ -6064,7 +6064,7 @@ globals@^11.1.0:
60646064
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
60656065
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
60666066

6067-
globals@^13.15.0, globals@^13.19.0:
6067+
globals@^13.19.0:
60686068
version "13.20.0"
60696069
resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82"
60706070
integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==

0 commit comments

Comments
 (0)