Unverified Commit 300bfe52 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[BREAKING] Support ESLint v9 in plugin, config and `next lint` (#71218)

> [!WARNING]
> **Breaking Change:** Now uses `eslint-plugin-react-hooks@5.0.0` which
has a new violation disallowing Component names starting with anything
but an uppercase letter. See
https://github.com/facebook/react/releases/tag/eslint-plugin-react-hooks%405.0.0
for more details.

Adds support of ESLint v9 to `eslint-plugin-next`, `eslint-config-next`
and `next lint`.

Does not require using the new flat config format. `next lint` will
automatically ensure the old config format can be used.

### Why?

As `eslint-plugin-react-hooks` has been updated for ESLint v9 support
and is a helpful package for Next v15 upgrade, unblock the restrictions
to upgrade to ESLint v9.

Also, ESLint v8 is [End of
Life](https://eslint.org/blog/2024/09/eslint-v8-eol-version-support/#:~:text=ESLint%20v8.-,x%20end%20of%20life%20is%20October%205%2C%202024,x%20on%20October%205%2C%202024.)
support since Oct 5th, so is good to unblock v9 now.

Plugins bumped:
- [x]
[@rushstack/eslint-patch](https://github.com/microsoft/rushstack/pull/4719)
([v1.10.3](https://www.npmjs.com/package/@rushstack/eslint-patch/v/1.10.3?activeTab=versions)
no release post, confirmed on NPM)
- [x]
[@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/pull/9002)
([v8.0.0](https://github.com/typescript-eslint/typescript-eslint/pull/9002#issuecomment-2106424400))
- [x]
[eslint-plugin-import](https://github.com/import-js/eslint-plugin-import/pull/2996)
([v2.31.0](https://github.com/import-js/eslint-plugin-import/releases/tag/v2.31.0))
- [x]
[eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/1009)
([v6.10.0](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases/tag/v6.10.0))
- [x]
[eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3759)
([v7.35.0](https://github.com/jsx-eslint/eslint-plugin-react/releases/tag/v7.35.0))
- [x]
[eslint-plugin-react-hooks](https://github.com/facebook/react/pull/28773)
([v5.0.0](https://github.com/facebook/react/releases/tag/eslint-plugin-react-hooks%405.0.0))

We have to switch to ESLint v9 in our repo due to a pnpm bug where it
automatically uses ESLint v9 even though we only installed it via
`eslint-v9: npm:eslint@9.0.0`. This is a pnpm bug that wouldn't happen
with Yarn v1, v4 nor NPM.

Closes https://github.com/vercel/next.js/issues/64409
Closes https://github.com/vercel/next.js/issues/64114
Closes https://github.com/vercel/next.js/issues/64453

Closes NEXT-3293

---------
Co-authored-by: 's avatarSebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
parent 863168d4
......@@ -45,6 +45,7 @@ packages/next-swc/docs/assets/**/*
test/lib/amp-validator-wasm.js
test/production/pages-dir/production/fixture/amp-validator-wasm.js
test/e2e/async-modules/amp-validator-wasm.js
test/development/next-lint-eslint-formatter-compact/**/*.js
# turbopack crates
turbopack/crates/*/tests/**
......
......@@ -66,7 +66,10 @@
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-tslint-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-restricted-types": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/no-wrapper-object-types": "off",
"@typescript-eslint/class-literal-property-style": "off",
"@typescript-eslint/consistent-generic-constructors": "off",
"@typescript-eslint/consistent-indexed-object-style": "off",
......@@ -77,6 +80,7 @@
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "off",
......@@ -104,6 +108,7 @@
"args": "none",
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_",
"caughtErrors": "none",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_"
......@@ -178,6 +183,7 @@
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "none",
"ignoreRestSiblings": true
}
]
......@@ -308,6 +314,7 @@
"error",
{
"args": "none",
"caughtErrors": "none",
"ignoreRestSiblings": true
}
],
......
......@@ -5,7 +5,7 @@ dist
target
packages/next/wasm/@next
tarballs/
packages/next/*.tgz
packages/**/*.tgz
# dependencies
node_modules
......
......@@ -16,6 +16,7 @@
"typescript",
"typescriptreact"
],
"eslint.useFlatConfig": false,
// Set Jest runMode to on-demand as otherwise it will start running all tests the first time.
// Equivalent to deprecated option "jest.autoRun": "off"
"jest.runMode": "on-demand",
......
......@@ -2,7 +2,7 @@ import ThirdPartyReact from "supertokens-auth-react/recipe/thirdparty";
import EmailPasswordReact from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session";
import { appInfo } from "./appInfo";
import { useRouter } from "next/navigation";
import { type useRouter } from "next/navigation";
import { SuperTokensConfig } from "supertokens-auth-react/lib/build/types";
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpassword/prebuiltui";
......
module.exports = {
'*.{js,jsx,mjs,ts,tsx,mts}': [
'prettier --with-node-modules --ignore-path .prettierignore --write',
'eslint --fix',
'cross-env ESLINT_USE_FLAT_CONFIG=false eslint --config .eslintrc.json --fix',
],
'*.{json,md,mdx,css,html,yml,yaml,scss}': [
'prettier --with-node-modules --ignore-path .prettierignore --write',
......
......@@ -34,7 +34,7 @@
"git-clean": "git clean -d -x -e node_modules -e packages -f",
"typescript": "tsc --noEmit",
"lint-typescript": "turbo run typescript",
"lint-eslint": "eslint . --ext js,jsx,ts,tsx --config .eslintrc.cli.json --no-eslintrc",
"lint-eslint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint . --ext js,jsx,ts,tsx --config .eslintrc.cli.json --no-eslintrc",
"lint-ast-grep": "ast-grep scan",
"lint-no-typescript": "run-p prettier-check lint-eslint lint-language",
"types-and-precompiled": "run-p lint-typescript check-precompiled validate-externals-doc",
......@@ -121,8 +121,8 @@
"@types/relay-runtime": "14.1.13",
"@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.3",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"@typescript-eslint/eslint-plugin": "8.0.0",
"@typescript-eslint/parser": "8.0.0",
"@vercel/devlow-bench": "workspace:*",
"@vercel/fetch": "6.1.1",
"@vercel/og": "0.6.3",
......@@ -144,15 +144,16 @@
"dd-trace": "4.12.0",
"es5-ext": "0.10.53",
"escape-string-regexp": "2.0.0",
"eslint": "8.56.0",
"eslint": "9.12.0",
"eslint-config-next": "workspace:*",
"eslint-formatter-codeframe": "7.32.1",
"eslint-plugin-eslint-plugin": "5.2.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jest": "27.6.3",
"eslint-plugin-jsdoc": "48.0.4",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-v8": "npm:eslint@^8.57.0",
"event-stream": "4.0.1",
"execa": "2.0.3",
"expect-type": "0.14.2",
......
......@@ -11,18 +11,18 @@
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "15.0.0-canary.190",
"@rushstack/eslint-patch": "^1.3.3",
"@rushstack/eslint-patch": "^1.10.3",
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.5.0 || 5.0.0-canary-7118f5dd7-20230705"
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.0.0"
},
"peerDependencies": {
"eslint": "^7.23.0 || ^8.0.0",
"eslint": "^7.23.0 || ^8.0.0 || ^9.0.0",
"typescript": ">=3.3.1"
},
"peerDependenciesMeta": {
......
......@@ -23,21 +23,23 @@ export type NextLintOptions = {
config?: string
dir?: string[]
errorOnUnmatchedPattern?: boolean
ext: string[]
file?: string[]
fix?: boolean
fixType?: string
format?: string
ignore: boolean
ignorePath?: string
inlineConfig: boolean
maxWarnings: number
outputFile?: string
quiet?: boolean
strict?: boolean
// TODO(jiwon): ESLint v9 unsupported options
// we currently delete them at `runLintCheck` when used in v9
ext: string[]
ignorePath?: string
reportUnusedDisableDirectivesSeverity: 'error' | 'off' | 'warn'
resolvePluginsRelativeTo?: string
rulesdir?: string
strict?: boolean
inlineConfig: boolean
maxWarnings: number
}
const eslintOptions = (
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
(function(){var r={992:function(r){r.exports=function(r,e,n){if(r.filter)return r.filter(e,n);if(void 0===r||null===r)throw new TypeError;if("function"!=typeof e)throw new TypeError;var o=[];for(var i=0;i<r.length;i++){if(!t.call(r,i))continue;var a=r[i];if(e.call(n,a,i,r))o.push(a)}return o};var t=Object.prototype.hasOwnProperty},256:function(r,t,e){"use strict";var n=e(925);var o=e(139);var i=o(n("String.prototype.indexOf"));r.exports=function callBoundIntrinsic(r,t){var e=n(r,!!t);if(typeof e==="function"&&i(r,".prototype.")>-1){return o(e)}return e}},139:function(r,t,e){"use strict";var n=e(212);var o=e(925);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var f=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var s=o("%Object.defineProperty%",true);var y=o("%Math.max%");if(s){try{s({},"a",{value:1})}catch(r){s=null}}r.exports=function callBind(r){var t=f(n,a,arguments);if(u&&s){var e=u(t,"length");if(e.configurable){s(t,"length",{value:1+y(0,r.length-(arguments.length-1))})}}return t};var c=function applyBind(){return f(n,i,arguments)};if(s){s(r.exports,"apply",{value:c})}else{r.exports.apply=c}},144:function(r){var t=Object.prototype.hasOwnProperty;var e=Object.prototype.toString;r.exports=function forEach(r,n,o){if(e.call(n)!=="[object Function]"){throw new TypeError("iterator must be a function")}var i=r.length;if(i===+i){for(var a=0;a<i;a++){n.call(o,r[a],a,r)}}else{for(var f in r){if(t.call(r,f)){n.call(o,r[f],f,r)}}}}},426:function(r){"use strict";var t="Function.prototype.bind called on incompatible ";var e=Array.prototype.slice;var n=Object.prototype.toString;var o="[object Function]";r.exports=function bind(r){var i=this;if(typeof i!=="function"||n.call(i)!==o){throw new TypeError(t+i)}var a=e.call(arguments,1);var f;var binder=function(){if(this instanceof f){var t=i.apply(this,a.concat(e.call(arguments)));if(Object(t)===t){return t}return this}else{return i.apply(r,a.concat(e.call(arguments)))}};var u=Math.max(0,i.length-a.length);var s=[];for(var y=0;y<u;y++){s.push("$"+y)}f=Function("binder","return function ("+s.join(",")+"){ return binder.apply(this,arguments); }")(binder);if(i.prototype){var c=function Empty(){};c.prototype=i.prototype;f.prototype=new c;c.prototype=null}return f}},174:function(r,t,e){"use strict";var n=e(426);r.exports=Function.prototype.bind||n},136:function(r){"use strict";var t="Function.prototype.bind called on incompatible ";var e=Object.prototype.toString;var n=Math.max;var o="[object Function]";var i=function concatty(r,t){var e=[];for(var n=0;n<r.length;n+=1){e[n]=r[n]}for(var o=0;o<t.length;o+=1){e[o+r.length]=t[o]}return e};var a=function slicy(r,t){var e=[];for(var n=t||0,o=0;n<r.length;n+=1,o+=1){e[o]=r[n]}return e};var joiny=function(r,t){var e="";for(var n=0;n<r.length;n+=1){e+=r[n];if(n+1<r.length){e+=t}}return e};r.exports=function bind(r){var f=this;if(typeof f!=="function"||e.apply(f)!==o){throw new TypeError(t+f)}var u=a(arguments,1);var s;var binder=function(){if(this instanceof s){var t=f.apply(this,i(u,arguments));if(Object(t)===t){return t}return this}return f.apply(r,i(u,arguments))};var y=n(0,f.length-u.length);var c=[];for(var p=0;p<y;p++){c[p]="$"+p}s=Function("binder","return function ("+joiny(c,",")+"){ return binder.apply(this,arguments); }")(binder);if(f.prototype){var l=function Empty(){};l.prototype=f.prototype;s.prototype=new l;l.prototype=null}return s}},212:function(r,t,e){"use strict";var n=e(136);r.exports=Function.prototype.bind||n},925:function(r,t,e){"use strict";var n;var o=SyntaxError;var i=Function;var a=TypeError;var getEvalledConstructor=function(r){try{return i('"use strict"; return ('+r+").constructor;")()}catch(r){}};var f=Object.getOwnPropertyDescriptor;if(f){try{f({},"")}catch(r){f=null}}var throwTypeError=function(){throw new a};var u=f?function(){try{arguments.callee;return throwTypeError}catch(r){try{return f(arguments,"callee").get}catch(r){return throwTypeError}}}():throwTypeError;var s=e(115)();var y=e(504)();var c=Object.getPrototypeOf||(y?function(r){return r.__proto__}:null);var p={};var l=typeof Uint8Array==="undefined"||!c?n:c(Uint8Array);var g={"%AggregateError%":typeof AggregateError==="undefined"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer==="undefined"?n:ArrayBuffer,"%ArrayIteratorPrototype%":s&&c?c([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":p,"%AsyncGenerator%":p,"%AsyncGeneratorFunction%":p,"%AsyncIteratorPrototype%":p,"%Atomics%":typeof Atomics==="undefined"?n:Atomics,"%BigInt%":typeof BigInt==="undefined"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array==="undefined"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array==="undefined"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView==="undefined"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array==="undefined"?n:Float32Array,"%Float64Array%":typeof Float64Array==="undefined"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry==="undefined"?n:FinalizationRegistry,"%Function%":i,"%GeneratorFunction%":p,"%Int8Array%":typeof Int8Array==="undefined"?n:Int8Array,"%Int16Array%":typeof Int16Array==="undefined"?n:Int16Array,"%Int32Array%":typeof Int32Array==="undefined"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":s&&c?c(c([][Symbol.iterator]())):n,"%JSON%":typeof JSON==="object"?JSON:n,"%Map%":typeof Map==="undefined"?n:Map,"%MapIteratorPrototype%":typeof Map==="undefined"||!s||!c?n:c((new Map)[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise==="undefined"?n:Promise,"%Proxy%":typeof Proxy==="undefined"?n:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect==="undefined"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set==="undefined"?n:Set,"%SetIteratorPrototype%":typeof Set==="undefined"||!s||!c?n:c((new Set)[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer==="undefined"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":s&&c?c(""[Symbol.iterator]()):n,"%Symbol%":s?Symbol:n,"%SyntaxError%":o,"%ThrowTypeError%":u,"%TypedArray%":l,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array==="undefined"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray==="undefined"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array==="undefined"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array==="undefined"?n:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap==="undefined"?n:WeakMap,"%WeakRef%":typeof WeakRef==="undefined"?n:WeakRef,"%WeakSet%":typeof WeakSet==="undefined"?n:WeakSet};if(c){try{null.error}catch(r){var b=c(c(r));g["%Error.prototype%"]=b}}var v=function doEval(r){var t;if(r==="%AsyncFunction%"){t=getEvalledConstructor("async function () {}")}else if(r==="%GeneratorFunction%"){t=getEvalledConstructor("function* () {}")}else if(r==="%AsyncGeneratorFunction%"){t=getEvalledConstructor("async function* () {}")}else if(r==="%AsyncGenerator%"){var e=doEval("%AsyncGeneratorFunction%");if(e){t=e.prototype}}else if(r==="%AsyncIteratorPrototype%"){var n=doEval("%AsyncGenerator%");if(n&&c){t=c(n.prototype)}}g[r]=t;return t};var d={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]};var m=e(174);var S=e(101);var A=m.call(Function.call,Array.prototype.concat);var h=m.call(Function.apply,Array.prototype.splice);var O=m.call(Function.call,String.prototype.replace);var j=m.call(Function.call,String.prototype.slice);var w=m.call(Function.call,RegExp.prototype.exec);var P=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;var B=/\\(\\)?/g;var E=function stringToPath(r){var t=j(r,0,1);var e=j(r,-1);if(t==="%"&&e!=="%"){throw new o("invalid intrinsic syntax, expected closing `%`")}else if(e==="%"&&t!=="%"){throw new o("invalid intrinsic syntax, expected opening `%`")}var n=[];O(r,P,(function(r,t,e,o){n[n.length]=e?O(o,B,"$1"):t||r}));return n};var T=function getBaseIntrinsic(r,t){var e=r;var n;if(S(d,e)){n=d[e];e="%"+n[0]+"%"}if(S(g,e)){var i=g[e];if(i===p){i=v(e)}if(typeof i==="undefined"&&!t){throw new a("intrinsic "+r+" exists, but is not available. Please file an issue!")}return{alias:n,name:e,value:i}}throw new o("intrinsic "+r+" does not exist!")};r.exports=function GetIntrinsic(r,t){if(typeof r!=="string"||r.length===0){throw new a("intrinsic name must be a non-empty string")}if(arguments.length>1&&typeof t!=="boolean"){throw new a('"allowMissing" argument must be a boolean')}if(w(/^%?[^%]*%?$/,r)===null){throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name")}var e=E(r);var i=e.length>0?e[0]:"";var u=T("%"+i+"%",t);var s=u.name;var y=u.value;var c=false;var p=u.alias;if(p){i=p[0];h(e,A([0,1],p))}for(var l=1,b=true;l<e.length;l+=1){var v=e[l];var d=j(v,0,1);var m=j(v,-1);if((d==='"'||d==="'"||d==="`"||(m==='"'||m==="'"||m==="`"))&&d!==m){throw new o("property names with quotes must have matching quotes")}if(v==="constructor"||!b){c=true}i+="."+v;s="%"+i+"%";if(S(g,s)){y=g[s]}else if(y!=null){if(!(v in y)){if(!t){throw new a("base intrinsic for "+r+" exists, but the property is not available.")}return void n}if(f&&l+1>=e.length){var O=f(y,v);b=!!O;if(b&&"get"in O&&!("originalValue"in O.get)){y=O.get}else{y=y[v]}}else{b=S(y,v);y=y[v]}if(b&&!c){g[s]=y}}}return y}},504:function(r){"use strict";var t={foo:{}};var e=Object;r.exports=function hasProto(){return{__proto__:t}.foo===t.foo&&!({__proto__:null}instanceof e)}},942:function(r,t,e){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=e(773);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var t=Symbol("test");var e=Object(t);if(typeof t==="string"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}var n=42;r[t]=n;for(t in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==t){return false}if(!Object.prototype.propertyIsEnumerable.call(r,t)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,t);if(i.value!==n||i.enumerable!==true){return false}}return true}},115:function(r,t,e){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=e(832);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},832:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var t=Symbol("test");var e=Object(t);if(typeof t==="string"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}var n=42;r[t]=n;for(t in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==t){return false}if(!Object.prototype.propertyIsEnumerable.call(r,t)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,t);if(i.value!==n||i.enumerable!==true){return false}}return true}},101:function(r,t,e){"use strict";var n=e(174);r.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},782:function(r){if(typeof Object.create==="function"){r.exports=function inherits(r,t){if(t){r.super_=t;r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}})}}}else{r.exports=function inherits(r,t){if(t){r.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype;r.prototype=new TempCtor;r.prototype.constructor=r}}}},157:function(r){"use strict";var t=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var e=Object.prototype.toString;var n=function isArguments(r){if(t&&r&&typeof r==="object"&&Symbol.toStringTag in r){return false}return e.call(r)==="[object Arguments]"};var o=function isArguments(r){if(n(r)){return true}return r!==null&&typeof r==="object"&&typeof r.length==="number"&&r.length>=0&&e.call(r)!=="[object Array]"&&e.call(r.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;r.exports=i?n:o},391:function(r){"use strict";var t=Object.prototype.toString;var e=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(r){}};var a=getGeneratorFunc();var f=a?i(a):{};r.exports=function isGeneratorFunction(r){if(typeof r!=="function"){return false}if(n.test(e.call(r))){return true}if(!o){var a=t.call(r);return a==="[object GeneratorFunction]"}return i(r)===f}},994:function(r,t,e){"use strict";var n=e(144);var o=e(349);var i=e(256);var a=i("Object.prototype.toString");var f=e(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var y=i("Array.prototype.indexOf",true)||function indexOf(r,t){for(var e=0;e<r.length;e+=1){if(r[e]===t){return e}}return-1};var c=i("String.prototype.slice");var p={};var l=e(24);var g=Object.getPrototypeOf;if(u&&l&&g){n(s,(function(r){var t=new global[r];if(!(Symbol.toStringTag in t)){throw new EvalError("this engine has support for Symbol.toStringTag, but "+r+" does not have the property! Please report this.")}var e=g(t);var n=l(e,Symbol.toStringTag);if(!n){var o=g(e);n=l(o,Symbol.toStringTag)}p[r]=n.get}))}var b=function tryAllTypedArrays(r){var t=false;n(p,(function(e,n){if(!t){try{t=e.call(r)===n}catch(r){}}}));return t};r.exports=function isTypedArray(r){if(!r||typeof r!=="object"){return false}if(!u){var t=c(a(r),8,-1);return y(s,t)>-1}if(!l){return false}return b(r)}},369:function(r){r.exports=function isBuffer(r){return r instanceof Buffer}},584:function(r,t,e){"use strict";var n=e(157);var o=e(391);var i=e(490);var a=e(994);function uncurryThis(r){return r.call.bind(r)}var f=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var s=uncurryThis(Object.prototype.toString);var y=uncurryThis(Number.prototype.valueOf);var c=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(f){var l=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(r,t){if(typeof r!=="object"){return false}try{t(r);return true}catch(r){return false}}t.isArgumentsObject=n;t.isGeneratorFunction=o;t.isTypedArray=a;function isPromise(r){return typeof Promise!=="undefined"&&r instanceof Promise||r!==null&&typeof r==="object"&&typeof r.then==="function"&&typeof r.catch==="function"}t.isPromise=isPromise;function isArrayBufferView(r){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(r)}return a(r)||isDataView(r)}t.isArrayBufferView=isArrayBufferView;function isUint8Array(r){return i(r)==="Uint8Array"}t.isUint8Array=isUint8Array;function isUint8ClampedArray(r){return i(r)==="Uint8ClampedArray"}t.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(r){return i(r)==="Uint16Array"}t.isUint16Array=isUint16Array;function isUint32Array(r){return i(r)==="Uint32Array"}t.isUint32Array=isUint32Array;function isInt8Array(r){return i(r)==="Int8Array"}t.isInt8Array=isInt8Array;function isInt16Array(r){return i(r)==="Int16Array"}t.isInt16Array=isInt16Array;function isInt32Array(r){return i(r)==="Int32Array"}t.isInt32Array=isInt32Array;function isFloat32Array(r){return i(r)==="Float32Array"}t.isFloat32Array=isFloat32Array;function isFloat64Array(r){return i(r)==="Float64Array"}t.isFloat64Array=isFloat64Array;function isBigInt64Array(r){return i(r)==="BigInt64Array"}t.isBigInt64Array=isBigInt64Array;function isBigUint64Array(r){return i(r)==="BigUint64Array"}t.isBigUint64Array=isBigUint64Array;function isMapToString(r){return s(r)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(r){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(r):r instanceof Map}t.isMap=isMap;function isSetToString(r){return s(r)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(r){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(r):r instanceof Set}t.isSet=isSet;function isWeakMapToString(r){return s(r)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(r){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(r):r instanceof WeakMap}t.isWeakMap=isWeakMap;function isWeakSetToString(r){return s(r)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(r){return isWeakSetToString(r)}t.isWeakSet=isWeakSet;function isArrayBufferToString(r){return s(r)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(r){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(r):r instanceof ArrayBuffer}t.isArrayBuffer=isArrayBuffer;function isDataViewToString(r){return s(r)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(r){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(r):r instanceof DataView}t.isDataView=isDataView;var b=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(r){return s(r)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(r){if(typeof b==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new b)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(r):r instanceof b}t.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(r){return s(r)==="[object AsyncFunction]"}t.isAsyncFunction=isAsyncFunction;function isMapIterator(r){return s(r)==="[object Map Iterator]"}t.isMapIterator=isMapIterator;function isSetIterator(r){return s(r)==="[object Set Iterator]"}t.isSetIterator=isSetIterator;function isGeneratorObject(r){return s(r)==="[object Generator]"}t.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(r){return s(r)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(r){return checkBoxedPrimitive(r,y)}t.isNumberObject=isNumberObject;function isStringObject(r){return checkBoxedPrimitive(r,c)}t.isStringObject=isStringObject;function isBooleanObject(r){return checkBoxedPrimitive(r,p)}t.isBooleanObject=isBooleanObject;function isBigIntObject(r){return f&&checkBoxedPrimitive(r,l)}t.isBigIntObject=isBigIntObject;function isSymbolObject(r){return u&&checkBoxedPrimitive(r,g)}t.isSymbolObject=isSymbolObject;function isBoxedPrimitive(r){return isNumberObject(r)||isStringObject(r)||isBooleanObject(r)||isBigIntObject(r)||isSymbolObject(r)}t.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(r){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(r)||isSharedArrayBuffer(r))}t.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(r){Object.defineProperty(t,r,{enumerable:false,value:function(){throw new Error(r+" is not supported in userland")}})}))},177:function(r,t,e){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(r){var t=Object.keys(r);var e={};for(var n=0;n<t.length;n++){e[t[n]]=Object.getOwnPropertyDescriptor(r,t[n])}return e};var o=/%[sdj%]/g;t.format=function(r){if(!isString(r)){var t=[];for(var e=0;e<arguments.length;e++){t.push(inspect(arguments[e]))}return t.join(" ")}var e=1;var n=arguments;var i=n.length;var a=String(r).replace(o,(function(r){if(r==="%%")return"%";if(e>=i)return r;switch(r){case"%s":return String(n[e++]);case"%d":return Number(n[e++]);case"%j":try{return JSON.stringify(n[e++])}catch(r){return"[Circular]"}default:return r}}));for(var f=n[e];e<i;f=n[++e]){if(isNull(f)||!isObject(f)){a+=" "+f}else{a+=" "+inspect(f)}}return a};t.deprecate=function(r,e){if(typeof process!=="undefined"&&process.noDeprecation===true){return r}if(typeof process==="undefined"){return function(){return t.deprecate(r,e).apply(this,arguments)}}var n=false;function deprecated(){if(!n){if(process.throwDeprecation){throw new Error(e)}else if(process.traceDeprecation){console.trace(e)}else{console.error(e)}n=true}return r.apply(this,arguments)}return deprecated};var i={};var a=/^$/;if(process.env.NODE_DEBUG){var f=process.env.NODE_DEBUG;f=f.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase();a=new RegExp("^"+f+"$","i")}t.debuglog=function(r){r=r.toUpperCase();if(!i[r]){if(a.test(r)){var e=process.pid;i[r]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",r,e,n)}}else{i[r]=function(){}}}return i[r]};function inspect(r,e){var n={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(e)){n.showHidden=e}else if(e){t._extend(n,e)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,r,n.depth)}t.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(r,t){var e=inspect.styles[t];if(e){return"["+inspect.colors[e][0]+"m"+r+"["+inspect.colors[e][1]+"m"}else{return r}}function stylizeNoColor(r,t){return r}function arrayToHash(r){var t={};r.forEach((function(r,e){t[r]=true}));return t}function formatValue(r,e,n){if(r.customInspect&&e&&isFunction(e.inspect)&&e.inspect!==t.inspect&&!(e.constructor&&e.constructor.prototype===e)){var o=e.inspect(n,r);if(!isString(o)){o=formatValue(r,o,n)}return o}var i=formatPrimitive(r,e);if(i){return i}var a=Object.keys(e);var f=arrayToHash(a);if(r.showHidden){a=Object.getOwnPropertyNames(e)}if(isError(e)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(e)}if(a.length===0){if(isFunction(e)){var u=e.name?": "+e.name:"";return r.stylize("[Function"+u+"]","special")}if(isRegExp(e)){return r.stylize(RegExp.prototype.toString.call(e),"regexp")}if(isDate(e)){return r.stylize(Date.prototype.toString.call(e),"date")}if(isError(e)){return formatError(e)}}var s="",y=false,c=["{","}"];if(isArray(e)){y=true;c=["[","]"]}if(isFunction(e)){var p=e.name?": "+e.name:"";s=" [Function"+p+"]"}if(isRegExp(e)){s=" "+RegExp.prototype.toString.call(e)}if(isDate(e)){s=" "+Date.prototype.toUTCString.call(e)}if(isError(e)){s=" "+formatError(e)}if(a.length===0&&(!y||e.length==0)){return c[0]+s+c[1]}if(n<0){if(isRegExp(e)){return r.stylize(RegExp.prototype.toString.call(e),"regexp")}else{return r.stylize("[Object]","special")}}r.seen.push(e);var l;if(y){l=formatArray(r,e,n,f,a)}else{l=a.map((function(t){return formatProperty(r,e,n,f,t,y)}))}r.seen.pop();return reduceToSingleString(l,s,c)}function formatPrimitive(r,t){if(isUndefined(t))return r.stylize("undefined","undefined");if(isString(t)){var e="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return r.stylize(e,"string")}if(isNumber(t))return r.stylize(""+t,"number");if(isBoolean(t))return r.stylize(""+t,"boolean");if(isNull(t))return r.stylize("null","null")}function formatError(r){return"["+Error.prototype.toString.call(r)+"]"}function formatArray(r,t,e,n,o){var i=[];for(var a=0,f=t.length;a<f;++a){if(hasOwnProperty(t,String(a))){i.push(formatProperty(r,t,e,n,String(a),true))}else{i.push("")}}o.forEach((function(o){if(!o.match(/^\d+$/)){i.push(formatProperty(r,t,e,n,o,true))}}));return i}function formatProperty(r,t,e,n,o,i){var a,f,u;u=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]};if(u.get){if(u.set){f=r.stylize("[Getter/Setter]","special")}else{f=r.stylize("[Getter]","special")}}else{if(u.set){f=r.stylize("[Setter]","special")}}if(!hasOwnProperty(n,o)){a="["+o+"]"}if(!f){if(r.seen.indexOf(u.value)<0){if(isNull(e)){f=formatValue(r,u.value,null)}else{f=formatValue(r,u.value,e-1)}if(f.indexOf("\n")>-1){if(i){f=f.split("\n").map((function(r){return" "+r})).join("\n").substr(2)}else{f="\n"+f.split("\n").map((function(r){return" "+r})).join("\n")}}}else{f=r.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return f}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=r.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=r.stylize(a,"string")}}return a+": "+f}function reduceToSingleString(r,t,e){var n=0;var o=r.reduce((function(r,t){n++;if(t.indexOf("\n")>=0)n++;return r+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return e[0]+(t===""?"":t+"\n ")+" "+r.join(",\n ")+" "+e[1]}return e[0]+t+" "+r.join(", ")+" "+e[1]}t.types=e(584);function isArray(r){return Array.isArray(r)}t.isArray=isArray;function isBoolean(r){return typeof r==="boolean"}t.isBoolean=isBoolean;function isNull(r){return r===null}t.isNull=isNull;function isNullOrUndefined(r){return r==null}t.isNullOrUndefined=isNullOrUndefined;function isNumber(r){return typeof r==="number"}t.isNumber=isNumber;function isString(r){return typeof r==="string"}t.isString=isString;function isSymbol(r){return typeof r==="symbol"}t.isSymbol=isSymbol;function isUndefined(r){return r===void 0}t.isUndefined=isUndefined;function isRegExp(r){return isObject(r)&&objectToString(r)==="[object RegExp]"}t.isRegExp=isRegExp;t.types.isRegExp=isRegExp;function isObject(r){return typeof r==="object"&&r!==null}t.isObject=isObject;function isDate(r){return isObject(r)&&objectToString(r)==="[object Date]"}t.isDate=isDate;t.types.isDate=isDate;function isError(r){return isObject(r)&&(objectToString(r)==="[object Error]"||r instanceof Error)}t.isError=isError;t.types.isNativeError=isError;function isFunction(r){return typeof r==="function"}t.isFunction=isFunction;function isPrimitive(r){return r===null||typeof r==="boolean"||typeof r==="number"||typeof r==="string"||typeof r==="symbol"||typeof r==="undefined"}t.isPrimitive=isPrimitive;t.isBuffer=e(369);function objectToString(r){return Object.prototype.toString.call(r)}function pad(r){return r<10?"0"+r.toString(10):r.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var r=new Date;var t=[pad(r.getHours()),pad(r.getMinutes()),pad(r.getSeconds())].join(":");return[r.getDate(),u[r.getMonth()],t].join(" ")}t.log=function(){console.log("%s - %s",timestamp(),t.format.apply(t,arguments))};t.inherits=e(782);t._extend=function(r,t){if(!t||!isObject(t))return r;var e=Object.keys(t);var n=e.length;while(n--){r[e[n]]=t[e[n]]}return r};function hasOwnProperty(r,t){return Object.prototype.hasOwnProperty.call(r,t)}var s=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;t.promisify=function promisify(r){if(typeof r!=="function")throw new TypeError('The "original" argument must be of type Function');if(s&&r[s]){var t=r[s];if(typeof t!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(t,s,{value:t,enumerable:false,writable:false,configurable:true});return t}function t(){var t,e;var n=new Promise((function(r,n){t=r;e=n}));var o=[];for(var i=0;i<arguments.length;i++){o.push(arguments[i])}o.push((function(r,n){if(r){e(r)}else{t(n)}}));try{r.apply(this,o)}catch(r){e(r)}return n}Object.setPrototypeOf(t,Object.getPrototypeOf(r));if(s)Object.defineProperty(t,s,{value:t,enumerable:false,writable:false,configurable:true});return Object.defineProperties(t,n(r))};t.promisify.custom=s;function callbackifyOnRejected(r,t){if(!r){var e=new Error("Promise was rejected with a falsy value");e.reason=r;r=e}return t(r)}function callbackify(r){if(typeof r!=="function"){throw new TypeError('The "original" argument must be of type Function')}function callbackified(){var t=[];for(var e=0;e<arguments.length;e++){t.push(arguments[e])}var n=t.pop();if(typeof n!=="function"){throw new TypeError("The last argument must be of type Function")}var o=this;var cb=function(){return n.apply(o,arguments)};r.apply(this,t).then((function(r){process.nextTick(cb.bind(null,null,r))}),(function(r){process.nextTick(callbackifyOnRejected.bind(null,r,cb))}))}Object.setPrototypeOf(callbackified,Object.getPrototypeOf(r));Object.defineProperties(callbackified,n(r));return callbackified}t.callbackify=callbackify},490:function(r,t,e){"use strict";var n=e(144);var o=e(349);var i=e(256);var a=i("Object.prototype.toString");var f=e(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var y=i("String.prototype.slice");var c={};var p=e(24);var l=Object.getPrototypeOf;if(u&&p&&l){n(s,(function(r){if(typeof global[r]==="function"){var t=new global[r];if(!(Symbol.toStringTag in t)){throw new EvalError("this engine has support for Symbol.toStringTag, but "+r+" does not have the property! Please report this.")}var e=l(t);var n=p(e,Symbol.toStringTag);if(!n){var o=l(e);n=p(o,Symbol.toStringTag)}c[r]=n.get}}))}var g=function tryAllTypedArrays(r){var t=false;n(c,(function(e,n){if(!t){try{var o=e.call(r);if(o===n){t=o}}catch(r){}}}));return t};var b=e(994);r.exports=function whichTypedArray(r){if(!b(r)){return false}if(!u){return y(a(r),8,-1)}return g(r)}},349:function(r,t,e){"use strict";var n=e(992);r.exports=function availableTypedArrays(){return n(["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],(function(r){return typeof global[r]==="function"}))}},24:function(r,t,e){"use strict";var n=e(925);var o=n("%Object.getOwnPropertyDescriptor%",true);if(o){try{o([],"length")}catch(r){o=null}}r.exports=o}};var t={};function __nccwpck_require__(e){var n=t[e];if(n!==undefined){return n.exports}var o=t[e]={exports:{}};var i=true;try{r[e](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[e]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var e=__nccwpck_require__(177);module.exports=e})();
\ No newline at end of file
(function(){var r={992:function(r){r.exports=function(r,t,n){if(r.filter)return r.filter(t,n);if(void 0===r||null===r)throw new TypeError;if("function"!=typeof t)throw new TypeError;var o=[];for(var i=0;i<r.length;i++){if(!e.call(r,i))continue;var a=r[i];if(t.call(n,a,i,r))o.push(a)}return o};var e=Object.prototype.hasOwnProperty},256:function(r,e,t){"use strict";var n=t(192);var o=t(139);var i=o(n("String.prototype.indexOf"));r.exports=function callBoundIntrinsic(r,e){var t=n(r,!!e);if(typeof t==="function"&&i(r,".prototype.")>-1){return o(t)}return t}},139:function(r,e,t){"use strict";var n=t(212);var o=t(192);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var f=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var s=o("%Object.defineProperty%",true);var c=o("%Math.max%");if(s){try{s({},"a",{value:1})}catch(r){s=null}}r.exports=function callBind(r){var e=f(n,a,arguments);if(u&&s){var t=u(e,"length");if(t.configurable){s(e,"length",{value:1+c(0,r.length-(arguments.length-1))})}}return e};var y=function applyBind(){return f(n,i,arguments)};if(s){s(r.exports,"apply",{value:y})}else{r.exports.apply=y}},181:function(r){"use strict";r.exports=EvalError},545:function(r){"use strict";r.exports=Error},22:function(r){"use strict";r.exports=RangeError},803:function(r){"use strict";r.exports=ReferenceError},182:function(r){"use strict";r.exports=SyntaxError},202:function(r){"use strict";r.exports=TypeError},284:function(r){"use strict";r.exports=URIError},144:function(r){var e=Object.prototype.hasOwnProperty;var t=Object.prototype.toString;r.exports=function forEach(r,n,o){if(t.call(n)!=="[object Function]"){throw new TypeError("iterator must be a function")}var i=r.length;if(i===+i){for(var a=0;a<i;a++){n.call(o,r[a],a,r)}}else{for(var f in r){if(e.call(r,f)){n.call(o,r[f],f,r)}}}}},136:function(r){"use strict";var e="Function.prototype.bind called on incompatible ";var t=Object.prototype.toString;var n=Math.max;var o="[object Function]";var i=function concatty(r,e){var t=[];for(var n=0;n<r.length;n+=1){t[n]=r[n]}for(var o=0;o<e.length;o+=1){t[o+r.length]=e[o]}return t};var a=function slicy(r,e){var t=[];for(var n=e||0,o=0;n<r.length;n+=1,o+=1){t[o]=r[n]}return t};var joiny=function(r,e){var t="";for(var n=0;n<r.length;n+=1){t+=r[n];if(n+1<r.length){t+=e}}return t};r.exports=function bind(r){var f=this;if(typeof f!=="function"||t.apply(f)!==o){throw new TypeError(e+f)}var u=a(arguments,1);var s;var binder=function(){if(this instanceof s){var e=f.apply(this,i(u,arguments));if(Object(e)===e){return e}return this}return f.apply(r,i(u,arguments))};var c=n(0,f.length-u.length);var y=[];for(var p=0;p<c;p++){y[p]="$"+p}s=Function("binder","return function ("+joiny(y,",")+"){ return binder.apply(this,arguments); }")(binder);if(f.prototype){var l=function Empty(){};l.prototype=f.prototype;s.prototype=new l;l.prototype=null}return s}},212:function(r,e,t){"use strict";var n=t(136);r.exports=Function.prototype.bind||n},192:function(r,e,t){"use strict";var n;var o=t(545);var i=t(181);var a=t(22);var f=t(803);var u=t(182);var s=t(202);var c=t(284);var y=Function;var getEvalledConstructor=function(r){try{return y('"use strict"; return ('+r+").constructor;")()}catch(r){}};var p=Object.getOwnPropertyDescriptor;if(p){try{p({},"")}catch(r){p=null}}var throwTypeError=function(){throw new s};var l=p?function(){try{arguments.callee;return throwTypeError}catch(r){try{return p(arguments,"callee").get}catch(r){return throwTypeError}}}():throwTypeError;var g=t(115)();var v=t(14)();var b=Object.getPrototypeOf||(v?function(r){return r.__proto__}:null);var d={};var m=typeof Uint8Array==="undefined"||!b?n:b(Uint8Array);var S={__proto__:null,"%AggregateError%":typeof AggregateError==="undefined"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer==="undefined"?n:ArrayBuffer,"%ArrayIteratorPrototype%":g&&b?b([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":d,"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":d,"%AsyncIteratorPrototype%":d,"%Atomics%":typeof Atomics==="undefined"?n:Atomics,"%BigInt%":typeof BigInt==="undefined"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array==="undefined"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array==="undefined"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView==="undefined"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":i,"%Float32Array%":typeof Float32Array==="undefined"?n:Float32Array,"%Float64Array%":typeof Float64Array==="undefined"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry==="undefined"?n:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":d,"%Int8Array%":typeof Int8Array==="undefined"?n:Int8Array,"%Int16Array%":typeof Int16Array==="undefined"?n:Int16Array,"%Int32Array%":typeof Int32Array==="undefined"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":g&&b?b(b([][Symbol.iterator]())):n,"%JSON%":typeof JSON==="object"?JSON:n,"%Map%":typeof Map==="undefined"?n:Map,"%MapIteratorPrototype%":typeof Map==="undefined"||!g||!b?n:b((new Map)[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise==="undefined"?n:Promise,"%Proxy%":typeof Proxy==="undefined"?n:Proxy,"%RangeError%":a,"%ReferenceError%":f,"%Reflect%":typeof Reflect==="undefined"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set==="undefined"?n:Set,"%SetIteratorPrototype%":typeof Set==="undefined"||!g||!b?n:b((new Set)[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer==="undefined"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":g&&b?b(""[Symbol.iterator]()):n,"%Symbol%":g?Symbol:n,"%SyntaxError%":u,"%ThrowTypeError%":l,"%TypedArray%":m,"%TypeError%":s,"%Uint8Array%":typeof Uint8Array==="undefined"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray==="undefined"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array==="undefined"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array==="undefined"?n:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap==="undefined"?n:WeakMap,"%WeakRef%":typeof WeakRef==="undefined"?n:WeakRef,"%WeakSet%":typeof WeakSet==="undefined"?n:WeakSet};if(b){try{null.error}catch(r){var A=b(b(r));S["%Error.prototype%"]=A}}var h=function doEval(r){var e;if(r==="%AsyncFunction%"){e=getEvalledConstructor("async function () {}")}else if(r==="%GeneratorFunction%"){e=getEvalledConstructor("function* () {}")}else if(r==="%AsyncGeneratorFunction%"){e=getEvalledConstructor("async function* () {}")}else if(r==="%AsyncGenerator%"){var t=doEval("%AsyncGeneratorFunction%");if(t){e=t.prototype}}else if(r==="%AsyncIteratorPrototype%"){var n=doEval("%AsyncGenerator%");if(n&&b){e=b(n.prototype)}}S[r]=e;return e};var O={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]};var j=t(212);var w=t(270);var P=j.call(Function.call,Array.prototype.concat);var B=j.call(Function.apply,Array.prototype.splice);var E=j.call(Function.call,String.prototype.replace);var x=j.call(Function.call,String.prototype.slice);var T=j.call(Function.call,RegExp.prototype.exec);var I=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;var k=/\\(\\)?/g;var F=function stringToPath(r){var e=x(r,0,1);var t=x(r,-1);if(e==="%"&&t!=="%"){throw new u("invalid intrinsic syntax, expected closing `%`")}else if(t==="%"&&e!=="%"){throw new u("invalid intrinsic syntax, expected opening `%`")}var n=[];E(r,I,(function(r,e,t,o){n[n.length]=t?E(o,k,"$1"):e||r}));return n};var U=function getBaseIntrinsic(r,e){var t=r;var n;if(w(O,t)){n=O[t];t="%"+n[0]+"%"}if(w(S,t)){var o=S[t];if(o===d){o=h(t)}if(typeof o==="undefined"&&!e){throw new s("intrinsic "+r+" exists, but is not available. Please file an issue!")}return{alias:n,name:t,value:o}}throw new u("intrinsic "+r+" does not exist!")};r.exports=function GetIntrinsic(r,e){if(typeof r!=="string"||r.length===0){throw new s("intrinsic name must be a non-empty string")}if(arguments.length>1&&typeof e!=="boolean"){throw new s('"allowMissing" argument must be a boolean')}if(T(/^%?[^%]*%?$/,r)===null){throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name")}var t=F(r);var o=t.length>0?t[0]:"";var i=U("%"+o+"%",e);var a=i.name;var f=i.value;var c=false;var y=i.alias;if(y){o=y[0];B(t,P([0,1],y))}for(var l=1,g=true;l<t.length;l+=1){var v=t[l];var b=x(v,0,1);var d=x(v,-1);if((b==='"'||b==="'"||b==="`"||(d==='"'||d==="'"||d==="`"))&&b!==d){throw new u("property names with quotes must have matching quotes")}if(v==="constructor"||!g){c=true}o+="."+v;a="%"+o+"%";if(w(S,a)){f=S[a]}else if(f!=null){if(!(v in f)){if(!e){throw new s("base intrinsic for "+r+" exists, but the property is not available.")}return void n}if(p&&l+1>=t.length){var m=p(f,v);g=!!m;if(g&&"get"in m&&!("originalValue"in m.get)){f=m.get}else{f=f[v]}}else{g=w(f,v);f=f[v]}if(g&&!c){S[a]=f}}}return f}},14:function(r){"use strict";var e={__proto__:null,foo:{}};var t=Object;r.exports=function hasProto(){return{__proto__:e}.foo===e.foo&&!(e instanceof t)}},942:function(r,e,t){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=t(773);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var e=Symbol("test");var t=Object(e);if(typeof e==="string"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}var n=42;r[e]=n;for(e in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==e){return false}if(!Object.prototype.propertyIsEnumerable.call(r,e)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,e);if(i.value!==n||i.enumerable!==true){return false}}return true}},115:function(r,e,t){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=t(832);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},832:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var e=Symbol("test");var t=Object(e);if(typeof e==="string"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}var n=42;r[e]=n;for(e in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==e){return false}if(!Object.prototype.propertyIsEnumerable.call(r,e)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,e);if(i.value!==n||i.enumerable!==true){return false}}return true}},270:function(r,e,t){"use strict";var n=Function.prototype.call;var o=Object.prototype.hasOwnProperty;var i=t(212);r.exports=i.call(n,o)},782:function(r){if(typeof Object.create==="function"){r.exports=function inherits(r,e){if(e){r.super_=e;r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}})}}}else{r.exports=function inherits(r,e){if(e){r.super_=e;var TempCtor=function(){};TempCtor.prototype=e.prototype;r.prototype=new TempCtor;r.prototype.constructor=r}}}},157:function(r){"use strict";var e=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var t=Object.prototype.toString;var n=function isArguments(r){if(e&&r&&typeof r==="object"&&Symbol.toStringTag in r){return false}return t.call(r)==="[object Arguments]"};var o=function isArguments(r){if(n(r)){return true}return r!==null&&typeof r==="object"&&typeof r.length==="number"&&r.length>=0&&t.call(r)!=="[object Array]"&&t.call(r.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;r.exports=i?n:o},391:function(r){"use strict";var e=Object.prototype.toString;var t=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(r){}};var a=getGeneratorFunc();var f=a?i(a):{};r.exports=function isGeneratorFunction(r){if(typeof r!=="function"){return false}if(n.test(t.call(r))){return true}if(!o){var a=e.call(r);return a==="[object GeneratorFunction]"}return i(r)===f}},994:function(r,e,t){"use strict";var n=t(144);var o=t(349);var i=t(256);var a=i("Object.prototype.toString");var f=t(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var c=i("Array.prototype.indexOf",true)||function indexOf(r,e){for(var t=0;t<r.length;t+=1){if(r[t]===e){return t}}return-1};var y=i("String.prototype.slice");var p={};var l=t(24);var g=Object.getPrototypeOf;if(u&&l&&g){n(s,(function(r){var e=new global[r];if(!(Symbol.toStringTag in e)){throw new EvalError("this engine has support for Symbol.toStringTag, but "+r+" does not have the property! Please report this.")}var t=g(e);var n=l(t,Symbol.toStringTag);if(!n){var o=g(t);n=l(o,Symbol.toStringTag)}p[r]=n.get}))}var v=function tryAllTypedArrays(r){var e=false;n(p,(function(t,n){if(!e){try{e=t.call(r)===n}catch(r){}}}));return e};r.exports=function isTypedArray(r){if(!r||typeof r!=="object"){return false}if(!u){var e=y(a(r),8,-1);return c(s,e)>-1}if(!l){return false}return v(r)}},369:function(r){r.exports=function isBuffer(r){return r instanceof Buffer}},584:function(r,e,t){"use strict";var n=t(157);var o=t(391);var i=t(490);var a=t(994);function uncurryThis(r){return r.call.bind(r)}var f=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var s=uncurryThis(Object.prototype.toString);var c=uncurryThis(Number.prototype.valueOf);var y=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(f){var l=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(r,e){if(typeof r!=="object"){return false}try{e(r);return true}catch(r){return false}}e.isArgumentsObject=n;e.isGeneratorFunction=o;e.isTypedArray=a;function isPromise(r){return typeof Promise!=="undefined"&&r instanceof Promise||r!==null&&typeof r==="object"&&typeof r.then==="function"&&typeof r.catch==="function"}e.isPromise=isPromise;function isArrayBufferView(r){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(r)}return a(r)||isDataView(r)}e.isArrayBufferView=isArrayBufferView;function isUint8Array(r){return i(r)==="Uint8Array"}e.isUint8Array=isUint8Array;function isUint8ClampedArray(r){return i(r)==="Uint8ClampedArray"}e.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(r){return i(r)==="Uint16Array"}e.isUint16Array=isUint16Array;function isUint32Array(r){return i(r)==="Uint32Array"}e.isUint32Array=isUint32Array;function isInt8Array(r){return i(r)==="Int8Array"}e.isInt8Array=isInt8Array;function isInt16Array(r){return i(r)==="Int16Array"}e.isInt16Array=isInt16Array;function isInt32Array(r){return i(r)==="Int32Array"}e.isInt32Array=isInt32Array;function isFloat32Array(r){return i(r)==="Float32Array"}e.isFloat32Array=isFloat32Array;function isFloat64Array(r){return i(r)==="Float64Array"}e.isFloat64Array=isFloat64Array;function isBigInt64Array(r){return i(r)==="BigInt64Array"}e.isBigInt64Array=isBigInt64Array;function isBigUint64Array(r){return i(r)==="BigUint64Array"}e.isBigUint64Array=isBigUint64Array;function isMapToString(r){return s(r)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(r){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(r):r instanceof Map}e.isMap=isMap;function isSetToString(r){return s(r)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(r){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(r):r instanceof Set}e.isSet=isSet;function isWeakMapToString(r){return s(r)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(r){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(r):r instanceof WeakMap}e.isWeakMap=isWeakMap;function isWeakSetToString(r){return s(r)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(r){return isWeakSetToString(r)}e.isWeakSet=isWeakSet;function isArrayBufferToString(r){return s(r)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(r){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(r):r instanceof ArrayBuffer}e.isArrayBuffer=isArrayBuffer;function isDataViewToString(r){return s(r)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(r){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(r):r instanceof DataView}e.isDataView=isDataView;var v=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(r){return s(r)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(r){if(typeof v==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new v)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(r):r instanceof v}e.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(r){return s(r)==="[object AsyncFunction]"}e.isAsyncFunction=isAsyncFunction;function isMapIterator(r){return s(r)==="[object Map Iterator]"}e.isMapIterator=isMapIterator;function isSetIterator(r){return s(r)==="[object Set Iterator]"}e.isSetIterator=isSetIterator;function isGeneratorObject(r){return s(r)==="[object Generator]"}e.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(r){return s(r)==="[object WebAssembly.Module]"}e.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(r){return checkBoxedPrimitive(r,c)}e.isNumberObject=isNumberObject;function isStringObject(r){return checkBoxedPrimitive(r,y)}e.isStringObject=isStringObject;function isBooleanObject(r){return checkBoxedPrimitive(r,p)}e.isBooleanObject=isBooleanObject;function isBigIntObject(r){return f&&checkBoxedPrimitive(r,l)}e.isBigIntObject=isBigIntObject;function isSymbolObject(r){return u&&checkBoxedPrimitive(r,g)}e.isSymbolObject=isSymbolObject;function isBoxedPrimitive(r){return isNumberObject(r)||isStringObject(r)||isBooleanObject(r)||isBigIntObject(r)||isSymbolObject(r)}e.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(r){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(r)||isSharedArrayBuffer(r))}e.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(r){Object.defineProperty(e,r,{enumerable:false,value:function(){throw new Error(r+" is not supported in userland")}})}))},177:function(r,e,t){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(r){var e=Object.keys(r);var t={};for(var n=0;n<e.length;n++){t[e[n]]=Object.getOwnPropertyDescriptor(r,e[n])}return t};var o=/%[sdj%]/g;e.format=function(r){if(!isString(r)){var e=[];for(var t=0;t<arguments.length;t++){e.push(inspect(arguments[t]))}return e.join(" ")}var t=1;var n=arguments;var i=n.length;var a=String(r).replace(o,(function(r){if(r==="%%")return"%";if(t>=i)return r;switch(r){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(r){return"[Circular]"}default:return r}}));for(var f=n[t];t<i;f=n[++t]){if(isNull(f)||!isObject(f)){a+=" "+f}else{a+=" "+inspect(f)}}return a};e.deprecate=function(r,t){if(typeof process!=="undefined"&&process.noDeprecation===true){return r}if(typeof process==="undefined"){return function(){return e.deprecate(r,t).apply(this,arguments)}}var n=false;function deprecated(){if(!n){if(process.throwDeprecation){throw new Error(t)}else if(process.traceDeprecation){console.trace(t)}else{console.error(t)}n=true}return r.apply(this,arguments)}return deprecated};var i={};var a=/^$/;if(process.env.NODE_DEBUG){var f=process.env.NODE_DEBUG;f=f.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase();a=new RegExp("^"+f+"$","i")}e.debuglog=function(r){r=r.toUpperCase();if(!i[r]){if(a.test(r)){var t=process.pid;i[r]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",r,t,n)}}else{i[r]=function(){}}}return i[r]};function inspect(r,t){var n={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(t)){n.showHidden=t}else if(t){e._extend(n,t)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,r,n.depth)}e.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(r,e){var t=inspect.styles[e];if(t){return"["+inspect.colors[t][0]+"m"+r+"["+inspect.colors[t][1]+"m"}else{return r}}function stylizeNoColor(r,e){return r}function arrayToHash(r){var e={};r.forEach((function(r,t){e[r]=true}));return e}function formatValue(r,t,n){if(r.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==e.inspect&&!(t.constructor&&t.constructor.prototype===t)){var o=t.inspect(n,r);if(!isString(o)){o=formatValue(r,o,n)}return o}var i=formatPrimitive(r,t);if(i){return i}var a=Object.keys(t);var f=arrayToHash(a);if(r.showHidden){a=Object.getOwnPropertyNames(t)}if(isError(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(t)}if(a.length===0){if(isFunction(t)){var u=t.name?": "+t.name:"";return r.stylize("[Function"+u+"]","special")}if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}if(isDate(t)){return r.stylize(Date.prototype.toString.call(t),"date")}if(isError(t)){return formatError(t)}}var s="",c=false,y=["{","}"];if(isArray(t)){c=true;y=["[","]"]}if(isFunction(t)){var p=t.name?": "+t.name:"";s=" [Function"+p+"]"}if(isRegExp(t)){s=" "+RegExp.prototype.toString.call(t)}if(isDate(t)){s=" "+Date.prototype.toUTCString.call(t)}if(isError(t)){s=" "+formatError(t)}if(a.length===0&&(!c||t.length==0)){return y[0]+s+y[1]}if(n<0){if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return r.stylize("[Object]","special")}}r.seen.push(t);var l;if(c){l=formatArray(r,t,n,f,a)}else{l=a.map((function(e){return formatProperty(r,t,n,f,e,c)}))}r.seen.pop();return reduceToSingleString(l,s,y)}function formatPrimitive(r,e){if(isUndefined(e))return r.stylize("undefined","undefined");if(isString(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return r.stylize(t,"string")}if(isNumber(e))return r.stylize(""+e,"number");if(isBoolean(e))return r.stylize(""+e,"boolean");if(isNull(e))return r.stylize("null","null")}function formatError(r){return"["+Error.prototype.toString.call(r)+"]"}function formatArray(r,e,t,n,o){var i=[];for(var a=0,f=e.length;a<f;++a){if(hasOwnProperty(e,String(a))){i.push(formatProperty(r,e,t,n,String(a),true))}else{i.push("")}}o.forEach((function(o){if(!o.match(/^\d+$/)){i.push(formatProperty(r,e,t,n,o,true))}}));return i}function formatProperty(r,e,t,n,o,i){var a,f,u;u=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]};if(u.get){if(u.set){f=r.stylize("[Getter/Setter]","special")}else{f=r.stylize("[Getter]","special")}}else{if(u.set){f=r.stylize("[Setter]","special")}}if(!hasOwnProperty(n,o)){a="["+o+"]"}if(!f){if(r.seen.indexOf(u.value)<0){if(isNull(t)){f=formatValue(r,u.value,null)}else{f=formatValue(r,u.value,t-1)}if(f.indexOf("\n")>-1){if(i){f=f.split("\n").map((function(r){return" "+r})).join("\n").substr(2)}else{f="\n"+f.split("\n").map((function(r){return" "+r})).join("\n")}}}else{f=r.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return f}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=r.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=r.stylize(a,"string")}}return a+": "+f}function reduceToSingleString(r,e,t){var n=0;var o=r.reduce((function(r,e){n++;if(e.indexOf("\n")>=0)n++;return r+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return t[0]+(e===""?"":e+"\n ")+" "+r.join(",\n ")+" "+t[1]}return t[0]+e+" "+r.join(", ")+" "+t[1]}e.types=t(584);function isArray(r){return Array.isArray(r)}e.isArray=isArray;function isBoolean(r){return typeof r==="boolean"}e.isBoolean=isBoolean;function isNull(r){return r===null}e.isNull=isNull;function isNullOrUndefined(r){return r==null}e.isNullOrUndefined=isNullOrUndefined;function isNumber(r){return typeof r==="number"}e.isNumber=isNumber;function isString(r){return typeof r==="string"}e.isString=isString;function isSymbol(r){return typeof r==="symbol"}e.isSymbol=isSymbol;function isUndefined(r){return r===void 0}e.isUndefined=isUndefined;function isRegExp(r){return isObject(r)&&objectToString(r)==="[object RegExp]"}e.isRegExp=isRegExp;e.types.isRegExp=isRegExp;function isObject(r){return typeof r==="object"&&r!==null}e.isObject=isObject;function isDate(r){return isObject(r)&&objectToString(r)==="[object Date]"}e.isDate=isDate;e.types.isDate=isDate;function isError(r){return isObject(r)&&(objectToString(r)==="[object Error]"||r instanceof Error)}e.isError=isError;e.types.isNativeError=isError;function isFunction(r){return typeof r==="function"}e.isFunction=isFunction;function isPrimitive(r){return r===null||typeof r==="boolean"||typeof r==="number"||typeof r==="string"||typeof r==="symbol"||typeof r==="undefined"}e.isPrimitive=isPrimitive;e.isBuffer=t(369);function objectToString(r){return Object.prototype.toString.call(r)}function pad(r){return r<10?"0"+r.toString(10):r.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var r=new Date;var e=[pad(r.getHours()),pad(r.getMinutes()),pad(r.getSeconds())].join(":");return[r.getDate(),u[r.getMonth()],e].join(" ")}e.log=function(){console.log("%s - %s",timestamp(),e.format.apply(e,arguments))};e.inherits=t(782);e._extend=function(r,e){if(!e||!isObject(e))return r;var t=Object.keys(e);var n=t.length;while(n--){r[t[n]]=e[t[n]]}return r};function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var s=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;e.promisify=function promisify(r){if(typeof r!=="function")throw new TypeError('The "original" argument must be of type Function');if(s&&r[s]){var e=r[s];if(typeof e!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(e,s,{value:e,enumerable:false,writable:false,configurable:true});return e}function e(){var e,t;var n=new Promise((function(r,n){e=r;t=n}));var o=[];for(var i=0;i<arguments.length;i++){o.push(arguments[i])}o.push((function(r,n){if(r){t(r)}else{e(n)}}));try{r.apply(this,o)}catch(r){t(r)}return n}Object.setPrototypeOf(e,Object.getPrototypeOf(r));if(s)Object.defineProperty(e,s,{value:e,enumerable:false,writable:false,configurable:true});return Object.defineProperties(e,n(r))};e.promisify.custom=s;function callbackifyOnRejected(r,e){if(!r){var t=new Error("Promise was rejected with a falsy value");t.reason=r;r=t}return e(r)}function callbackify(r){if(typeof r!=="function"){throw new TypeError('The "original" argument must be of type Function')}function callbackified(){var e=[];for(var t=0;t<arguments.length;t++){e.push(arguments[t])}var n=e.pop();if(typeof n!=="function"){throw new TypeError("The last argument must be of type Function")}var o=this;var cb=function(){return n.apply(o,arguments)};r.apply(this,e).then((function(r){process.nextTick(cb.bind(null,null,r))}),(function(r){process.nextTick(callbackifyOnRejected.bind(null,r,cb))}))}Object.setPrototypeOf(callbackified,Object.getPrototypeOf(r));Object.defineProperties(callbackified,n(r));return callbackified}e.callbackify=callbackify},490:function(r,e,t){"use strict";var n=t(144);var o=t(349);var i=t(256);var a=i("Object.prototype.toString");var f=t(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var c=i("String.prototype.slice");var y={};var p=t(24);var l=Object.getPrototypeOf;if(u&&p&&l){n(s,(function(r){if(typeof global[r]==="function"){var e=new global[r];if(!(Symbol.toStringTag in e)){throw new EvalError("this engine has support for Symbol.toStringTag, but "+r+" does not have the property! Please report this.")}var t=l(e);var n=p(t,Symbol.toStringTag);if(!n){var o=l(t);n=p(o,Symbol.toStringTag)}y[r]=n.get}}))}var g=function tryAllTypedArrays(r){var e=false;n(y,(function(t,n){if(!e){try{var o=t.call(r);if(o===n){e=o}}catch(r){}}}));return e};var v=t(994);r.exports=function whichTypedArray(r){if(!v(r)){return false}if(!u){return c(a(r),8,-1)}return g(r)}},349:function(r,e,t){"use strict";var n=t(992);r.exports=function availableTypedArrays(){return n(["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],(function(r){return typeof global[r]==="function"}))}},24:function(r,e,t){"use strict";var n=t(192);var o=n("%Object.getOwnPropertyDescriptor%",true);if(o){try{o([],"length")}catch(r){o=null}}r.exports=o}};var e={};function __nccwpck_require__(t){var n=e[t];if(n!==undefined){return n.exports}var o=e[t]={exports:{}};var i=true;try{r[t](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete e[t]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(177);module.exports=t})();
\ No newline at end of file
......@@ -77,6 +77,7 @@ export async function applyNextFixture(
const fixture = new NextFixtureImpl(testInfo, nextOptions, nextWorker, page)
await fixture.setup()
// eslint-disable-next-line react-hooks/rules-of-hooks -- not React.use()
await use(fixture)
fixture.teardown()
......
......@@ -54,6 +54,7 @@ export async function applyNextWorkerFixture(
): Promise<void> {
const fixture = new NextWorkerFixtureImpl()
await fixture.setup()
// eslint-disable-next-line react-hooks/rules-of-hooks -- not React.use()
await use(fixture)
fixture.teardown()
}
......@@ -135,7 +135,25 @@ async function lint(
const mod = await Promise.resolve(require(deps.resolved.get('eslint')!))
const { ESLint } = mod
const useFlatConfig =
// If V9 config was found, use flat config, or else use legacy.
eslintrcFile?.startsWith('eslint.config.')
let ESLint
// loadESLint is >= 8.57.0
// PR https://github.com/eslint/eslint/pull/18098
// Release https://github.com/eslint/eslint/releases/tag/v8.57.0
if ('loadESLint' in mod) {
// By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.
// https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613
ESLint = await mod.loadESLint({
useFlatConfig,
})
} else {
// eslint < 8.57.0, use legacy ESLint
ESLint = mod.ESLint
}
let eslintVersion = ESLint?.version ?? mod.CLIEngine?.version
if (!eslintVersion || semver.lt(eslintVersion, '7.0.0')) {
......@@ -155,6 +173,23 @@ async function lint(
...eslintOptions,
}
if (semver.gte(eslintVersion, '9.0.0') && useFlatConfig) {
for (const option of [
'useEslintrc',
'extensions',
'ignorePath',
'reportUnusedDisableDirectives',
'resolvePluginsRelativeTo',
'rulePaths',
'inlineConfig',
'maxWarnings',
]) {
if (option in options) {
delete options[option]
}
}
}
let eslint = new ESLint(options)
let nextEslintPluginIsEnabled = false
......@@ -163,10 +198,20 @@ async function lint(
for (const configFile of [eslintrcFile, pkgJsonPath]) {
if (!configFile) continue
const completeConfig: Config =
const completeConfig: Config | undefined =
await eslint.calculateConfigForFile(configFile)
if (!completeConfig) continue
const plugins = completeConfig.plugins
const hasNextPlugin =
// in ESLint < 9, `plugins` value is string[]
Array.isArray(plugins)
? plugins.includes('@next/next')
: // in ESLint >= 9, `plugins` value is Record<string, unknown>
'@next/next' in plugins
if (completeConfig.plugins?.includes('@next/next')) {
if (hasNextPlugin) {
nextEslintPluginIsEnabled = true
for (const [name, [severity]] of Object.entries(completeConfig.rules)) {
if (!name.startsWith('@next/next/')) {
......@@ -309,6 +354,17 @@ export async function runLintCheck(
const eslintrcFile =
(await findUp(
[
// eslint v9
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs',
// TODO(jiwon): Support when it's stable.
// TS extensions are experimental and requires to install another package `jiti`.
// https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files
// 'eslint.config.ts',
// 'eslint.config.mts',
// 'eslint.config.cts',
// eslint <= v8
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
......
......@@ -603,6 +603,7 @@ function inheritFromMetadata(
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const commonOgKeys = ['title', 'description', 'images'] as const
function postProcessMetadata(
metadata: ResolvedMetadata,
......
......@@ -5,6 +5,7 @@ import path from 'path'
import { PHASE_DEVELOPMENT_SERVER } from '../../shared/lib/constants'
import type { TraceEvent } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const localEndpoint = {
serviceName: 'nextjs',
ipv4: '127.0.0.1',
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import { nextTestSetup } from 'e2e-utils'
import { readFileSync } from 'fs'
import { nextLint } from 'next-test-utils'
describe('next-lint-eslint-formatter-compact', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: { eslint: '^8', 'eslint-config-next': 'canary' },
})
it('should format flag "compact" creates a file respecting the chosen format', async () => {
const filePath = `${next.testDir}/output/output.txt`
const { stdout, stderr } = await nextLint(
next.testDir,
['--format', 'compact', '--output-file', filePath],
{
stdout: true,
stderr: true,
}
)
const cliOutput = stdout + stderr
const fileOutput = readFileSync(filePath, 'utf8')
expect(cliOutput).toContain(`The output file has been created: ${filePath}`)
expect(fileOutput).toContain(`${next.testDir}/pages/bar.js`)
expect(fileOutput).toContain(
'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.'
)
expect(fileOutput).toContain(
'Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element'
)
expect(fileOutput).toContain(`${next.testDir}/pages/index.js`)
expect(fileOutput).toContain(
'Synchronous scripts should not be used. See: https://nextjs.org/docs/messages/no-sync-scripts'
)
})
it('should show error message when the file path is a directory', async () => {
const filePath = next.testDir
const { stdout, stderr } = await nextLint(
next.testDir,
['--format', 'compact', '--output-file', filePath],
{
stdout: true,
stderr: true,
}
)
const cliOutput = stdout + stderr
console.log({ cliOutput })
expect(cliOutput).toContain(
`Cannot write to output file path, it is a directory: ${filePath}`
)
})
})
export default class Bar {
render() {
return (
<div>
<h1>Hello title</h1>
<img src="img" />
</div>
)
}
}
export default class Home {
render() {
return (
<div>
<h1>Hello title</h1>
<script src="test"></script>
</div>
)
}
}
export default class Test {
render() {
return (
<div>
<h1>Hello title</h1>
/* Badly formatted comment */
</div>
)
}
}
......@@ -7,7 +7,7 @@ async function getData() {
}
}
export default function gspLayout(props) {
export default function GspLayout(props) {
const data = use(getData())
return (
......
......@@ -9,7 +9,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
......
......@@ -7,7 +7,7 @@ async function getData() {
}
}
export default function gspLayout(props) {
export default function GspLayout(props) {
const data = use(getData())
return (
......
......@@ -7,7 +7,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
......
......@@ -8,7 +8,7 @@ async function getData() {
}
}
export default function gspLayout(props) {
export default function GspLayout(props) {
const data = use(getData())
return (
<>
......
......@@ -8,7 +8,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
<>
......
......@@ -8,7 +8,7 @@ async function getData() {
}
}
export default function gsspLayout(props) {
export default function GsspLayout(props) {
const data = use(getData())
return (
......
......@@ -6,7 +6,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
......
......@@ -9,7 +9,7 @@ async function getData() {
}
}
export default function gsspLayout(props) {
export default function GsspLayout(props) {
// TODO-APP: refactor this test page to `async function` instead.
if (!i) {
i = getData()
......
......@@ -8,7 +8,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
// TODO-APP: refactor this test page to `async function` instead.
if (!i) {
i = getData()
......
......@@ -6,7 +6,7 @@ async function getData() {
}
}
export default function gspLayout(props) {
export default function GspLayout(props) {
const data = use(getData())
return (
......
......@@ -8,7 +8,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
<>
......
......@@ -7,7 +7,7 @@ async function getData() {
}
}
export default function gspLayout(props) {
export default function GspLayout(props) {
const data = use(getData())
return (
......
......@@ -9,7 +9,7 @@ async function getData() {
}
}
export default function nestedPage(props) {
export default function NestedPage(props) {
const data = use(getData())
return (
<>
......
import { useRouter } from 'next/router'
const $comment = ({ gipQuery }) => {
const Comment = ({ gipQuery }) => {
const router = useRouter()
const { query } = router
......@@ -14,8 +14,8 @@ const $comment = ({ gipQuery }) => {
)
}
$comment.getInitialProps = async ({ query }) => {
Comment.getInitialProps = async ({ query }) => {
return { gipQuery: query }
}
export default $comment
export default Comment
......@@ -556,54 +556,6 @@ describe('Next Lint', () => {
}
})
test('format flag "compact" creates a file respecting the chosen format', async () => {
const filePath = `${__dirname}/output/output.txt`
const { stdout, stderr } = await nextLint(
dirFileLinting,
['--format', 'compact', '--output-file', filePath],
{
stdout: true,
stderr: true,
}
)
const cliOutput = stdout + stderr
const fileOutput = fs.readFileSync(filePath, 'utf8')
expect(cliOutput).toContain(`The output file has been created: ${filePath}`)
expect(fileOutput).toContain('file-linting/pages/bar.js')
expect(fileOutput).toContain(
'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.'
)
expect(fileOutput).toContain(
'Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element'
)
expect(fileOutput).toContain('file-linting/pages/index.js')
expect(fileOutput).toContain(
'Synchronous scripts should not be used. See: https://nextjs.org/docs/messages/no-sync-scripts'
)
})
test('show error message when the file path is a directory', async () => {
const filePath = `${__dirname}`
const { stdout, stderr } = await nextLint(
dirFileLinting,
['--format', 'compact', '--output-file', filePath],
{
stdout: true,
stderr: true,
}
)
const cliOutput = stdout + stderr
expect(cliOutput).toContain(
`Cannot write to output file path, it is a directory: ${filePath}`
)
})
test('lint files with cjs and mjs file extension', async () => {
const { stdout, stderr } = await nextLint(mjsCjsLinting, [], {
stdout: true,
......
import { useRouter } from 'next/router'
const $comment = ({ gipQuery }) => {
const Comment = ({ gipQuery }) => {
const router = useRouter()
const { query } = router
......@@ -14,8 +14,8 @@ const $comment = ({ gipQuery }) => {
)
}
$comment.getInitialProps = async ({ query }) => {
Comment.getInitialProps = async ({ query }) => {
return { gipQuery: query }
}
export default $comment
export default Comment
......@@ -10,7 +10,7 @@ import { promisify } from 'util'
import http from 'http'
import path from 'path'
import cheerio from 'cheerio'
import type cheerio from 'cheerio'
import spawn from 'cross-spawn'
import { writeFile } from 'fs-extra'
import getPort from 'get-port'
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Next Build production mode first time setup 1`] = `
exports[`Next Build production mode first time setup - ESLint v8 1`] = `
{
"env": {
"browser": true,
......@@ -200,7 +200,540 @@ exports[`Next Build production mode first time setup 1`] = `
}
`;
exports[`Next Build production mode first time setup with TypeScript 1`] = `
exports[`Next Build production mode first time setup - ESLint v9 1`] = `
{
"env": {
"browser": true,
"node": true,
},
"globals": {},
"ignorePatterns": [],
"parserOptions": {
"allowImportExportEverywhere": true,
"babelOptions": {
"caller": {
"supportsTopLevelAwait": true,
},
"presets": [
"next/babel",
],
},
"ecmaFeatures": {
"jsx": true,
},
"requireConfigFile": false,
"sourceType": "module",
},
"plugins": [
"react-hooks",
"jsx-a11y",
"react",
"import",
"@next/next",
],
"rules": {
"@next/next/google-font-display": [
"warn",
],
"@next/next/google-font-preconnect": [
"warn",
],
"@next/next/inline-script-id": [
"error",
],
"@next/next/next-script-for-ga": [
"warn",
],
"@next/next/no-assign-module-variable": [
"error",
],
"@next/next/no-async-client-component": [
"warn",
],
"@next/next/no-before-interactive-script-outside-document": [
"warn",
],
"@next/next/no-css-tags": [
"warn",
],
"@next/next/no-document-import-in-page": [
"error",
],
"@next/next/no-duplicate-head": [
"error",
],
"@next/next/no-head-element": [
"warn",
],
"@next/next/no-head-import-in-document": [
"error",
],
"@next/next/no-html-link-for-pages": [
"error",
],
"@next/next/no-img-element": [
"warn",
],
"@next/next/no-page-custom-font": [
"warn",
],
"@next/next/no-script-component-in-head": [
"error",
],
"@next/next/no-styled-jsx-in-document": [
"warn",
],
"@next/next/no-sync-scripts": [
"error",
],
"@next/next/no-title-in-document-head": [
"warn",
],
"@next/next/no-typos": [
"warn",
],
"@next/next/no-unwanted-polyfillio": [
"warn",
],
"import/no-anonymous-default-export": [
"warn",
],
"jsx-a11y/alt-text": [
"warn",
{
"elements": [
"img",
],
"img": [
"Image",
],
},
],
"jsx-a11y/aria-props": [
"warn",
],
"jsx-a11y/aria-proptypes": [
"warn",
],
"jsx-a11y/aria-unsupported-elements": [
"warn",
],
"jsx-a11y/role-has-required-aria-props": [
"warn",
],
"jsx-a11y/role-supports-aria-props": [
"warn",
],
"react-hooks/exhaustive-deps": [
"warn",
],
"react-hooks/rules-of-hooks": [
"error",
],
"react/display-name": [
2,
],
"react/jsx-key": [
2,
],
"react/jsx-no-comment-textnodes": [
2,
],
"react/jsx-no-duplicate-props": [
2,
],
"react/jsx-no-target-blank": [
"off",
],
"react/jsx-no-undef": [
2,
],
"react/jsx-uses-react": [
2,
],
"react/jsx-uses-vars": [
2,
],
"react/no-children-prop": [
2,
],
"react/no-danger-with-children": [
2,
],
"react/no-deprecated": [
2,
],
"react/no-direct-mutation-state": [
2,
],
"react/no-find-dom-node": [
2,
],
"react/no-is-mounted": [
2,
],
"react/no-render-return-value": [
2,
],
"react/no-string-refs": [
2,
],
"react/no-unescaped-entities": [
2,
],
"react/no-unknown-property": [
"off",
],
"react/no-unsafe": [
0,
],
"react/prop-types": [
"off",
],
"react/react-in-jsx-scope": [
"off",
],
"react/require-render-return": [
2,
],
},
}
`;
exports[`Next Build production mode first time setup with TypeScript - ESLint v8 1`] = `
{
"env": {
"browser": true,
"node": true,
},
"globals": {},
"ignorePatterns": [],
"parserOptions": {
"allowImportExportEverywhere": true,
"babelOptions": {
"caller": {
"supportsTopLevelAwait": true,
},
"presets": [
"next/babel",
],
},
"ecmaFeatures": {
"jsx": true,
},
"requireConfigFile": false,
"sourceType": "module",
},
"plugins": [
"react-hooks",
"jsx-a11y",
"react",
"import",
"@next/next",
"@typescript-eslint",
],
"rules": {
"@next/next/google-font-display": [
"warn",
],
"@next/next/google-font-preconnect": [
"warn",
],
"@next/next/inline-script-id": [
"error",
],
"@next/next/next-script-for-ga": [
"warn",
],
"@next/next/no-assign-module-variable": [
"error",
],
"@next/next/no-async-client-component": [
"warn",
],
"@next/next/no-before-interactive-script-outside-document": [
"warn",
],
"@next/next/no-css-tags": [
"warn",
],
"@next/next/no-document-import-in-page": [
"error",
],
"@next/next/no-duplicate-head": [
"error",
],
"@next/next/no-head-element": [
"warn",
],
"@next/next/no-head-import-in-document": [
"error",
],
"@next/next/no-html-link-for-pages": [
"error",
],
"@next/next/no-img-element": [
"warn",
],
"@next/next/no-page-custom-font": [
"warn",
],
"@next/next/no-script-component-in-head": [
"error",
],
"@next/next/no-styled-jsx-in-document": [
"warn",
],
"@next/next/no-sync-scripts": [
"error",
],
"@next/next/no-title-in-document-head": [
"warn",
],
"@next/next/no-typos": [
"warn",
],
"@next/next/no-unwanted-polyfillio": [
"warn",
],
"@typescript-eslint/ban-ts-comment": [
"error",
],
"@typescript-eslint/no-array-constructor": [
"error",
],
"@typescript-eslint/no-duplicate-enum-values": [
"error",
],
"@typescript-eslint/no-empty-object-type": [
"error",
],
"@typescript-eslint/no-explicit-any": [
"error",
],
"@typescript-eslint/no-extra-non-null-assertion": [
"error",
],
"@typescript-eslint/no-misused-new": [
"error",
],
"@typescript-eslint/no-namespace": [
"error",
],
"@typescript-eslint/no-non-null-asserted-optional-chain": [
"error",
],
"@typescript-eslint/no-require-imports": [
"error",
],
"@typescript-eslint/no-this-alias": [
"error",
],
"@typescript-eslint/no-unnecessary-type-constraint": [
"error",
],
"@typescript-eslint/no-unsafe-declaration-merging": [
"error",
],
"@typescript-eslint/no-unsafe-function-type": [
"error",
],
"@typescript-eslint/no-unused-expressions": [
"error",
],
"@typescript-eslint/no-unused-vars": [
"error",
],
"@typescript-eslint/no-wrapper-object-types": [
"error",
],
"@typescript-eslint/prefer-as-const": [
"error",
],
"@typescript-eslint/prefer-namespace-keyword": [
"error",
],
"@typescript-eslint/triple-slash-reference": [
"error",
],
"constructor-super": [
"off",
],
"getter-return": [
"off",
],
"import/no-anonymous-default-export": [
"warn",
],
"jsx-a11y/alt-text": [
"warn",
{
"elements": [
"img",
],
"img": [
"Image",
],
},
],
"jsx-a11y/aria-props": [
"warn",
],
"jsx-a11y/aria-proptypes": [
"warn",
],
"jsx-a11y/aria-unsupported-elements": [
"warn",
],
"jsx-a11y/role-has-required-aria-props": [
"warn",
],
"jsx-a11y/role-supports-aria-props": [
"warn",
],
"no-array-constructor": [
"off",
],
"no-const-assign": [
"off",
],
"no-dupe-args": [
"off",
],
"no-dupe-class-members": [
"off",
],
"no-dupe-keys": [
"off",
],
"no-func-assign": [
"off",
],
"no-import-assign": [
"off",
],
"no-new-native-nonconstructor": [
"off",
],
"no-new-symbol": [
"off",
],
"no-obj-calls": [
"off",
],
"no-redeclare": [
"off",
],
"no-setter-return": [
"off",
],
"no-this-before-super": [
"off",
],
"no-undef": [
"off",
],
"no-unreachable": [
"off",
],
"no-unsafe-negation": [
"off",
],
"no-unused-expressions": [
"off",
],
"no-unused-vars": [
"off",
],
"no-var": [
"error",
],
"prefer-const": [
"error",
],
"prefer-rest-params": [
"error",
],
"prefer-spread": [
"error",
],
"react-hooks/exhaustive-deps": [
"warn",
],
"react-hooks/rules-of-hooks": [
"error",
],
"react/display-name": [
2,
],
"react/jsx-key": [
2,
],
"react/jsx-no-comment-textnodes": [
2,
],
"react/jsx-no-duplicate-props": [
2,
],
"react/jsx-no-target-blank": [
"off",
],
"react/jsx-no-undef": [
2,
],
"react/jsx-uses-react": [
2,
],
"react/jsx-uses-vars": [
2,
],
"react/no-children-prop": [
2,
],
"react/no-danger-with-children": [
2,
],
"react/no-deprecated": [
2,
],
"react/no-direct-mutation-state": [
2,
],
"react/no-find-dom-node": [
2,
],
"react/no-is-mounted": [
2,
],
"react/no-render-return-value": [
2,
],
"react/no-string-refs": [
2,
],
"react/no-unescaped-entities": [
2,
],
"react/no-unknown-property": [
"off",
],
"react/no-unsafe": [
0,
],
"react/prop-types": [
"off",
],
"react/react-in-jsx-scope": [
"off",
],
"react/require-render-return": [
2,
],
},
}
`;
exports[`Next Build production mode first time setup with TypeScript - ESLint v9 1`] = `
{
"env": {
"browser": true,
......
......@@ -12,12 +12,13 @@ describe('Next Build', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
test('first time setup', async () => {
test('first time setup - ESLint v8', async () => {
const next = await createNext({
files: new FileRef(dirFirstTimeSetup),
dependencies: {
// create-next-install will replace this with a version built from the local source
'eslint-config-next': 'canary',
eslint: '^8',
},
skipStart: true,
})
......@@ -92,12 +93,96 @@ describe('Next Build', () => {
}
})
test('first time setup with TypeScript', async () => {
test('first time setup - ESLint v9', async () => {
const next = await createNext({
files: new FileRef(dirFirstTimeSetup),
dependencies: {
// create-next-install will replace this with a version built from the local source
'eslint-config-next': 'canary',
eslint: '^9',
},
skipStart: true,
})
try {
const eslintrcJsonPath = join(next.testDir, '.eslintrc.json')
await fs.writeFile(eslintrcJsonPath, '')
const nextBuildCommand = await next.build()
const buildOutput = nextBuildCommand.cliOutput
expect(buildOutput).toContain(
'No ESLint configuration detected. Run next lint to begin setup'
)
// TODO: Should we exit non-zero here if the config was created? Should we maybe even directly start linting?
expect(() => {
execSync(`pnpm next lint --strict`, {
cwd: next.testDir,
encoding: 'utf8',
stdio: 'inherit',
})
}).toThrow('Command failed: pnpm next lint --strict')
const eslintConfigAfterSetupJSON = execSync(
// TODO(jiwon): remove `ESLINT_USE_FLAT_CONFIG=false` when we create the config for ESLint 9.
// https://eslint.org/docs/latest/use/migrate-to-9.0.0#-new-default-config-format-eslintconfigjs
`ESLINT_USE_FLAT_CONFIG=false pnpm eslint --print-config pages/index.js`,
{
cwd: next.testDir,
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'inherit'],
}
)
const { parser, settings, ...eslintConfigAfterSetup } = JSON.parse(
eslintConfigAfterSetupJSON
)
expect(eslintConfigAfterSetup).toMatchSnapshot()
expect({
parser,
settings,
}).toEqual({
// parser: require.resolve('eslint-config-next')
parser: expect.stringContaining('eslint-config-next'),
settings: {
'import/parsers': expect.any(Object),
'import/resolver': expect.any(Object),
react: {
version: 'detect',
},
},
})
expect(Object.entries(settings['import/parsers'])).toEqual([
[
// require.resolve('@typescript-eslint/parser')
expect.stringContaining('@typescript-eslint/parser'),
['.ts', '.mts', '.cts', '.tsx', '.d.ts'],
],
])
expect(Object.entries(settings['import/resolver'])).toEqual([
[
// require.resolve('eslint-import-resolver-node')
expect.stringContaining('eslint-import-resolver-node'),
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
],
[
// require.resolve('eslint-import-resolver-typescript')
expect.stringContaining('eslint-import-resolver-typescript'),
{ alwaysTryTypes: true },
],
])
} finally {
await next.destroy()
}
})
test('first time setup with TypeScript - ESLint v8', async () => {
const next = await createNext({
files: new FileRef(dirFirstTimeSetupTS),
dependencies: {
// create-next-install will replace this with a version built from the local source
'eslint-config-next': 'canary',
eslint: '^8',
},
skipStart: true,
})
......@@ -171,6 +256,89 @@ describe('Next Build', () => {
await next.destroy()
}
})
test('first time setup with TypeScript - ESLint v9', async () => {
const next = await createNext({
files: new FileRef(dirFirstTimeSetupTS),
dependencies: {
// create-next-install will replace this with a version built from the local source
'eslint-config-next': 'canary',
eslint: '^9',
},
skipStart: true,
})
try {
const eslintrcJsonPath = join(next.testDir, '.eslintrc.json')
await fs.writeFile(eslintrcJsonPath, '')
const nextBuildCommand = await next.build()
const buildOutput = nextBuildCommand.cliOutput
expect(buildOutput).toContain(
'No ESLint configuration detected. Run next lint to begin setup'
)
// TODO: Should we exit non-zero here if the config was created? Should we maybe even directly start linting?
expect(() => {
execSync(`pnpm next lint --strict`, {
cwd: next.testDir,
encoding: 'utf8',
stdio: 'inherit',
})
}).toThrow('Command failed: pnpm next lint --strict')
const eslintConfigAfterSetupJSON = execSync(
// TODO(jiwon): remove `ESLINT_USE_FLAT_CONFIG=false` when we create the config for ESLint 9.
// https://eslint.org/docs/latest/use/migrate-to-9.0.0#-new-default-config-format-eslintconfigjs
`ESLINT_USE_FLAT_CONFIG=false pnpm eslint --print-config pages/index.tsx`,
{
cwd: next.testDir,
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'inherit'],
}
)
const { parser, settings, ...eslintConfigAfterSetup } = JSON.parse(
eslintConfigAfterSetupJSON
)
expect(eslintConfigAfterSetup).toMatchSnapshot()
expect({
parser,
settings,
}).toEqual({
// parser: require.resolve('@typescript-eslint/parser')
parser: expect.stringContaining('@typescript-eslint/parser'),
settings: {
'import/parsers': expect.any(Object),
'import/resolver': expect.any(Object),
react: {
version: 'detect',
},
},
})
expect(Object.entries(settings['import/parsers'])).toEqual([
[
// require.resolve('@typescript-eslint/parser')
expect.stringContaining('@typescript-eslint/parser'),
['.ts', '.mts', '.cts', '.tsx', '.d.ts'],
],
])
expect(Object.entries(settings['import/resolver'])).toEqual([
[
// require.resolve('eslint-import-resolver-node')
expect.stringContaining('eslint-import-resolver-node'),
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
],
[
// require.resolve('eslint-import-resolver-typescript')
expect.stringContaining('eslint-import-resolver-typescript'),
{ alwaysTryTypes: true },
],
])
} finally {
await next.destroy()
}
})
}
)
})
import rule from '@next/eslint-plugin-next/dist/rules/google-font-display'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('google-font-display', rule, {
const NextESLintRule = rules['google-font-display']
const tests = {
valid: [
`import Head from "next/head";
......@@ -169,4 +161,30 @@ ruleTester.run('google-font-display', rule, {
],
},
],
}
describe('google-font-display', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/google-font-preconnect'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('google-font-preconnect', rule, {
const NextESLintRule = rules['google-font-preconnect']
const tests = {
valid: [
`export const Test = () => (
<div>
......@@ -64,4 +56,30 @@ ruleTester.run('google-font-preconnect', rule, {
],
},
],
}
describe('google-font-preconnect', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/inline-script-id'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['inline-script-id']
const errorMessage =
'`next/script` components with inline content must specify an `id` attribute. See: https://nextjs.org/docs/messages/inline-script-id'
const ruleTester = new RuleTester()
ruleTester.run('inline-script-id', rule, {
const tests = {
valid: [
{
code: `import Script from 'next/script';
......@@ -184,4 +176,30 @@ ruleTester.run('inline-script-id', rule, {
],
},
],
}
describe('inline-script-id', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/next-script-for-ga'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['next-script-for-ga']
const ERROR_MSG =
'Prefer `next/script` component when using the inline script for Google Analytics. See: https://nextjs.org/docs/messages/next-script-for-ga'
const ruleTester = new RuleTester()
ruleTester.run('sync-scripts', rule, {
const tests = {
valid: [
`import Script from 'next/script'
......@@ -238,4 +229,30 @@ ruleTester.run('sync-scripts', rule, {
],
},
],
}
describe('next-script-for-ga', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-assign-module-variable'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('no-assign-module-variable', rule, {
const NextESLintRule = rules['no-assign-module-variable']
const tests = {
valid: [
`
let myModule = {};
......@@ -39,4 +31,30 @@ ruleTester.run('no-assign-module-variable', rule, {
],
},
],
}
describe('no-assign-module-variable', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-async-client-component'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-async-client-component']
const message =
'Prevent client components from being async functions. See: https://nextjs.org/docs/messages/no-async-client-component'
ruleTester.run('no-async-client-component single line', rule, {
const tests = {
valid: [
`
// single line
export default async function MyComponent() {
return <></>
}
`,
`
// single line capitalization
"use client"
export default async function myFunction() {
return ''
}
`,
`
// multiple line
async function MyComponent() {
return <></>
}
export default MyComponent
`,
`
// multiple line capitalization
"use client"
async function myFunction() {
return ''
}
export default myFunction
`,
`
// arrow function
"use client"
const myFunction = () => {
return ''
}
export default myFunction
`,
],
invalid: [
{
code: `
// single line
"use client"
export default async function MyComponent() {
return <></>
}
`,
errors: [
{
message,
},
],
errors: [{ message }],
},
],
})
ruleTester.run('no-async-client-component single line capitalization', rule, {
valid: [
`
"use client"
export default async function myFunction() {
return ''
}
`,
],
invalid: [
{
code: `
// single line capitalization
"use client"
export default async function MyFunction() {
return ''
}
`,
errors: [
{
message,
},
],
errors: [{ message }],
},
],
})
ruleTester.run('no-async-client-component multiple line', rule, {
valid: [
`
async function MyComponent() {
return <></>
}
export default MyComponent
`,
],
invalid: [
{
code: `
// multiple line
"use client"
async function MyComponent() {
......@@ -90,30 +86,11 @@ ruleTester.run('no-async-client-component multiple line', rule, {
export default MyComponent
`,
errors: [
{
message,
},
],
errors: [{ message }],
},
],
})
ruleTester.run('no-async-client-component multiple line capitalization', rule, {
valid: [
`
"use client"
async function myFunction() {
return ''
}
export default myFunction
`,
],
invalid: [
{
code: `
// multiple line capitalization
"use client"
async function MyFunction() {
......@@ -122,30 +99,11 @@ ruleTester.run('no-async-client-component multiple line capitalization', rule, {
export default MyFunction
`,
errors: [
{
message,
},
],
errors: [{ message }],
},
],
})
ruleTester.run('no-async-client-component arrow function', rule, {
valid: [
`
"use client"
const myFunction = () => {
return ''
}
export default myFunction
`,
],
invalid: [
{
code: `
// arrow function
"use client"
const MyFunction = async () => {
......@@ -154,11 +112,33 @@ ruleTester.run('no-async-client-component arrow function', rule, {
export default MyFunction
`,
errors: [
{
message,
},
],
errors: [{ message }],
},
],
}
describe('no-async-client-component', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-before-interactive-script-outside-document'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-before-interactive-script-outside-document']
const message =
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document"
ruleTester.run('no-before-interactive-script-outside-document', rule, {
const tests = {
valid: [
{
code: `
......@@ -172,13 +167,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
filename:
'C:\\Users\\username\\projects\\project-name\\src\\app\\layout.tsx',
},
].map((obj, idx) => ({
...obj,
code: `// valid-${idx}
${obj.code}
`,
})),
],
invalid: [
{
code: `
......@@ -195,12 +184,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
);
}`,
filename: 'pages/index.js',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
},
],
errors: [{ message }],
},
{
code: `
......@@ -217,12 +201,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
);
}`,
filename: 'components/outside-known-dirs.js',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
},
],
errors: [{ message }],
},
{
code: `
......@@ -240,12 +219,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
);
}`,
filename: '/Users/user_name/projects/project-name/pages/layout.tsx',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
},
],
errors: [{ message }],
},
{
code: `
......@@ -264,12 +238,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
}`,
filename:
'C:\\Users\\username\\projects\\project-name\\pages\\layout.tsx',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
},
],
errors: [{ message }],
},
{
code: `
......@@ -287,12 +256,7 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
);
}`,
filename: '/Users/user_name/projects/project-name/src/pages/layout.tsx',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
},
],
errors: [{ message }],
},
{
code: `
......@@ -311,17 +275,33 @@ ruleTester.run('no-before-interactive-script-outside-document', rule, {
}`,
filename:
'C:\\Users\\username\\projects\\project-name\\src\\pages\\layout.tsx',
errors: [
{
message:
"`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-before-interactive-script-outside-document",
errors: [{ message }],
},
],
}
describe('no-before-interactive-script-outside-document', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
],
},
},
].map((obj, idx) => ({
...obj,
code: `// invalid-${idx}
${obj.code}
`,
})),
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-css-tags'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-css-tags']
ruleTester.run('no-css-tags', rule, {
const message =
'Do not include stylesheets manually. See: https://nextjs.org/docs/messages/no-css-tags'
const tests = {
valid: [
`import {Head} from 'next/document';
......@@ -80,8 +75,7 @@ ruleTester.run('no-css-tags', rule, {
}`,
errors: [
{
message:
'Do not include stylesheets manually. See: https://nextjs.org/docs/messages/no-css-tags',
message,
type: 'JSXOpeningElement',
},
],
......@@ -93,11 +87,36 @@ ruleTester.run('no-css-tags', rule, {
</div>`,
errors: [
{
message:
'Do not include stylesheets manually. See: https://nextjs.org/docs/messages/no-css-tags',
message,
type: 'JSXOpeningElement',
},
],
},
],
}
describe('no-css-tags', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import path from 'path'
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
import rule from '@next/eslint-plugin-next/dist/rules/no-document-import-in-page'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
const NextESLintRule = rules['no-document-import-in-page']
ruleTester.run('no-document-import-in-page', rule, {
const tests = {
valid: [
{
code: `import Document from "next/document"
......@@ -33,34 +23,6 @@ ruleTester.run('no-document-import-in-page', rule, {
{
code: `import Document from "next/document"
export default class MyDocument extends Document {
render() {
return (
<Html>
</Html>
);
}
}
`,
filename: `pages${path.sep}_document.js`,
},
{
code: `import NextDocument from "next/document"
export default class MyDocument extends NextDocument {
render() {
return (
<Html>
</Html>
);
}
}
`,
filename: `pages${path.posix.sep}_document.tsx`,
},
{
code: `import Document from "next/document"
export default class MyDocument extends Document {
render() {
return (
......@@ -144,19 +106,31 @@ ruleTester.run('no-document-import-in-page', rule, {
},
],
},
{
code: `import Document from "next/document"
],
}
export const Test = () => <p>Test</p>
`,
filename: `pages${path.sep}test.js`,
errors: [
{
message:
'`<Document />` from `next/document` should not be imported outside of `pages/_document.js`. See: https://nextjs.org/docs/messages/no-document-import-in-page',
type: 'ImportDeclaration',
describe('no-document-import-in-page', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
],
},
},
],
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-duplicate-head'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-duplicate-head']
ruleTester.run('no-duplicate-head', rule, {
const message =
'Do not include multiple instances of `<Head/>`. See: https://nextjs.org/docs/messages/no-duplicate-head'
const tests = {
valid: [
{
code: `import Document, { Html, Head, Main, NextScript } from 'next/document'
......@@ -82,13 +77,11 @@ ruleTester.run('no-duplicate-head', rule, {
filename: 'pages/_document.js',
errors: [
{
message:
'Do not include multiple instances of `<Head/>`. See: https://nextjs.org/docs/messages/no-duplicate-head',
message,
type: 'JSXElement',
},
{
message:
'Do not include multiple instances of `<Head/>`. See: https://nextjs.org/docs/messages/no-duplicate-head',
message,
type: 'JSXElement',
},
],
......@@ -130,11 +123,36 @@ ruleTester.run('no-duplicate-head', rule, {
filename: 'pages/_document.page.tsx',
errors: [
{
message:
'Do not include multiple instances of `<Head/>`. See: https://nextjs.org/docs/messages/no-duplicate-head',
message,
type: 'JSXElement',
},
],
},
],
}
describe('no-duplicate-head', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-head-element'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-head-element']
ruleTester.run('no-head-element', rule, {
const message =
'Do not use `<head>` element. Use `<Head />` from `next/head` instead. See: https://nextjs.org/docs/messages/no-head-element'
const tests = {
valid: [
{
code: `import Head from 'next/head';
......@@ -81,8 +76,7 @@ ruleTester.run('no-head-element', rule, {
filename: './pages/index.js',
errors: [
{
message:
'Do not use `<head>` element. Use `<Head />` from `next/head` instead. See: https://nextjs.org/docs/messages/no-head-element',
message,
type: 'JSXOpeningElement',
},
],
......@@ -107,11 +101,36 @@ ruleTester.run('no-head-element', rule, {
filename: 'pages/index.ts',
errors: [
{
message:
'Do not use `<head>` element. Use `<Head />` from `next/head` instead. See: https://nextjs.org/docs/messages/no-head-element',
message,
type: 'JSXOpeningElement',
},
],
},
],
}
describe('no-head-element', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-head-import-in-document'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('no-head-import-in-document', rule, {
const NextESLintRule = rules['no-head-import-in-document']
const tests = {
valid: [
{
code: `import Document, { Html, Head, Main, NextScript } from 'next/document'
......@@ -173,4 +165,30 @@ ruleTester.run('no-head-import-in-document', rule, {
],
},
],
}
describe('no-head-import-in-document', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
/* eslint-env jest */
import rule from '@next/eslint-plugin-next/dist/rules/no-html-link-for-pages'
import { Linter } from 'eslint'
import { Linter as ESLintLinterV8 } from 'eslint-v8'
import { Linter as ESLintLinterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
import assert from 'assert'
import path from 'path'
const withCustomPagesDirectory = path.join(__dirname, 'with-custom-pages-dir')
const withNestedPagesDirectory = path.join(__dirname, 'with-nested-pages-dir')
const withoutPagesLinter = new Linter({
cwd: path.join(__dirname, 'without-pages-dir'),
})
const withAppLinter = new Linter({
cwd: path.join(__dirname, 'with-app-dir'),
})
const withNestedPagesLinter = new Linter({
cwd: withNestedPagesDirectory,
})
const withCustomPagesLinter = new Linter({
cwd: withCustomPagesDirectory,
})
const NextESLintRule = rules['no-html-link-for-pages']
const withCustomPagesDir = path.join(__dirname, 'with-custom-pages-dir')
const withNestedPagesDir = path.join(__dirname, 'with-nested-pages-dir')
const withoutPagesDir = path.join(__dirname, 'without-pages-dir')
const withAppDir = path.join(__dirname, 'with-app-dir')
const linters = {
v8: {
withoutPages: new ESLintLinterV8({
cwd: withoutPagesDir,
}),
withApp: new ESLintLinterV8({
cwd: withAppDir,
}),
withNestedPages: new ESLintLinterV8({
cwd: withNestedPagesDir,
}),
withCustomPages: new ESLintLinterV8({
cwd: withCustomPagesDir,
}),
},
v9: {
withoutPages: new ESLintLinterV9({
cwd: withoutPagesDir,
configType: 'eslintrc',
}),
withApp: new ESLintLinterV9({
cwd: withAppDir,
configType: 'eslintrc',
}),
withNestedPages: new ESLintLinterV9({
cwd: withNestedPagesDir,
configType: 'eslintrc',
}),
withCustomPages: new ESLintLinterV9({
cwd: withCustomPagesDir,
configType: 'eslintrc',
}),
},
}
const linterConfig: any = {
rules: {
......@@ -38,7 +65,7 @@ const linterConfigWithCustomDirectory: any = {
rules: {
'no-html-link-for-pages': [
2,
path.join(withCustomPagesDirectory, 'custom-pages'),
path.join(withCustomPagesDir, 'custom-pages'),
],
},
}
......@@ -48,8 +75,8 @@ const linterConfigWithMultipleDirectories = {
'no-html-link-for-pages': [
2,
[
path.join(withCustomPagesDirectory, 'custom-pages'),
path.join(withCustomPagesDirectory, 'custom-pages/list'),
path.join(withCustomPagesDir, 'custom-pages'),
path.join(withCustomPagesDir, 'custom-pages/list'),
],
],
},
......@@ -58,23 +85,18 @@ const linterConfigWithNestedContentRootDirDirectory = {
...linterConfig,
settings: {
next: {
rootDir: path.join(withNestedPagesDirectory, 'demos/with-nextjs'),
rootDir: path.join(withNestedPagesDir, 'demos/with-nextjs'),
},
},
}
withoutPagesLinter.defineRules({
'no-html-link-for-pages': rule,
})
withAppLinter.defineRules({
'no-html-link-for-pages': rule,
})
withNestedPagesLinter.defineRules({
'no-html-link-for-pages': rule,
})
withCustomPagesLinter.defineRules({
'no-html-link-for-pages': rule,
})
for (const version of ['v8', 'v9'] as const) {
for (const linter of Object.values(linters[version])) {
linter.defineRules({
'no-html-link-for-pages': NextESLintRule,
})
}
}
const validCode = `
import Link from 'next/link';
......@@ -253,300 +275,264 @@ export class Blah extends Head {
}
`
describe('no-html-link-for-pages', function () {
it('does not print warning when there are "pages" or "app" directories with rootDir in context settings', function () {
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
withNestedPagesLinter.verify(
validCode,
linterConfigWithNestedContentRootDirDirectory,
{
filename: 'foo.js',
}
)
expect(consoleSpy).not.toHaveBeenCalled()
consoleSpy.mockRestore()
})
it('prints warning when there are no "pages" or "app" directories', function () {
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
withoutPagesLinter.verify(validCode, linterConfig, {
filename: 'foo.js',
for (const version of ['v8', 'v9']) {
it(`does not print warning when there are "pages" or "app" directories with rootDir in context settings (${version})`, function () {
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
linters[version].withNestedPages.verify(
validCode,
linterConfigWithNestedContentRootDirDirectory,
{ filename: 'foo.js' }
)
expect(consoleSpy).not.toHaveBeenCalled()
consoleSpy.mockRestore()
})
const rootDirectory = path.join(__dirname, 'without-pages-dir')
expect(consoleSpy).toHaveBeenCalledWith(
`Pages directory cannot be found at ${path.join(
rootDirectory,
'pages'
)} or ${path.join(
rootDirectory,
'src',
'pages'
)}. If using a custom path, please configure with the \`no-html-link-for-pages\` rule in your eslint config file.`
)
consoleSpy.mockRestore()
})
it('does not print warning when there is "app" directory and no "pages" directory', function () {
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
withAppLinter.verify(validCode, linterConfig, {
filename: 'foo.js',
})
expect(consoleSpy).not.toHaveBeenCalled()
consoleSpy.mockRestore()
})
it('valid link element', function () {
const report = withCustomPagesLinter.verify(
validCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid link element with multiple directories', function () {
const report = withCustomPagesLinter.verify(
validCode,
linterConfigWithMultipleDirectories,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid anchor element', function () {
const report = withCustomPagesLinter.verify(
validAnchorCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid external link element', function () {
const report = withCustomPagesLinter.verify(
validExternalLinkCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid download link element', function () {
const report = withCustomPagesLinter.verify(
validDownloadLinkCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid target="_blank" link element', function () {
const report = withCustomPagesLinter.verify(
validTargetBlankLinkCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid public file link element', function () {
const report = withCustomPagesLinter.verify(
validPublicFile,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('invalid static route', function () {
const [report] = withCustomPagesLinter.verify(
invalidStaticCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it('invalid dynamic route', function () {
const [report] = withCustomPagesLinter.verify(
invalidDynamicCode,
linterConfigWithCustomDirectory,
{
it(`prints warning when there are no "pages" or "app" directories (${version})`, function () {
// TODO(jiwon): unskip v8 test
// If this test runs standalone, it correctly calls warning,
// but on the second run, it doesn't. Skip the v8 test for now as
// there were no rule changes. Maybe related to:
// https://github.com/facebook/react/issues/7047#issuecomment-228614964
if (version === 'v8') return
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
linters[version].withoutPages.verify(validCode, linterConfig, {
filename: 'foo.js',
}
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/list/foo/bar/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [secondReport] = withCustomPagesLinter.verify(
secondInvalidDynamicCode,
linterConfigWithCustomDirectory,
{
filename: 'foo.js',
}
)
assert.notEqual(secondReport, undefined, 'No lint errors found.')
assert.equal(
secondReport.message,
'Do not use an `<a>` element to navigate to `/list/foo/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [thirdReport] = withCustomPagesLinter.verify(
thirdInvalidDynamicCode,
linterConfigWithCustomDirectory,
{
})
expect(consoleSpy).toHaveBeenCalledWith(
`Pages directory cannot be found at ${path.join(
withoutPagesDir,
'pages'
)} or ${path.join(
withoutPagesDir,
'src',
'pages'
)}. If using a custom path, please configure with the \`no-html-link-for-pages\` rule in your eslint config file.`
)
consoleSpy.mockRestore()
})
it(`does not print warning when there is "app" directory and no "pages" directory (${version})`, function () {
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation()
linters[version].withApp.verify(validCode, linterConfig, {
filename: 'foo.js',
}
)
assert.notEqual(thirdReport, undefined, 'No lint errors found.')
assert.equal(
thirdReport.message,
'Do not use an `<a>` element to navigate to `/list/lorem-ipsum/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it('valid link element with appDir', function () {
const report = withAppLinter.verify(validCode, linterConfig, {
filename: 'foo.js',
})
expect(consoleSpy).not.toHaveBeenCalled()
consoleSpy.mockRestore()
})
assert.deepEqual(report, [])
})
it('valid link element with multiple directories with appDir', function () {
const report = withAppLinter.verify(validCode, linterConfig, {
filename: 'foo.js',
it(`valid link element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.deepEqual(report, [])
})
it('valid anchor element with appDir', function () {
const report = withAppLinter.verify(validAnchorCode, linterConfig, {
filename: 'foo.js',
it(`valid link element with multiple directories (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validCode,
linterConfigWithMultipleDirectories,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.deepEqual(report, [])
})
it('valid external link element with appDir', function () {
const report = withAppLinter.verify(validExternalLinkCode, linterConfig, {
filename: 'foo.js',
it(`valid anchor element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validAnchorCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.deepEqual(report, [])
})
it('valid download link element with appDir', function () {
const report = withAppLinter.verify(validDownloadLinkCode, linterConfig, {
filename: 'foo.js',
it(`valid external link element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validExternalLinkCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.deepEqual(report, [])
})
it('valid target="_blank" link element with appDir', function () {
const report = withAppLinter.verify(
validTargetBlankLinkCode,
linterConfig,
{
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('valid public file link element with appDir', function () {
const report = withAppLinter.verify(validPublicFile, linterConfig, {
filename: 'foo.js',
it(`valid download link element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validDownloadLinkCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.deepEqual(report, [])
})
it('invalid static route with appDir', function () {
const [report] = withAppLinter.verify(invalidStaticCode, linterConfig, {
filename: 'foo.js',
it(`valid target="_blank" link element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validTargetBlankLinkCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it('invalid dynamic route with appDir', function () {
const [report] = withAppLinter.verify(invalidDynamicCode, linterConfig, {
filename: 'foo.js',
it(`valid public file link element (${version})`, function () {
const report = linters[version].withCustomPages.verify(
validPublicFile,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/list/foo/bar/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [secondReport] = withAppLinter.verify(
secondInvalidDynamicCode,
linterConfig,
{
filename: 'foo.js',
}
)
assert.notEqual(secondReport, undefined, 'No lint errors found.')
assert.equal(
secondReport.message,
'Do not use an `<a>` element to navigate to `/list/foo/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [thirdReport] = withAppLinter.verify(
thirdInvalidDynamicCode,
linterConfig,
{
filename: 'foo.js',
}
)
assert.notEqual(thirdReport, undefined, 'No lint errors found.')
assert.equal(
thirdReport.message,
'Do not use an `<a>` element to navigate to `/list/lorem-ipsum/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it('valid intercepted route with appDir', function () {
const report = withAppLinter.verify(
validInterceptedRouteCode,
linterConfig,
{
it(`invalid static route (${version})`, function () {
const [report] = linters[version].withCustomPages.verify(
invalidStaticCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it(`invalid dynamic route (${version})`, function () {
const [report] = linters[version].withCustomPages.verify(
invalidDynamicCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/list/foo/bar/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [secondReport] = linters[version].withCustomPages.verify(
secondInvalidDynamicCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.notEqual(secondReport, undefined, 'No lint errors found.')
assert.equal(
secondReport.message,
'Do not use an `<a>` element to navigate to `/list/foo/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [thirdReport] = linters[version].withCustomPages.verify(
thirdInvalidDynamicCode,
linterConfigWithCustomDirectory,
{ filename: 'foo.js' }
)
assert.notEqual(thirdReport, undefined, 'No lint errors found.')
assert.equal(
thirdReport.message,
'Do not use an `<a>` element to navigate to `/list/lorem-ipsum/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it(`valid link element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(validCode, linterConfig, {
filename: 'foo.js',
}
)
assert.deepEqual(report, [])
})
it('invalid intercepted route with appDir', function () {
const [report] = withAppLinter.verify(
invalidInterceptedRouteCode,
linterConfig,
{
})
assert.deepEqual(report, [])
})
it(`valid link element with multiple directories with appDir (${version})`, function () {
const report = linters[version].withApp.verify(validCode, linterConfig, {
filename: 'foo.js',
}
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/photo/1/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
})
assert.deepEqual(report, [])
})
it(`valid anchor element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validAnchorCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`valid external link element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validExternalLinkCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`valid download link element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validDownloadLinkCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`valid target="_blank" link element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validTargetBlankLinkCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`valid public file link element with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validPublicFile,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`invalid static route with appDir (${version})`, function () {
const [report] = linters[version].withApp.verify(
invalidStaticCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it(`invalid dynamic route with appDir (${version})`, function () {
const [report] = linters[version].withApp.verify(
invalidDynamicCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/list/foo/bar/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [secondReport] = linters[version].withApp.verify(
secondInvalidDynamicCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.notEqual(secondReport, undefined, 'No lint errors found.')
assert.equal(
secondReport.message,
'Do not use an `<a>` element to navigate to `/list/foo/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
const [thirdReport] = linters[version].withApp.verify(
thirdInvalidDynamicCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.notEqual(thirdReport, undefined, 'No lint errors found.')
assert.equal(
thirdReport.message,
'Do not use an `<a>` element to navigate to `/list/lorem-ipsum/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
it(`valid intercepted route with appDir (${version})`, function () {
const report = linters[version].withApp.verify(
validInterceptedRouteCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.deepEqual(report, [])
})
it(`invalid intercepted route with appDir (${version})`, function () {
const [report] = linters[version].withApp.verify(
invalidInterceptedRouteCode,
linterConfig,
{ filename: 'foo.js' }
)
assert.notEqual(report, undefined, 'No lint errors found.')
assert.equal(
report.message,
'Do not use an `<a>` element to navigate to `/photo/1/`. Use `<Link />` from `next/link` instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages'
)
})
}
})
import * as rule from '@next/eslint-plugin-next/dist/rules/no-img-element'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-img-element']
ruleTester.run('no-img-element', rule, {
const message =
'Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element'
const tests = {
valid: [
`import { Image } from 'next/image';
......@@ -78,13 +73,7 @@ ruleTester.run('no-img-element', rule, {
);
}
}`,
errors: [
{
message:
'Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element',
type: 'JSXOpeningElement',
},
],
errors: [{ message, type: 'JSXOpeningElement' }],
},
{
code: `
......@@ -100,13 +89,33 @@ ruleTester.run('no-img-element', rule, {
);
}
}`,
errors: [
{
message:
'Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element',
type: 'JSXOpeningElement',
},
],
errors: [{ message, type: 'JSXOpeningElement' }],
},
],
}
describe('no-img-element', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-page-custom-font'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-page-custom-font']
const filename = 'pages/_document.js'
ruleTester.run('no-page-custom-font', rule, {
const tests = {
valid: [
{
code: `import Document, { Html, Head } from "next/document";
......@@ -197,4 +189,30 @@ ruleTester.run('no-page-custom-font', rule, {
],
},
],
}
describe('no-page-custom-font', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-script-component-in-head'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-script-component-in-head']
ruleTester.run('no-script-in-head', rule, {
const message =
'`next/script` should not be used in `next/head` component. Move `<Script />` outside of `<Head>` instead. See: https://nextjs.org/docs/messages/no-script-component-in-head'
const tests = {
valid: [
`import Script from "next/script";
const Head = ({children}) => children
......@@ -41,12 +36,33 @@ ruleTester.run('no-script-in-head', rule, {
);
}`,
filename: 'pages/index.js',
errors: [
{
message:
'`next/script` should not be used in `next/head` component. Move `<Script />` outside of `<Head>` instead. See: https://nextjs.org/docs/messages/no-script-component-in-head',
},
],
errors: [{ message }],
},
],
}
describe('no-script-component-in-head', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-styled-jsx-in-document'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('no-styled-jsx-in-document', rule, {
const NextESLintRule = rules['no-styled-jsx-in-document']
const tests = {
valid: [
{
filename: 'pages/_document.js',
......@@ -121,4 +113,30 @@ ruleTester.run('no-styled-jsx-in-document', rule, {
],
},
],
}
describe('no-styled-jsx-in-document', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-sync-scripts'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const NextESLintRule = rules['no-sync-scripts']
ruleTester.run('sync-scripts', rule, {
const message =
'Synchronous scripts should not be used. See: https://nextjs.org/docs/messages/no-sync-scripts'
const tests = {
valid: [
`import {Head} from 'next/document';
......@@ -55,13 +50,7 @@ ruleTester.run('sync-scripts', rule, {
);
}
}`,
errors: [
{
message:
'Synchronous scripts should not be used. See: https://nextjs.org/docs/messages/no-sync-scripts',
type: 'JSXOpeningElement',
},
],
errors: [{ message, type: 'JSXOpeningElement' }],
},
{
code: `
......@@ -77,13 +66,33 @@ ruleTester.run('sync-scripts', rule, {
);
}
}`,
errors: [
{
message:
'Synchronous scripts should not be used. See: https://nextjs.org/docs/messages/no-sync-scripts',
type: 'JSXOpeningElement',
},
],
errors: [{ message, type: 'JSXOpeningElement' }],
},
],
}
describe('no-sync-scripts', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-title-in-document-head'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('no-title-in-document-head', rule, {
const NextESLintRule = rules['no-title-in-document-head']
const tests = {
valid: [
`import Head from "next/head";
......@@ -66,4 +58,30 @@ ruleTester.run('no-title-in-document-head', rule, {
],
},
],
}
describe('no-title-in-document-head', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-typos'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
const ruleTester = new RuleTester()
const NextESLintRule = rules['no-typos']
ruleTester.run('no-typos', rule, {
const tests = {
valid: [
`
export default function Page() {
......@@ -127,4 +118,30 @@ ruleTester.run('no-typos', rule, {
],
},
],
}
describe('no-typos', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
import rule from '@next/eslint-plugin-next/dist/rules/no-unwanted-polyfillio'
import { RuleTester } from 'eslint'
;(RuleTester as any).setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
})
const ruleTester = new RuleTester()
import { RuleTester as ESLintTesterV8 } from 'eslint-v8'
import { RuleTester as ESLintTesterV9 } from 'eslint'
import { rules } from '@next/eslint-plugin-next'
ruleTester.run('unwanted-polyfillsio', rule, {
const NextESLintRule = rules['no-unwanted-polyfillio']
const tests = {
valid: [
`import {Head} from 'next/document';
......@@ -142,4 +134,30 @@ ruleTester.run('unwanted-polyfillsio', rule, {
],
},
],
}
describe('no-unwanted-polyfillio', () => {
new ESLintTesterV8({
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
modules: true,
jsx: true,
},
},
}).run('eslint-v8', NextESLintRule, tests)
new ESLintTesterV9({
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
modules: true,
jsx: true,
},
},
},
}).run('eslint-v9', NextESLintRule, tests)
})
......@@ -6,6 +6,7 @@ import { expectTypeOf } from 'expect-type'
describe('InferGetServerSidePropsType', () => {
it('should work with sync functions', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getServerSideProps(context: GetServerSidePropsContext) {
if (context.params?.notFound) {
return {
......@@ -26,6 +27,7 @@ describe('InferGetServerSidePropsType', () => {
})
it('should work with async functions', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getServerSideProps(context: GetServerSidePropsContext) {
if (context.params?.notFound) {
return {
......@@ -54,6 +56,7 @@ describe('InferGetServerSidePropsType', () => {
})
it('should work with promised props', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getServerSideProps() {
return {
props: Promise.resolve({
......
......@@ -3,6 +3,7 @@ import { expectTypeOf } from 'expect-type'
describe('InferGetServerSidePropsType', () => {
it('should work with sync functions', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getStaticProps(context: GetStaticPropsContext) {
if (context.params?.notFound) {
return {
......@@ -23,6 +24,7 @@ describe('InferGetServerSidePropsType', () => {
})
it('should work with async functions', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getStaticProps(context: GetStaticPropsContext) {
if (context.params?.notFound) {
return {
......
import * as expectMod from "./tests/execution/node_modules/expect";
import * as jest from "./tests/execution/node_modules/jest-circus";
import type * as expectMod from "./tests/execution/node_modules/expect";
import type * as jest from "./tests/execution/node_modules/jest-circus";
export {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment