1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 03:17:30 -04:00
notes/node_modules/stylelint/lib/postcssPlugin.js

28 lines
732 B
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
/* @flow */
"use strict"
const _ = require("lodash")
const createStylelint = require("./createStylelint")
const postcss = require("postcss")
const path = require("path")
module.exports = postcss.plugin("stylelint", function (options) {
options = options || {}
const tailoredOptions/*: Object*/ = options.rules
? { config: options }
: options
const stylelint = createStylelint(tailoredOptions)
return (root, result) => {
let filePath = options.from || _.get(root, "source.input.file")
if (filePath !== undefined && !path.isAbsolute(filePath)) {
filePath = path.join(process.cwd(), filePath)
}
return stylelint._lintSource({
filePath,
existingPostcssResult: result,
})
}
})