Skip to content

Bug: [array-type] Does not validate shape of config #6892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
domdomegg opened this issue Apr 12, 2023 · 1 comment
Closed
4 tasks done

Bug: [array-type] Does not validate shape of config #6892

domdomegg opened this issue Apr 12, 2023 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@domdomegg
Copy link
Contributor

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.3&sourceType=module&code=MYewdgzgLgBAtgTwMpQE4EswHMIC4bQbYDaAujALwxkDcAUKJLCFABYCmqKRO+AgqlQBDBAB5CmLAD5K1UvSA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AQ2mncNqNPRgA2pERcA9tEgAaKJ26FIAXXBgAviDVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

const myStrings: string[] = [];
const otherStrings: Array<string> = [];


### ESLint Config

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

tsconfig

No response

Expected Result

I initially expected that I'd enforce array types (e.g. string[] rather than Array<string> everywhere), becuase I skimmed https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/docs/rules/array-type.md and didn't realise this should be an options object.

This is a user error, and should instead be configured:

    "@typescript-eslint/array-type": ["error", { default: "array" }]

That said, I then expected the rule would give me some kind of warning or error that my eslint config was invalid, so I could debug this quickly.

Actual Result

The rule doesn't complain about its configuration, but instead highlights every array type it sees as an error - and tries to convert them to the other type in a loop.

Additional Info

There is also #6852, which relates to other config not being validated by this rule.

@domdomegg domdomegg added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 12, 2023
@bradzacher
Copy link
Member

This is a duplicate of #6852, yeah - exact same problem.

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Apr 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants