Skip to content

Commit

Permalink
Refactor borderZero position reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Jul 21, 2017
1 parent cbaa535 commit 1e6fe88
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/linters/border_zero.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,40 @@ module.exports = {
return;
}

const value = node.value;

// Bail if it's an actual border
if (node.value !== '0' && node.value !== 'none') {
if (value !== '0' && value !== 'none') {
return;
}

let message;

switch (config.style) {
case 'none':
if (node.value === '0') {
if (value === '0') {
message = this.message.none;
}

break;
case 'zero':
if (node.value === 'none') {
if (value === 'none') {
message = this.message.zero;
}

break;
default:
throw new Error(
'Invalid setting value for borderZero: ' + config.style
);
throw new Error(`Invalid setting value for borderZero: ${ config.style }`);
}

if (message) {
const position = node.positionBy({
word: value
});

return [{
column: node.source.start.column + node.prop.length + node.raws.between.length,
line: node.source.start.line,
column: position.column,
line: position.line,
message: message
}];
}
Expand Down

0 comments on commit 1e6fe88

Please sign in to comment.