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

Rule no-extra-spacing-attrs removing other attributes. #137

Closed
maheshbansod opened this issue Jul 17, 2023 · 4 comments · Fixed by #139
Closed

Rule no-extra-spacing-attrs removing other attributes. #137

maheshbansod opened this issue Jul 17, 2023 · 4 comments · Fixed by #139
Labels
bug Something isn't working

Comments

@maheshbansod
Copy link
Contributor

maheshbansod commented Jul 17, 2023

Noticed that if an attribute value with special characters (e.g. _ / { ) or some invalid value appears in HTML and the rule @html-eslint/no-extra-spacing-attrs is active then eslint (with --fix) strips off everything after the attribute name.

Example:
HTML

<a target=”_blank” a b c d e f>
link
</a>

eslint config:

{
	"plugins": ["@html-eslint"],
	"overrides": [{
		"files": ["*.html"],
		"parser": "@html-eslint/parser",
		"rules": {
			"@html-eslint/no-extra-spacing-attrs": ["warn"]
		}
	}]
}

Observed result HTML:

<a target>
link
</a>

Edit: I've not quite figured out the actual problem.. after changing it to target="blank" (i.e. without special characters), I still get the same result - the other attributes are removed - this doesn't happen in case of href attribute.

@yeonjuan
Copy link
Owner

yeonjuan commented Jul 19, 2023

Hi @maheshbansod , Thanks for the reporting.
I can reproduce it with but cannot reproduce with ". (Is the a typo?)
But I think the autofix is wrong anyway.

@maheshbansod
Copy link
Contributor Author

You're right, @yeonjuan , the " was a typo. Embarassd that I didn't notice it sooner 😄
I guess it's breaking for special characters then.

@yeonjuan yeonjuan added the bug Something isn't working label Jul 20, 2023
@yeonjuan
Copy link
Owner

It's bugs in es-html-parser.
The parser produces incorrect location information.

스크린샷 2023-07-21 오전 12 32 25

@yeonjuan
Copy link
Owner

@maheshbansod It's fixed and released! (v1.9.1) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants