Skip to content

Commit

Permalink
docs: update README.md and documentation
Browse files Browse the repository at this point in the history
- Update README.md for end user instruction, badges
- Add more comments for clarity in src/index.js
  • Loading branch information
jeremy-code committed Apr 28, 2024
1 parent 9712308 commit e3ea74e
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 280 deletions.
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
73 changes: 61 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

<!-- Badges -->

[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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
Loading

0 comments on commit e3ea74e

Please sign in to comment.