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

Enhancement: Custom error messages #23

Closed
originalfoo opened this issue Jun 19, 2016 · 3 comments
Closed

Enhancement: Custom error messages #23

originalfoo opened this issue Jun 19, 2016 · 3 comments

Comments

@originalfoo
Copy link

Rules

Currently rules have a static error message, it would be useful if they could generate context-sensitive errors, for example:

errors.push({
  lineNumber: whatever,
  error: `The '${headingText}' heading should be at level ${expectedLevel}`
});

Styles

An optional top-level error message that gets output upon the first error for a given batch of documents.

options.config._guidance = 'Please refer to the style guide for more information on the errors below: http://whatever.com/styleguide'

This would be particularly useful in CI builds of open source projects to help guide contributors to the style guide or templates, etc.

@DavidAnson
Copy link
Owner

Makes total sense. Will think about this more and look into it soon! Much appreciated. :)

@originalfoo
Copy link
Author

originalfoo commented Jun 21, 2016

On the subject of custom rule errors, it would be useful if configurable rules stated the config in their error message. For example, I just got these CI errors on some doc updates for eslint:

docs/rules/sort-imports.md: 164: MD004 Unordered list style
docs/rules/sort-imports.md: 37: MD007 Unordered list indentation

I had to search build scripts to work out what params had been sent to the linter, for example how many spaces should be used for list indentation? It would save time if errors looked like this:

docs/rules/sort-imports.md: 164: MD004 Use {asterisk} style for unordered lists
docs/rules/sort-imports.md: 37: MD007 Use {4} spaces when indenting lists

That will enable me, and others, to see at a glance what needs changing to fix an error.

nzakas pushed a commit to eslint/eslint that referenced this issue Jun 22, 2016
* Docs: Consistent example headings & text pt4 #5446

Final batch of es6 docs for this sweep!

1. Ensure each doc has "Examples" heading, and that each
option-specific example pair also has a suitable heading.

2. Ensure text above examples is consistent as per #5446

This PR does not attempt to address issues other than
those stated above; such issues will be dealt with on
subsequent sweeps of the docs detailed in #6444..

* Docs: Fixed lint errors in doc

docs/rules/sort-imports.md: 161: MD004 Unordered list style
docs/rules/sort-imports.md: 162: MD004 Unordered list style
docs/rules/sort-imports.md: 163: MD004 Unordered list style
docs/rules/sort-imports.md: 164: MD004 Unordered list style
docs/rules/sort-imports.md: 37: MD007 Unordered list indentation
docs/rules/sort-imports.md: 37: MD010 Hard tabs
docs/rules/sort-imports.md: 38: MD010 Hard tabs
docs/rules/sort-imports.md: 39: MD010 Hard tabs
docs/rules/sort-imports.md: 40: MD010 Hard tabs

* Docs: List indentation should be 4, not 2

FYI: I've requested enhanced error reporting for markdown linter - e.g.
to expose rule settings in error messages:
DavidAnson/markdownlint#23 (comment)
171
@DavidAnson
Copy link
Owner

This ended up being a bigger task than I expected, but I think it's a significant improvement, thanks for suggesting it!

PS - I did not implement a guidance message because it seems like configuration/process that will be handled differently by various projects (documentation, output message, code comment, etc.).

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

No branches or pull requests

2 participants