{
  "env": {
    "browser": true,
    "es2021": true,
    "node": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": [
      "demo/tsconfig.json",
      "src/browser/tsconfig.json",
      "src/common/tsconfig.json",
      "src/headless/tsconfig.json",
      "test/api/tsconfig.json",
      "test/benchmark/tsconfig.json",
      "test/playwright/tsconfig.json",
      "addons/addon-attach/src/tsconfig.json",
      "addons/addon-attach/test/tsconfig.json",
      "addons/addon-canvas/src/tsconfig.json",
      "addons/addon-canvas/test/tsconfig.json",
      "addons/addon-fit/src/tsconfig.json",
      "addons/addon-fit/test/tsconfig.json",
      "addons/addon-image/src/tsconfig.json",
      "addons/addon-image/test/tsconfig.json",
      "addons/addon-ligatures/src/tsconfig.json",
      "addons/addon-search/src/tsconfig.json",
      "addons/addon-search/test/tsconfig.json",
      "addons/addon-serialize/src/tsconfig.json",
      "addons/addon-serialize/test/tsconfig.json",
      "addons/addon-serialize/benchmark/tsconfig.json",
      "addons/addon-unicode11/src/tsconfig.json",
      "addons/addon-unicode11/test/tsconfig.json",
      "addons/addon-unicode-graphemes/src/tsconfig.json",
      "addons/addon-unicode-graphemes/test/tsconfig.json",
      "addons/addon-unicode-graphemes/benchmark/tsconfig.json",
      "addons/addon-web-links/src/tsconfig.json",
      "addons/addon-web-links/test/tsconfig.json",
      "addons/addon-webgl/src/tsconfig.json",
      "addons/addon-webgl/test/tsconfig.json"
    ],
    "sourceType": "module"
  },
  "ignorePatterns": [
    "addons/*/src/third-party/*.ts",
    "out/*",
    "out-test/*",
    "**/inwasm-sdks/*",
    "**/typings/*.d.ts",
    "**/node_modules",
    "**/*.js"
  ],
  "plugins": [
    "@typescript-eslint",
    "jsdoc"
  ],
  "rules": {
    "no-extra-semi": "error",
    "@typescript-eslint/array-type": [
      "warn",
      {
        "default": "array",
        "readonly": "generic"
      }
    ],
    "@typescript-eslint/consistent-type-assertions": "warn",
    "@typescript-eslint/consistent-type-definitions": "warn",
    "@typescript-eslint/explicit-function-return-type": [
      "warn",
      {
        "allowExpressions": true
      }
    ],
    "@typescript-eslint/explicit-member-accessibility": [
      "warn",
      {
        "accessibility": "explicit",
        "overrides": {
          "constructors": "off"
        }
      }
    ],
    "@typescript-eslint/indent": [
      "warn",
      2
    ],
    "@typescript-eslint/member-delimiter-style": [
      "warn",
      {
        "multiline": {
          "delimiter": "semi",
          "requireLast": true
        },
        "singleline": {
          "delimiter": "comma",
          "requireLast": false
        }
      }
    ],
    "@typescript-eslint/naming-convention": [
      "warn",
      { "selector": "default", "format": ["camelCase"],
        "filter": {
          "regex": "^[a-z]",
          "match": true
        }
      },
      // variableLike
      { "selector": "variable", "format": ["camelCase", "UPPER_CASE"] },
      { "selector": "variable", "filter": "^I.+Service$", "format": ["PascalCase"], "prefix": ["I"] },
      // memberLike
      { "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
      { "selector": "memberLike", "modifiers": ["protected"], "format": ["camelCase"], "leadingUnderscore": "require" },
      { "selector": "enumMember", "format": ["UPPER_CASE"] },
      // memberLike - Allow enum-like objects to use UPPER_CASE
      { "selector": "property", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"],
        "filter": {
          "regex": "^[a-z]",
          "match": true
        }
      },
      // restrict on* naming for events only
      { "selector": "method", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"], "custom": {
        "regex": "^on[A-Z].+",
        "match": false
      } },
      { "selector": "method", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require", "custom": {
        "regex": "^on[A-Z].+",
        "match": false
      } },
      { "selector": "method", "modifiers": ["protected"], "format": ["camelCase"], "leadingUnderscore": "require", "custom": {
        "regex": "^on[A-Z].+",
        "match": false
      } },
      // typeLike
      { "selector": "typeLike", "format": ["PascalCase"] },
      { "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] }
    ],
    "@typescript-eslint/no-confusing-void-expression": [
      "warn",
      { "ignoreArrowShorthand": true }
    ],
    "@typescript-eslint/no-useless-constructor": "warn",
    "@typescript-eslint/prefer-namespace-keyword": "warn",
    "@typescript-eslint/type-annotation-spacing": "warn",
    "@typescript-eslint/quotes": [
      "warn",
      "single",
      { "allowTemplateLiterals": true }
    ],
    "@typescript-eslint/semi": [
      "warn",
      "always"
    ],
    "comma-dangle": [
      "warn",
      {
        "objects": "never",
        "arrays": "never",
        "functions": "never"
      }
    ],
    "curly": [
      "warn",
      "multi-line"
    ],
    "eol-last": "warn",
    "eqeqeq": [
      "warn",
      "always"
    ],
    "jsdoc/check-alignment": 1,
    "jsdoc/check-param-names": 1,
    "jsdoc/no-multi-asterisks": 1,
    "keyword-spacing": "warn",
    "max-len": [
      "warn",
      {
        "code": 1000, // Don't enforce for code
        "comments": 100,
        "ignoreTrailingComments": true,
        "ignoreUrls": true,
        "ignorePattern": "^ *((?<vt_comment>(//|\\*) @vt)|(?<table_comment>\\* \\| )|(?<commented_code>//  ))"
      }
    ],
    "new-parens": "warn",
    "no-duplicate-imports": "warn",
    "no-else-return": [
      "warn",
      {
        "allowElseIf": false
      }
    ],
    "no-eval": "warn",
    "no-irregular-whitespace": "warn",
    "no-restricted-imports": [
      "warn",
      {
        "patterns": [
          ".*\\/out\\/.*"
        ]
      }
    ],
    "no-restricted-syntax": [
      "warn",
      {
        "selector": "CallExpression[callee.name='requestAnimationFrame']",
        "message": "The global requestAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService."
      },
      {
        "selector": "CallExpression[callee.name='cancelAnimationFrame']",
        "message": "The global cancelAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService."
      },
      {
        "selector": "CallExpression > MemberExpression[object.name='window'][property.name='requestAnimationFrame']",
        "message": "window.requestAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService."
      },
      {
        "selector": "CallExpression > MemberExpression[object.name='window'][property.name='cancelAnimationFrame']",
        "message": "window.cancelAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService."
      },
      {
        "selector": "MemberExpression[object.name='window'][property.name='devicePixelRatio']",
        "message": "window.devicePixelRatio should be avoided, get it from ICoreBrowserService."
      }
    ],
    "no-trailing-spaces": "warn",
    "no-unsafe-finally": "warn",
    "no-unused-vars": ["warn", {
      "vars": "all",
      "args": "none"
    }],
    "no-var": "warn",
    "one-var": [
      "warn",
      "never"
    ],
    "object-curly-spacing": [
      "warn",
      "always"
    ],
    "prefer-const": "warn",
    "spaced-comment": [
      "warn",
      "always",
      {
        "markers": ["/"],
        "exceptions": ["-"]
      }
    ]
  },
  "overrides": [
    {
      "files": [
        "**/*.api.ts",
        "**/*.test.ts"
      ],
      "rules": {
        "object-curly-spacing": "off",
        "max-len": "off",
        "no-unused-vars": "off"
      }
    }
  ]
}
