dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
eslint next-line directives are broken on format
Not a bug but something to consider. I am not sure if this just needs to be handled manually, maybe?
Example:
// eslint-disable-next-line no-restricted-properties
getNavigateToHelpTroubleshootingArticle = makeActionGetter(this.navigateToHelpTroubleshootingArticle.bind(this));
formats to:
// eslint-disable-next-line no-restricted-properties
getNavigateToHelpTroubleshootingArticle = makeActionGetter(
this.navigateToHelpTroubleshootingArticle.bind(this),
);
now the forbidden property is .bind, and because of the reformat, the eslint-disable-next-line is now pointing to a line that does no longer have the property.
Ideally (this would need semantic understanding of the rule and is quite tricky) this would reformat to:
getNavigateToHelpTroubleshootingArticle = makeActionGetter(
// eslint-disable-next-line no-restricted-properties
this.navigateToHelpTroubleshootingArticle.bind(this),
);
There are two simpler alternatives:
- Do not break lines up that follow an
// <some-tool>-disable-next-linedirective, e.g. just leave the next line unformatted - transform the one liner into:
/* eslint-disable no-restricted-properties */ getNavigateToHelpTroubleshootingArticle = makeActionGetter( this.navigateToHelpTroubleshootingArticle.bind(this), ); /* eslint-enable no-restricted-properties */
- is simple but not ideal
- is a bit more tricky and requires maybe some keyword formatting, but because before the rule was applied to the whole next line, it is safe to split it and mark the block as such.