Eslint-plugin-jsdoc: How to add Iterable type

Created on 19 Jun 2019  路  6Comments  路  Source: gajus/eslint-plugin-jsdoc

My current settings is:

  // ...
  "eslintConfig": {
    // ...
    "settings": {
      "jsdoc": {
        "preferredTypes": {
          "Iterable": "Iterable"
        }
      }
    }
  },
  // ...
question

All 6 comments

How to add the Iterable type to do what?

Do you want to forbid it, recommend a new name, or what?

I got the error: The type 'Iterable' is undefined.eslint(jsdoc/no-undefined-types)

Assuming you have a type Iterable, the simplest solution is for you to add it as part of the definedTypes option within your jsdoc/no-undefined-types rule:

"eslintConfig": {
  "rules": {
    ...
    "jsdoc/no-undefined-types": ["error", {"definedTypes": ["Iterable"]}]
    ...
  }
}

The setting you have referenced would be useful in cases like where you were already calling for renaming some bad type names into a different preferred type name, the preferredTypesDefined option will assume the renaming targets exist as types, allowing you to avoid adding such types again to definedTypes:

"eslintConfig": {
  "rules": {
    ...
    "jsdoc/no-undefined-types": ["error", {"preferredTypesDefined": true}]
    ...
  },
  "settings": {
    "jsdoc": {
      "preferredTypes": {
        "BadlyNamedIterableType": "Iterable"
      }
    }
  }
}

That should answer it, so closing, though feel free to comment further or reopen as needed.

Thanks :clap:

Was this page helpful?
0 / 5 - 0 ratings