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

feat(lint): add output file option (close #4849) #4850

Merged
merged 2 commits into from
Oct 12, 2020
Merged

feat(lint): add output file option (close #4849) #4850

merged 2 commits into from
Oct 12, 2020

Conversation

ataylorme
Copy link
Contributor

Add an output-file option to the ESLint plugin that saves lint report results to the specified file path.

This mimics the ESLint option of the same name

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:
Closes #4849

@ataylorme
Copy link
Contributor Author

@LinusBorg I just noticed your comments in #4007 -- after I submitted this PR.

So in summary: The lint command itself doesn't do much more than run eslint

Given that, and given that there are eslint options that only work with eslint CLI, not with eslint CLIEngine, I don't think that it's worth re-creating these options in our codebase, as it doesn't take much to run eslint "manually" and use the options directly.

Maybe you will change your mind about implementing the output-file since I did the work 😄

I think it would make more sense to document how to run eslint manually (with which globs etc) to make it work exactly like lint - then people can use that when they need to use eslint options that only work in the cli version.

Does this documentation exist?

@ataylorme
Copy link
Contributor Author

For some more context I am currently adding GitHub actions to existing Vue projects.

I was able to get npm run lint (aliased to vue-cli-service lint) to run and set up branch protection if linting fails.

However, when if there are errors (or even warnings, which still send a status code of 0 allowing the build to pass) they are buried in the GitHub actions CI logs.

I would like to create an actions similar to this ESLint action that annotates the diffs of the pull request with lint errors and warnings.

In order to do that, I need the results of the Vue lint report to analyze -- outside of just being printed in the terminal. Saving the results to a JSON file will allow me to accomplish that.

Once I have the JSON, I can parse it, loop through all errors and warning, then call the GitHub API to add the appropriate annotations to the pull request from a custom GitHub action.

Adds an `output-file` option to the ESLint plugin that saves lint report results to the specified file path.

This mimics the [ESLint option](https://eslint.org/docs/user-guide/command-line-interface#options) of the same name.
@Herr-Sepp
Copy link

Are there any reasons why the Pull request hangs?

I find the "output-file" option really handy because currently the eslint plugin outputs a string (" DONE No lint errors found!") if no errors are found and ignores the --format setting.

Also the change in the documentation would saved me a lot of time, because it is currently just wrong.

@ataylorme
Copy link
Contributor Author

Are there any reasons why the Pull request hangs?

@Herr-Sepp I'm not sure what you mean. All the tests are passing.

If you mean why hasn't it been merged, like most open-source projects, the maintainers of this project donate their time. It is best to have patience, I'm sure they will get to this when they can.

I am grateful for their work and Vue/vue-cli either way.

Copy link
Member

@haoqunjiang haoqunjiang left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the PR and thanks for your understanding!

@haoqunjiang haoqunjiang merged commit 1a0d4df into vuejs:dev Oct 12, 2020
@litan1106
Copy link

Nice. I wanted this --output-file and --format option for ci too.

@ataylorme ataylorme deleted the feature/support-lint-output-file branch October 12, 2020 17:30
@ataylorme
Copy link
Contributor Author

Looks good. Thanks for the PR and thanks for your understanding!

Thank you for merging! I'm looking forward to using this when it makes it into a release

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

Successfully merging this pull request may close these issues.

ESLint --output-file option not supported in @vue/cli-plugin-eslint
4 participants