Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 427821

Summary: [CSSLint] Support CSSLint in HTML files (was: csslint gives different results for external versus embedded stylesheets)
Product: [ECD] Orion Reporter: Anthony Hunter <ahunter.eclipse>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: curtis.windatt.public, emoffatt, grant_gayed, mamacdon, Michael_Rennie
Version: 5.0   
Target Milestone: 9.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Anthony Hunter CLA 2014-02-10 11:54:23 EST
The following embedded css in an html file:

<style> 
div
{
border:2px solid #a1a1a1;
padding:10px 40px; 
background:#dddddd;
width:300px;
border-radius:25px;
}
</style>

Gives one css warning:
line 11: Unrecognized style attribute 'border-radius'.

The same style in a stylesheet: style.css
div {
	border: 2px solid #a1a1a1;
	padding: 10px 40px; 
	background:#dddddd;
	width:300px;
	border-radius:25px;
}

Gives two different warnings but nothing for line 6.
line 2: Using width with border can sometimes make elements larger than you expect.
line 3: Using width with padding can sometimes make elements larger than you expect.

Not sure why the warnings are not identical since the css is exactly the same. I am finding various sets of styles have different results whether they are embedded or are in an external file.
Comment 1 Mark Macdonald CLA 2014-02-10 12:20:30 EST
It's because the warnings on inline HTML are actually provided by JSLint which does a crummy job of validating CSS. CSSLint is currently only run on .css files, and we currently don't have a story for validating embedded content. A similar issue exists for inline <script> tags versus .js files.
Comment 2 Grant Gayed CLA 2014-02-10 12:47:25 EST
This could probably now be done if the styler was to provide API to get at all of its block styles, from which ranges of embedded css or js could be extracted and manually fed to the appropriate validator.  Some additional line number mapping may be needed.
Comment 3 Michael Rennie CLA 2015-02-03 14:17:18 EST
I committed the hooks to use the CCSLint validator, but there is a problem with the way CSSLint produces its warning messages - the problem being it uses line + col infos and the proxy compilation unit used for HTML files works with offsets, so the warnings end up in the wrong place.

Hooks: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=77e4decd83f2eaec9d0d4186cc5f1de1ac3710e7
Comment 4 Curtis Windatt CLA 2015-05-20 10:52:37 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=c87c54c1768a72d5f0f758ccba52219703e66869
Fixed in master

I'm going to do some more testing on linux to check that different line endings don't cause off-by-one errors.

Also will look into tests, but the new functionality doesn't run when you don't have an editor context with line information.

Moving to JS Tools as this is language tooling, not a client bug.
Comment 5 Curtis Windatt CLA 2015-05-20 12:58:50 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=0f709949958eec8868ead6649ae88cf1e28057c8

Mike sent me a patch that separates the compilationUnit changes out into the web tools bundle.  This makes sense as there would be some performance lost in places where we provide the editor context but don't need correct line numbers (js hover/quickfixes is one such place).

Closing as FIXED, though I will confirm the changes are correct on a linux machine.