Skip to content

linter: eslint(no-undef) false positive #12693

@shellscape

Description

@shellscape

What version of Oxlint are you using?

1.9.0

What command did you run?

oxlint --format stylish

What does your .oxlintrc.json config file look like?

{
  "env": {
    "browser": true,
    "node": true,
    "es2022": true,
    "jest": true,
    "vitest": true
  },
  "globals": {
    "jest": "off"
  },
  "ignore": [
    "**/*.coffee",
    "**/*.css",
    "**/*.hbs",
    "**/*.json",
    "**/*.less",
    "**/*.scss",
    "**/*.svg",
    "dist/**",
    "node_modules/**"
  ],
  "overrides": [
    {
      "files": ["apps/**/*.*", "**/scripts/**/*.*"],
      "rules": {
        "no-await-in-loop": "off",
        "no-empty": "off",
        "no-empty-function": "off",
        "no-empty-pattern": "off",
        "no-console": "off",
        "no-lonely-if": "warn",
        "no-new": "warn",
        "no-self-compare": "warn",
        "no-unsafe-finally": "warn",
        "no-unused-expressions": "warn",
        "radix": "off",
        "no-unneeded-ternary": "off",
        "no-extra-boolean-cast": "off",
        "no-template-curly-in-string": "off"
      }
    }
  ],
  "project": [
    "./apps/**/tsconfig.json",
    "./shared/tsconfig.lint.json"
  ],
  "rules": {
    "no-array-constructor": "error",
    "no-class-assign": "error",
    "no-cond-assign": "error",
    "no-const-assign": "error",
    "no-constant-condition": "warn",
    "no-control-regex": "error",
    "no-debugger": "error",
    "no-dupe-args": "error",
    "no-dupe-class-members": "error",
    "no-dupe-keys": "error",
    "no-duplicate-case": "error",
    "no-empty-character-class": "error",
    "no-empty-pattern": "error",
    "no-ex-assign": "error",
    "no-func-assign": "error",
    "no-invalid-regexp": "error",
    "no-irregular-whitespace": "error",
    "no-obj-calls": "error",
    "no-octal": "error",
    "no-prototype-builtins": "error",
    "no-regex-spaces": "error",
    "no-self-assign": "error",
    "no-sparse-arrays": "error",
    "no-template-curly-in-string": "error",
    "no-this-before-super": "error",
    "no-undef": "error",
    "no-unreachable": "error",
    "no-unsafe-finally": "error",
    "no-unsafe-negation": "error",
    "require-yield": "error",
    "use-isnan": "error",
    "valid-typeof": "error",
    "no-new-buffer": "error",
    "camelcase": [
      "error",
      {
        "properties": "never"
      }
    ],
    "capitalized-comments": "off",
    "comma-dangle": ["error", "never"],
    "eqeqeq": [
      "error",
      "always",
      {
        "null": "ignore"
      }
    ],
    "linebreak-style": ["error", "unix"],
    "new-cap": [
      "error",
      {
        "capIsNew": false,
        "newIsCap": true
      }
    ],
    "no-bitwise": "warn",
    "no-continue": "warn",
    "no-else-return": "warn",
    "no-lonely-if": "error",
    "no-multi-assign": ["error"],
    "no-new-object": "error",
    "no-param-reassign": ["warn", { "props": false }],
    "no-plusplus": [
      "warn",
      {
        "allowForLoopAfterthoughts": true
      }
    ],
    "no-unneeded-ternary": [
      "error",
      {
        "defaultAssignment": false
      }
    ],
    "no-var": "error",
    "object-shorthand": [
      "error",
      "always",
      {
        "avoidQuotes": true,
        "ignoreConstructors": false
      }
    ],
    "one-var": ["error", "never"],
    "operator-assignment": ["error", "always"],
    "prefer-const": [
      "error",
      {
        "destructuring": "any",
        "ignoreReadBeforeAssign": true
      }
    ],
    "prefer-destructuring": [
      "warn",
      {
        "array": false,
        "object": true
      }
    ],
    "prefer-numeric-literals": "error",
    "prefer-rest-params": "error",
    "prefer-spread": "error",
    "prefer-template": "error",
    "radix": "warn",
    "spaced-comment": ["error", "always"],
    "strict": "error",
    "symbol-description": "error",
    "vars-on-top": "error",
    "yoda": "error",
    "no-await-in-loop": "warn",
    "no-compare-neg-zero": "error",
    "no-empty": ["error", { "allowEmptyCatch": true }],
    "no-empty-function": "off",
    "no-eval": "error",
    "no-extend-native": "error",
    "no-extra-bind": "error",
    "no-extra-boolean-cast": "error",
    "no-fallthrough": "error",
    "no-global-assign": "error",
    "no-implied-eval": "error",
    "no-inner-declarations": "error",
    "no-iterator": "error",
    "no-labels": "error",
    "no-lone-blocks": "error",
    "no-loop-func": "error",
    "no-multi-str": "error",
    "no-new": "error",
    "no-new-func": "error",
    "no-new-wrappers": "error",
    "no-octal-escape": "error",
    "no-return-assign": "error",
    "no-return-await": "error",
    "no-script-url": "error",
    "no-self-compare": "error",
    "no-sequences": "error",
    "no-throw-literal": "error",
    "no-unmodified-loop-condition": "off",
    "no-unused-expressions": [
      "error",
      {
        "allowShortCircuit": true,
        "allowTernary": false
      }
    ],
    "no-unused-labels": "error",
    "no-useless-concat": "error",
    "no-useless-constructor": "error",
    "no-useless-escape": "error",
    "no-useless-return": "error",
    "no-void": "off",
    "no-with": "error",
    "unicorn/no-new-array": "off",
    "unicorn/no-useless-fallback-in-spread": "off",
    "react/rules-of-hooks": "error",
    "react/exhaustive-deps": "warn"
  },
  "typescript": true,
  "vitest": true
}

What happened?

Oxlint erroneously errors for no-undef on the following TypeScript interface:

export interface StoreImpl {
  onOutputBlobs: (callback: (blobs: MediaSetBlobs) => void) => import('rxjs').Subscription;
  onStartRecording: (callback: () => void) => import('rxjs').Subscription;
  onStopRecording: (callback: () => void) => import('rxjs').Subscription;
  onRestartRecording: (callback: () => void) => import('rxjs').Subscription;
  onCancelRecording: (callback: () => void) => import('rxjs').Subscription;
}

For each use of Subscription it reports 'Subscription' is not defined. eslint(no-undef)

This is incorrect, as that's a type definition and a property of an import. This code, while wonky looking, does compile and run correctly. Oxlint has a false positive here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions