stylelint-plugin-use-baseline 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -393,6 +393,34 @@ a {
393
393
  }
394
394
  ```
395
395
 
396
+ ### `ignoreUnits`
397
+
398
+ ```json
399
+ { "ignoreUnits": ["array", "of", "units", "/regex/"] }
400
+ ```
401
+
402
+ Given:
403
+
404
+ ```json
405
+ {
406
+ "plugin/use-baseline": [true, { "available": 2021, "ignoreUnits": ["svh", "/^dv/"] }]
407
+ }
408
+ ```
409
+
410
+ The following patterns are _not_ considered problems:
411
+
412
+ ```css
413
+ a {
414
+ height: 100svh;
415
+ }
416
+ ```
417
+
418
+ ```css
419
+ a {
420
+ height: 100dvh;
421
+ }
422
+ ```
423
+
396
424
  ## Prior art
397
425
 
398
426
  [eslint/css use-baseline](https://github.com/eslint/css/blob/main/docs/rules/use-baseline.md)
package/dist/index.js CHANGED
@@ -5,5 +5,5 @@ import{parse as e,walk as n}from"css-tree";import t from"stylelint";import a fro
5
5
  * Copyright (c) 2014-2017, Jon Schlinkert.
6
6
  * Released under the MIT License.
7
7
  */
8
- function d(e){return"[object Object]"===Object.prototype.toString.call(e)}function u(e){return"number"==typeof e||e instanceof Number}function m(e){return e instanceof RegExp}function h(e){return"string"==typeof e||e instanceof String}function g(e){return!1!==d(n=e)&&(void 0===(t=n.constructor)||!1!==d(a=t.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf"));var n,t,a}function w(e,n,t){return Boolean(e&&e[n]&&"string"==typeof t&&b(t,e[n]))}function b(e,n){if(!Array.isArray(e))return f(e,n);for(const t of e){const e=f(t,n);if(e)return e}return!1}function f(e,n){if(!Array.isArray(n))return y(e,n);for(const t of n){const n=y(e,t);if(n)return n}return!1}function M(e,n){const t=e.match(n);return!!t&&{match:e,pattern:n,substring:t[0]??""}}function y(e,n){if(n instanceof RegExp)return M(e,n);if(n.startsWith("/")&&(n.endsWith("/")||n.endsWith("/i"))){const t=M(e,n.endsWith("i")?new RegExp(n.slice(1,-2),"i"):new RegExp(n.slice(1,-1)));return t&&(t.pattern=n),t}return e===n&&{match:e,pattern:n,substring:e}}const k=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function v(...e){return n=>!!g(n)&&Object.values(n).flat().every(n=>e.some(e=>e(n)))}const{createPlugin:x,utils:{report:z,ruleMessages:j,validateOptions:S}}=t,P="plugin/use-baseline",q=j(P,{notBaselineProperty:(e,n)=>`Property "${e}" is not a ${n} available baseline feature.`,notBaselinePropertyValue:(e,n,t)=>`Value "${n}" of property "${e}" is not a ${t} available baseline feature.`,notBaselineFunction:(e,n)=>`Function "${e}" is not a ${n} available baseline feature.`,notBaselineAtRule:(e,n)=>`At-rule "${e}" is not a ${n} available baseline feature.`,notBaselineMediaCondition:(e,n)=>`Media condition "${e}" is not a ${n} available baseline feature.`,notBaselineUnit:(e,n)=>`Unit "${e}" is not a ${n} available baseline feature.`,notBaselineSelector:(e,n)=>`Selector "${e}" is not a ${n} available baseline feature.`,unnecessarySupports:(e,n)=>`@supports ${e} is unnecessary as the feature meets the ${n} availability requirement.`});class I{name;#e=new Set;#n=new Set;#t=new Set;constructor(e){this.name=e}addIdentifier(e){this.#e.add(e)}hasIdentifier(e){return this.#e.has(e)}hasIdentifiers(){return this.#e.size>0}addUnit(e){this.#n.add(e)}hasUnit(e){return this.#n.has(e)}addFunction(e){this.#t.add(e)}hasFunction(e){return this.#t.has(e)}hasFunctions(){return this.#t.size>0}}class F{#a=new Map;#o=new Set;addProperty(e){if(this.#a.has(e))return this.#a.get(e);const n=new I(e);return this.#a.set(e,n),n}hasProperty(e){return this.#a.has(e)}getProperty(e){return this.#a.get(e)}hasPropertyIdentifier(e,n){const t=this.#a.get(e);return!!t&&t.hasIdentifier(n)}hasPropertyIdentifiers(e){const n=this.#a.get(e);return!!n&&n.hasIdentifiers()}hasFunction(e,n){const t=this.#a.get(e);return!!t&&t.hasFunction(n)}hasFunctions(e){const n=this.#a.get(e);return!!n&&n.hasFunctions()}hasUnit(e,n){const t=this.#a.get(e);return!!t&&t.hasUnit(n)}addSelector(e){this.#o.add(e)}hasSelector(e){return this.#o.has(e)}}class ${#r=[];push(e){this.#r.push(e)}pop(){return this.#r.pop()}last(){return this.#r.at(-1)}hasProperty(e){return this.#r.some(n=>n.hasProperty(e))}hasPropertyIdentifier(e,n){return this.#r.some(t=>t.hasPropertyIdentifier(e,n))}hasPropertyIdentifiers(e){return this.#r.some(n=>n.hasPropertyIdentifiers(e))}hasPropertyFunction(e,n){return this.#r.some(t=>t.hasFunction(e,n))}hasPropertyFunctions(e){return this.#r.some(n=>n.hasFunctions(e))}hasPropertyUnit(e,n){return this.#r.some(t=>t.hasUnit(e,n))}hasSelector(e){return this.#r.some(n=>n.hasSelector(e))}}class A{#i=void 0;#s=void 0;constructor(e="widely"){this.availability=e,"number"==typeof e?this.#i=e:this.#s="widely"===e?10:5}isSupported(e){const n=e.split(":"),t=Number(n[0]),a=Number(n[1]||NaN);return this.#i?a<=this.#i:t>=this.#s}}const B=(t,d)=>(g,f)=>{if(!S(f,P,{actual:t,possible:[!0]},{actual:d,possible:{available:["widely","newly",u],ignoreAtRules:[h,m],ignoreProperties:v(h,m),ignoreSelectors:[h,m],ignoreFunctions:[h,m]},optional:!0}))return;const M=new A(d?.available),y=new $;function x(t){const a=new F;y.push(a);const r=[];try{const i=e(t.params,{context:"atrulePrelude",atrule:"supports",parseAtrulePrelude:!0,positions:!0});let d=!1,u=0;if(n(i,{enter(e){if(!d){if("Identifier"===e.type&&"not"===e.name)return d=!0,void u++;if("SupportsDeclaration"===e.type){const{declaration:n}=e,i=n.property,c=a.addProperty(i);let d=!1;if(o.has(i)){const e=o.get(i);d=M.isSupported(e)}const u=e.loc?.start?.offset||0,m=e.loc?.end?.offset||0,h=t.params.substring(u,m);let g=!d;n.value.children.forEach(e=>{if("Identifier"===e.type){if(c.addIdentifier(e.name),g)return;const n=e.name;if(k.has(n))return;if(p.has(i)){const e=p.get(i);e.has(n)&&M.isSupported(e.get(n))||(g=!0)}}else if("Dimension"===e.type){if(c.addUnit(e.unit),g)return;l.has(e.unit)&&!M.isSupported(l.get(e.unit))&&(g=!0)}else if("Function"===e.type){if(c.addFunction(e.name),g)return;s.has(e.name)&&M.isSupported(s.get(e.name))||(g=!0)}}),g||r.push({conditionText:h,startIndex:u,endIndex:m})}if("FeatureFunction"===e.type&&"selector"===e.feature){const n=e.loc?.start?.offset||0,o=e.loc?.end?.offset||0,i=t.params.substring(n,o);let s=!1;for(const n of e.value.children)a.addSelector(n.name),s||c.has(n.name)&&M.isSupported(c.get(n.name))||(s=!0);s||r.push({conditionText:i,startIndex:n,endIndex:o})}}},leave(){d&&(0===u?d=!1:u--)}}),r.length>0){const e=R(t);r.forEach(n=>{z({ruleName:P,message:q.unnecessarySupports,messageArgs:[n.conditionText,M.availability],result:f,node:t,index:e+n.startIndex,endIndex:e+n.endIndex})})}}catch{}t.each(e=>{if("supports"!==e.name){switch(e.type){case"atrule":j(e);break;case"decl":I(e);break;case"rule":B(e)}"function"==typeof e.walk&&e.walk(e=>{switch(e.type){case"atrule":j(e);break;case"decl":I(e);break;case"rule":B(e)}})}else x(e)}),y.pop()}function j(t){const{name:a}=t;if("supports"===a.toLowerCase())return void x(t);if("media"===a)return void function(t){const a=t.params;try{const o=e(a,{context:"atrulePrelude",atrule:"media",parseAtrulePrelude:!0,positions:!0});n(o,e=>{if("Feature"===e.type){const n=e.name;if(!i.has(n))return;const a=i.get(n);if(!M.isSupported(a)){const a=R(t),o=e.loc.start.column,r=o+n.length;z({ruleName:P,result:f,message:q.notBaselineMediaCondition(n,M.availability),node:t,index:a+o,endIndex:a+r})}}})}catch{}}(t);if(w(d,"ignoreAtRules",a))return;if(!r.has(a))return;const o=r.get(a);M.isSupported(o)||z({ruleName:P,message:q.notBaselineAtRule,messageArgs:[`@${a}`,M.availability],result:f,node:t,index:0,endIndex:a.length+1})}function I(e){const{prop:n,value:t}=e;if(function(e,n){if(y.hasProperty(n))return;if(function(e,n){const t=e?.ignoreProperties;if(!t)return!1;for(const[e]of Object.entries(t))if(b(n,e))return!0;return!1}(d,n))return;if(!o.has(n))return;const t=o.get(n);if(!M.isSupported(t))return z({ruleName:P,message:q.notBaselineProperty,messageArgs:[n,M.availability],result:f,node:e,word:n}),!0;return!1}(e,n))return;a(t).walk(t=>{if("word"===t.type){const o=a.unit(t.value);o&&o.unit?function(e,n){if(y.hasPropertyUnit(e.prop,n))return;if(!l.has(n))return;const t=l.get(n);M.isSupported(t)||z({ruleName:P,message:q.notBaselineUnit,messageArgs:[n,M.availability],result:f,node:e,word:n})}(e,o.unit):function(e,n,t){if(y.hasPropertyIdentifier(n,t))return;if(function(e,n,t){const a=e?.ignoreProperties;if(!a)return!1;for(const[e,o]of Object.entries(a))if(b(n,e)){if(0===o.length)return!1;for(const e of o)if(b(t,e))return!0}return!1}(d,n,t))return;if(k.has(t))return;if(!p.has(n))return;const a=p.get(n);if(!a.has(t))return;const o=a.get(t);M.isSupported(o)||z({ruleName:P,message:q.notBaselinePropertyValue,messageArgs:[n,t,M.availability],result:f,node:e,word:t})}(e,n,t.value)}else"function"===t.type&&function(e,n){if(w(d,"ignoreFunctions",n))return;if(y.hasPropertyFunction(e.prop,n))return;if(!s.has(n))return;const t=s.get(n);M.isSupported(t)||z({ruleName:P,message:q.notBaselineFunction,messageArgs:[n,M.availability],result:f,node:e,word:n})}(e,t.value)})}function B(t){const{selector:a}=t;try{const o=e(a,{context:"selectorList",positions:!0});n(o,e=>{let n=e.name;const a=e.type;if("NestingSelector"===a)n="nesting";else if("PseudoClassSelector"!==a&&"PseudoElementSelector"!==a)return;if(w(d,"ignoreSelectors",n))return;if(y.hasSelector(n))return;if(!c.has(n))return;const o=c.get(n);if(!M.isSupported(o)){let a=0;"PseudoClassSelector"===e.type?a=1:"PseudoElementSelector"===e.type&&(a=2);const o=e.loc.start.offset;let r=o;"nesting"!==n&&(r+=n.length+a),z({ruleName:P,result:f,message:q.notBaselineSelector(n,M.availability),node:t,index:o,endIndex:r})}})}catch{}}g.walkAtRules(/^supports$/i,e=>{N(e)||x(e)}),g.walk(e=>{if(("atrule"!==e.type||"supports"!==e.name.toLowerCase())&&!N(e))switch(e.type){case"atrule":j(e);break;case"rule":B(e);break;case"decl":I(e)}})};function N(e){let n=e.parent;for(;n;){if("atrule"===n.type&&"supports"===n.name)return!0;n=n.parent}return!1}function R(e){return 1+e.name.length+(e.raws.afterName?.length??0)}B.ruleName=P,B.messages=q;var U=x(P,B);export{U as default};
8
+ function d(e){return"[object Object]"===Object.prototype.toString.call(e)}function u(e){return"number"==typeof e||e instanceof Number}function m(e){return e instanceof RegExp}function h(e){return"string"==typeof e||e instanceof String}function g(e){return!1!==d(n=e)&&(void 0===(t=n.constructor)||!1!==d(a=t.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf"));var n,t,a}function w(e,n,t){return Boolean(e&&e[n]&&"string"==typeof t&&b(t,e[n]))}function b(e,n){if(!Array.isArray(e))return f(e,n);for(const t of e){const e=f(t,n);if(e)return e}return!1}function f(e,n){if(!Array.isArray(n))return y(e,n);for(const t of n){const n=y(e,t);if(n)return n}return!1}function M(e,n){const t=e.match(n);return!!t&&{match:e,pattern:n,substring:t[0]??""}}function y(e,n){if(n instanceof RegExp)return M(e,n);if(n.startsWith("/")&&(n.endsWith("/")||n.endsWith("/i"))){const t=M(e,n.endsWith("i")?new RegExp(n.slice(1,-2),"i"):new RegExp(n.slice(1,-1)));return t&&(t.pattern=n),t}return e===n&&{match:e,pattern:n,substring:e}}const k=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function v(...e){return n=>!!g(n)&&Object.values(n).flat().every(n=>e.some(e=>e(n)))}const{createPlugin:x,utils:{report:z,ruleMessages:j,validateOptions:S}}=t,P="plugin/use-baseline",q=j(P,{notBaselineProperty:(e,n)=>`Property "${e}" is not a ${n} available baseline feature.`,notBaselinePropertyValue:(e,n,t)=>`Value "${n}" of property "${e}" is not a ${t} available baseline feature.`,notBaselineFunction:(e,n)=>`Function "${e}" is not a ${n} available baseline feature.`,notBaselineAtRule:(e,n)=>`At-rule "${e}" is not a ${n} available baseline feature.`,notBaselineMediaCondition:(e,n)=>`Media condition "${e}" is not a ${n} available baseline feature.`,notBaselineUnit:(e,n)=>`Unit "${e}" is not a ${n} available baseline feature.`,notBaselineSelector:(e,n)=>`Selector "${e}" is not a ${n} available baseline feature.`,unnecessarySupports:(e,n)=>`@supports ${e} is unnecessary as the feature meets the ${n} availability requirement.`});class I{name;#e=new Set;constructor(e){this.name=e}addIdentifier(e){this.#e.add(e)}hasIdentifier(e){return this.#e.has(e)}hasIdentifiers(){return this.#e.size>0}}class ${#n=new Map;#t=new Set;#a=new Set;#o=new Set;addProperty(e){if(this.#n.has(e))return this.#n.get(e);const n=new I(e);return this.#n.set(e,n),n}hasProperty(e){return this.#n.has(e)}getProperty(e){return this.#n.get(e)}hasPropertyIdentifier(e,n){const t=this.#n.get(e);return!!t&&t.hasIdentifier(n)}hasPropertyIdentifiers(e){const n=this.#n.get(e);return!!n&&n.hasIdentifiers()}addFunction(e){this.#a.add(e)}hasFunction(e){return this.#a.has(e)}addUnit(e){this.#t.add(e)}hasUnit(e){return this.#t.has(e)}addSelector(e){this.#o.add(e)}hasSelector(e){return this.#o.has(e)}}class A{#r=[];push(e){this.#r.push(e)}pop(){return this.#r.pop()}last(){return this.#r.at(-1)}hasProperty(e){return this.#r.some(n=>n.hasProperty(e))}hasPropertyIdentifier(e,n){return this.#r.some(t=>t.hasPropertyIdentifier(e,n))}hasPropertyIdentifiers(e){return this.#r.some(n=>n.hasPropertyIdentifiers(e))}hasFunction(e){return this.#r.some(n=>n.hasFunction(e))}hasUnit(e){return this.#r.some(n=>n.hasUnit(e))}hasSelector(e){return this.#r.some(n=>n.hasSelector(e))}}class B{#i=void 0;#s=void 0;constructor(e="widely"){this.availability=e,"number"==typeof e?this.#i=e:this.#s="widely"===e?10:5}isSupported(e){const n=e.split(":"),t=Number(n[0]),a=Number(n[1]||NaN);return this.#i?a<=this.#i:t>=this.#s}}const N=(t,d)=>(g,f)=>{if(!S(f,P,{actual:t,possible:[!0]},{actual:d,possible:{available:["widely","newly",u],ignoreAtRules:[h,m],ignoreProperties:v(h,m),ignoreSelectors:[h,m],ignoreFunctions:[h,m],ignoreUnits:[h,m]},optional:!0}))return;const M=new B(d?.available),y=new A;function x(t){const a=new $;y.push(a);const r=[];try{const i=e(t.params,{context:"atrulePrelude",atrule:"supports",parseAtrulePrelude:!0,positions:!0});let d=!1,u=0;if(n(i,{enter(e){if(!d){if("Identifier"===e.type&&"not"===e.name)return d=!0,void u++;if("SupportsDeclaration"===e.type){const{declaration:n}=e,i=n.property,c=a.addProperty(i);let d=!1;if(o.has(i)){const e=o.get(i);d=M.isSupported(e)}const u=e.loc?.start?.offset||0,m=e.loc?.end?.offset||0,h=t.params.substring(u,m);let g=!d;n.value.children.forEach(e=>{if("Identifier"===e.type){if(c.addIdentifier(e.name),g)return;const n=e.name;if(k.has(n))return;if(p.has(i)){const e=p.get(i);e.has(n)&&M.isSupported(e.get(n))||(g=!0)}}else if("Dimension"===e.type){if(a.addUnit(e.unit),g)return;l.has(e.unit)&&!M.isSupported(l.get(e.unit))&&(g=!0)}else if("Function"===e.type){if(a.addFunction(e.name),g)return;s.has(e.name)&&M.isSupported(s.get(e.name))||(g=!0)}}),g||r.push({conditionText:h,startIndex:u,endIndex:m})}if("FeatureFunction"===e.type&&"selector"===e.feature){const n=e.loc?.start?.offset||0,o=e.loc?.end?.offset||0,i=t.params.substring(n,o);let s=!1;for(const n of e.value.children)a.addSelector(n.name),s||c.has(n.name)&&M.isSupported(c.get(n.name))||(s=!0);s||r.push({conditionText:i,startIndex:n,endIndex:o})}}},leave(){d&&(0===u?d=!1:u--)}}),r.length>0){const e=R(t);r.forEach(n=>{z({ruleName:P,message:q.unnecessarySupports,messageArgs:[n.conditionText,M.availability],result:f,node:t,index:e+n.startIndex,endIndex:e+n.endIndex})})}}catch{}t.each(e=>{if("supports"!==e.name){switch(e.type){case"atrule":j(e);break;case"decl":I(e);break;case"rule":N(e)}"function"==typeof e.walk&&e.walk(e=>{switch(e.type){case"atrule":j(e);break;case"decl":I(e);break;case"rule":N(e)}})}else x(e)}),y.pop()}function j(t){const{name:a}=t;if("supports"===a.toLowerCase())return void x(t);if("media"===a)return void function(t){const a=t.params;try{const o=e(a,{context:"atrulePrelude",atrule:"media",parseAtrulePrelude:!0,positions:!0});n(o,e=>{if("Feature"===e.type){const n=e.name;if(!i.has(n))return;const a=i.get(n);if(!M.isSupported(a)){const a=R(t),o=e.loc.start.column,r=o+n.length;z({ruleName:P,result:f,message:q.notBaselineMediaCondition(n,M.availability),node:t,index:a+o,endIndex:a+r})}}})}catch{}}(t);if(w(d,"ignoreAtRules",a))return;if(!r.has(a))return;const o=r.get(a);M.isSupported(o)||z({ruleName:P,message:q.notBaselineAtRule,messageArgs:[`@${a}`,M.availability],result:f,node:t,index:0,endIndex:a.length+1})}function I(e){const{prop:n,value:t}=e;if(function(e,n){if(y.hasProperty(n))return;if(function(e,n){const t=e?.ignoreProperties;if(!t)return!1;for(const[e]of Object.entries(t))if(b(n,e))return!0;return!1}(d,n))return;if(!o.has(n))return;const t=o.get(n);if(!M.isSupported(t))return z({ruleName:P,message:q.notBaselineProperty,messageArgs:[n,M.availability],result:f,node:e,word:n}),!0;return!1}(e,n))return;a(t).walk(t=>{if("word"===t.type){const o=a.unit(t.value);o&&o.unit?function(e,n){if(w(d,"ignoreUnits",n))return;if(y.hasUnit(n))return;if(!l.has(n))return;const t=l.get(n);M.isSupported(t)||z({ruleName:P,message:q.notBaselineUnit,messageArgs:[n,M.availability],result:f,node:e,word:n})}(e,o.unit):function(e,n,t){if(y.hasPropertyIdentifier(n,t))return;if(function(e,n,t){const a=e?.ignoreProperties;if(!a)return!1;for(const[e,o]of Object.entries(a))if(b(n,e)){if(0===o.length)return!1;for(const e of o)if(b(t,e))return!0}return!1}(d,n,t))return;if(k.has(t))return;if(!p.has(n))return;const a=p.get(n);if(!a.has(t))return;const o=a.get(t);M.isSupported(o)||z({ruleName:P,message:q.notBaselinePropertyValue,messageArgs:[n,t,M.availability],result:f,node:e,word:t})}(e,n,t.value)}else"function"===t.type&&function(e,n){if(w(d,"ignoreFunctions",n))return;if(y.hasFunction(n))return;if(!s.has(n))return;const t=s.get(n);M.isSupported(t)||z({ruleName:P,message:q.notBaselineFunction,messageArgs:[n,M.availability],result:f,node:e,word:n})}(e,t.value)})}function N(t){const{selector:a}=t;try{const o=e(a,{context:"selectorList",positions:!0});n(o,e=>{let n=e.name;const a=e.type;if("NestingSelector"===a)n="nesting";else if("PseudoClassSelector"!==a&&"PseudoElementSelector"!==a)return;if(w(d,"ignoreSelectors",n))return;if(y.hasSelector(n))return;if(!c.has(n))return;const o=c.get(n);if(!M.isSupported(o)){let a=0;"PseudoClassSelector"===e.type?a=1:"PseudoElementSelector"===e.type&&(a=2);const o=e.loc.start.offset;let r=o;"nesting"!==n&&(r+=n.length+a),z({ruleName:P,result:f,message:q.notBaselineSelector(n,M.availability),node:t,index:o,endIndex:r})}})}catch{}}g.walkAtRules(/^supports$/i,e=>{F(e)||x(e)}),g.walk(e=>{if(("atrule"!==e.type||"supports"!==e.name.toLowerCase())&&!F(e))switch(e.type){case"atrule":j(e);break;case"rule":N(e);break;case"decl":I(e)}})};function F(e){let n=e.parent;for(;n;){if("atrule"===n.type&&"supports"===n.name)return!0;n=n.parent}return!1}function R(e){return 1+e.name.length+(e.raws.afterName?.length??0)}N.ruleName=P,N.messages=q;var U=x(P,N);export{U as default};
9
9
  //# sourceMappingURL=index.js.map