Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

22.9 KB
Raw Blame
{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "jsPlugins": [
    "./plugins/signoz.mjs",
    "eslint-plugin-sonarjs"
  ],
  "plugins": [
    "eslint",
    "react",
    "react-perf",
    "typescript",
    "jsx-a11y",
    "import",
    "jest",
    "promise",
    "jsdoc"
  ],
  "categories": {
    "correctness": "warn"
    // TODO: Eventually turn this to error, and enable other categories
  },
  "env": {
    "builtin": true,
    "es2021": true,
    "browser": true,
    "jest": true,
    "node": true
  },
  "options": {
    "typeAware": true,
    "typeCheck": false
  },
  "settings": {
    "react": {
      "version": "18.2.0"
    }
  },
  "rules": {
    "constructor-super": "error",
    "for-direction": "error",
    "getter-return": "error",
    "no-async-promise-executor": "error",
    "no-case-declarations": "error",
    "no-class-assign": "error",
    "no-compare-neg-zero": "error",
    "no-cond-assign": "error",
    // Prevents accidental assignment in conditions (if (x = 1) instead of if (x === 1))
    "no-const-assign": "error",
    "no-constant-binary-expression": "error",
    "no-constant-condition": "error",
    "no-control-regex": "error",
    "no-debugger": "error",
    // Disallows debugger statements in production code
    "no-delete-var": "error",
    "no-dupe-class-members": "error",
    "no-dupe-else-if": "error",
    "no-dupe-keys": "error",
    "no-duplicate-case": "error",
    "no-empty": "error",
    "no-empty-character-class": "error",
    "no-empty-pattern": "error",
    "no-empty-static-block": "error",
    "no-ex-assign": "error",
    "no-extra-boolean-cast": "error",
    "no-fallthrough": "error",
    "no-func-assign": "error",
    "no-global-assign": "error",
    "no-import-assign": "error",
    "no-invalid-regexp": "error",
    "no-irregular-whitespace": "error",
    "no-loss-of-precision": "error",
    "no-misleading-character-class": "error",
    "no-new-native-nonconstructor": "error",
    "no-nonoctal-decimal-escape": "error",
    "no-obj-calls": "error",
    "no-prototype-builtins": "error",
    "no-redeclare": "error",
    "no-regex-spaces": "error",
    "no-self-assign": "error",
    "no-setter-return": "error",
    "no-shadow-restricted-names": "warn",
    // TODO: Change to error after migration to oxlint
    "no-sparse-arrays": "error",
    "no-this-before-super": "error",
    "no-undef": "warn",
    // TODO: Change to error after migration to oxlint
    "no-unreachable": "warn",
    // TODO: Change to error after the migration to oxlint
    "no-unsafe-finally": "error",
    "no-unsafe-negation": "error",
    "no-unsafe-optional-chaining": "warn",
    // TODO: Change to error after migration to oxlint
    "no-unused-labels": "error",
    "no-unused-private-class-members": "error",
    "no-useless-backreference": "error",
    "no-useless-catch": "error",
    "no-useless-escape": "error",
    "no-with": "error",
    "require-yield": "error",
    "use-isnan": "error",
    "valid-typeof": "error",
    "prefer-rest-params": "error",
    "prefer-spread": "error",
    "no-inner-declarations": "error",
    // "no-octal": "error", // Not supported by oxlint
    "react/display-name": "error",
    "react/jsx-key": "warn",
    // TODO: Change to error after migration to oxlint
    "react/jsx-no-comment-textnodes": "error",
    "react/jsx-no-duplicate-props": "error",
    "react/jsx-no-target-blank": "warn",
    // TODO: Change to error after migration to oxlint
    "react/jsx-no-undef": "warn",
    "react/no-children-prop": "error",
    "react/no-danger-with-children": "error",
    "react/no-direct-mutation-state": "error",
    "react/no-find-dom-node": "error",
    "react/no-is-mounted": "error",
    "react/no-render-return-value": "error",
    "react/no-string-refs": "error",
    "react/no-unescaped-entities": "error",
    "react/no-unknown-property": "error",
    "react/require-render-return": "error",
    "react/no-unsafe": "off",
    "no-array-constructor": "error",
    "jsdoc/check-tag-names": "off",
    "@typescript-eslint/no-duplicate-enum-values": "warn",
    // TODO: Change to error after migration to oxlint
    "@typescript-eslint/no-empty-object-type": "error",
    "@typescript-eslint/no-explicit-any": "warn",
    // Warns when using 'any' type (consider upgrading to error)
    "@typescript-eslint/no-empty-function": "off",
    // TODO: Change to 'error' after fixing ~80 empty function placeholders in providers/contexts
    "@typescript-eslint/ban-ts-comment": "warn",
    // Warns when using @ts-ignore comments (sometimes needed for third-party libs)
    "no-empty-function": "off",
    // Disabled in favor of TypeScript version above
    "@typescript-eslint/no-extra-non-null-assertion": "error",
    "@typescript-eslint/no-misused-new": "error",
    "@typescript-eslint/no-namespace": "error",
    "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
    "@typescript-eslint/no-require-imports": "error",
    "@typescript-eslint/no-this-alias": "error",
    "@typescript-eslint/no-unnecessary-type-constraint": "warn",
    // TODO: Change to error after migration to oxlint
    "@typescript-eslint/no-unsafe-declaration-merging": "error",
    "@typescript-eslint/no-unsafe-function-type": "error",
    "no-unused-expressions": "warn",
    // TODO: Change to error after migration to oxlint
    "@typescript-eslint/no-wrapper-object-types": "error",
    "@typescript-eslint/prefer-as-const": "error",
    "@typescript-eslint/prefer-namespace-keyword": "error",
    "@typescript-eslint/triple-slash-reference": "error",
    "@typescript-eslint/adjacent-overload-signatures": "error",
    "@typescript-eslint/ban-types": "error",
    "@typescript-eslint/explicit-module-boundary-types": "warn",
    "@typescript-eslint/no-empty-interface": "error",
    "@typescript-eslint/no-inferrable-types": "error",
    "@typescript-eslint/no-non-null-assertion": "warn",
    "@typescript-eslint/no-unused-vars": [
      // TypeScript-specific unused vars checking
      "error",
      {
        "argsIgnorePattern": "^_",
        "varsIgnorePattern": "^_",
        "caughtErrors": "none"
      }
    ],
    "curly": "error",
    // Requires curly braces for all control statements
    // TODO: Change to error after migration to oxlint
    "prefer-const": "warn",
    // Enforces const for variables never reassigned
    "no-var": "error",
    // Disallows var, enforces let/const
    "no-else-return": [
      // Reduces nesting by disallowing else after return
      "error",
      {
        "allowElseIf": false
      }
    ],
    "eqeqeq": [
      // Enforces === and !== (allows == null for null/undefined check)
      "error",
      "always",
      {
        "null": "ignore"
      }
    ],
    "no-console": [
      // Warns on console.log, allows console.warn/error
      "error",
      {
        "allow": [
          "warn",
          "error"
        ]
      }
    ],
    "max-params": "off",
    // Warns when functions have more than 3 parameters
    "@typescript-eslint/explicit-function-return-type": "error",
    // Requires explicit return types on functions
    "@typescript-eslint/no-var-requires": "error",
    "@typescript-eslint/no-useless-default-assignment": "off", // provide unsafe fixes in our codebase due to bad typing
    "@typescript-eslint/no-duplicate-type-constituents": "off", // provide fixes that breaks some assumptions, eg: type A = L, B = L, C = A | B (removes B)
    // Disallows require() in TypeScript (use import instead)
    // Disabled - using TypeScript instead
    "react/jsx-props-no-spreading": "off",
    // Allows {...props} spreading (common in HOCs, forms, wrappers)
    "react/jsx-filename-extension": [
      // Warns if JSX is used in non-.jsx/.tsx files
      "error",
      {
        "extensions": [
          ".tsx",
          ".jsx"
        ]
      }
    ],
    "react/no-array-index-key": "error",
    // Prevents using array index as key (causes bugs when list changes)
    "jsx-a11y/label-has-associated-control": [
      // Accessibility rules - Labels must either wrap inputs or use htmlFor/id
      "error",
      {
        "required": {
          "some": [
            "nesting",
            "id"
          ]
        }
      }
    ],
    "import/extensions": [
      "error",
      "ignorePackages",
      {
        // Import/export rules - Disallows .js/.jsx/.ts/.tsx extension in imports
        "js": "never",
        "jsx": "never",
        "ts": "never",
        "tsx": "never"
      }
    ],
    "import/no-cycle": "warn",
    // Warns about circular dependencies
    "import/first": "error",
    "import/no-duplicates": "warn",
    // TODO: Changed to warn during oxlint migration, should be changed to error
    "arrow-body-style": "off",
    "jest/no-disabled-tests": "warn",
    // Jest test rules
    "jest/no-focused-tests": "error",
    "jest/no-identical-title": "warn",
    "jest/prefer-to-have-length": "warn",
    "jest/valid-expect": "warn",
    // TODO: Change to error after migration to oxlint
    // TODO: Change to error after migration to oxlint
    "react-hooks/rules-of-hooks": "warn",
    // React Hooks rules - Enforces Rules of Hooks (only call at top level)
    "react-hooks/exhaustive-deps": "warn",
    // Warns about missing dependencies in useEffect/useMemo/useCallback
    // React Compiler rules, off because we don't have React Compiler enabled
    "react/error-boundaries": "off",
    "react/globals": "off",
    "react/immutability": "off",
    "react/incompatible-library": "off",
    "react/preserve-manual-memoization": "off",
    "react/purity": "off",
    "react/refs": "off",
    "react/set-state-in-effect": "off",
    "react/set-state-in-render": "off",
    "react/static-components": "off",
    "react/unsupported-syntax": "off",
    "react/use-memo": "off",
    "react/void-use-memo": "off",
    "signoz/no-unsupported-asset-pattern": "error",
    // Prevents the wrong usage of assets to break custom base path installations
    "signoz/no-zustand-getstate-in-hooks": "error",
    // Prevents useStore.getState() - export standalone actions instead
    "signoz/no-navigator-clipboard": "error",
    // Prevents navigator.clipboard - use useCopyToClipboard hook instead (disabled in tests via override)
    "signoz/no-raw-absolute-path": "error",
    // Prevents window.open(path), window.location.origin + path, window.location.href = path
    "signoz/no-antd-components": "error",
    // Prevents the usage of specific antd components in favor of our lib
    "signoz/no-signozhq-ui-barrel": "error",
    // Forces subpath imports (@signozhq/ui/<component>) instead of the eagerly-loaded barrel
    "signoz/no-css-module-bracket-access": "warn",
    // Prevents bracket access on CSS modules (styles['kebab-case']) which fails with camelCaseOnly config
    "signoz/no-dashboard-fetch-outside-root": "error",
    // Forces useDashboardFetchRequired() outside the root V2 pages (allowlisted in overrides below)
    "signoz/no-msw-in-story-file": "error",
    // Bans msw imports in *.stories.tsx; handlers/mock data belong in the sibling .stories.mocks.tsx
    "signoz/no-direct-react-router-import": "error",
    // Steers call sites to the src/lib/router facade (allowlisted in overrides below)
    "no-restricted-globals": [
      "error",
      {
        "name": "localStorage",
        "message": "Use scoped wrappers from api/browser/localstorage/ instead (ensures keys are prefixed when served under a URL base path)."
      },
      {
        "name": "sessionStorage",
        "message": "Use scoped wrappers from api/browser/sessionstorage/ instead (ensures keys are prefixed when served under a URL base path)."
      }
    ],
    // Prevents direct localStorage/sessionStorage access — use scoped wrappers
    "no-restricted-imports": [
      "error",
      {
        "paths": [
          {
            "name": "redux",
            "message": "[State mgmt] redux is deprecated. Migrate to Zustand, nuqs, or react-query."
          },
          {
            "name": "react-redux",
            "message": "[State mgmt] react-redux is deprecated. Migrate to Zustand, nuqs, or react-query."
          },
          {
            "name": "react",
            "importNames": [
              "createContext",
              "useContext",
              "useSyncExternalStore"
            ],
            "message": "[State mgmt] React Context and hand-rolled external stores are deprecated. Migrate shared state to Zustand."
          },
          {
            "name": "immer",
            "message": "[State mgmt] Direct immer usage is deprecated. Use Zustand (which integrates immer via the immer middleware) instead."
          },
          {
            "name": "api/generated/services/dashboard",
            "importNames": ["patchDashboardV2", "usePatchDashboardV2"],
            "message": "[dashboard-v2] Don't call patchDashboardV2/usePatchDashboardV2 directly — use useOptimisticPatch().patchAsync so spec edits update the react-query cache optimistically and reconcile on settle."
          },
          {
            "name": "motion/react-client",
            "message": "[motion] motion/react-client is for React Server Components only. Use 'motion/react' instead — it provides the same exports and works correctly in client-side SPAs."
          }
        ]
      }
    ],
    "react/no-array-index-key": "warn",
    // TODO: Changed to warn during oxlint migration, should be changed to error,

    "oxc/bad-array-method-on-arguments": "error",
    "oxc/bad-bitwise-operator": "error",
    "oxc/bad-comparison-sequence": "error",
    "oxc/bad-object-literal-comparison": "error",
    "oxc/bad-replace-all-arg": "error",
    "oxc/double-comparisons": "error",
    "oxc/erasing-op": "error",
    "oxc/misrefactored-assign-op": "error",
    "oxc/missing-throw": "error",
    "oxc/no-accumulating-spread": "error",
    "oxc/no-async-endpoint-handlers": "error",
    "oxc/no-const-enum": "error",
    "oxc/number-arg-out-of-range": "error",
    "oxc/only-used-in-recursion": "warn",
    "oxc/uninvoked-array-callback": "error",
    "jest/consistent-test-it": [
      "warn",
      {
        "fn": "it"
      }
    ],
    "jest/expect-expect": "warn",
    "jest/no-alias-methods": "warn",
    "jest/no-commented-out-tests": "warn",
    "jest/no-conditional-expect": "warn",
    "jest/no-deprecated-functions": "warn",
    "jest/no-done-callback": "warn",
    "jest/no-duplicate-hooks": "warn",
    "jest/no-export": "warn",
    "jest/no-jasmine-globals": "warn",
    "jest/no-mocks-import": "warn",
    "jest/no-standalone-expect": "warn",
    "jest/no-test-prefixes": "warn",
    "jest/no-test-return-statement": "warn",
    "jest/prefer-called-with": "off", // The auto-fix for this can break the tests when the function has args
    "jest/prefer-comparison-matcher": "warn",
    "jest/prefer-equality-matcher": "warn",
    "jest/prefer-expect-resolves": "warn",
    "jest/prefer-hooks-on-top": "warn",
    "jest/prefer-spy-on": "warn",
    "jest/prefer-strict-equal": "warn",
    "jest/prefer-to-be": "warn",
    "jest/prefer-to-contain": "warn",
    "jest/prefer-todo": "warn",
    "jest/valid-describe-callback": "warn",
    "jest/valid-title": "warn",
    "promise/catch-or-return": "warn",
    "promise/no-return-wrap": "error",
    "promise/param-names": "warn",
    "promise/always-return": "warn",
    "promise/no-nesting": "warn",
    "promise/no-promise-in-callback": "warn",
    "promise/no-callback-in-promise": "warn",
    "promise/avoid-new": "off",
    "promise/no-new-statics": "error",
    "promise/no-return-in-finally": "error",
    "promise/valid-params": "error",
    "import/no-default-export": "off",
    "import/no-named-as-default": "warn",
    "import/no-named-as-default-member": "warn",
    "import/no-self-import": "error",
    "import/no-webpack-loader-syntax": "error",
    "jsx-a11y/alt-text": "error",
    "jsx-a11y/anchor-has-content": "warn",
    "jsx-a11y/anchor-is-valid": "warn",
    "jsx-a11y/aria-activedescendant-has-tabindex": "error",
    "jsx-a11y/aria-props": "error",
    "jsx-a11y/aria-role": "error",
    "jsx-a11y/aria-unsupported-elements": "error",
    "jsx-a11y/autocomplete-valid": "error",
    "jsx-a11y/click-events-have-key-events": "warn",
    "jsx-a11y/heading-has-content": "error",
    "jsx-a11y/html-has-lang": "error",
    "jsx-a11y/iframe-has-title": "error",
    "jsx-a11y/img-redundant-alt": "warn",
    "jsx-a11y/media-has-caption": "warn",
    "jsx-a11y/mouse-events-have-key-events": "warn",
    "jsx-a11y/no-access-key": "error",
    "jsx-a11y/no-autofocus": "off",
    "jsx-a11y/no-distracting-elements": "error",
    "jsx-a11y/no-redundant-roles": "warn",
    "jsx-a11y/role-has-required-aria-props": "warn",
    "jsx-a11y/role-supports-aria-props": "error",
    "jsx-a11y/scope": "error",
    "jsx-a11y/tabindex-no-positive": "warn",

    // SonarJS rules - migrated from ESLint
    "sonarjs/cognitive-complexity": "warn", // TODO: Change to error after migration
    // Prevents overly complex functions (use SonarQube/SonarCloud for detailed analysis)
    "sonarjs/max-switch-cases": "error",
    // Limits switch statement cases
    "sonarjs/no-all-duplicated-branches": "error",
    // Prevents identical if/else branches
    "sonarjs/no-collapsible-if": "error",
    // Suggests merging nested ifs
    "sonarjs/no-collection-size-mischeck": "error",
    // Validates collection size checks
    "sonarjs/no-duplicated-branches": "error",
    // Detects duplicate conditional branches
    "sonarjs/no-duplicate-string": "off",
    // Warns on repeated string literals (was disabled)
    "sonarjs/no-element-overwrite": "error",
    // Prevents array element overwrites
    "sonarjs/no-empty-collection": "error",
    // Detects empty collections
    "sonarjs/no-extra-arguments": "off",
    // Detects extra function arguments (TypeScript handles this)
    "sonarjs/no-gratuitous-expressions": "error",
    // Removes unnecessary expressions
    "sonarjs/no-identical-conditions": "error",
    // Prevents duplicate conditions
    "sonarjs/no-identical-expressions": "error",
    // Detects duplicate expressions
    "sonarjs/no-identical-functions": "error",
    // Finds duplicated function implementations
    "sonarjs/no-ignored-return": "error",
    // Ensures return values are used
    "sonarjs/no-inverted-boolean-check": "off",
    // Simplifies boolean checks (was disabled)
    "sonarjs/no-nested-switch": "error",
    // Prevents nested switch statements
    "sonarjs/no-nested-template-literals": "error",
    // Avoids nested template literals
    "sonarjs/no-redundant-boolean": "warn", // TODO: Change to error after migration
    // Removes redundant boolean literals - turned off because it clashes with unicorn rules
    "sonarjs/no-redundant-jump": "off",
    // Removes unnecessary returns/continues
    "sonarjs/no-same-line-conditional": "error",
    // Prevents same-line conditionals
    "sonarjs/no-small-switch": "error",
    // Discourages tiny switch statements
    "sonarjs/no-unused-collection": "error",
    // Finds unused collections
    "sonarjs/no-use-of-empty-return-value": "error",
    // Prevents using void returns
    "sonarjs/non-existent-operator": "error",
    // Catches typos like =+ instead of +=
    "sonarjs/prefer-immediate-return": "error",
    // Returns directly instead of assigning
    "sonarjs/prefer-object-literal": "error",
    // Prefers object literals
    "sonarjs/prefer-single-boolean-return": "error",
    // Simplifies boolean returns
    "sonarjs/prefer-while": "error",
    // Suggests while loops over for loops
    "sonarjs/elseif-without-else": "off",
    // Requires final else in if-else-if chains (was disabled)
    "signoz/no-conditional-text-nodes-with-siblings": "warn",
    // Vendored from eslint-plugin-react-google-translate
    "signoz/no-return-text-nodes": "warn"
  },
  "ignorePatterns": [
    "src/parser/*.ts",
    "scripts/update-registry.cjs",
    "scripts/generate-permissions-type.cjs",
    "**/node_modules",
    "**/build",
    "**/*.typegen.ts",
    "**/i18-generate-hash.cjs",
    "src/parser/TraceOperatorParser/**/*",
    "**/orval.config.ts"
  ],
  "overrides": [
    {
      "files": [
        "src/api/generated/**/*.ts",
        "src/api/ai-assistant/**/*.ts"
      ],
      "rules": {
        "@typescript-eslint/explicit-function-return-type": "off",
        "@typescript-eslint/explicit-module-boundary-types": "off",
        "no-nested-ternary": "off",
        "no-unused-vars": [
          "warn",
          {
            "argsIgnorePattern": "^_",
            "varsIgnorePattern": "^_",
            "caughtErrors": "none"
          }
        ]
      }
    },
    {
      // Test files: disable clipboard rule and import/first
      "files": [
        "**/*.test.ts",
        "**/*.test.tsx",
        "**/*.test.js",
        "**/*.test.jsx",
        "**/*.spec.ts",
        "**/*.spec.tsx",
        "**/*.spec.js",
        "**/*.spec.jsx",
        "**/__tests__/**/*.ts",
        "**/__tests__/**/*.tsx",
        "**/__tests__/**/*.js",
        "**/__tests__/**/*.jsx"
      ],
      "rules": {
        "import/first": "off",
        // Should ignore due to mocks
        "signoz/no-navigator-clipboard": "off",
        // Tests can use navigator.clipboard directly,
        "signoz/no-raw-absolute-path":"off",
        "no-restricted-globals": "off",
        // Tests need raw localStorage/sessionStorage to seed DOM state for isolation
        "signoz/no-zustand-getstate-in-hooks": "off",
        "@typescript-eslint/no-explicit-any": "off", // Tests often need any for mocks/stubs
        "@typescript-eslint/explicit-module-boundary-types": "off", // Return types not required in tests
        "@typescript-eslint/explicit-function-return-type": "off" // Same as above rule, don't need to care about return type
      }
    },
    {
      // Store files are allowed to use .getState() as they export standalone actions
      "files": [
        "**/*Store.ts",
        "**/*Store.tsx"
      ],
      "rules": {
        "signoz/no-zustand-getstate-in-hooks": "off"
      }
    },
    {
      // Root dashboard pages own the fetch lifecycle; useDashboardFetchRequired wraps it.
      // Everywhere else must use useDashboardFetchRequired().
      "files": [
        "src/pages/DashboardPage/DashboardPage.tsx",
        "src/pages/DashboardPage/PanelEditorPage/PanelEditorPage.tsx",
        "src/pages/DashboardPage/DashboardContainer/hooks/useDashboardFetchRequired.ts"
      ],
      "rules": {
        "signoz/no-dashboard-fetch-outside-root": "off"
      }
    },
    {
      // TypeScript reports real redeclarations; this rule also flags `const X` + `type X` pairs.
      "files": [
        "**/*.ts",
        "**/*.tsx"
      ],
      "rules": {
        "no-redeclare": "off"
      }
    },
    {
      // The react-router allowlist: the facade itself, the route table, `useSafeNavigate`,
      // the history singleton and the test and story router mounts. Test files are
      // deliberately absent: they render at a route or use tests/router-mocks.
      "files": [
        "src/lib/router/**",
        "src/AppRoutes/**",
        "src/hooks/useSafeNavigate.ts",
        "src/lib/history.ts",
        "src/tests/router.tsx",
        "src/storybook/providers/StorybookProviders.tsx",
        "src/storybook/renderAtRoute.tsx"
      ],
      "rules": {
        "signoz/no-direct-react-router-import": "off"
      }
    }
  ]
}