UNPKG

3.67 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/scripts/lint.ts"],"names":["unnecessaryArgumentsCount","args","process","argv","slice","here","p","path","join","__dirname","hereRelative","replace","cwd","parsedArgs","useBuiltinConfig","includes","config","cache","filesGiven","_","length","filesToApply","extensions","cacheLocation","isLintable","file","endsWith","filter","a","lintArguments","result","spawn","sync","stdio","exit","status"],"mappings":";;AAAA;;AACA;;AACA;;AAEA;;;;AAEA,IAAMA,4BAA4B,CAAlC;AAEA,IAAIC,OAAOC,QAAQC,IAAR,CAAaC,KAAb,CAAmBJ,yBAAnB,CAAX;;AACA,IAAMK,OAAO,UAACC,CAAD;AAAA,SAAeC,cAAKC,IAAL,CAAUC,SAAV,EAAqBH,CAArB,CAAf;AAAA,CAAb;;AACA,IAAMI,eAAe,UAACJ,CAAD;AAAA,SAAeD,KAAKC,CAAL,EAAQK,OAAR,CAAgBT,QAAQU,GAAR,EAAhB,EAA+B,GAA/B,CAAf;AAAA,CAArB;;AACA,IAAMC,aAAa,0BAAYZ,IAAZ,CAAnB;AAEA,IAAMa,mBACJ,CAACb,KAAKc,QAAL,CAAc,UAAd,CAAD,IACA,CAAC,oBAAQ,WAAR,CADD,IAEA,CAAC,oBAAQ,cAAR,CAFD,IAGA,CAAC,uBAAW,cAAX,CAJH;AAMA,IAAMC,SAASF,mBACX,CAAC,UAAD,EAAaJ,aAAa,uBAAb,CAAb,CADW,GAEX,EAFJ;AAIA,IAAMO,QAAQhB,KAAKc,QAAL,CAAc,YAAd,IAA8B,EAA9B,GAAmC,CAAC,SAAD,CAAjD;AAEA,IAAMG,aAAaL,WAAWM,CAAX,CAAaC,MAAb,GAAsB,CAAzC;AAEA,IAAMC,eAAeH,aAAa,EAAb,GAAkB,CAAC,GAAD,CAAvC;AAEA,IAAMI,aAAa,CAAC,OAAD,EAAU,mBAAV,CAAnB;AAEA,IAAMC,gBAAgB,CAAC,kBAAD,EAAqB,kCAArB,CAAtB;;AAEA,IAAMC,aAAa,UAACC,IAAD;AAAA,SACjBA,KAAKC,QAAL,CAAc,KAAd,KACAD,KAAKC,QAAL,CAAc,KAAd,CADA,IAEAD,KAAKC,QAAL,CAAc,MAAd,CAFA,IAGAD,KAAKC,QAAL,CAAc,MAAd,CAJiB;AAAA,CAAnB;;AAMA,IAAIR,UAAJ,EAAgB;AACd;AACA;AACA;AACAjB,SAAOA,KAAK0B,MAAL,CAAY;AAAA,WAAK,CAACd,WAAWM,CAAX,CAAaJ,QAAb,CAAsBa,CAAtB,CAAD,IAA6BJ,WAAWI,CAAX,CAAlC;AAAA,GAAZ,CAAP;AACD;;AAED,IAAMC,gBACDb,MADC,QAEDM,UAFC,EAGDC,aAHC,EAIDN,KAJC,EAKDhB,IALC,EAMDoB,YANC,CAAN;;AASA,IAAMS,SAASC,oBAAMC,IAAN,CAAW,uBAAW,QAAX,CAAX,EAAiCH,aAAjC,EAAgD;AAC7DI,SAAO;AADsD,CAAhD,CAAf;;AAIA/B,QAAQgC,IAAR,CAAaJ,OAAOK,MAApB","sourcesContent":["import path from \"path\"\r\nimport spawn from \"cross-spawn\"\r\nimport yargsParser from \"yargs-parser\"\r\n\r\nimport { hasPkgProp, resolveBin, hasFile } from \"../utils\"\r\n\r\nconst unnecessaryArgumentsCount = 2\r\n\r\nlet args = process.argv.slice(unnecessaryArgumentsCount)\r\nconst here = (p: string) => path.join(__dirname, p)\r\nconst hereRelative = (p: string) => here(p).replace(process.cwd(), \".\")\r\nconst parsedArgs = yargsParser(args)\r\n\r\nconst useBuiltinConfig =\r\n !args.includes(\"--config\") &&\r\n !hasFile(\".eslintrc\") &&\r\n !hasFile(\".eslintrc.js\") &&\r\n !hasPkgProp(\"eslintConfig\")\r\n\r\nconst config = useBuiltinConfig\r\n ? [\"--config\", hereRelative(\"../config/eslintrc.js\")]\r\n : []\r\n\r\nconst cache = args.includes(\"--no-cache\") ? [] : [\"--cache\"]\r\n\r\nconst filesGiven = parsedArgs._.length > 0\r\n\r\nconst filesToApply = filesGiven ? [] : [\".\"]\r\n\r\nconst extensions = [\"--ext\", \".js,.jsx,.ts,.tsx\"]\r\n\r\nconst cacheLocation = [\"--cache-location\", \"node_modules/.cache/.eslintcache\"]\r\n\r\nconst isLintable = (file: string) =>\r\n file.endsWith(\".js\") ||\r\n file.endsWith(\".ts\") ||\r\n file.endsWith(\".jsx\") ||\r\n file.endsWith(\".tsx\")\r\n\r\nif (filesGiven) {\r\n // we need to take all the flag-less arguments (the files that should be linted)\r\n // and filter out the ones that aren't js files. Otherwise json or css files\r\n // may be passed through\r\n args = args.filter(a => !parsedArgs._.includes(a) || isLintable(a))\r\n}\r\n\r\nconst lintArguments = [\r\n ...config,\r\n ...extensions,\r\n ...cacheLocation,\r\n ...cache,\r\n ...args,\r\n ...filesToApply,\r\n]\r\n\r\nconst result = spawn.sync(resolveBin(\"eslint\"), lintArguments, {\r\n stdio: \"inherit\",\r\n})\r\n\r\nprocess.exit(result.status)\r\n"],"file":"lint.js"}
\No newline at end of file