From e3ea74e4f2f2f8ce75ccf0f44616891bb1a87955 Mon Sep 17 00:00:00 2001 From: Jeremy Nguyen Date: Sat, 27 Apr 2024 17:25:05 -0700 Subject: [PATCH] docs: update README.md and documentation - Update README.md for end user instruction, badges - Add more comments for clarity in src/index.js --- .vscode/settings.json | 8 +- README.md | 73 ++++++++++--- package.json | 3 +- pnpm-lock.yaml | 246 ------------------------------------------ src/index.js | 45 +++++--- 5 files changed, 95 insertions(+), 280 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 67cd0cb..5abd67c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,9 +3,9 @@ "quickfix.biome": "explicit", "source.organizeImports.biome": "explicit" }, - "[javascript][json]": { - "editor.defaultFormatter": "biomejs.biome" - }, "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "[javascript][json][jsonc]": { + "editor.defaultFormatter": "biomejs.biome" + } } diff --git a/README.md b/README.md index bd4b3fc..a12b2bd 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,73 @@ -# eslint-config-next-flat [![GitHub Actions badge](https://github.com/jeremy-code/eslint-config-next-flat/actions/workflows/ci.yml/badge.svg)](https://github.com/jeremy-code/eslint-config-next-flat/actions/workflows/ci.yml) [![License](https://img.shields.io/github/license/jeremy-code/eslint-config-next-flat)](LICENSE) +# eslint-config-next-flat + +[![GitHub Actions badge][github-actions-badge]][github-actions] +[![License][license-badge]](LICENSE) +[![License][npm-version-badge]][npm-package] + +Flat config port of the Next.js ESLint config [`eslint-config-next`](https://www.npmjs.com/package/eslint-config-next). ## Installation ```bash -git clone https://github.com/jeremy-code/eslint-config-next-flat.git -cd eslint-config-next-flat -corepack enable -pnpm install +npm install -D eslint eslint-config-next-flat # npm +yarn add -D eslint eslint-config-next-flat # yarn +pnpm install -D eslint eslint-config-next-flat # pnpm ``` -## Usage +Create an `eslint.config.js` file in the root of your Next.js project and add the following: -```bash -# Set Node.js version -nvm use +```js +const js = require("@eslint/js"); +const next = require("eslint-config-next-flat"); -# Build -pnpm build +/** @type {import('eslint').Linter.FlatConfig}[] */ +module.exports = [ + { ignore: [".next"] }, // Change if `distDir` in Next.js config is different + js.configs.recommended, + next, +]; +``` + +If not using TypeScript, add custom Next.js Babel parser from `"next/dist/compiled/babel/eslint-parser"`. Otherwise, for TypeScript, use [`typescript-eslint`](https://typescript-eslint.io/getting-started/). + +```js +const js = require("@eslint/js"); +const next = require("eslint-config-next-flat"); +const parser = require("next/dist/compiled/babel/eslint-parser"); + +/** @type {import('eslint').Linter.FlatConfig}[] */ +module.exports = [ + { ignore: [".next"] }, // Change if `distDir` in Next.js config is different + js.configs.recommended, + next, + { + files: ["**/*.js", "**/*.mjs"], + languageOptions: { + parser, + parserOptions: { + requireConfigFile: false, + sourceType: "module", + allowImportExportEverywhere: true, + babelOptions: { + presets: ["next/babel"], + caller: { + supportsTopLevelAwait: true, + }, + }, + }, + }, + }, +]; ``` ## License -This project is licensed under the [MIT license](LICENSE). +`next-config-next-flat` is licensed under the [MIT license](LICENSE). + + + +[github-actions-badge]: https://github.com/jeremy-code/eslint-config-next-flat/actions/workflows/ci.yml/badge.svg +[github-actions]: https://github.com/jeremy-code/eslint-config-next-flat/actions/workflows/ci.yml +[license-badge]: https://img.shields.io/github/license/jeremy-code/eslint-config-next-flat +[npm-version-badge]: https://img.shields.io/npm/v/eslint-config-next-flat +[npm-package]: https://npmjs.com/package/eslint-config-next-flat diff --git a/package.json b/package.json index b6a1252..0f2f59c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next-flat", - "version": "0.1.0", + "version": "0.1.1", "description": "(Tentative) ESLint Flat Config for Next.js", "keywords": [ "eslint", @@ -43,7 +43,6 @@ "eslint-plugin-react-hooks": "^4.6.2", "globals": "^15.0.0", "husky": "^9.0.11", - "next": "^14.2.3", "rollup": "^4.16.4" }, "packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6436e78..074c36f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,9 +41,6 @@ importers: husky: specifier: ^9.0.11 version: 9.0.11 - next: - specifier: ^14.2.3 - version: 14.2.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) rollup: specifier: ^4.16.4 version: 4.16.4 @@ -140,66 +137,9 @@ packages: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} - '@next/env@14.2.3': - resolution: {integrity: sha512-W7fd7IbkfmeeY2gXrzJYDx8D2lWKbVoTIj1o1ScPHNzvp30s1AuoEFSdr39bC5sjxJaxTtq3OTCZboNp0lNWHA==} - '@next/eslint-plugin-next@14.2.3': resolution: {integrity: sha512-L3oDricIIjgj1AVnRdRor21gI7mShlSwU/1ZGHmqM3LzHhXXhdkrfeNY5zif25Bi5Dd7fiJHsbhoZCHfXYvlAw==} - '@next/swc-darwin-arm64@14.2.3': - resolution: {integrity: sha512-3pEYo/RaGqPP0YzwnlmPN2puaF2WMLM3apt5jLW2fFdXD9+pqcoTzRk+iZsf8ta7+quAe4Q6Ms0nR0SFGFdS1A==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - - '@next/swc-darwin-x64@14.2.3': - resolution: {integrity: sha512-6adp7waE6P1TYFSXpY366xwsOnEXM+y1kgRpjSRVI2CBDOcbRjsJ67Z6EgKIqWIue52d2q/Mx8g9MszARj8IEA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - - '@next/swc-linux-arm64-gnu@14.2.3': - resolution: {integrity: sha512-cuzCE/1G0ZSnTAHJPUT1rPgQx1w5tzSX7POXSLaS7w2nIUJUD+e25QoXD/hMfxbsT9rslEXugWypJMILBj/QsA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - - '@next/swc-linux-arm64-musl@14.2.3': - resolution: {integrity: sha512-0D4/oMM2Y9Ta3nGuCcQN8jjJjmDPYpHX9OJzqk42NZGJocU2MqhBq5tWkJrUQOQY9N+In9xOdymzapM09GeiZw==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - - '@next/swc-linux-x64-gnu@14.2.3': - resolution: {integrity: sha512-ENPiNnBNDInBLyUU5ii8PMQh+4XLr4pG51tOp6aJ9xqFQ2iRI6IH0Ds2yJkAzNV1CfyagcyzPfROMViS2wOZ9w==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - '@next/swc-linux-x64-musl@14.2.3': - resolution: {integrity: sha512-BTAbq0LnCbF5MtoM7I/9UeUu/8ZBY0i8SFjUMCbPDOLv+un67e2JgyN4pmgfXBwy/I+RHu8q+k+MCkDN6P9ViQ==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - '@next/swc-win32-arm64-msvc@14.2.3': - resolution: {integrity: sha512-AEHIw/dhAMLNFJFJIJIyOFDzrzI5bAjI9J26gbO5xhAKHYTZ9Or04BesFPXiAYXDNdrwTP2dQceYA4dL1geu8A==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - - '@next/swc-win32-ia32-msvc@14.2.3': - resolution: {integrity: sha512-vga40n1q6aYb0CLrM+eEmisfKCR45ixQYXuBXxOOmmoV8sYST9k7E3US32FsY+CkkF7NtzdcebiFT4CHuMSyZw==} - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - - '@next/swc-win32-x64-msvc@14.2.3': - resolution: {integrity: sha512-Q1/zm43RWynxrO7lW4ehciQVj+5ePBhOK+/K2P7pLFX3JaJ/IZVC69SHidrmZSOkqz7ECIOhhy7XhAFG4JYyHA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -296,12 +236,6 @@ packages: cpu: [x64] os: [win32] - '@swc/counter@0.1.3': - resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} - - '@swc/helpers@0.5.5': - resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==} - '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -407,10 +341,6 @@ packages: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} - busboy@1.6.0: - resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} - engines: {node: '>=10.16.0'} - call-bind@1.0.7: resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} engines: {node: '>= 0.4'} @@ -419,16 +349,10 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - caniuse-lite@1.0.30001612: - resolution: {integrity: sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==} - chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - client-only@0.0.1: - resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} - color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -994,32 +918,9 @@ packages: ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - nanoid@3.3.7: - resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - next@14.2.3: - resolution: {integrity: sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==} - engines: {node: '>=18.17.0'} - hasBin: true - peerDependencies: - '@opentelemetry/api': ^1.1.0 - '@playwright/test': ^1.41.2 - react: ^18.2.0 - react-dom: ^18.2.0 - sass: ^1.3.0 - peerDependenciesMeta: - '@opentelemetry/api': - optional: true - '@playwright/test': - optional: true - sass: - optional: true - object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -1093,9 +994,6 @@ packages: resolution: {integrity: sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==} engines: {node: '>=16 || 14 >=14.17'} - picocolors@1.0.0: - resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} - picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -1104,10 +1002,6 @@ packages: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} - postcss@8.4.31: - resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} - engines: {node: ^10 || ^12 || >=14} - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -1122,18 +1016,9 @@ packages: queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - react-dom@18.3.1: - resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} - peerDependencies: - react: ^18.3.1 - react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} - react@18.3.1: - resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} - engines: {node: '>=0.10.0'} - reflect.getprototypeof@1.0.6: resolution: {integrity: sha512-fmfw4XgoDke3kdI6h4xcUz1dG8uaiv5q9gcEwLS4Pnth2kxT+GZ7YehS1JTMGBQmtV7Y4GFGbs2re2NqhdozUg==} engines: {node: '>= 0.4'} @@ -1184,9 +1069,6 @@ packages: resolution: {integrity: sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==} engines: {node: '>= 0.4'} - scheduler@0.23.2: - resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} - semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true @@ -1215,14 +1097,6 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} - source-map-js@1.2.0: - resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} - engines: {node: '>=0.10.0'} - - streamsearch@1.1.0: - resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} - engines: {node: '>=10.0.0'} - string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -1262,19 +1136,6 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} - styled-jsx@5.1.1: - resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} - engines: {node: '>= 12.0.0'} - peerDependencies: - '@babel/core': '*' - babel-plugin-macros: '*' - react: '>= 16.8.0 || 17.x.x || ^18.0.0-0' - peerDependenciesMeta: - '@babel/core': - optional: true - babel-plugin-macros: - optional: true - supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -1297,9 +1158,6 @@ packages: tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} - tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -1454,39 +1312,10 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 - '@next/env@14.2.3': {} - '@next/eslint-plugin-next@14.2.3': dependencies: glob: 10.3.10 - '@next/swc-darwin-arm64@14.2.3': - optional: true - - '@next/swc-darwin-x64@14.2.3': - optional: true - - '@next/swc-linux-arm64-gnu@14.2.3': - optional: true - - '@next/swc-linux-arm64-musl@14.2.3': - optional: true - - '@next/swc-linux-x64-gnu@14.2.3': - optional: true - - '@next/swc-linux-x64-musl@14.2.3': - optional: true - - '@next/swc-win32-arm64-msvc@14.2.3': - optional: true - - '@next/swc-win32-ia32-msvc@14.2.3': - optional: true - - '@next/swc-win32-x64-msvc@14.2.3': - optional: true - '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -1550,13 +1379,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.16.4': optional: true - '@swc/counter@0.1.3': {} - - '@swc/helpers@0.5.5': - dependencies: - '@swc/counter': 0.1.3 - tslib: 2.6.2 - '@types/estree@1.0.5': {} '@types/json5@0.0.29': {} @@ -1691,10 +1513,6 @@ snapshots: dependencies: fill-range: 7.0.1 - busboy@1.6.0: - dependencies: - streamsearch: 1.1.0 - call-bind@1.0.7: dependencies: es-define-property: 1.0.0 @@ -1705,15 +1523,11 @@ snapshots: callsites@3.1.0: {} - caniuse-lite@1.0.30001612: {} - chalk@4.1.2: dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 - client-only@0.0.1: {} - color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -2411,35 +2225,8 @@ snapshots: ms@2.1.2: {} - nanoid@3.3.7: {} - natural-compare@1.4.0: {} - next@14.2.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1): - dependencies: - '@next/env': 14.2.3 - '@swc/helpers': 0.5.5 - busboy: 1.6.0 - caniuse-lite: 1.0.30001612 - graceful-fs: 4.2.11 - postcss: 8.4.31 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - styled-jsx: 5.1.1(react@18.3.1) - optionalDependencies: - '@next/swc-darwin-arm64': 14.2.3 - '@next/swc-darwin-x64': 14.2.3 - '@next/swc-linux-arm64-gnu': 14.2.3 - '@next/swc-linux-arm64-musl': 14.2.3 - '@next/swc-linux-x64-gnu': 14.2.3 - '@next/swc-linux-x64-musl': 14.2.3 - '@next/swc-win32-arm64-msvc': 14.2.3 - '@next/swc-win32-ia32-msvc': 14.2.3 - '@next/swc-win32-x64-msvc': 14.2.3 - transitivePeerDependencies: - - '@babel/core' - - babel-plugin-macros - object-assign@4.1.1: {} object-inspect@1.13.1: {} @@ -2522,18 +2309,10 @@ snapshots: lru-cache: 10.2.1 minipass: 7.0.4 - picocolors@1.0.0: {} - picomatch@2.3.1: {} possible-typed-array-names@1.0.0: {} - postcss@8.4.31: - dependencies: - nanoid: 3.3.7 - picocolors: 1.0.0 - source-map-js: 1.2.0 - prelude-ls@1.2.1: {} prop-types@15.8.1: @@ -2546,18 +2325,8 @@ snapshots: queue-microtask@1.2.3: {} - react-dom@18.3.1(react@18.3.1): - dependencies: - loose-envify: 1.4.0 - react: 18.3.1 - scheduler: 0.23.2 - react-is@16.13.1: {} - react@18.3.1: - dependencies: - loose-envify: 1.4.0 - reflect.getprototypeof@1.0.6: dependencies: call-bind: 1.0.7 @@ -2638,10 +2407,6 @@ snapshots: es-errors: 1.3.0 is-regex: 1.1.4 - scheduler@0.23.2: - dependencies: - loose-envify: 1.4.0 - semver@6.3.1: {} set-function-length@1.2.2: @@ -2675,10 +2440,6 @@ snapshots: signal-exit@4.1.0: {} - source-map-js@1.2.0: {} - - streamsearch@1.1.0: {} - string-width@4.2.3: dependencies: emoji-regex: 8.0.0 @@ -2737,11 +2498,6 @@ snapshots: strip-json-comments@3.1.1: {} - styled-jsx@5.1.1(react@18.3.1): - dependencies: - client-only: 0.0.1 - react: 18.3.1 - supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -2763,8 +2519,6 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - tslib@2.6.2: {} - type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/src/index.js b/src/index.js index a3a351f..2c76450 100644 --- a/src/index.js +++ b/src/index.js @@ -9,36 +9,47 @@ import globals from "globals"; export default { plugins: { /** - * Plugins that aren't patched for Next.js (e.g. have metadata property) are - * not usable with --cache or --print-config - * + * Plugins that aren't patched for ESLint flat config (e.g. have metadata + * property) are not usable with --cache or --print-config. All plugins used + * have yet to be patched. * {@see https://eslint.org/docs/latest/extend/plugin-migration-flat-config#adding-plugin-meta-information} */ - import: eslintImport, // not patched + import: eslintImport, react, - "jsx-a11y": jsxA11y, // not patched - "react-hooks": reactHooks, // not patched - "@next/next": next, // not patched + "jsx-a11y": jsxA11y, + "react-hooks": reactHooks, + "@next/next": next, }, rules: { ...react.configs.recommended.rules, - ...react.configs["jsx-runtime"].rules, // jsx-runtime for react-in-jsx-scope + ...react.configs["jsx-runtime"].rules, // Allow `react-in-jsx-scope` in React 17 ...reactHooks.configs.recommended.rules, ...next.configs.recommended.rules, - // when using @vercel/og (which is bundled into Next.js), tw prop is possible - // see https://github.com/vercel/next.js/blob/canary/packages/next/src/compiled/%40vercel/og/types.d.ts#L115 + + /** + * `@vercel/og` (which is bundled into Next.js) uses `tw` prop + * {@see https://github.com/vercel/next.js/blob/canary/packages/next/src/compiled/%40vercel/og/types.d.ts#L115} + * {@see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md} + */ "react/no-unknown-property": ["error", { ignore: ["tw"] }], }, languageOptions: { - globals: { - ...globals.browser, - ...globals.node, - }, - // No custom parser options or Babel parser, as typescript-esLint & Babel seem to have some conflicts, see https://github.com/typescript-eslint/typescript-eslint/issues/3517 + /** + * Config originally set browser + node globals. FlatConfig standard is to + * not set globals, and have end users configure them themselves. + * {@see https://eslint.org/blog/2022/08/new-config-system-part-2/#goodbye-environments%2C-hello-globals} + */ + globals: { ...globals.browser, ...globals.node }, + /** + * Legacy `eslint-config-next` uses custom Next.js parser + parserOptions + * with Babel by default, and sets parser '@typescript-eslint/parser` for + * .ts, .tsx files. This is not possible in one config with FlatConfig, and + * doing that would result in conflicts between the two parsers. + */ parserOptions: { ecmaFeatures: { - jsx: true, // set true by eslint-plugin-react default config + jsx: true, // set true by eslint-plugin-react's recommended config }, }, }, @@ -46,6 +57,8 @@ export default { react: { version: "detect", }, + // Settings for eslint-plugin-import, may be better to use the + // React/TypeScript eslint-plugin-import configs instead "import/parsers": { "@typescript-eslint/parser": [".ts", ".mts", ".cts", ".tsx", ".d.ts"], },