-
Notifications
You must be signed in to change notification settings - Fork 889
Pass all linted file names to formatter #3838
Pass all linted file names to formatter #3838
Conversation
Thanks for your interest in palantir/tslint, @mastermatt! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks really great! just one small comment about the formatter interface
@@ -20,7 +20,7 @@ import { IFormatter, IFormatterMetadata } from "./formatter"; | |||
|
|||
export abstract class AbstractFormatter implements IFormatter { | |||
public static metadata: IFormatterMetadata; | |||
public abstract format(failures: RuleFailure[]): string; | |||
public abstract format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if i'm wrong: these parameters in the interface definition should not have ?
as they are always passed to the implementation. implementors should instead choose to omit the args from their implementations if unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@giladgray I think you're right. I was following the convention already on fixes
in IFormatter
, however, since the args are always provided they shouldn't be marked as optional.
I've pushed a patch to remove the ?
s.
*/ | ||
format(failures: RuleFailure[], fixes?: RuleFailure[]): string; | ||
format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, pretty sure the params should not be marked optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you mean or if this is still relevant. required arguments can't come after optional arguments. and we don't want to break this API.
As noted in comments on palantir#3838, these parameters in the interface definition should not have `?` as they are always passed to the implementation. Implementors should instead choose to _omit_ the args from their implementations if unused.
@giladgray I was quick to push a patch that removed the |
ba646a1
to
76c2ece
Compare
@mastermatt the CI failures do not look related to the formatter syntax. i don't see any such incompatibilities. |
@giladgray these are the errors I get:
|
76c2ece
to
1690abb
Compare
@giladgray any thoughts on this? |
@mastermatt as a brief follow up, it looks to me like the failing tests are because those tests are using the |
ad2e789
to
7a6fbe8
Compare
Could I get some eyes on this again? To address the comments by @giladgray and @johnwiseheart: @giladgray was right with his first set of comments. The args should not be marked as optional on the |
@mastermatt can you resolve merge conflicts here so we can merge this PR? |
For palantir#3837, allows the Checkstyle and JUnit formatters to output the files that did not have any failures. Adding a third argument to `IFormatter.format` seems like a more reasonable option than changing its signature and having a breaking change.
7a6fbe8
to
013a9ee
Compare
@giladgray done. |
const groupedFailures: { [k: string]: RuleFailure[] } = {}; | ||
for (const failure of failures) { | ||
const fileName = failure.getFileName(); | ||
if (fileName in groupedFailures) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically we don't use the in
operator (sorry, I know we should lint for it)
*/ | ||
format(failures: RuleFailure[], fixes?: RuleFailure[]): string; | ||
format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you mean or if this is still relevant. required arguments can't come after optional arguments. and we don't want to break this API.
src/language/formatter/formatter.ts
Outdated
@@ -55,6 +55,7 @@ export interface IFormatter { | |||
* Formats linter results | |||
* @param failures Linter failures that were not fixed | |||
* @param fixes Fixed linter failures. Available when the `--fix` argument is used on the command line | |||
* @param fileNames All of file paths that were linted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"All of the file paths that were linted"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but let's wait until we're ready to release 5.13 before merging this (I think there will be a 5.12.1 release before that)
Lint failure is unrelated due to a semantic merge conflict, I'll fix it on master |
PR checklist
Overview of change:
Allows the Checkstyle and JUnit formatters to output the
files that did not have any failures.
Is there anything you'd like reviewers to focus on?
Adding a third argument to
IFormatter.format
seems like a more reasonable option than changing its signature and having a breaking change, but it's not pretty.CHANGELOG.md entry:
[enhancement] Formatters now receive the full list of of linted file paths as a third argument.
[enhancement] Checkstyle formatter includes every file linted regardless of lint errors.