Skip to content

linter: Cannot detect not defined errors #20039

@Abhinav1217

Description

@Abhinav1217

What version of Oxlint are you using?

Version: 1.50.0

What command did you run?

bunx oxlint . --quiet

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

This is my .oxlintrc.json

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": [],
  "categories": {
    "correctness": "off"
  },
  "env": {
    "builtin": true,
    "commonjs": true,
    "es2024": true
  },
  "rules": {
    "no-unused-vars": [
      "warn",
      {
        "args": "all",
        "argsIgnorePattern": "^(_|next|req|res|error)$"
      }
    ]
  },
  "globals": {
    "__dirname": "readonly",
    "__filename": "readonly",
    "AbortController": "readonly",
    "AbortSignal": "readonly",
    "atob": "readonly",
    "Blob": "readonly",
    "BroadcastChannel": "readonly",
    "btoa": "readonly",
    "Buffer": "readonly",
    "ByteLengthQueuingStrategy": "readonly",
    "clearImmediate": "readonly",
    "clearInterval": "readonly",
    "clearTimeout": "readonly",
    "CloseEvent": "readonly",
    "CompressionStream": "readonly",
    "console": "readonly",
    "CountQueuingStrategy": "readonly",
    "crypto": "readonly",
    "Crypto": "readonly",
    "CryptoKey": "readonly",
    "CustomEvent": "readonly",
    "DecompressionStream": "readonly",
    "DOMException": "readonly",
    "Event": "readonly",
    "EventTarget": "readonly",
    "fetch": "readonly",
    "File": "readonly",
    "FormData": "readonly",
    "Headers": "readonly",
    "MessageChannel": "readonly",
    "MessageEvent": "readonly",
    "MessagePort": "readonly",
    "navigator": "readonly",
    "Navigator": "readonly",
    "performance": "readonly",
    "Performance": "readonly",
    "PerformanceEntry": "readonly",
    "PerformanceMark": "readonly",
    "PerformanceMeasure": "readonly",
    "PerformanceObserver": "readonly",
    "PerformanceObserverEntryList": "readonly",
    "PerformanceResourceTiming": "readonly",
    "process": "readonly",
    "queueMicrotask": "readonly",
    "ReadableByteStreamController": "readonly",
    "ReadableStream": "readonly",
    "ReadableStreamBYOBReader": "readonly",
    "ReadableStreamBYOBRequest": "readonly",
    "ReadableStreamDefaultController": "readonly",
    "ReadableStreamDefaultReader": "readonly",
    "Request": "readonly",
    "Response": "readonly",
    "setImmediate": "readonly",
    "setInterval": "readonly",
    "setTimeout": "readonly",
    "structuredClone": "readonly",
    "SubtleCrypto": "readonly",
    "TextDecoder": "readonly",
    "TextDecoderStream": "readonly",
    "TextEncoder": "readonly",
    "TextEncoderStream": "readonly",
    "TransformStream": "readonly",
    "TransformStreamDefaultController": "readonly",
    "URL": "readonly",
    "URLSearchParams": "readonly",
    "WebAssembly": "readonly",
    "WebSocket": "readonly",
    "WritableStream": "readonly",
    "WritableStreamDefaultController": "readonly",
    "WritableStreamDefaultWriter": "readonly"
  },
  "overrides": [
    {
      "files": [
        "**/appNotificationTemplates.js",
        "**/smsTemplates.js",
        "**/emailTemplates.js"
      ],
      "rules": {
        "no-unused-vars": "off"
      }
    }
  ]
}

which is migrated using bunx @oxlint/migrate on our existing eslint.config.js

const globals = require("globals");

module.exports = [
  {
    languageOptions: {
      parserOptions: {
        requireConfigFile: false,
      },
      globals: {
        ...globals.node,
        ...globals.commonjs,
        ...globals.es2021,
      },
    },
    rules: {
      "no-undef": "error",
      "no-unused-vars": [
        "warn",
        {
          args: "all",
          argsIgnorePattern: "^(_|next|req|res|error)$",
        },
      ],
    },
  },
  {
    files: [
      "**/appNotificationTemplates.js",
      "**/smsTemplates.js",
      "**/emailTemplates.js",
    ],
    rules: {
      "no-unused-vars": "off",
    },
  },
];

What happened?

I am evaluating oxc for replacing eslint and prettier in our company. I noticed that it is not detecting all undefined errors

instaservice@Instaservices-MacBook-Pro backend-suite % time bunx oxlint . --quiet

Found 1018 warnings and 0 errors.
Finished in 19ms on 1421 files with 1 rules using 11 threads.
bunx oxlint . --quiet  0.10s user 0.09s system 326% cpu 0.057 total
instaservice@Instaservices-MacBook-Pro backend-suite % time bunx eslint . --quiet

/Users/instaservice/Projects/Instaservice/backend-suite/account-service/src/consumers/index.js
  1281:9   error  'spTokenMap' is not defined  no-undef
  1282:29  error  'spTokenMap' is not defined  no-undef
  1283:25  error  'spTokenMap' is not defined  no-undef

✖ 3 problems (3 errors, 0 warnings)

bunx eslint . --quiet  2.41s user 0.21s system 167% cpu 1.562 total
instaservice@Instaservices-MacBook-Pro backend-suite % 

Also noticed that oxlint throws few less warnings. eslint shows 1026 warnings, while oxlint shows 1018 warnings. Tried with both bunx and npx.

instaservice@Instaservices-MacBook-Pro backend-suite % bunx eslint --version
v9.39.2
instaservice@Instaservices-MacBook-Pro backend-suite % bunx oxlint --version
Version: 1.50.0

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions