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

Making baseline not reliant on a line numbers #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChobotX
Copy link

@ChobotX ChobotX commented May 30, 2024

Hi @Humni,

As discussed in this issue, I am trying to make your package not reliant on line numbers.

Instead of hashing filePath, message.line, message.column, and message.ruleId, I hash filePath, message.ruleId, and context for comparison of errors instead.

Context is composed of the file lines (one before the error, the error line, and one after it), trimmed from both sides.

Also, the baseline is sorted by file>ruleId>line in order to make it stable between rebuilds.

Let me know if any changes are needed!

index.js Show resolved Hide resolved
@JasonEleventeen
Copy link
Contributor

JasonEleventeen commented Jul 1, 2024

I'd suggest copying the way phpstan does this and just count the unique errors/ruleIds per file, this removes the line count completely so headers/comments etc can be changed without issue

example phpstan baseline

		-
			message: "#^Cannot access property \\$id on mixed\\.$#"
			count: 3
			path: app/Console/Commands/CommandIsBroken.php
			
		-
			message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
			count: 1
			path: app/Console/Commands/CommandIsBroken.php
			

@ChobotX
Copy link
Author

ChobotX commented Jul 2, 2024

@JasonEleventeen phpstan was exactly my inspiration, the problem is, that the error messages from eslint are not specific enough. Tried this way and it was not good at all.

@ChobotX ChobotX requested a review from kodieupton August 1, 2024 08:11
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

Successfully merging this pull request may close these issues.

3 participants