diff --git a/.eslintrc-module_system.js b/.eslintrc-module_system.js new file mode 100644 index 0000000000..cdf5cf64b5 --- /dev/null +++ b/.eslintrc-module_system.js @@ -0,0 +1,72 @@ +module.exports = { + plugins: ["matrix-org"], + extends: ["./.eslintrc.js"], + parserOptions: { + project: ["./tsconfig.module_system.json"], + }, + overrides: [ + { + files: ["module_system/**/*.{ts,tsx}"], + extends: ["plugin:matrix-org/typescript", "plugin:matrix-org/react"], + // NOTE: These rules are frozen and new rules should not be added here. + // New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/ + rules: { + // Things we do that break the ideal style + "prefer-promise-reject-errors": "off", + "quotes": "off", + + // We disable this while we're transitioning + "@typescript-eslint/no-explicit-any": "off", + // We're okay with assertion errors when we ask for them + "@typescript-eslint/no-non-null-assertion": "off", + + // Ban matrix-js-sdk/src imports in favour of matrix-js-sdk/src/matrix imports to prevent unleashing hell. + "no-restricted-imports": [ + "error", + { + paths: [ + { + name: "matrix-js-sdk", + message: "Please use matrix-js-sdk/src/matrix instead", + }, + { + name: "matrix-js-sdk/", + message: "Please use matrix-js-sdk/src/matrix instead", + }, + { + name: "matrix-js-sdk/src", + message: "Please use matrix-js-sdk/src/matrix instead", + }, + { + name: "matrix-js-sdk/src/", + message: "Please use matrix-js-sdk/src/matrix instead", + }, + { + name: "matrix-js-sdk/src/index", + message: "Please use matrix-js-sdk/src/matrix instead", + }, + { + name: "matrix-react-sdk", + message: "Please use matrix-react-sdk/src/index instead", + }, + { + name: "matrix-react-sdk/", + message: "Please use matrix-react-sdk/src/index instead", + }, + ], + patterns: [ + { + group: ["matrix-js-sdk/lib", "matrix-js-sdk/lib/", "matrix-js-sdk/lib/**"], + message: "Please use matrix-js-sdk/src/* instead", + }, + { + group: ["matrix-react-sdk/lib", "matrix-react-sdk/lib/", "matrix-react-sdk/lib/**"], + message: "Please use matrix-react-sdk/src/* instead", + }, + ], + }, + ], + }, + }, + ], +}; diff --git a/.eslintrc.js b/.eslintrc.js index 3e00c9ebaa..6fd40eb9f7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,9 @@ module.exports = { plugins: ["matrix-org"], extends: ["plugin:matrix-org/babel", "plugin:matrix-org/react"], + parserOptions: { + project: ["./tsconfig.json"], + }, env: { browser: true, node: true, @@ -16,7 +19,7 @@ module.exports = { }, overrides: [ { - files: ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}", "module_system/**/*.{ts,tsx}"], + files: ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}"], extends: ["plugin:matrix-org/typescript", "plugin:matrix-org/react"], // NOTE: These rules are frozen and new rules should not be added here. // New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/ diff --git a/package.json b/package.json index 1048151ee2..28b48fd25b 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,15 @@ "start:res": "yarn build:jitsi && node scripts/copy-res.js -w", "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", "lint": "yarn lint:types && yarn lint:js && yarn lint:style", - "lint:js": "eslint --max-warnings 0 src module_system test && prettier --check .", - "lint:js-fix": "prettier --write . && eslint --fix src module_system test", - "lint:types": "tsc --noEmit --jsx react && tsc --noEmit --project ./tsconfig.module_system.json", + "lint:js": "yarn lint:js:src && yarn lint:js:module_system", + "lint:js:src": "eslint --max-warnings 0 src test && prettier --check .", + "lint:js:module_system": "eslint --max-warnings 0 --config .eslintrc-module_system.js module_system", + "lint:js-fix": "yarn lint:js-fix:src && yarn lint:js-fix:module_system", + "lint:js-fix:src": "prettier --write . && eslint --fix src test", + "lint:js-fix:module_system": "eslint --fix --config .eslintrc-module_system.js module_system", + "lint:types": "yarn lint:types:src && yarn lint:types:module_system", + "lint:types:src": "tsc --noEmit --jsx react", + "lint:types:module_system": "tsc --noEmit --project ./tsconfig.module_system.json", "lint:style": "stylelint \"res/css/**/*.pcss\"", "test": "jest", "coverage": "yarn test --coverage", @@ -103,8 +109,8 @@ "@types/react-dom": "17.0.19", "@types/sanitize-html": "^2.3.1", "@types/ua-parser-js": "^0.7.36", - "@typescript-eslint/eslint-plugin": "^5.6.0", - "@typescript-eslint/parser": "^5.6.0", + "@typescript-eslint/eslint-plugin": "^5.45.0", + "@typescript-eslint/parser": "^5.45.0", "allchange": "^1.0.6", "babel-jest": "^29.0.0", "babel-loader": "^8.2.2", @@ -113,12 +119,12 @@ "cpx": "^1.5.0", "css-loader": "^4", "dotenv": "^16.0.2", - "eslint": "8.28.0", + "eslint": "8.33.0", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-deprecate": "^0.7.0", - "eslint-plugin-import": "^2.25.4", - "eslint-plugin-matrix-org": "^0.9.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-matrix-org": "^1.0.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-unicorn": "^45.0.0", diff --git a/test/test-utils.ts b/test/test-utils.ts index 84234ef34e..af9502ea52 100644 --- a/test/test-utils.ts +++ b/test/test-utils.ts @@ -34,7 +34,7 @@ export function deleteIndexedDB(dbName: string): Promise { }; req.onerror = (ev): void => { - reject(new Error(`${Date.now()}: unable to delete indexeddb ${dbName}: ${req.error}`)); + reject(new Error(`${Date.now()}: unable to delete indexeddb ${dbName}: ${req.error?.message}`)); }; req.onsuccess = (): void => { diff --git a/yarn.lock b/yarn.lock index ba7b19cca0..d47d47114b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1118,7 +1118,7 @@ dependencies: eslint-visitor-keys "^3.3.0" -"@eslint/eslintrc@^1.3.3": +"@eslint/eslintrc@^1.4.1": version "1.4.1" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e" integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA== @@ -1138,7 +1138,7 @@ resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== -"@humanwhocodes/config-array@^0.11.6": +"@humanwhocodes/config-array@^0.11.8": version "0.11.8" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== @@ -5019,7 +5019,7 @@ eslint-plugin-deprecate@^0.7.0: resolved "https://registry.yarnpkg.com/eslint-plugin-deprecate/-/eslint-plugin-deprecate-0.7.0.tgz#04805d2f2884800c580d59933b9c895f31b02437" integrity sha512-MylhCqoH/SJ2MwzVgX0we6oE+lKPVwhOu9hAJ98vMCmbz3FNwqJ8XipdI23bCF7NHxUbhd6mdxFjywKE52pt7A== -eslint-plugin-import@^2.25.4: +eslint-plugin-import@^2.26.0: version "2.27.5" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow== @@ -5040,10 +5040,10 @@ eslint-plugin-import@^2.25.4: semver "^6.3.0" tsconfig-paths "^3.14.1" -eslint-plugin-matrix-org@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-0.9.0.tgz#b2a5186052ddbfa7dc9878779bafa5d68681c7b4" - integrity sha512-+j6JuMnFH421Z2vOxc+0YMt5Su5vD76RSatviy3zHBaZpgd+sOeAWoCLBHD5E7mMz5oKae3Y3wewCt9LRzq2Nw== +eslint-plugin-matrix-org@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-1.0.0.tgz#cead71391e2a36d63cb8f8018a38305ecf81b4b8" + integrity sha512-JSjw+hswEcFR+N4N2JXZttK65cK6huykZKkbnwcITxPTelsaOfZ8qXG0Az9BfmVADaLgY3MGmHK1YYKbykUfBQ== eslint-plugin-react-hooks@^4.3.0: version "4.6.0" @@ -5139,13 +5139,13 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@8.28.0: - version "8.28.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.28.0.tgz#81a680732634677cc890134bcdd9fdfea8e63d6e" - integrity sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ== +eslint@8.33.0: + version "8.33.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.33.0.tgz#02f110f32998cb598c6461f24f4d306e41ca33d7" + integrity sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA== dependencies: - "@eslint/eslintrc" "^1.3.3" - "@humanwhocodes/config-array" "^0.11.6" + "@eslint/eslintrc" "^1.4.1" + "@humanwhocodes/config-array" "^0.11.8" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" @@ -5164,7 +5164,7 @@ eslint@8.28.0: file-entry-cache "^6.0.1" find-up "^5.0.0" glob-parent "^6.0.2" - globals "^13.15.0" + globals "^13.19.0" grapheme-splitter "^1.0.4" ignore "^5.2.0" import-fresh "^3.0.0" @@ -6064,7 +6064,7 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.15.0, globals@^13.19.0: +globals@^13.19.0: version "13.20.0" resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==