Skip to content

add --verbose flag#415

Draft
MFTabriz wants to merge 8 commits into
igorshubovych:masterfrom
MFTabriz:verbose
Draft

add --verbose flag#415
MFTabriz wants to merge 8 commits into
igorshubovych:masterfrom
MFTabriz:verbose

Conversation

@MFTabriz
Copy link
Copy Markdown
Contributor

@MFTabriz MFTabriz commented Jul 31, 2023

--verbose flag can be used to ensure linter is actually parsing the files when using globs or for general debugging.

PS: I couldn’t think of a simple solution to logs the relevant messages after each file’s name.

@MFTabriz MFTabriz marked this pull request as ready for review July 31, 2023 21:32
@MFTabriz
Copy link
Copy Markdown
Contributor Author

MFTabriz commented Jul 31, 2023

The failing test (failing to parse error message on windows) seems to be unrelated to this PR. It is the same issue which is blocking the dependabot.

@MFTabriz
Copy link
Copy Markdown
Contributor Author

MFTabriz commented Jul 31, 2023

I think I also fixed the path issue on windows!

@DavidAnson
Copy link
Copy Markdown
Collaborator

Do you mind applying that test path fix to the pending Dependabot PR? It should pass after that and I'll accept the PR.

Copy link
Copy Markdown
Collaborator

@DavidAnson DavidAnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tiny change request and also one thing to think about: Is "verbose" the right name for this flag? It's not wrong but it's also pretty specific about reporting "progress" - so is something like that maybe better?

Comment thread markdownlint.js Outdated
@DavidAnson
Copy link
Copy Markdown
Collaborator

Appreciate the tests, BTW!

@MFTabriz MFTabriz marked this pull request as draft July 31, 2023 23:13
@DavidAnson
Copy link
Copy Markdown
Collaborator

Looks good - tho I can't merge it because it's a Draft PR?

@MFTabriz
Copy link
Copy Markdown
Contributor Author

MFTabriz commented Aug 1, 2023

Looks good - tho I can't merge it because it's a Draft PR?

Thanks for your quick feedback and helps. I'm trying an idea (and simultaneously learning a bit of JS). I'll finalize this in a couple of days.

@DavidAnson
Copy link
Copy Markdown
Collaborator

I'm not sure there's a lot of room to improve upon what you have here, but I will keep an open mind until I see what you're up to. :)

meisam added 3 commits August 1, 2023 23:44
file names given to and received the library are logged independently
linters’s success messages are logged to stdout and fail to stderr
@MFTabriz
Copy link
Copy Markdown
Contributor Author

MFTabriz commented Aug 3, 2023

@DavidAnson Thanks for keeping an open mind. 😄I hope you are not allergic to bad JS codes!

Now the --verbose flag:

  • logs version
  • logs the list of the files given to the linter and the list of files reported back separately
  • respects --quiet and --output

As you already know, I’m not familiar with idiomatic JS. I’ll appreciate if you can guide me to improve this PR.

@MFTabriz MFTabriz marked this pull request as ready for review August 3, 2023 19:10
Copy link
Copy Markdown
Collaborator

@DavidAnson DavidAnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see what you're going for and it makes sense in the context of what I've seen from other tools! However, the new behavior raises some more questions and I've left new comments. I will need to look at this again on a bigger screen than my phone, but I think this captures all the significant feedback. Thank you!

Comment thread markdownlint.js
program.parse(process.argv);

if (options.quiet && options.verbose) {
options.verbose = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me feel like it's one setting with three values?

Comment thread markdownlint.js
const customRules = loadCustomRules(options.rules);
const diff = files.filter(file => !ignores.some(ignore => ignore.absolute === file.absolute)).map(paths => paths.original);
if (options.verbose && !options.stdin) {
console.log('files to check:', diff.join(' '));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be all on the same line? That is harder to scan visually.

Comment thread markdownlint.js
const fixes = fixResult[file].filter(error => error.fixInfo);
if (fixes.length > 0) {
if (options.verbose && !options.output) {
console.log('fixing', file);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a colon above, let's use one here also.

Comment thread markdownlint.js
);
.filter(Boolean);

let lintResultString = '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of keeping this, I think it can be removed and recreated if it is needed. It looks like it is empty exactly when the strings array has no elements?

Comment thread markdownlint.js
// @see {@link https://nodejs.org/dist/latest-v8.x/docs/api/process.html#process_process_exit_code}
// @see {@link https://github.com/igorshubovych/markdownlint-cli/pull/29#issuecomment-343535291}
process.exitCode = exitCodes.lintFindings;
return `${result.file}: ✔`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect failing files to end with a little 'x'?

Comment thread test/test.js
t.is(result.exitCode, 0);
});

test('--verbose flag with --fix for incorrect file', async t => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for verbose with broken file (no fix).

Comment thread test/test.js
t.is(result.exitCode, 0);
});

test('--output and --verbose with valid input logs nothing to console', async t => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could argue that verbose should always mean "verbose to console". If so, these two test cases would not be different. Just like I don't like how quiet and verbose overlap, disabling verbose for output seems not obvious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants