Files
codeql-action/node_modules/prettier/parser-flow.js
T

23 lines
3.0 MiB
JavaScript
Raw Normal View History

2021-07-27 16:54:26 +00:00
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((r="undefined"!=typeof globalThis?globalThis:r||self).prettierPlugins=r.prettierPlugins||{},r.prettierPlugins.flow=t())}(this,(function(){"use strict";var r=function(r,t){const e=new SyntaxError(r+" ("+t.start.line+":"+t.start.column+")");return e.loc=t,e},t=r=>"string"==typeof r?r.replace((({onlyFirst:r=!1}={})=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,r?void 0:"g")})(),""):r;const e=r=>!Number.isNaN(r)&&(r>=4352&&(r<=4447||9001===r||9002===r||11904<=r&&r<=12871&&12351!==r||12880<=r&&r<=19903||19968<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65131||65281<=r&&r<=65376||65504<=r&&r<=65510||110592<=r&&r<=110593||127488<=r&&r<=127569||131072<=r&&r<=262141));var n=e,u=e;n.default=u;const a=r=>{if("string"!=typeof r||0===r.length)return 0;if(0===(r=t(r)).length)return 0;r=r.replace(/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|
Print (to stderr) where a cursor at the given position would move to after formatting.
This option cannot be used with --range-start and --range-end.
`,cliCategory:Be},endOfLine:{since:"1.15.0",category:Ie,type:"choice",default:[{since:"1.15.0",value:"auto"},{since:"2.0.0",value:"lf"}],description:"Which end of line characters to apply.",choices:[{value:"lf",description:"Line Feed only (\\n), common on Linux and macOS as well as inside git repos"},{value:"crlf",description:"Carriage Return + Line Feed characters (\\r\\n), common on Windows"},{value:"cr",description:"Carriage Return character only (\\r), used very rarely"},{value:"auto",description:Se`
Maintain existing
(mixed values within one file are normalised by looking at what's used after the first line)
`}]},filepath:{since:"1.4.0",category:Oe,type:"path",description:"Specify the input filepath. This will be used to do parser inference.",cliName:"stdin-filepath",cliCategory:Te,cliDescription:"Path to the file to pretend that stdin comes from."},insertPragma:{since:"1.8.0",category:Oe,type:"boolean",default:!1,description:"Insert @format pragma into file's first docblock comment.",cliCategory:Te},parser:{since:"0.0.10",category:Ie,type:"choice",default:[{since:"0.0.10",value:"babylon"},{since:"1.13.0",value:void 0}],description:"Which parser to use.",exception:r=>"string"==typeof r||"function"==typeof r,choices:[{value:"flow",description:"Flow"},{value:"babel",since:"1.16.0",description:"JavaScript"},{value:"babel-flow",since:"1.16.0",description:"Flow"},{value:"babel-ts",since:"2.0.0",description:"TypeScript"},{value:"typescript",since:"1.4.0",description:"TypeScript"},{value:"espree",since:"2.2.0",description:"JavaScript"},{value:"meriyah",since:"2.2.0",description:"JavaScript"},{value:"css",since:"1.7.1",description:"CSS"},{value:"less",since:"1.7.1",description:"Less"},{value:"scss",since:"1.7.1",description:"SCSS"},{value:"json",since:"1.5.0",description:"JSON"},{value:"json5",since:"1.13.0",description:"JSON5"},{value:"json-stringify",since:"1.13.0",description:"JSON.stringify"},{value:"graphql",since:"1.5.0",description:"GraphQL"},{value:"markdown",since:"1.8.0",description:"Markdown"},{value:"mdx",since:"1.15.0",description:"MDX"},{value:"vue",since:"1.10.0",description:"Vue"},{value:"yaml",since:"1.14.0",description:"YAML"},{value:"glimmer",since:"2.3.0",description:"Ember / Handlebars"},{value:"html",since:"1.15.0",description:"HTML"},{value:"angular",since:"1.15.0",description:"Angular"},{value:"lwc",since:"1.17.0",description:"Lightning Web Components"}]},plugins:{since:"1.10.0",type:"path",array:!0,default:[{value:[]}],category:Ie,description:"Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",exception:r=>"string"==typeof r||"object"==typeof r,cliName:"plugin",cliCategory:ge},pluginSearchDirs:{since:"1.13.0",type:"path",array:!0,default:[{value:[]}],category:Ie,description:Se`
Custom directory that contains prettier plugins in node_modules subdirectory.
Overrides default behavior when plugins are searched relatively to the location of Prettier.
Multiple values are accepted.
`,exception:r=>"string"==typeof r||"object"==typeof r,cliName:"plugin-search-dir",cliCategory:ge},printWidth:{since:"0.0.0",category:Ie,type:"int",default:80,description:"The line length where Prettier will try wrap.",range:{start:0,end:Number.POSITIVE_INFINITY,step:1}},rangeEnd:{since:"1.4.0",category:Oe,type:"int",default:Number.POSITIVE_INFINITY,range:{start:0,end:Number.POSITIVE_INFINITY,step:1},description:Se`
Format code ending at a given character offset (exclusive).
The range will extend forwards to the end of the selected statement.
This option cannot be used with --cursor-offset.
`,cliCategory:Be},rangeStart:{since:"1.4.0",category:Oe,type:"int",default:0,range:{start:0,end:Number.POSITIVE_INFINITY,step:1},description:Se`
Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.
`,cliCategory:Be},requirePragma:{since:"1.7.0",category:Oe,type:"boolean",default:!1,description:Se`
Require either '@prettier' or '@format' to be present in the file's first docblock comment
in order for it to be formatted.
`,cliCategory:Te},tabWidth:{type:"int",category:Ie,default:2,description:"Number of spaces per indentation level.",range:{start:0,end:Number.POSITIVE_INFINITY,step:1}},useTabs:{since:"1.0.0",category:Ie,type:"boolean",default:!1,description:"Indent with tabs instead of spaces."},embeddedLanguageFormatting:{since:"2.1.0",category:Ie,type:"choice",default:[{since:"2.1.0",value:"auto"}],description:"Control how Prettier formats quoted code embedded in the file.",choices:[{value:"auto",description:"Format embedded code if Prettier can automatically identify it."},{value:"off",description:"Never automatically format embedded code."}]}};const xe=["cliName","cliCategory","cliDescription"],Le={compare:ye,lt:Ae,gte:_e},Pe=Ce,Re={CATEGORY_CONFIG:ge,CATEGORY_EDITOR:Be,CATEGORY_FORMAT:"Format",CATEGORY_OTHER:Te,CATEGORY_OUTPUT:"Output",CATEGORY_GLOBAL:Ie,CATEGORY_SPECIAL:Oe,options:Ne}.options;var Me={getSupportInfo:function({plugins:r=[],showUnreleased:t=!1,showDeprecated:e=!1,showInternal:n=!1}={}){const u=Pe.split("-",1)[0],a=r.flatMap((r=>r.languages||[])).filter(o),i=(c=Object.assign({},...r.map((({options:r})=>r)),Re),f="name",Object.entries(c).map((([r,t])=>Object.assign({[f]:r},t)))).filter((r=>o(r)&&v(r))).sort(((r,t)=>r.name===t.name?0:r.name<t.name?-1:1)).map((function(r){if(n)return r;return s(r,xe)})).map((t=>{t=Object.assign({},t),Array.isArray(t.default)&&(t.default=1===t.default.length?t.default[0].value:t.default.filter(o).sort(((r,t)=>Le.compare(t.since,r.since)))[0].value),Array.isArray(t.choices)&&(t.choices=t.choices.filter((r=>o(r)&&v(r))),"parser"===t.name&&function(r,t,e){const n=new Set(r.choices.map((r=>r.value)));for(const u of t)if(u.parsers)for(const t of u.parsers)if(!n.has(t)){n.add(t);const a=e.find((r=>r.parsers&&r.parsers[t]));let i=u.name;a&&a.name&&(i+=` (plugin: ${a.name})`),r.choices.push({value:t,description:i})}}(t,a,r));const e=Object.fromEntries(r.filter((r=>r.defaultOptions&&void 0!==r.defaultOptions[t.name])).map((r=>[r.name,r.defaultOptions[t.name]])));return Object.assign(Object.assign({},t),{},{pluginDefaults:e})}));var c,f;return{languages:a,options:i};function o(r){return t||!("since"in r)||r.since&&Le.gte(u,r.since)}function v(r){return e||!("deprecated"in r)||r.deprecated&&Le.lt(u,r.deprecated)}}};const{getSupportInfo:Ge}=Me,Ue=/[^\x20-\x7F]/;function je(r){return(t,e,n)=>{const u=n&&n.backwards;if(!1===e)return!1;const{length:a}=t;let i=e;for(;i>=0&&i<a;){const e=t.charAt(i);if(r instanceof RegExp){if(!r.test(e))return i}else if(!r.includes(e))return i;u?i--:i++}return(-1===i||i===a)&&i}}const Xe=je(/\s/),He=je(" \t"),$e=je(",; \t"),Ye=je(/[^\n\r]/);function Ve(r,t){if(!1===t)return!1;if("/"===r.charAt(t)&&"*"===r.charAt(t+1))for(let e=t+2;e<r.length;++e)if("*"===r.charAt(e)&&"/"===r.charAt(e+1))return e+2;return t}function Ke(r,t){return!1!==t&&("/"===r.charAt(t)&&"/"===r.charAt(t+1)?Ye(r,t):t)}function Je(r,t,e){const n=e&&e.backwards;if(!1===t)return!1;const u=r.charAt(t);if(n){if("\r"===r.charAt(t-1)&&"\n"===u)return t-2;if("\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)return t-1}else{if("\r"===u&&"\n"===r.charAt(t+1))return t+2;if("\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)return t+1}return t}function We(r,t,e={}){const n=He(r,e.backwards?t-1:t,e);return n!==Je(r,n,e)}function qe(r,t){let e=null,n=t;for(;n!==e;)e=n,n=$e(r,n),n=Ve(r,n),n=He(r,n);return n=Ke(r,n),n=Je(r,n),!1!==n&&We(r,n)}function ze(r,t){let e=null,n=t;for(;n!==e;)e=n,n=He(r,n),n=Ve(r,n),n=Ke(r,n),n=Je(r,n);return n}function Qe(r,t,e){return ze(r,e(t))}function Ze(r,t,e=0){let n=0;for(let u=e;u<r.length;++u)"\t"===r[u]?n=n+t-n%t:n++;return n}function rn(r,t){const e=r.slice(1,-1),n={quote:'"',regex:/"/g},u={quote:"'",regex:/'/g},a="'"===t?u:n,i=a===u?n:u;let c=a.quote;if(e.includes(a.quote)||e.includes(i.quote)){c=(e.match(a.regex)||[]).length>(e.match(i.regex)||[]).length?i.quote:a.quote}return c}function tn(r,t,e){const n='"'===t?"'":'"',u=r.replace(/\\(.)|(["'])/gs,((r,u,a)=>u===n?u:a===t?"\\"+a:a||(e&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(u)?u:"\\"+u)));return t+u+t}function en(r,t){(r.comme