{
    "root": true,
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "script"
    },
    "env": {
        "browser": true,
        "es2017": true,
        "webextensions": true
    },
    "plugins": ["no-unsanitized"],
    "ignorePatterns": [
        "/ext/mixed/lib/",
        "/ext/bg/js/templates.js"
    ],
    "rules": {
        "arrow-parens": ["error", "always"],
        "comma-dangle": ["error", "never"],
        "curly": ["error", "all"],
        "dot-notation": "error",
        "eqeqeq": "error",
        "func-names": ["error", "always"],
        "guard-for-in": "error",
        "new-parens": "error",
        "no-case-declarations": "error",
        "no-const-assign": "error",
        "no-constant-condition": "off",
        "no-global-assign": "error",
        "no-param-reassign": "off",
        "no-prototype-builtins": "error",
        "no-shadow": ["error", {"builtinGlobals": false}],
        "no-undef": "error",
        "no-undefined": "error",
        "no-underscore-dangle": ["error", {"allowAfterThis": true, "allowAfterSuper": false, "allowAfterThisConstructor": false}],
        "no-unexpected-multiline": "error",
        "no-unneeded-ternary": "error",
        "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}],
        "no-unused-expressions": "error",
        "no-var": "error",
        "prefer-const": ["error", {"destructuring": "all"}],
        "quote-props": ["error", "consistent"],
        "quotes": ["error", "single", "avoid-escape"],
        "require-atomic-updates": "off",
        "semi": "error",
        "wrap-iife": ["error", "inside"],

        "brace-style": ["error", "1tbs", {"allowSingleLine": true}],
        "indent": ["error", 4, {"SwitchCase": 1, "MemberExpression": 1, "flatTernaryExpressions": true, "ignoredNodes": ["ConditionalExpression"]}],
        "object-curly-newline": "error",
        "padded-blocks": ["error", "never"],

        "array-bracket-spacing": ["error", "never"],
        "arrow-spacing": ["error", {"before": true, "after": true}],
        "block-spacing": ["error", "always"],
        "comma-spacing": ["error", { "before": false, "after": true }],
        "computed-property-spacing": ["error", "never"],
        "func-call-spacing": ["error", "never"],
        "function-paren-newline": ["error", "multiline-arguments"],
        "generator-star-spacing": ["error", "before"],
        "key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "strict"}],
        "keyword-spacing": ["error", {"before": true, "after": true}],
        "no-trailing-spaces": "error",
        "no-whitespace-before-property": "error",
        "object-curly-spacing": ["error", "never"],
        "rest-spread-spacing": ["error", "never"],
        "semi-spacing": ["error", {"before": false, "after": true}],
        "space-before-function-paren": ["error", {
            "anonymous": "never",
            "named": "never",
            "asyncArrow": "always"
        }],
        "space-in-parens": ["error", "never"],
        "space-unary-ops": "error",
        "spaced-comment": ["error", "always"],
        "switch-colon-spacing": ["error", {"after": true, "before": false}],
        "template-curly-spacing": ["error", "never"],
        "template-tag-spacing": ["error", "never"],

        "no-unsanitized/method": "error",
        "no-unsanitized/property": "error"
    },
    "overrides": [
        {
            "files": [
                "ext/mixed/js/core.js",
                "ext/bg/js/template-renderer.js",
                "ext/mixed/js/dictionary-data-util.js"
            ],
            "env": {
                "webextensions": false
            }
        },
        {
            "files": ["ext/**/*.js"],
            "excludedFiles": [
                "ext/mixed/js/core.js",
                "ext/bg/js/template-renderer.js",
                "ext/bg/js/anki-note-data.js",
                "ext/mixed/js/dictionary-data-util.js"
            ],
            "globals": {
                "serializeError": "readonly",
                "deserializeError": "readonly",
                "isObject": "readonly",
                "stringReverse": "readonly",
                "promiseTimeout": "readonly",
                "escapeRegExp": "readonly",
                "deferPromise": "readonly",
                "clone": "readonly",
                "deepEqual": "readonly",
                "generateId": "readonly",
                "promiseAnimationFrame": "readonly",
                "DynamicProperty": "readonly",
                "EventDispatcher": "readonly",
                "EventListenerCollection": "readonly"
            }
        },
        {
            "files": ["ext/**/*.js"],
            "excludedFiles": [
                "ext/mixed/js/core.js",
                "ext/mixed/js/yomichan.js"
            ],
            "globals": {
                "yomichan": "readonly"
            }
        },
        {
            "files": ["ext/mixed/js/yomichan.js"],
            "globals": {
                "chrome": "writable"
            }
        },
        {
            "files": ["ext/bg/js/settings/*.js"],
            "env": {
                "jquery": true
            }
        },
        {
            "files": [
                "test/**/*.js",
                "dev/**/*.js"
            ],
            "excludedFiles": ["test/data/html/*.js"],
            "parserOptions": {
                "ecmaVersion": 8,
                "sourceType": "module"
            },
            "env": {
                "browser": false,
                "es2017": true,
                "node": true,
                "webextensions": false
            }
        },
        {
            "files": [
                "ext/mixed/js/core.js",
                "ext/mixed/js/yomichan.js",
                "ext/mixed/js/environment.js",
                "ext/mixed/js/japanese.js",
                "ext/mixed/js/cache-map.js",
                "ext/mixed/js/dictionary-data-util.js",
                "ext/mixed/js/object-property-accessor.js",
                "ext/bg/js/anki.js",
                "ext/bg/js/audio-downloader.js",
                "ext/bg/js/clipboard-monitor.js",
                "ext/bg/js/clipboard-reader.js",
                "ext/bg/js/database.js",
                "ext/bg/js/deinflector.js",
                "ext/bg/js/dictionary-database.js",
                "ext/bg/js/json-schema.js",
                "ext/bg/js/mecab.js",
                "ext/bg/js/media-utility.js",
                "ext/bg/js/options.js",
                "ext/bg/js/profile-conditions.js",
                "ext/bg/js/request-builder.js",
                "ext/bg/js/simple-dom-parser.js",
                "ext/bg/js/template-patcher.js",
                "ext/bg/js/text-source-map.js",
                "ext/bg/js/translator.js",
                "ext/bg/js/backend.js",
                "ext/bg/js/background-main.js"
            ],
            "env": {
                "browser": false,
                "serviceworker": true,
                "es2017": true,
                "webextensions": true
            },
            "globals": {
                "FileReader": "readonly",
                "Intl": "readonly",
                "crypto": "readonly"
            }
        }
    ]
}