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

processString error format #4

Open
iamstarkov opened this issue Aug 20, 2014 · 2 comments
Open

processString error format #4

iamstarkov opened this issue Aug 20, 2014 · 2 comments

Comments

@iamstarkov
Copy link

  1. Thrown error should have file property which should be relative path to file:
var filename = options && options.filename &&path.relative(file.cwd, file.path)
  1. Thrown error should have clear message property without note about path to current file or csscomb and gonzales versions.

If we csscomb core will throw error in this format then linters will can collect invalid files with errors in and output the result it at the end of linting all the files like this

CSScomb linting failed for these files:
! css/asd.css
! css/qwe.css

css/asd.css
1 | asd{
2*|     asd
3 | }

css/qwe.css
1 | asd{
2*|     color: red !important;
3 | }

Total: 2 bad files.
@tonyganch
Copy link
Member

There are 4 types of errors in CSScomb based on who is responsible for breaking stuff:

  1. User (e.g. unacceptable value in config, something weird in comb.use())
  2. Third-party developer
  3. Parser
  4. Linter

processString method throws only parsing errors, so they have nothing to do with linting.
What you need for a linter (as I think) is a separate method lintString (see csscomb/csscomb.js#261) that will return a list of errors:

[
  {
    file: "css/asd.css",
    line: 2,
    column: 9,
    message: "Missing semicolon"
  }, {
    file: "css/qwe.css",
    line: 2,
    column: 11,
    message: "Extra space after colon"
  }
]

And inside your plugin you can decide yourself how you'll print those errors.

@iamstarkov
Copy link
Author

yep, you are right. separate method is what I need. it will be better in performance too.

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

No branches or pull requests

2 participants