mirror of
https://github.com/HackPlan/polaris-react.git
synced 2026-04-29 17:55:57 +08:00
Prior to this version of eslint-plugin-shopify some rules were inadvertently disabled due to ordering of plugins causing prior plugins to be disabled. This has now been fixed so we can see errors for things that were problematic.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
const hash = require('object-hash');
|
|
|
|
function shitlistCheck(results, immutableShitlist) {
|
|
const mutableShitlist = {};
|
|
const remainingIssues = [];
|
|
Object.keys(immutableShitlist).forEach((key) => {
|
|
mutableShitlist[key] = Array.from(immutableShitlist[key]);
|
|
});
|
|
|
|
const filteredResults = results.map((result) => {
|
|
if (mutableShitlist[result.pageUrl]) {
|
|
result.issues = result.issues.filter((issue) => {
|
|
const issueHash = hash(issue);
|
|
const matchIndex = mutableShitlist[result.pageUrl].findIndex(
|
|
(shitlistedResult) => {
|
|
return hash(shitlistedResult) === issueHash;
|
|
},
|
|
);
|
|
if (matchIndex >= 0) {
|
|
mutableShitlist[result.pageUrl].splice(matchIndex, 1);
|
|
}
|
|
return matchIndex === -1;
|
|
});
|
|
}
|
|
return result;
|
|
});
|
|
|
|
Object.keys(mutableShitlist).forEach((key) => {
|
|
if (mutableShitlist[key].length) {
|
|
remainingIssues.push({
|
|
pageUrl: key,
|
|
issues: mutableShitlist[key],
|
|
});
|
|
}
|
|
});
|
|
|
|
return {
|
|
results: filteredResults.filter((result) => result.issues.length),
|
|
remainingIssues: Object.keys(remainingIssues).length
|
|
? remainingIssues
|
|
: null,
|
|
};
|
|
}
|
|
|
|
module.exports.shitlistCheck = shitlistCheck;
|