epiphany/node_modules/stylelint-declaration-strict-value/dist/index.umd.js
2023-12-09 22:48:07 -08:00

2 lines
6 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("stylelint"),require("shortcss"),require("shortcss/lib/list"),require("css-values"),require("path")):"function"==typeof define&&define.amd?define(["exports","stylelint","shortcss","shortcss/lib/list","css-values","path"],t):t((e=e||self).stylelintDeclarationStrictValue={},e.stylelint,e.shortcss,e.list,e.cssValues,e.path)}(this,function(e,t,n,r,o,s){t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,o=o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o,s=s&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s;const i="scale-unlimited/declaration-strict-value",l=(e,t)=>"object"==typeof e&&Object.hasOwnProperty.call(e,t),a={ignoreVariables:!0,ignoreFunctions:!0,ignoreKeywords:null,ignoreValues:null,expandShorthand:!1,recurseLonghand:!1,severity:"error",message:void 0,disableFix:!1,autoFixFunc:null};function u(e){const t=typeof e;return"string"===t||"number"===t}function c(e){return u(e)||Array.isArray(e)&&e.every(e=>u(e))}function f(e){return!("object"!=typeof e||!e)&&Object.keys(e).every(t=>c(e[t]))}function p(e){return!("object"!=typeof e||!e)&&Object.keys(e).every(t=>"boolean"==typeof e[t])}function y(e){if("object"!=typeof e)return!1;const t=Object.keys(a);return!(!Object.keys(e).every(e=>t.indexOf(e)>-1)||"ignoreVariables"in e&&"boolean"!=typeof e.ignoreVariables&&!p(e.ignoreVariables)&&null!==e.ignoreVariables||"ignoreFunctions"in e&&"boolean"!=typeof e.ignoreFunctions&&!p(e.ignoreFunctions)&&null!==e.ignoreFunctions||"severity"in e&&"string"!=typeof e.severity&&null!==e.severity||"ignoreKeywords"in e&&!c(e.ignoreKeywords)&&!f(e.ignoreKeywords)||"ignoreValues"in e&&!c(e.ignoreValues)&&!f(e.ignoreValues)||"expandShorthand"in e&&"boolean"!=typeof e.expandShorthand&&null!==e.expandShorthand||"recurseLonghand"in e&&"boolean"!=typeof e.recurseLonghand&&null!==e.recurseLonghand||"message"in e&&"string"!=typeof e.message&&null!==e.message||"disableFix"in e&&"boolean"!=typeof e.disableFix&&null!==e.disableFix||"autoFixFunc"in e&&"function"!=typeof e.autoFixFunc&&"string"!=typeof e.autoFixFunc&&null!==e.autoFixFunc)}function d(e){let t;if(Array.isArray(e)){const n=e.pop();t=e.length?`${e.join(", ")} or ${n}`:n}else t=e;return t}function g(e,t){return"boolean"==typeof e?e:"object"==typeof e&&e&&{}.hasOwnProperty.call(e,t)?e[t]:!!e}function h(e,t){if(!e)return null;let n=e;return l(n,t)?n=n[t]:l(n,"")&&(n=n[""]),Array.isArray(n)?n:[n]}function b(e,t){if(!e)return null;let n=e;return l(n,t)?n=n[t]:l(n,"")&&(n=n[""]),Array.isArray(n)?n:[n]}const{utils:x}=t,m=x.ruleMessages(i,{expected:function(e,t,n){return`Expected ${e} for "${t}" of "${n}"`},customExpected:function(e,t,n,r){return r.replace("${types}",e).replace("${value}",t).replace("${property}",n)},failedToFix:function(e,t,n){return e&&("string"==typeof e||e instanceof Error)?"string"==typeof e?e:e.message:`Property "${n}" with value "${t}" can't be autofixed`}}),F=/^(?:@|\$|--).+$/,w=/^-?(?:@.+|(?:(?:[a-zA-Z_-]|[^\x20-\x7F])+(?:[a-zA-Z0-9_-]|[^\x20-\x7F])*\.)?\$.+|var\(\s*--[\s\S]+\))$/,v=/^(?!var\(\s*--)[\s\S]+\([\s\S]*\)$/,$=/^\/(.*)\/([a-zA-Z]*)$/,O=/color/,j=e=>$.test(e),V=e=>{const[t,n]=(e=>e.match($).slice(1))(e);return new RegExp(t,n)},A=e=>j(""+e)?V(""+e):new RegExp(`^${e}$`),E=(e,t,l={})=>(u,f)=>{if(f&&f.stylelint&&f.stylelint.customMessages&&f.stylelint.customMessages[i]&&delete f.stylelint.customMessages[i],!x.validateOptions(f,i,{actual:e,possible:c},{actual:t,possible:y,optional:!0}))return;Array.isArray(e)||(e=[e]);const p={...a,...t},{ignoreVariables:$,ignoreFunctions:E,ignoreKeywords:k,ignoreValues:P,message:S,disableFix:q,autoFixFunc:K,expandShorthand:R,recurseLonghand:L}=p,N=function(e,t,n){if("function"==typeof e)return e;if("string"==typeof e){let t;try{t=require.resolve(e)}catch(n){t=require.resolve(s.join(process.cwd(),e))}return require(t)}return!t&&n&&console.warn(`No \`autoFix\` function provided, consider using \`disableFix\` for "${i}"`),null}(K,q,l.fix),M=k?{}:null,z=P?{}:null;let Z;if($){const e=[];u.walkAtRules("value",t=>{const{params:n}=t,r=n.split(":")[0].trim();e.push(r)}),Z=new RegExp(`^-?(:?${e.join("|")})$`)}e.forEach(e=>{let t=e;function s(t,n,r,s=!1){const{value:a,prop:c}=t,y=r||a;let F=!1,j=!1,V=!1,K=!1;if($&&g($,e)&&(F=w.test(y)||Z.test(y)),E&&!F&&g(E,e)&&(j=v.test(y)),s&&(!$||$&&!F)&&(!E||E&&!j)&&!0!==((e,t)=>O.test(e)&&"transparent"===t||w.test(t)||v.test(t)||o(e,t))(n,r))return!1;if(k&&(!F||!j)){let t=M[e];if(!t){const n=h(k,e);n&&(t=new RegExp(`^${n.join("$|^")}$`),M[e]=t)}t&&(V=t.test(y))}if(P&&(!F||!j||!V)){let t=z[e];if(!t){const n=b(P,e);n&&(t=n.map(A),z[e]=t)}t&&(K=t.filter(e=>e.test(y)).length>0)}if(!(F||j||V||K)){const o=function(e,t){const{ignoreVariables:n,ignoreFunctions:r,ignoreKeywords:o,ignoreValues:s}=e,i=[];return n&&i.push("variable"),r&&i.push("function"),o&&h(o,t)&&i.push("keyword"),-1===i.indexOf("keyword")&&s&&b(s,t)&&i.push("keyword"),i}(p,e);if(l.fix&&!q&&N)try{const e=N(t,{validVar:F,validFunc:j,validKeyword:V,validValue:K,longhandProp:n,longhandValue:r},u,p);e&&(t.value=e)}catch(e){const{raws:n}=t,r=t.source.start;x.report({ruleName:i,result:f,node:t,line:r.line,column:r.column+c.length+n.between.length,message:m.failedToFix(e,y,c)})}else{const{raws:e}=t,n=t.source.start;x.report({ruleName:i,result:f,node:t,line:n.line,column:n.column+c.length+e.between.length,message:S?m.customExpected(d(o),y,c,S):m.expected(d(o),y,c)})}return!0}return!1}j(t)&&(t=V(t)),u.walkDecls(function(e){const{value:o,prop:i}=e;if(F.test(i))return;const l=R&&n.isShorthand(i);if(i===t||!l&&t instanceof RegExp&&t.test(i)){const t=r.space(o);if(t.length>1){let n=!1;t.forEach(t=>{n||(n=s(e,i,t))})}else s(e)}else if(l){const r=n.expand(i,o,L);let l=!1;Object.keys(r).forEach(n=>{const o=r[n];!l&&(n===t||t instanceof RegExp&&t.test(n))&&(l=s(e,n,o,!0))})}})})};E.primaryOptionArray=!0,E.ruleName=i,E.messages=m;const k=t.createPlugin(i,E);e.default=k,e.messages=m,e.ruleName=i});
//# sourceMappingURL=index.umd.js.map