Skip to content
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

How to add Iterable type #280

Closed
lgaticaq opened this issue Jun 19, 2019 · 6 comments
Closed

How to add Iterable type #280

lgaticaq opened this issue Jun 19, 2019 · 6 comments
Labels

Comments

@lgaticaq
Copy link

My current settings is:

  // ...
  "eslintConfig": {
    // ...
    "settings": {
      "jsdoc": {
        "preferredTypes": {
          "Iterable": "Iterable"
        }
      }
    }
  },
  // ...
@brettz9
Copy link
Collaborator

brettz9 commented Jun 19, 2019

How to add the Iterable type to do what?

@brettz9
Copy link
Collaborator

brettz9 commented Jun 19, 2019

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

@lgaticaq
Copy link
Author

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

@brettz9
Copy link
Collaborator

brettz9 commented Jun 20, 2019

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"
      }
    }
  }
}

@brettz9
Copy link
Collaborator

brettz9 commented Jun 20, 2019

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

@brettz9 brettz9 closed this as completed Jun 20, 2019
@lgaticaq
Copy link
Author

Thanks 👏

gobengo added a commit to gobengo/hd-scripts that referenced this issue Feb 1, 2023
wrt the mentioned issues with this rule:
* gajus/eslint-plugin-jsdoc#559 is resolved
* gajus/eslint-plugin-jsdoc#280 - this seems like we can [use this workaround](gajus/eslint-plugin-jsdoc#280 (comment)) including configuration for common builtin types here in hd-scripts
hugomrdias pushed a commit to hugomrdias/hd-scripts that referenced this issue Feb 1, 2023
wrt the mentioned issues with this rule:
* gajus/eslint-plugin-jsdoc#559 is resolved
* gajus/eslint-plugin-jsdoc#280 - this seems like we can [use this workaround](gajus/eslint-plugin-jsdoc#280 (comment)) including configuration for common builtin types here in hd-scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants