Skip to content

linter: eslint/no-empty-function with allow: ['functions'] reports anonymous function args #22754

@jeanne-cai

Description

@jeanne-cai

What version of Oxlint are you using?

1.67.0

What command did you run?

yarn oxlint -c oxlint.config.mjs

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

import { defineConfig } from 'oxlint';

export default defineConfig({
    categories: {
        correctness: 'off',
    },
    rules: {
        'eslint/no-empty-function': [
            'error',
            {
                allow: ['functions'],
            },
        ],
    },
});

What happened?

Functions are allowed, but oxlint flags anonymous functions when they are used as arguments or callbacks.

Example:

// no flag
const x = function () {};

// oxlint flags this as incorrect
function fetchData(callback = function () {}) {
    callback();
}

// oxlint flags this as incorrect
button.onclick = function () {};

// oxlint flags this as incorrect
setTimeout(function () {}, 1000);

Output:

  × eslint(no-empty-function): Unexpected empty function
   ╭─[test.ts:5:43]
 4 │ // oxlint flags this as incorrect
 5 │ function fetchData(callback = function () {}) {
   ·                                           ──
 6 │     callback();
   ╰────
  help: Consider removing this function or adding logic to it.

  × eslint(no-empty-function): Unexpected empty function
    ╭─[test.ts:10:30]
  9 │ // oxlint flags this as incorrect
 10 │ button.onclick = function () {};
    ·                              ──
 11 │ 
    ╰────
  help: Consider removing this function or adding logic to it.

  × eslint(no-empty-function): Unexpected empty function
    ╭─[test.ts:13:24]
 12 │ // oxlint flags this as incorrect
 13 │ setTimeout(function () {}, 1000);
    ·                        ──
    ╰────
  help: Consider removing this function or adding logic to it.

Found 0 warnings and 3 errors.
Finished in 74ms on 1 file with 1 rules using 16 threads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions