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

Fix dimension-no-non-numeric-values end positions #907

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/rules/dimension-no-non-numeric-values/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ testRule({
`,
message: messages.rejected("%unit%"),
line: 3,
column: 27,
column: 18,
endLine: 3,
endColumn: 33,
description: "Rejects interpolation with %unit%"
}).concat([
{
code: "$pad: 2; $padAndMore: #{$pad + 5}px;",
description: "reports lint when expression used in interpolation",
line: 1,
column: 34,
column: 23,
endLine: 1,
endColumn: 36,
message: messages.rejected("px")
},
{
Expand All @@ -61,7 +65,9 @@ testRule({
`,
description: "reports lint when mixing accepted and rejected syntax",
line: 3,
column: 39,
column: 32,
endLine: 3,
endColumn: 41,
message: messages.rejected("px")
},
{
Expand All @@ -72,7 +78,9 @@ testRule({
`,
description: "reports lint when mixing accepted and rejected syntax",
line: 3,
column: 39,
column: 32,
endLine: 3,
endColumn: 41,
message: messages.rejected("px")
},
{
Expand All @@ -83,7 +91,9 @@ testRule({
`,
description: "reports lint when mixing normal unit and rejected syntax",
line: 3,
column: 29,
column: 22,
endLine: 3,
endColumn: 33,
message: messages.rejected("vmin")
},
{
Expand All @@ -94,7 +104,9 @@ testRule({
`,
description: "reports lint when mixing normal unit and rejected syntax",
line: 3,
column: 29,
column: 22,
endLine: 3,
endColumn: 33,
message: messages.rejected("vmin")
}
])
Expand Down
5 changes: 1 addition & 4 deletions src/rules/dimension-no-non-numeric-values/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const valueParser = require("postcss-value-parser");
const { utils } = require("stylelint");
const declarationValueIndex = require("../../utils/declarationValueIndex");
const namespace = require("../../utils/namespace");
const ruleUrl = require("../../utils/ruleUrl");

Expand Down Expand Up @@ -107,13 +106,11 @@ function rule(primary) {
}

const unit = matchUnit[1];
const offset = decl.value.indexOf(unit);

utils.report({
ruleName,
result,
message: messages.rejected(unit),
index: declarationValueIndex(decl) + offset,
word: matchUnit[0],
node: decl
});
});
Expand Down