Keycloak
1/** @type {import("eslint").Linter.Config } */
2module.exports = {3root: true,4ignorePatterns: [5"node_modules",6"dist",7"target",8"keycloak-theme",9"server",10// Keycloak JS follows a completely different and outdated style, so we'll exclude it for now.11// TODO: Eventually align the code-style for Keycloak JS.12"libs/keycloak-js",13],14parserOptions: {15tsconfigRootDir: __dirname,16project: "./tsconfig.eslint.json",17extraFileExtensions: [".mjs"],18},19env: {20node: true,21},22plugins: ["lodash"],23extends: [24"eslint:recommended",25"plugin:import/recommended",26"plugin:import/typescript",27"plugin:react/recommended",28"plugin:react/jsx-runtime",29"plugin:react-hooks/recommended",30"plugin:@typescript-eslint/base",31"plugin:@typescript-eslint/eslint-recommended",32"plugin:prettier/recommended",33],34settings: {35react: {36version: "detect",37},38"import/resolver": {39typescript: true,40node: true,41},42},43rules: {44// Prefer using `includes()` to check if values exist over `indexOf() === -1`, as it's a more appropriate API for this.45"@typescript-eslint/prefer-includes": "error",46// Prefer using an optional chain expression, as it's more concise and easier to read.47"@typescript-eslint/prefer-optional-chain": "error",48"no-unused-vars": "off",49"@typescript-eslint/no-empty-function": "error",50"@typescript-eslint/no-unnecessary-condition": "warn",51"@typescript-eslint/no-unused-vars": "error",52"lodash/import-scope": ["error", "member"],53// react/prop-types cannot handle generic props, so we need to disable it.54// https://github.com/yannickcr/eslint-plugin-react/issues/2777#issuecomment-81496843255"react/prop-types": "off",56// Prevent fragments from being added that have only a single child.57"react/jsx-no-useless-fragment": "error",58// Ban nesting components, as this will cause unintended re-mounting of components.59// TODO: All issues should be fixed and this rule should be set to "error".60"react/no-unstable-nested-components": ["warn", { allowAsProps: true }],61"prefer-arrow-callback": "error",62"prettier/prettier": [63"error",64{65endOfLine: "auto",66},67],68// Prevent default imports from React, named imports should be used instead.69"no-restricted-imports": [70"error",71{72paths: [73{74name: "react",75importNames: ["default"],76},77],78},79],80// Prefer using the `#private` syntax for private class members, we want to keep this consistent and use the same syntax.81"no-restricted-syntax": [82"error",83{84selector:85':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',86message: "Use #private instead",87},88],89},90overrides: [91{92files: ["*.test.*"],93rules: {94// For tests it can make sense to pass empty functions as mocks.95"@typescript-eslint/no-empty-function": "off",96},97},98{99files: ["**/cypress/**/*"],100extends: ["plugin:cypress/recommended", "plugin:mocha/recommended"],101// TODO: Set these rules to "error" when issues have been resolved.102rules: {103"cypress/no-unnecessary-waiting": "warn",104"cypress/unsafe-to-chain-command": "warn",105"mocha/max-top-level-suites": "off",106"mocha/no-exclusive-tests": "error",107"mocha/no-identical-title": "off",108"mocha/no-mocha-arrows": "off",109"mocha/no-setup-in-describe": "off",110},111},112],113};114