Files
react-native-devtools-frontend/node_modules/stylelint/lib/invalidScopeDisables.js
T
Mathias Bynens 79e2cf0633 Add stylelint dependency
This also adds CC-BY-4.0 to the list of accepted licenses.

DISABLE_THIRD_PARTY_CHECK=update dependencies

Bug: chromium:1083142
Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
2020-06-11 06:20:04 +00:00

55 lines
1.4 KiB
JavaScript

'use strict';
/** @typedef {import('stylelint').RangeType} RangeType */
/** @typedef {import('stylelint').UnusedRange} UnusedRange */
/** @typedef {import('stylelint').StylelintDisableOptionsReport} StylelintDisableOptionsReport */
/**
* @param {import('stylelint').StylelintResult[]} results
* @param {import('stylelint').StylelintConfig|undefined} config
* @returns {StylelintDisableOptionsReport}
*/
module.exports = function (results, config = {}) {
/** @type {StylelintDisableOptionsReport} */
const report = [];
const usedRules = new Set(Object.keys(config.rules || {}));
usedRules.add('all');
results.forEach((result) => {
// File with `CssSyntaxError` have not `_postcssResult`
if (!result._postcssResult) {
return;
}
/** @type {import('stylelint').StylelintDisableReportEntry} */
const sourceReport = { source: result.source, ranges: [] };
const rangeData = result._postcssResult.stylelint.disabledRanges;
const disabledRules = Object.keys(rangeData);
disabledRules.forEach((rule) => {
if (usedRules.has(rule)) {
return;
}
rangeData[rule].forEach((range) => {
if (!range.strictStart && !range.strictEnd) {
return;
}
sourceReport.ranges.push({
unusedRule: rule,
start: range.start,
end: range.end,
});
});
});
if (sourceReport.ranges.length > 0) {
report.push(sourceReport);
}
});
return report;
};