Using an ID in a selector should report first ID column #459

Open
wants to merge 1 commit into
from

Projects

None yet

5 participants

@jgable
jgable commented Mar 1, 2014
  • Grab the col the first id was found at in a selector from the part
  • Report it later instead of selector.col
  • Add unit tests for single and multiple ids

The use case for this is that in the grunt-lesslint task we are using source maps to show the original less line that causes the error and since it's reporting column 0 the relevent LESS line is not as accurate as it could be.

For reference: jgable/grunt-lesslint#6

@joshuaspence

+1

@nschonni nschonni added the Triage label Apr 2, 2014
@nschonni nschonni and 1 other commented on an outdated diff Apr 7, 2014
src/rules/ids.js
@@ -31,6 +32,9 @@ CSSLint.addRule({
for (k=0; k < part.modifiers.length; k++){
modifier = part.modifiers[k];
if (modifier.type == "id"){
+ if (!firstIdCol) {
@nschonni
nschonni Apr 7, 2014 Member

When part.col is zero (ID is in the first selector column), then this will coerce to true on the second iteration

firstIdCol = typeof firstIdCol === "undefined" ? part.col : firstIdCol;
@jgable
jgable Apr 7, 2014

Good catch, will update shortly.

@jgable jgable Using an ID in a selector should report first ID col
- Grab the col the first id was found at in a selector
- Report it later instead of selector.col
- Add unit tests for single and multiple ids
68d4348
@jgable
jgable commented Apr 7, 2014

Updated

  • Switch to explicit false check to prevent possible truthy coercion on second iteration when id is in 0th column.
  • Rebased on master.
@XhmikosR
Member
XhmikosR commented Jan 9, 2016

@jgable: can you fetch and rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment