Skip to content

Commit

Permalink
fix: fix detecting a mix of supported/unsupported rules
Browse files Browse the repository at this point in the history
  • Loading branch information
timogasda authored and ismay committed Feb 19, 2022
1 parent 4472c77 commit 9c63dd0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ function ruleFunction(on, options) {
const doiuseOptions = _.pick(options, Object.keys(optionsSchema));
const doiuseResult = new Result();

let usageInfo;
const usedFeatures = {};

doiuseOptions.onFeatureUsage = (info) => {
usageInfo = info;
// Use the node as key to store feature information
usedFeatures[info.usage] = info.featureData;
};

doiuse(doiuseOptions).postcss(root, doiuseResult);
doiuseResult.warnings().forEach((doiuseWarning) => {
if (ignorePartialSupport && usageInfo.featureData.partial && !usageInfo.featureData.missing) {
const featureData = usedFeatures[doiuseWarning.node];
if (featureData && ignorePartialSupport && featureData.partial && !featureData.missing) {
return;
}

Expand Down
23 changes: 23 additions & 0 deletions lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,26 @@ testRule({
},
],
});

// IE 11 mix of not supported and partially supported
testRule({
plugins: ['.'],
ruleName,
config: [
true,
{
browsers: ['IE 11'],
ignorePartialSupport: true,
},
],

reject: [
{
code: 'div { display: flex;\nposition: sticky; }',
description: 'handle unsupported and partially supported separately',
message: `Unexpected browser feature "css-sticky" is not supported by IE 11 (plugin/no-unsupported-browser-features)`,
line: 2,
column: 1,
},
],
});

0 comments on commit 9c63dd0

Please sign in to comment.