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

V2 Annotation #37

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

V2 Annotation #37

wants to merge 5 commits into from

Conversation

billyma
Copy link
Collaborator

@billyma billyma commented Dec 22, 2021

V2 Annotation to enable Eslint-like behavior to ignore / to allow SLDS Recommendation. With this PR, SLDS-LSP supports the follow: In-Line Option, Full File Option, Global Option.

This PR changes how CSS handles Annotation.

new Range(
new Location(i, startColumnIgnore),
new Location(Integer.MAX_VALUE, Integer.MAX_VALUE)
new Location(i, Integer.MAX_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is changing Integer.MAX_VALUE to i intentional? From what I recall (rather vaguely) the point here was to figure out the range that suppression should be applied to.

For example, if we had a doc with 100 lines and at line i=50 we encountered sldsValidatorIgnore but in lines 51-100 there were no mention of sldsValidatorAllow then we would want to suppress warnings in lines 50-100 (which I believe is consistent with ESLint rules).

But with this change here, we would only ignore lines 50-50 instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the previous version, annotation applied to the line only. Let me play with it to see what the syntax would look like. Thanks.

Copy link
Collaborator Author

@billyma billyma Dec 27, 2021

Choose a reason for hiding this comment

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

Here is what I'm thinking for CSS, let me know what you think

/* ESLint Pattern */
/* @sldsValidatorIgnore */ .THIS { padding: 0; } /* @sldsValidatorAllow */

.THIS { /* @sldsValidatorIgnoreNextLine */ 
padding: 0;
padding: 0;
}

/*CSS Lint Pattern for inline ignore */
.THIS { /* @sldsValidatorIgnore */ padding: 0
padding: 0; }

Copy link
Contributor

Choose a reason for hiding this comment

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

When I was adding the support for linting warning suppression for HTML files, I decided to use <!-- sldsValidatorIgnoreNextLine --> for ignoring the line containing the warning and to use <!-- sldsValidatorIgnore --> + <!-- sldsValidatorAllow --> to ignore a range... and if we added <!-- sldsValidatorIgnore --> without <!-- sldsValidatorAllow --> then all the following lines would be ignored. Here's a screenshot of this behavior:
slds

I decided to implement it this way b/c this seemed to be inline with what I was observing with ESLint in VSCode on a Typescript file. I did not design the suppression per HTML tag or what an HTML tag would contain, but rather it was purely based on row/column ranges in a document.

I would leave it at your discretion to decide whether it makes sense to follow the same pattern for CSS files or not... although it would be nice to have the same behavior everywhere.

@billyma billyma marked this pull request as ready for review December 29, 2021 22:48
Copy link
Contributor

@maliroteh-sf maliroteh-sf left a comment

Choose a reason for hiding this comment

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

Left a comment about suppression approach I used for HTML files vs what you're using for CSS files. I'll leave it up to you to decide on the approach best fitting for CSS files. Aside from that LGTM 👍

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.

None yet

2 participants