duhaime / eslint-plugin-frontmatter

Remove YAML frontmatter from `.js` files before calling ESLint
MIT License
0 stars 3 forks source link

Fix: postprocess reports accurate line numbers (fixes #5) #8

Closed platinumazure closed 6 years ago

platinumazure commented 6 years ago

Note: I removed the trim logic in the preprocessor, for a couple of reasons:

  1. According to the Jekyll front matter docs, front matter doesn't work if there is even a byte order mark. So I take that to mean any whitespace before the initial --- will also prevent Jekyll from processing it. Thus I thought it made more sense to only process files with --- at the very beginning with no leading whitespace.
  2. Removing trailing whitespace from the end of the file could create some false positives or negatives in core ESLint rules (e.g., no-trailing-whitespace, eol-last), which care about trailing whitespace.
  3. In general, the preprocessor should try to change the text as little as possible.

I added some postprocess tests as well-- in those cases, I just used the CLIEngine executeOnFiles method to simplify things a bit. Let me know if you think anything should change.

duhaime commented 6 years ago

Thanks @platinumazure this is helpful!