rsnext/packages/next/compiled/cross-spawn/index.js

1 line
8.1 KiB
JavaScript
Raw Normal View History

[ESLint] Introduce a new setup process when `next lint` is run for the first time (#26584) This PR introduces an improved developer experience when `next lint` is run for the first time. ### Current behavior `eslint-config-next` is a required package that must be installed before proceeding with `next lint` or `next build`: ![image](https://user-images.githubusercontent.com/12476932/123468791-43088100-d5c0-11eb-9ad0-5beb80b6c968.png) Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues: - Users are required to install the full config (`eslint-config-next`) even if they do not use it or use the Next.js plugin directly (`eslint-plugin-next`). - #26348 - There's some confusion on why `eslint-config-next` needs to be installed or how it should be used instead of `eslint-plugin-next`. - #26574 - #26475 - #26438 ### New behavior Instead of enforcing `eslint-config-next` as a required package, this PR prompts the user by asking what config they would like to start. This happens when `next lint` is run for the first time **and** if no ESLint configuration is detected in the application. <img src="https://user-images.githubusercontent.com/12476932/124331177-e1668a80-db5c-11eb-8915-38d3dc20f5d4.gif" width="800" /> - The CLI will take care of installing `eslint` or `eslint-config-next` if either is not already installed - Users now have the option to choose between a strict configuration (`next/core-web-vitals`) or just the base configuration (`next`) - For users that decide to create their own ESLint configuration, or already have an existing one, **installing `eslint-config-next` will not be a requirement for `next lint` or `next build` to run**. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config. <img width="682" alt="Screen Shot 2021-06-25 at 3 02 12 PM" src="https://user-images.githubusercontent.com/12476932/123473329-6cc4a680-d5c6-11eb-9a57-d5c0b89a2732.png"> --- In addition, this PR also: - Fixes #26348 - Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
2021-08-04 23:53:15 +02:00
module.exports=(()=>{var e={875:(e,t,r)=>{"use strict";const n=r(129);const o=r(915);const s=r(985);function spawn(e,t,r){const c=o(e,t,r);const i=n.spawn(c.command,c.args,c.options);s.hookChildProcess(i,c);return i}function spawnSync(e,t,r){const c=o(e,t,r);const i=n.spawnSync(c.command,c.args,c.options);i.error=i.error||s.verifyENOENTSync(i.status,c);return i}e.exports=spawn;e.exports.spawn=spawn;e.exports.sync=spawnSync;e.exports._parse=o;e.exports._enoent=s},985:e=>{"use strict";const t=process.platform==="win32";function notFoundError(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function hookChildProcess(e,r){if(!t){return}const n=e.emit;e.emit=function(t,o){if(t==="exit"){const t=verifyENOENT(o,r,"spawn");if(t){return n.call(e,"error",t)}}return n.apply(e,arguments)}}function verifyENOENT(e,r){if(t&&e===1&&!r.file){return notFoundError(r.original,"spawn")}return null}function verifyENOENTSync(e,r){if(t&&e===1&&!r.file){return notFoundError(r.original,"spawnSync")}return null}e.exports={hookChildProcess:hookChildProcess,verifyENOENT:verifyENOENT,verifyENOENTSync:verifyENOENTSync,notFoundError:notFoundError}},915:(e,t,r)=>{"use strict";const n=r(622);const o=r(458);const s=r(921);const c=r(266);const i=r(217);const a=r(519);const u=process.platform==="win32";const f=/\.(?:com|exe)$/i;const l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;const p=o(()=>a.satisfies(process.version,"^4.8.0 || ^5.7.0 || >= 6.0.0",true))||false;function detectShebang(e){e.file=s(e);const t=e.file&&i(e.file);if(t){e.args.unshift(e.file);e.command=t;return s(e)}return e.file}function parseNonShell(e){if(!u){return e}const t=detectShebang(e);const r=!f.test(t);if(e.options.forceShell||r){const r=l.test(t);e.command=n.normalize(e.command);e.command=c.command(e.command);e.args=e.args.map(e=>c.argument(e,r));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`];e.command=process.env.comspec||"cmd.exe";e.options.windowsVerbatimArguments=true}return e}function parseShell(e){if(p){return e}const t=[e.command].concat(e.args).join(" ");if(u){e.command=typeof e.options.shell==="string"?e.options.shell:process.env.comspec||"cmd.exe";e.args=["/d","/s","/c",`"${t}"`];e.options.windowsVerbatimArguments=true}else{if(typeof e.options.shell==="string"){e.command=e.options.shell}else if(process.platform==="android"){e.command="/system/bin/sh"}else{e.command="/bin/sh"}e.args=["-c",t]}return e}function parse(e,t,r){if(t&&!Array.isArray(t)){r=t;t=null}t=t?t.slice(0):[];r=Object.assign({},r);const n={command:e,args:t,options:r,file:undefined,original:{command:e,args:t}};return r.shell?parseShell(n):parseNonShell(n)}e.exports=parse},266:e=>{"use strict";const t=/([()\][%!^"`<>&|;, *?])/g;function escapeCommand(e){e=e.replace(t,"^$1");return e}function escapeArgument(e,r){e=`${e}`;e=e.replace(/(\\*)"/g,'$1$1\\"');e=e.replace(/(\\*)$/,"$1$1");e=`"${e}"`;e=e.replace(t,"^$1");if(r){e=e.replace(t,"^$1")}return e}e.exports.command=escapeCommand;e.exports.argument=escapeArgument},217:(e,t,r)=>{"use strict";const n=r(747);const o=r(598);function readShebang(e){const t=150;let r;if(Buffer.alloc){r=Buffer.alloc(t)}else{r=new Buffer(t);r.fill(0)}let s;try{s=n.openSync(e,"r");n.readSync(s,r,0,t,0);n.closeSync(s)}catch(e){}return o(r.toString())}e.exports=readShebang},921:(e,t,r)=>{"use strict";const n=r(622);const o=r(753);const s=r(226)();function resolveCommandAttempt(e,t){const r=process.cwd();const c=e.options.cwd!=null;if(c){try{process.chdir(e.options.cwd)}catch(e){}}let i;try{i=o.sync(e.command,{path:(e.options.env||process.env)[s],pathExt:t?n.delimiter:undefined})}catch(e){}finally{process.chdir(r)}if(i){i=n.resolve(c?e.options.cwd:"",i)}return i}function resolveCommand(e){return resolveCommandAttempt(e)||resolveCommandAttempt(e,true)}e.exports=resolveCommand},226:e=>{"use strict";e.exports=(e=>{e=e||{};const t=e.env||process.env;const r=e.platform||process.platform;if(r!=="win32"){return"PATH"}return Object.keys(t).find(e=>e.toUpperCase