Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 14d313e

Browse files
committed
Fix result.errored and make codes more readable
1 parent 088e986 commit 14d313e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/index.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ module.exports = options => ({
4444
.filter(
4545
warning =>
4646
// Filter indentation warnings generated by interpolations substitution
47-
warning.rule !== 'indentation' ||
48-
interpolationLines.indexOf(lineCorrection[warning.line]) < 0
47+
!(
48+
warning.rule === 'indentation' &&
49+
interpolationLines.indexOf(lineCorrection[warning.line]) >= 0
50+
)
4951
)
5052
.map(warning =>
5153
Object.assign({}, warning, {
@@ -56,10 +58,11 @@ module.exports = options => ({
5658
})
5759
)
5860

59-
return Object.assign({}, stylelintResult, {
60-
warnings,
61-
// Remember to fix
62-
errored: warnings.length ? true : undefined
63-
})
61+
const result = Object.assign({}, stylelintResult, { warnings })
62+
// Undo `errored` if no warnings with error severity any more
63+
if (result.errored && !warnings.some(warning => warning.severity === 'error')) {
64+
delete result.errored
65+
}
66+
return result
6467
}
6568
})

src/parsers/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ const processStyledComponentsFile = (ast, absolutePath, options) => {
7777
sourceMap,
7878
getSourceMap(extractedCSS.join('\n'), wrappedContent, processedNode.quasi.loc.start.line)
7979
)
80-
// Save interpolation lines
80+
// Save dummy interpolation lines
8181
node.quasi.expressions.forEach((expression, i) => {
82+
// Skip the end line of previous text
83+
// because the indentation is not generated by substitution
8284
let l = node.quasi.quasis[i].loc.end.line + 1
8385
while (l <= node.quasi.quasis[i + 1].loc.start.line) {
8486
interpolationLines.push(l)

0 commit comments

Comments
 (0)