1
0
mirror of https://github.com/thangisme/notes.git synced 2024-06-16 09:25:23 +00:00
notes/node_modules/stylelint/lib/postcssPlugin.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

28 lines
732 B
JavaScript

/* @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,
})
}
})