11module . exports = {
2- extends : [ "matrix-org" , "matrix-org/react-legacy" ] ,
3- parser : "babel-eslint" ,
4-
2+ plugins : [ "matrix-org" ] ,
3+ extends : [
4+ "plugin:matrix-org/babel" ,
5+ "plugin:matrix-org/react" ,
6+ ] ,
57 env : {
68 browser : true ,
79 node : true ,
@@ -15,20 +17,69 @@ module.exports = {
1517 "prefer-promise-reject-errors" : "off" ,
1618 "no-async-promise-executor" : "off" ,
1719 "quotes" : "off" ,
18- "indent" : "off" ,
19- } ,
20+ "no-extra-boolean-cast" : "off" ,
21+
22+ // Bind or arrow functions in props causes performance issues (but we
23+ // currently use them in some places).
24+ // It's disabled here, but we should using it sparingly.
25+ "react/jsx-no-bind" : "off" ,
26+ "react/jsx-key" : [ "error" ] ,
2027
28+ "no-restricted-properties" : [
29+ "error" ,
30+ ...buildRestrictedPropertiesOptions (
31+ [ "window.innerHeight" , "window.innerWidth" , "window.visualViewport" ] ,
32+ "Use UIStore to access window dimensions instead." ,
33+ ) ,
34+ ...buildRestrictedPropertiesOptions (
35+ [ "*.mxcUrlToHttp" , "*.getHttpUriForMxc" ] ,
36+ "Use Media helper instead to centralise access for customisation." ,
37+ ) ,
38+ ] ,
39+ } ,
2140 overrides : [ {
22- "files" : [ "src/**/*.{ts,tsx}" ] ,
23- "extends" : [ "matrix-org/ts" ] ,
24- "rules" : {
41+ files : [
42+ "src/**/*.{ts,tsx}" ,
43+ "test/**/*.{ts,tsx}" ,
44+ ] ,
45+ extends : [
46+ "plugin:matrix-org/typescript" ,
47+ "plugin:matrix-org/react" ,
48+ ] ,
49+ rules : {
50+ // Things we do that break the ideal style
51+ "prefer-promise-reject-errors" : "off" ,
52+ "quotes" : "off" ,
53+ "no-extra-boolean-cast" : "off" ,
54+
55+ // Remove Babel things manually due to override limitations
56+ "@babel/no-invalid-this" : [ "off" ] ,
57+
58+ // We're okay being explicit at the moment
59+ "@typescript-eslint/no-empty-interface" : "off" ,
2560 // We disable this while we're transitioning
2661 "@typescript-eslint/no-explicit-any" : "off" ,
2762 // We'd rather not do this but we do
2863 "@typescript-eslint/ban-ts-comment" : "off" ,
29-
30- "quotes" : "off" ,
31- "no-extra-boolean-cast" : "off" ,
3264 } ,
3365 } ] ,
66+ settings : {
67+ react : {
68+ version : "detect" ,
69+ }
70+ }
3471} ;
72+
73+ function buildRestrictedPropertiesOptions ( properties , message ) {
74+ return properties . map ( prop => {
75+ let [ object , property ] = prop . split ( "." ) ;
76+ if ( object === "*" ) {
77+ object = undefined ;
78+ }
79+ return {
80+ object,
81+ property,
82+ message,
83+ } ;
84+ } ) ;
85+ }
0 commit comments