Skip to content
Permalink
Browse files

Fix: Off-by-one error with hint-css-prefix-order

Locations reported by `postcss` are one-based wheraes those used within
`webhint` are zero-based. The hint-compat-api already accounted for
this discrepency and now hint-css-prefix-order does as well.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Close #1955
  • Loading branch information...
antross authored and molant committed Feb 22, 2019
1 parent 173e35b commit 091a3b1968360c1745372a4eba45148e4970e9e0
Showing with 30 additions and 21 deletions.
  1. +10 −1 packages/hint-css-prefix-order/src/hint.ts
  2. +20 −20 packages/hint-css-prefix-order/tests/tests.ts
@@ -22,7 +22,16 @@ type DeclarationPair = {

/** Convert `NodeSource` details to a `ProblemLocation`. */
const getLocation = (decl: Declaration): ProblemLocation => {
return decl.source && decl.source.start || {
const start = decl.source && decl.source.start;

if (start) {
return {
column: start.column - 1,
line: start.line - 1
};
}

return {
column: 0,
line: 0
};
@@ -28,8 +28,8 @@ const tests: HintTest[] = [
reports: [{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 3
column: 4,
line: 2
}
}],
serverConfig: generateConfig('interleaved-prefixes')
@@ -43,8 +43,8 @@ const tests: HintTest[] = [
reports: [{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
}],
serverConfig: generateConfig('mixed-with-prefixes-last')
@@ -55,15 +55,15 @@ const tests: HintTest[] = [
{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
},
{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 8
column: 4,
line: 7
}
}
],
@@ -75,15 +75,15 @@ const tests: HintTest[] = [
{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
},
{
message: `'background-size' should be listed after '-moz-background-size'.`,
position: {
column: 5,
line: 5
column: 4,
line: 4
}
}
],
@@ -102,8 +102,8 @@ const tests: HintTest[] = [
reports: [{
message: `'display: grid' should be listed after 'display: -ms-grid'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
}],
serverConfig: generateConfig('prefixed-values-last')
@@ -121,8 +121,8 @@ const tests: HintTest[] = [
reports: [{
message: `'appearance' should be listed after '-moz-appearance'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
}],
serverConfig: generateConfig('prefixes-last-moz')
@@ -132,8 +132,8 @@ const tests: HintTest[] = [
reports: [{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 12,
line: 1
column: 11,
line: 0
}
}],
serverConfig: generateConfig('prefixes-last-same-line')
@@ -143,8 +143,8 @@ const tests: HintTest[] = [
reports: [{
message: `'appearance' should be listed after '-webkit-appearance'.`,
position: {
column: 5,
line: 2
column: 4,
line: 1
}
}],
serverConfig: generateConfig('prefixes-last-webkit')

0 comments on commit 091a3b1

Please sign in to comment.
You can’t perform that action at this time.