Disable inline comments out of diff-scope #1195
BrunnerLivio
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
I don't think we need this, you can use |
Beta Was this translation helpful? Give feedback.
1 reply
-
I was able to figure it out. It's a bit cumbersome but it works: async function getAddedLinesForFile(path: string): Promise<number[]> {
const structuredDiff = await danger.git.structuredDiffForFile(path);
const chunks = structuredDiff.chunks.reduce(
(prev, chunk) => prev.concat(chunk.changes),
[]
) as { ln: number; type: string }[];
const lines = chunks
.filter((chunk) => chunk.type === "add")
.map((chunk) => chunk.ln);
return [...new Set(lines)];
}
async function printLinterMessages() {
// The file you wanna lint
const path = 'my-file.md';
// Warning maybe coming from remark or another linter
const warnings = [{ line: 13, message: '"modify" is wordy or unneeded' }]
const addedLines = await getAddedLinesForFile(path);
warnings
// Only get the warnings which were added by the user
.filter(w => addedLines.include(w.line))
.forEach(w => warn(w.message, path, w.line))
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using e.g.
warn('Message', 'my-file.js', 203)
, Danger automatically adds an inline comment to the file ifmy-file.js#203
is part of the diff in Gitlab (don't know about the other Platforms. If it is outside of the diff-scope, it will just simply add it to the PR comment.Would it be possible to decide per message or globally whether the messages out of the "diff" should be displayed?
Some options:
Using paramter
Globally disable it
Programmatic way
Beta Was this translation helpful? Give feedback.
All reactions