Skip to content

linter: array-type set to 'generic' does not catch Promise<string[]> #8693

@MichaelGoff

Description

@MichaelGoff

What version of Oxlint are you using?

0.15.8

What command did you run?

npx oxlint

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

{
  "env": {
    "browser": true
  },
  "categories": {
    "correctness": "error"
  },
  "rules": {
    "no-unused-vars": ["error", {"args":  "none", "caughtErrors":  "none"}],
    "no-extra-boolean-cast": "off",
    "no-useless-escape": "off",
    "no-useless-catch": "off",
    "no-constant-binary-expression": "off",
    "no-caller": "off",
    "no-await-in-promise-methods": "off",
    "no-useless-fallback-in-spread": "off",
    "no-useless-spread": "off",
    "no-empty-file": "off",
    "prefer-set-size": "off",
    "no-new-array": "off",
    "no-unnecessary-await": "off",
    "prefer-string-starts-ends-with": "off",
    "valid-typeof": ["error", {"requireStringLiterals": true}],

    // Correctness
    "named": "error",
    "default": "error",
    "namespace": "error",

    // Restriction
    "default-case": "error",
    "no-alert": "error",
    "no-console": "error",
    "no-empty": "error",
    "no-empty-object-type": "error",
    "no-eval": "error",
    "no-iterator": "error",
    "no-namespace": "error",
    "no-proto": "error",
    "no-var": "error",
    "no-void": ["error", {"allowAsStatement": true}],
    "no-amd": "error",
    "no-cycle": ["error", {"maxDepth": ""}],
    "no-dynamic-require": "error",
    "no-unnecessary-type-constraint": "error",
    "no-webpack-loader-syntax": "error",

    // Suspicious
    "no-extend-native": "error",
    "no-useless-constructor": "error",
    "no-duplicates": "error",
    "no-named-as-default": "error",
    "no-named-as-default-member": "error",
    "no-self-import": "error",

    // Pedantic
    "ban-ts-comment": "error",
    "eqeqeq": ["error", "always"],
    "no-array-constructor": "error",
    "no-case-declarations": "error",
    "no-constructor-return": "error",
    "no-new-wrappers": "error",
    "no-redeclare": "error",
    "no-self-compare": "error",
    "no-unsafe-function-type": "error",
    "symbol-description": "error",

    // Style
    "array-type": ["error", {"default": "generic"}],
    "default-case-last": "error",
    "no-label-var": "error",
    "no-new-func": "error",
    "no-return-assign": ["error", "always"],
    "no-script-url": "error",
    "no-template-curly-in-string": "error",
    "prefer-exponentiation-operator": "error",
    "prefer-namespace-keyword": "error",
    "prefer-numeric-literals": "error",
    "import/first": "error",
    "yoda": "error"
  }
}

What happened?

When writing a function that returns a promise resolving to an array, oxlint does not catch when the array is written in 'array' style when the config is set to convert to 'generic'.

The Rule:

"array-type": ["error", {"default": "generic"}],

Example code

// oxlint does not catch this violation. Eslint with the same configuration does.
function somePromise() : Promise<string[]> {
  return new Promise((resolve) => resolve(['foo', 'bar']));
}

async function run() {
    console.log(await somePromise());
}
run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linterArea - LinterC-bugCategory - Buggood first issueExperience Level - Good for newcomers

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions