Skip to content
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

Unpack todo/warning comments #39

Closed
wants to merge 2 commits into from
Closed

Conversation

jamestalmage
Copy link
Contributor

@jamestalmage jamestalmage commented Jan 11, 2019

Show the warning comments right in the terminal.

Also, will truncate all messages now based on terminal width.
For unpacked warning comments, will drop the ruleId before truncating.

Fixes: #27

Show the warning comments right in the terminal.

Also, will truncate all messages now based on terminal width.
For unpacked warning comments, will drop the ruleId before truncating.
@jamestalmage
Copy link
Contributor Author

Truncates messages according to terminal width.

screenshot 2019-01-11 04 07 33

Will drop the ruleId for no-warning-comments to display more of the message.
screenshot 2019-01-11 04 08 53

index.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

The .source property is not always in the result:

{ ruleId: 'no-warning-comments',
  severity: 1,
  message: 'Unexpected \'todo\' comment.',
  line: 197,
  column: 61,
  nodeType: 'Line',
  endLine: 197,
  endColumn: 118 }

From linting: https://github.com/avajs/ava/blob/c3bcbf2a568c12017fe0da041dc247a226019001/lib/babel-pipeline.js#L197

@jamestalmage
Copy link
Contributor Author

The .source property is not always in the result:

Interesting. Is there a rhym or reason to that? Should we try to recover the comment in that case?

@sindresorhus
Copy link
Owner

Seems you're using an undocumented property. The .source property is documented to be on the result object, not the message object: https://eslint.org/docs/developer-guide/working-with-custom-formatters#the-result-object

@sindresorhus
Copy link
Owner

Also note:

source: The source code for the given file. This property is omitted if this file has no errors/warnings or if the output property is present.
- https://eslint.org/docs/developer-guide/working-with-custom-formatters#the-result-object

So if there's no .source, try .output.

@sindresorhus
Copy link
Owner

Confirmed: eslint/eslint@27e3f24

@sindresorhus sindresorhus changed the title unpack todo/warning comments Unpack todo/warning comments Feb 4, 2019
@jamestalmage
Copy link
Contributor Author

Oh crap.
I guess I should have at least attempted to read documentation.

Unfortunately, our existing test fixtures don't have what I need to test this properly.

I've got a busy next week and a half, but I'll try to get to it next weekend.

Come on GitHub. We need reminders!

@sindresorhus
Copy link
Owner

Come on GitHub. We need reminders!

Agreed! For now, you can go to https://github.com/notifications/read, find the notification for this issue, and click "Save for later". Or click "Mark as unread" here if you use Refined GitHub.

@sindresorhus
Copy link
Owner

Ping :)

(If you're busy, no worries. Just pinging in case you just forgot about it)

@sindresorhus
Copy link
Owner

Closing in favor of sindresorhus/eslint-plugin-unicorn#401. Better and easier to fix the rules instead.

@sindresorhus sindresorhus deleted the explode-warning-comments branch September 27, 2019 10:42
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.

Unpack "todo" comments
2 participants