Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pehbehbeh committed Nov 29, 2016
2 parents 85547e1 + 936c1e7 commit eedc6d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions lib/linter.js
Expand Up @@ -39,12 +39,15 @@ class Linter {

fileTemplates.forEach((template) => {
const fileErrors = sassLint.lintText({
text: template,
text: template.content,
filename: filename,
format: 'scss'
})

if (fileErrors.messages.length) {
fileErrors.messages.forEach((message) => {
message.line += template.lineOffset
})
this.lintErrors = this.lintErrors.concat(fileErrors)
}
})
Expand All @@ -67,14 +70,28 @@ class Linter {
}

const $ = cheerio.load(dom)
templates = templates.concat($('style[lang="sass"]').text())
templates = templates.concat($('style[lang="scss"]').text())
const template = $('style[lang="scss"]').text()

if (template.length <= 0) {
return
}

templates.push({
content: template,
lineOffset: this.getLineOffset(template, $.text())
})
})

var parser = new htmlparser.Parser(handler)
parser.parseComplete(fileData)
return templates
}

getLineOffset (needle, haystack) {
const targetPosition = haystack.indexOf(needle)
const untilTargetPosition = haystack.substring(0, targetPosition)
return untilTargetPosition.split(/\r?\n/).length - 1
}
}

module.exports = Linter
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "sass-lint-vue",
"version": "0.1.0",
"version": "0.2.0",
"description": "Command line tool to lint Sass styles in Vue single file components.",
"keywords": [
"lint",
Expand Down

0 comments on commit eedc6d9

Please sign in to comment.