Skip to content

Bug: [array-type] the config simple-array should be disallowed by the schema #6852

@Gotos

Description

@Gotos

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.0.2&sourceType=module&code=MYewdgzgLgBAhgLhgCmgJwJZgOYwD4xgCuAtgEYCmaAlANoC6MAvDAwNwBQoksZSx5Kg2at6nbtBjAkAQTRo4ATwA86LLgIDKaAHwj2XcJIAms+UuVaqeluyA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AQ2mncNqNPRgA2pERcA9tEgAaTJAAmiAGbsE+QZGSUAtsSS1O3QpAC+AXXBgTIE0A

Repro Code

const a: (string | number)[] = [];
const b: number[] = [];
const c: Array<string | number> = [];
const d: Array<number> = [];

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  "rules": {
    "@typescript-eslint/array-type": ["error", {"default": "simple-array"}]
  }
};

tsconfig

No response

Expected Result

The constants a and d should fail the 'array-simple' rule and thus cause the following errors:

a: Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>'
d: Array type using 'Array<number>' is forbidden for simple types. Use 'number[]' instead.

Actual Result

All four constants fail the rule and cause errors. This means for example that neither number[] nor Array<number> is allowed, making it impossible to annotate array types without causing eslint error, if the "array-type" rule is configured with "simple-array".

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy