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