Skip to content

Rule proposal: ban calls that result into base toString() methods #258

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
mohsen1 opened this issue Feb 12, 2019 · 0 comments · Fixed by #1522
Closed

Rule proposal: ban calls that result into base toString() methods #258

mohsen1 opened this issue Feb 12, 2019 · 0 comments · Fixed by #1522
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented Feb 12, 2019

Code that result into runtime strings like'[object Object]', '[object Function]' and others are usually wrong. if it's possible to trace the prototype chain and determine the call will result in call of Object.prototype.toString, we can warn against it

String({}) 

({}).toString() 

I'm not sure if it's possible to do this with string interpolation:

var a = `${{}}`

Versions

package version
@typescript-eslint/eslint-plugin 1.3.0
@mohsen1 mohsen1 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 12, 2019
@bradzacher bradzacher added enhancement: new plugin rule New rule request for eslint-plugin and removed triage Waiting for team members to take a look labels Feb 12, 2019
kaicataldo pushed a commit to kaicataldo/typescript-eslint that referenced this issue Aug 27, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants