Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

7
node_modules/stylelint/lib/formatters/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
"use strict"
module.exports = {
json: require("./jsonFormatter"),
string: require("./stringFormatter"),
verbose: require("./verboseFormatter"),
}

11
node_modules/stylelint/lib/formatters/jsonFormatter.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict"
const _ = require("lodash")
// Omit any properties starting with `_`, which are fake-private
module.exports = function (results) {
const cleanedResults = results.map(result => {
return _.omitBy(result, (value, key) => key[0] === "_")
})
return JSON.stringify(cleanedResults)
}

View File

@@ -0,0 +1,30 @@
"use strict"
const chalk = require("chalk")
const path = require("path")
function logFrom(fromValue) {
if (fromValue.charAt(0) === "<") return fromValue
return path.relative(process.cwd(), fromValue).split(path.sep).join("/")
}
module.exports = function (report) {
let output = ""
report.forEach(sourceReport => {
if (!sourceReport.ranges || sourceReport.ranges.length === 0) {
return
}
output += "\n"
output += chalk.underline(logFrom(sourceReport.source)) + "\n"
sourceReport.ranges.forEach(range => {
output += `start: ${range.start}`
if (range.end !== undefined) {
output += `, end: ${range.end}`
}
output += "\n"
})
})
return output
}

View File

@@ -0,0 +1,140 @@
"use strict"
const table = require("table")
const _ = require("lodash")
const chalk = require("chalk")
const path = require("path")
const stringWidth = require("string-width")
const symbols = require("log-symbols")
const utils = require("postcss-reporter/lib/util")
const MARGIN_WIDTHS = 9
const levelColors = {
info: "blue",
warning: "yellow",
error: "red",
}
function deprecationsFormatter(results) {
const allDeprecationWarnings = _.flatMap(results, "deprecations")
const uniqueDeprecationWarnings = _.uniqBy(allDeprecationWarnings, "text")
if (!uniqueDeprecationWarnings || !uniqueDeprecationWarnings.length) {
return ""
}
return uniqueDeprecationWarnings.reduce((output, warning) => {
output += chalk.yellow("Deprecation Warning: ")
output += warning.text
if (warning.reference) {
output += chalk.dim(" See: ")
output += chalk.dim.underline(warning.reference)
}
return output + "\n"
}, "\n")
}
function invalidOptionsFormatter(results) {
const allInvalidOptionWarnings = _.flatMap(results, r => r.invalidOptionWarnings.map(w => w.text))
const uniqueInvalidOptionWarnings = _.uniq(allInvalidOptionWarnings)
return uniqueInvalidOptionWarnings.reduce((output, warning) => {
output += chalk.red("Invalid Option: ")
output += warning
return output + "\n"
}, "\n")
}
function logFrom(fromValue) {
if (fromValue.charAt(0) === "<") return fromValue
return path.relative(process.cwd(), fromValue).split(path.sep).join("/")
}
function getMessageWidth(columnWidths) {
if (!process.stdout.isTTY) {
return columnWidths[3]
}
const availableWidth = process.stdout.columns < 80 ? 80 : process.stdout.columns
const fullWidth = _.sum(_.values(columnWidths))
// If there is no reason to wrap the text, we won't align the last column to the right
if (availableWidth > fullWidth + MARGIN_WIDTHS) {
return columnWidths[3]
}
return availableWidth - (fullWidth - columnWidths[3] + MARGIN_WIDTHS)
}
function formatter(messages, source) {
if (!messages.length) return ""
const orderedMessages = _.sortBy(messages, m => m.line ? 2 : 1, // positionless first
m => m.line, m => m.column)
// Create a list of column widths, needed to calculate
// the size of the message column and if needed wrap it.
const columnWidths = { 0: 1, 1: 1, 2: 1, 3: 1, 4: 1 }
const calculateWidths = function (columns) {
_.forOwn(columns, (value, key) => {
const normalisedValue = value ? value.toString() : value
columnWidths[key] = Math.max(columnWidths[key], stringWidth(normalisedValue))
})
return columns
}
let output = "\n"
if (source) {
output += chalk.underline(logFrom(source)) + "\n"
}
const cleanedMessages = orderedMessages.map(message => {
const location = utils.getLocation(message)
const severity = message.severity
const row = [ location.line || "", location.column || "", symbols[severity] ? chalk[levelColors[severity]](symbols[severity]) : severity, message.text
// Remove all control characters (newline, tab and etc)
.replace(/[\x01-\x1A]+/g, " ") // eslint-disable-line
.replace(/\.$/, "").replace(new RegExp(_.escapeRegExp("(" + message.rule + ")") + "$"), ""), chalk.dim(message.rule || "") ]
calculateWidths(row)
return row
})
output += table.table(cleanedMessages, {
border: table.getBorderCharacters("void"),
columns: {
0: { alignment: "right", width: columnWidths[0], paddingRight: 0 },
1: { alignment: "left", width: columnWidths[1] },
2: { alignment: "center", width: columnWidths[2] },
3: { alignment: "left", width: getMessageWidth(columnWidths), wrapWord: true },
4: { alignment: "left", width: columnWidths[4], paddingRight: 0 },
},
drawHorizontalLine: () => false,
}).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/, (m, p1, p2) => chalk.dim(p1 + ":" + p2))).join("\n")
return output
}
module.exports = function (results) {
let output = invalidOptionsFormatter(results)
output += deprecationsFormatter(results)
output = results.reduce((output, result) => {
output += formatter(result.warnings, result.source)
return output
}, output)
// Ensure consistent padding
output = output.trim()
if (output !== "") {
output = "\n" + output + "\n\n"
}
return output
}

View File

@@ -0,0 +1,49 @@
"use strict"
const _ = require("lodash")
const chalk = require("chalk")
const stringFormatter = require("./stringFormatter")
module.exports = function (results) {
let output = stringFormatter(results)
if (output === "") {
output = "\n"
}
const sourceWord = results.length > 1 ? "sources" : "source"
const ignoredCount = results.filter(result => result.ignored).length
const checkedDisplay = ignoredCount ? `${results.length - ignoredCount} of ${results.length}` : results.length
output += chalk.underline(`${checkedDisplay} ${sourceWord} checked\n`)
results.forEach(result => {
let formatting = "green"
if (result.errored) {
formatting = "red"
} else if (result.warnings.length) {
formatting = "yellow"
} else if (result.ignored) {
formatting = "dim"
}
let sourceText = `${result.source}`
if (result.ignored) {
sourceText += " (ignored)"
}
output += _.get(chalk, formatting)(` ${sourceText}\n`)
})
const warnings = _.flatten(results.map(r => r.warnings))
const warningsBySeverity = _.groupBy(warnings, "severity")
const problemWord = warnings.length === 1 ? "problem" : "problems"
output += chalk.underline(`\n${warnings.length} ${problemWord} found\n`)
_.forOwn(warningsBySeverity, (warningList, severityLevel) => {
const warningsByRule = _.groupBy(warningList, "rule")
output += ` severity level "${severityLevel}": ${warningList.length}\n`
_.forOwn(warningsByRule, (list, rule) => {
output += chalk.dim(` ${rule}: ${list.length}\n`)
})
})
return output + "\n"
}