{
  "root": true,
  "extends": ["@pega"],
  "parserOptions": {
    "project": "tsconfig.json",
    "ecmaVersion": 13
  },
  "globals": {
    "PCore": "readonly"
  },
  "settings": {
    "import/resolver": {
      "typescript": {},
      "node": {
        "extensions": [".js", ".jsx", ".ts", ".tsx"]
      }
    },
    "react": {
      "version": "detect"
    }
  },
  "ignorePatterns": [
    "node_modules",
    "packages/*/lib",
    "!.storybook",
    ".storybook/public",
    "**/demo.stories.jsx",
    "**/mock.stories.js",
    "**/demo.stories.tsx",
    "**/mock.stories.ts",
    "**/*.mdx"
  ],
  "rules": {
    // Prettier recommends running separately from a linter.
    // https://prettier.io/docs/en/integrating-with-linters.html#notes
    "prettier/prettier": "off",

    // Disable rules from shared configs we're not ready for yet.
    "sonarjs/cognitive-complexity": "off",
    "sonarjs/no-identical-functions": "off",
    "sonarjs/no-duplicate-string": "off",
    "sonarjs/no-nested-template-literals": "off",

    //
    // JA - Override some default lint handling here
    "@typescript-eslint/array-type": "off",
    // "import/extensions": ["warn", "never"],    // Turning off for now (see below)

    //
    // Initial release: turning these off; phase in to "warn" or "error" over time
    //  For "quotes" and "@typescript-eslint/quotes", see override below for .ts/.tsx files
    "import/extensions": ["off", "never"],
    "import/named": "off",
    "import/no-cycle": "off",
    "import/no-duplicates": "off",
    "import/no-extraneous-dependencies": "off",
    "import/no-named-as-default": "off",
    "import/no-named-as-default-member": "off",
    "import/no-self-import": "off",
    "import/no-unresolved": "off",
    "import/no-useless-path-segments": "off",
    "import/order": "off",

    "no-else-return": "off",
    "no-restricted-syntax": "off",
    "no-underscore-dangle": "off",

    "jsx-a11y/alt-text": "off",
    "jsx-a11y/anchor-is-valid": "off",
    "jsx-a11y/click-events-have-key-events": "off",
    "jsx-a11y/label-has-associated-control": "off",
    "jsx-a11y/no-static-element-interactions": "off",

    "react/jsx-fragments": "off",
    "react/jsx-no-bind": "off",
    "react/self-closing-comp": "off",

    "sonarjs/prefer-immediate-return": "off",

    "@typescript-eslint/dot-notation": "off", // prefer warn but needs different parserOptions
    "@typescript-eslint/naming-convention": "off", // prefer warn but needs different parserOptions
    "@typescript-eslint/ban-types": "off", // also, see override below

    //
    // Initial release: set to error
    "@typescript-eslint/no-inferrable-types": "error",
    "eqeqeq": "off",
    "no-alert": "off",
    "no-console": "error",
    "no-fallthrough": "error",
    "no-undef": "error",
    "no-unused-vars": "off",
    "no-var": "off",
    "yoda": "error",
    "no-irregular-whitespace": "off",
    "no-empty": "off",
    "no-new-object": "off",
    "import/no-relative-packages": "off",

    "import/no-mutable-exports": "error",
    "sonarjs/max-switch-cases": "error",
    "sonarjs/no-collapsible-if": "error",
    "sonarjs/no-all-duplicated-branches": "error",
    "sonarjs/no-duplicated-branches": "error",
    "sonarjs/no-gratuitous-expressions": "error",
    "sonarjs/no-ignored-return": "error",
    "sonarjs/no-small-switch": "error",
    "sonarjs/prefer-object-literal": "error",
    "sonarjs/prefer-single-boolean-return": "error",
    "@typescript-eslint/no-shadow": "error",
    "react/default-props-match-prop-types": "error",
    "react/no-unescaped-entities": "error",
    "react/no-unused-prop-types": "error",
    "react/static-property-placement": "error",
    "array-callback-return": "error",
    "camelcase": "error",
    "func-names": "error",
    "no-case-declarations": "error",
    "no-lonely-if": "error",
    "no-nested-ternary": "error",
    "no-plusplus": "error",
    "no-restricted-globals": "error",
    "no-restricted-properties": "error",
    "no-shadow": "error",
    "radix": "error",
    "spaced-comment": "error",

    "import/newline-after-import": "error",
    "sonarjs/no-nested-switch": "error",
    "@typescript-eslint/no-array-constructor": "error",
    "@typescript-eslint/no-empty-function": "error",
    "@typescript-eslint/no-unused-vars": "error",
    "@typescript-eslint/no-useless-constructor": "error",
    "react/button-has-type": "error",
    "react/jsx-curly-brace-presence": "error",
    "react/jsx-boolean-value": "error",
    "react/no-array-index-key": "error",
    "class-methods-use-this": "error",
    "guard-for-in": "error",
    "no-unneeded-ternary": "error",
    "no-unused-expressions": "error",
    "operator-assignment": "error",
    "prefer-template": "error",
    "vars-on-top": "error",
    "prefer-regex-literals": "off",

    "no-use-before-define": "off", // doc for @typescript-eslint/no-use-before-define says to turn off the base implementation
    "@typescript-eslint/no-use-before-define": "error"
  },
  "overrides": [
    {
      "files": "*.@(ts|tsx)",
      "rules": {
        "@typescript-eslint/method-signature-style": ["error", "property"],
        // "@typescript-eslint/ban-types": [
        //   "warn",
        //   {
        //     "types": {
        //       "Omit": "Please use the 'OmitStrict' type from 'src/types/' instead.",
        //       "object": false,
        //       "Function": false
        //     },
        //     "extendDefaults": true
        //   }
        // ],

        "quotes": "off",
        "@typescript-eslint/quotes": "off"
        // [
        //   "error",
        //   "single",
        //   {
        //     "avoidEscape": true,
        //     "allowTemplateLiterals": false
        //   }
        // ]
      }
    },
    {
      "files": "*.@(jsx|tsx|mdx)",
      "rules": {
        "react/react-in-jsx-scope": "off",
        // Set up configuration for future sweep
        "react-hooks/exhaustive-deps": [
          "off",
          {
            "additionalHooks": "useAfterInitialEffect"
          }
        ]
      }
    },
    {
      // rules for typescript (keeping old rules for js)
      "files": "*.@(ts|tsx)",
      "rules": {
        "no-undef": "off",
        "no-console": "off",
        "import/prefer-default-export": "off",
        "import/no-relative-packages": "off",
        "react/jsx-fragments": "off",
        "react/react-in-jsx-scope": "off",
        // Set up configuration for future sweep
        "react-hooks/exhaustive-deps": [
          "error",
          {
            "additionalHooks": "useAfterInitialEffect"
          }
        ],
        "sonarjs/cognitive-complexity": ["warn", 45]
      }
    },
    // {
    //   "files": "*.@(tsx)",
    //   "rules": {
    //     "react/react-in-jsx-scope": "off",
    //     // Set up configuration for future sweep
    //     "react-hooks/exhaustive-deps": [
    //       "error",
    //       {
    //         "additionalHooks": "useAfterInitialEffect"
    //       }
    //     ]
    //   }
    // },
    {
      "files": "*.@(js|jsx|ts|tsx|mdx)",
      "rules": {}
    },
    {
      "files": ".storybook/*.js",
      "extends": ["@pega/eslint-config/script"]
    },
    {
      "files": "*/**/mocks/**.@(mocks|styles).@(tsx|ts)",
      "rules": {
        "import/prefer-default-export": ["off"]
      }
    }
  ]
}
