module.exports = {
    plugins: ["matrix-org", "import"],
    extends: [
        "plugin:matrix-org/babel",
        "plugin:matrix-org/react",
    ],
    env: {
        browser: true,
        node: true,
    },
    globals: {
        LANGUAGES_FILE: "readonly",
    },
    rules: {
        // Things we do that break the ideal style
        "no-constant-condition": "off",
        "prefer-promise-reject-errors": "off",
        "no-async-promise-executor": "off",
        "quotes": "off",
        "no-extra-boolean-cast": "off",

        // Bind or arrow functions in props causes performance issues (but we
        // currently use them in some places).
        // It's disabled here, but we should using it sparingly.
        "react/jsx-no-bind": "off",
        "react/jsx-key": ["error"],

        "no-restricted-properties": [
            "error",
            ...buildRestrictedPropertiesOptions(
                ["window.innerHeight", "window.innerWidth", "window.visualViewport"],
                "Use UIStore to access window dimensions instead.",
            ),
            ...buildRestrictedPropertiesOptions(
                ["*.mxcUrlToHttp", "*.getHttpUriForMxc"],
                "Use Media helper instead to centralise access for customisation.",
            ),
        ],

        "import/order": [
            "error", {
                "groups": [["builtin", "external"], ["internal", "parent", "sibling", "index", "object", "type"]],
                "newlines-between": "always",
            },
        ],
        "import/first": "error",
    },
    overrides: [{
        files: [
            "src/**/*.{ts,tsx}",
            "test/**/*.{ts,tsx}",
        ],
        extends: [
            "plugin:matrix-org/typescript",
            "plugin:matrix-org/react",
        ],
        rules: {
            // Things we do that break the ideal style
            "prefer-promise-reject-errors": "off",
            "quotes": "off",
            "no-extra-boolean-cast": "off",

            // Remove Babel things manually due to override limitations
            "@babel/no-invalid-this": ["off"],

            // We're okay being explicit at the moment
            "@typescript-eslint/no-empty-interface": "off",
            // We disable this while we're transitioning
            "@typescript-eslint/no-explicit-any": "off",
            // We'd rather not do this but we do
            "@typescript-eslint/ban-ts-comment": "off",
        },
    }],
    settings: {
        react: {
            version: "detect",
        },
    },
};

function buildRestrictedPropertiesOptions(properties, message) {
    return properties.map(prop => {
        let [object, property] = prop.split(".");
        if (object === "*") {
            object = undefined;
        }
        return {
            object,
            property,
            message,
        };
    });
}

@@ -42,18 +42,8 @@
 org%22
-, %22import%22
 %5D,%0A 
@@ -1273,278 +1273,8 @@
   %5D,
-%0A%0A        %22import/order%22: %5B%0A            %22error%22, %7B%0A                %22groups%22: %5B%5B%22builtin%22, %22external%22%5D, %5B%22internal%22, %22parent%22, %22sibling%22, %22index%22, %22object%22, %22type%22%5D%5D,%0A                %22newlines-between%22: %22always%22,%0A            %7D,%0A        %5D,%0A        %22import/first%22: %22error%22,
 %0A   

Remove import rules from .eslintrc.js