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

Fix: Do not output undefined as line and column when it's unavailable in checkstyle format #13519

Merged
merged 1 commit into from Jul 31, 2020

Conversation

haya14busa
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What did you do? Please include the actual source code causing the issue.
Run eslint with checkstyle format and .eslintignore.

$ eslint ./testdata/*.js -f=checkstyle

What did you expect to happen?
eslintignore warning should output line and column as 0 or do not output line and column fields.

What actually happened? Please include the actual, raw output from ESLint.
eslintignore warning output undefined as line and column fields of checkstyle XML.

<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name="/home/haya14busa/src/github.com/reviewdog/action-eslint/testdata/test.js"><error line="undefined" column="undefined" severity="warning" message="File ignored because of a matching ignore pattern. Use &quot;--no-ignore&quot; to override." source="" /></file></checkstyle>

What changes did you make? (Give an overview)

Use 0 if line and column are undefined. It's consistent with other formatters.

Is there anything you'd like reviewers to focus on?

N/A

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jul 22, 2020
@haya14busa haya14busa changed the title Fix: Do not output undefined as line and column when it's unavailable Fix: Do not output undefined as line and column when it's unavailable in checkstyle format Jul 22, 2020
@mdjermanovic mdjermanovic added bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion formatter Relates to the formatters bundled with ESLint and removed triage An ESLint team member will look at this issue soon labels Jul 22, 2020
@mdjermanovic
Copy link
Member

Hi @haya14busa, thanks for the PR!

eslintignore warning should output line and column as 0 or do not output line and column fields.

I think it's safe to output 0 (just as you implemented) rather than to omit those attributes, because some tools might expect them to be defined.

@mdjermanovic
Copy link
Member

@haya14busa
Copy link
Contributor Author

haya14busa commented Jul 28, 2020

I don't know, unfortunately. I just found this issue because parsing XML itself failed because line and column value was string "undefined".

As far as I know, there are no formal spec of checkstyle XML format (although many tools use it).
I checked the history briefly and looks like line presents from the beginning and column was added later (it's still from very old. May 13, 2002) as optional.
checkstyle/checkstyle@65989e7
This is just my guess, but at that time probably all check results have line number so there is no if check for line.

I'm fine to omit column if you prefer or omit both.
I think there are too many tools which consume checkstyle XML to check which is better.
I'd say both should be much better than "undefined" though.

@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 28, 2020
@mdjermanovic
Copy link
Member

Agreed, it definitely shouldn't be "undefined", so marked as accepted.

Since there is no formal spec, and since it seems that checkstyle itself can produce line="0" which should indicate that it isn't a location within the code, line="0" column="0" might be the best choice to start with. We could change it later (e.g., omit the column) based on the feedback.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kaicataldo kaicataldo merged commit 318fe10 into eslint:master Jul 31, 2020
@haya14busa haya14busa deleted the fix-checkstyle-undefined branch August 4, 2020 10:18
moeriki added a commit to moeriki/eslint that referenced this pull request Aug 9, 2020
…gnore-default-values

* upstream/master: (66 commits)
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  Chore: remove leche (fixes eslint#13287) (eslint#13533)
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  7.6.0
  Build: changelog update for 7.6.0
  Update: require `meta` for fixable rules in RuleTester (refs eslint#13349) (eslint#13489)
  Docs: fix broken links in developer guide (eslint#13518)
  Fix: Do not output `undefined` as line and column when it's unavailable (eslint#13519)
  Sponsors: Sync README with website
  Sponsors: Sync README with website
  Fix: Update the chatroom link to go directly to help channel (eslint#13536)
  Sponsors: Sync README with website
  Update: Change no-duplicate-case to comparing tokens (fixes eslint#13485) (eslint#13494)
  Docs: add ECMAScript 2020 to README (eslint#13510)
  7.5.0
  ...
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 28, 2021
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly formatter Relates to the formatters bundled with ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants