@drazenbebic/eslint-config-next 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +17 -85
  2. package/index.js +20 -15
  3. package/package.json +1 -2
package/README.md CHANGED
@@ -2,52 +2,21 @@
2
2
 
3
3
  > Opinionated, shareable [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files) for personal Next.js projects.
4
4
 
5
- It composes the official [`eslint-config-next`](https://www.npmjs.com/package/eslint-config-next) (Core Web Vitals + TypeScript) with Prettier, import sorting, unused-import removal, and [`perfectionist`](https://perfectionist.dev/) sorting so a new Next.js app gets a consistent, batteries-included lint setup from a single dependency.
5
+ Composes the official [`eslint-config-next`](https://www.npmjs.com/package/eslint-config-next) (Core Web Vitals + TypeScript) with Prettier, import sorting, unused-import removal, and [`perfectionist`](https://perfectionist.dev/) — a batteries-included setup from a single dependency.
6
6
 
7
- > **Heads up:** this is a personal config tuned to my own preferences. You're welcome to use it, but it will change to suit my projects, not yours. Pin a version if that matters to you.
7
+ > **Heads up:** a personal config tuned to my preferences. Use it if you like, but it changes to suit my projects pin a version if that matters.
8
8
 
9
- ## What's inside
10
-
11
- - **`eslint-config-next/core-web-vitals`** and **`eslint-config-next/typescript`** — the official Next.js rules.
12
- - **Prettier** via [`eslint-plugin-prettier`](https://github.com/prettier/eslint-plugin-prettier) (`prettier/prettier` runs as an ESLint rule, and conflicting stylistic rules are turned off by `eslint-config-prettier`).
13
- - **`simple-import-sort`** — deterministic import/export ordering grouped as: side-effects → React/Next/node builtins → third-party → `@/` alias → relative.
14
- - **`unused-imports`** — auto-removes unused imports and warns on unused vars.
15
- - **`perfectionist`** — alphabetical sorting of JSX props, named imports/exports, union/intersection types, arrays, and more.
16
- - A few hand-picked core rules: `no-console` (allowing `warn`/`error`), `curly: all`, and `padding-line-between-statements` (blank lines around `if`/`for`/`try`/`return`).
17
- - Default ignores: `.next/**`, `out/**`, `build/**`, `next-env.d.ts`.
18
-
19
- ## Requirements
20
-
21
- - **Node.js** `>= 20`
22
- - **ESLint** `^9 || ^10` (flat config only — there is no `.eslintrc` support)
23
- - **Next.js** (`next`) `>= 15` — already in your app; required because this config extends `eslint-config-next`, whose parser loads from `next`
24
- - **Prettier** `^3`
25
- - **TypeScript** `>= 5` (optional, only if your project uses it)
26
-
27
- The ESLint plugins themselves ship as dependencies of this package, so you don't install them separately — only the peers above. In a real Next.js project `next` is already present, so you typically only add `eslint` and `prettier`.
28
-
29
- ## Installation
9
+ ## Install
30
10
 
31
11
  ```bash
32
12
  pnpm add -D @drazenbebic/eslint-config-next eslint prettier
33
- # add typescript if your project uses it:
34
- pnpm add -D typescript
35
13
  ```
36
14
 
37
- <details>
38
- <summary>npm / yarn</summary>
39
-
40
- ```bash
41
- npm install -D @drazenbebic/eslint-config-next eslint prettier typescript
42
- # or
43
- yarn add -D @drazenbebic/eslint-config-next eslint prettier typescript
44
- ```
45
-
46
- </details>
15
+ All ESLint plugins are bundled. Peers you provide: **ESLint** `^9 || ^10` and **Prettier** `^3`, plus **Next.js** `>= 15` and **TypeScript** `>= 5` — both already present in a typical Next.js + TS app. Requires Node `>= 20` and flat config (no `.eslintrc`).
47
16
 
48
17
  ## Usage
49
18
 
50
- Create an `eslint.config.mjs` (flat config) at the root of your project:
19
+ Create `eslint.config.mjs` at your project root:
51
20
 
52
21
  ```js
53
22
  import config from '@drazenbebic/eslint-config-next';
@@ -55,11 +24,11 @@ import config from '@drazenbebic/eslint-config-next';
55
24
  export default config;
56
25
  ```
57
26
 
58
- That's it. The default export is a flat-config array, so you can spread it and add your own overrides on top.
27
+ Formatting runs through ESLint (`prettier/prettier`), but the style stays yours add your own `.prettierrc`.
59
28
 
60
- ### Adding project-specific overrides
29
+ ### Overrides
61
30
 
62
- Because the config is a plain array, anything you add **after** the spread wins:
31
+ The default export is a flat-config array, so anything you append wins:
63
32
 
64
33
  ```js
65
34
  import { globalIgnores } from 'eslint/config';
@@ -68,58 +37,21 @@ import config from '@drazenbebic/eslint-config-next';
68
37
 
69
38
  const eslintConfig = [
70
39
  ...config,
71
-
72
- // Ignore generated files (e.g. Sanity TypeGen output).
73
- globalIgnores(['sanity.types.ts']),
74
-
75
- // Tweak or disable rules for your project.
76
- {
77
- rules: {
78
- 'no-console': 'off',
79
- },
80
- },
40
+ globalIgnores(['sanity.types.ts']), // e.g. Sanity TypeGen output
41
+ { rules: { 'no-console': 'off' } },
81
42
  ];
82
43
 
83
44
  export default eslintConfig;
84
45
  ```
85
46
 
86
- > **Note:** This config no longer ignores `sanity.types.ts` by default — add the `globalIgnores` line above in projects that use Sanity TypeGen.
87
-
88
- ### Prettier
89
-
90
- `prettier/prettier` runs inside ESLint, so formatting issues show up as lint errors and are fixable with `eslint --fix`. Add your own `.prettierrc` to control formatting (this config does not impose a Prettier style on your project). A typical `package.json`:
91
-
92
- ```json
93
- {
94
- "scripts": {
95
- "lint": "next lint",
96
- "lint:fix": "eslint . --fix"
97
- }
98
- }
99
- ```
100
-
101
- ### The `@/` import group
102
-
103
- The import-sort rules put imports matching `^@/` in their own group, which assumes you use the `@/*` path alias (the Next.js default). If you use a different alias, override `simple-import-sort/imports` in your project config.
104
-
105
- ## Releasing (maintainer notes)
106
-
107
- This package uses [release-please](https://github.com/googleapis/release-please) with **Conventional Commits**. Versions, the changelog, and the GitHub release are derived from commit messages on `main`:
108
-
109
- - `feat: …` → minor bump
110
- - `fix: …` / `perf: …` → patch bump
111
- - `feat!: …` or a `BREAKING CHANGE:` footer → major bump (minor while pre-1.0)
112
-
113
- When release-please's "Version Packages" PR is merged, the `release-please` workflow publishes to npm with [provenance](https://docs.npmjs.com/generating-provenance-statements) using [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC) — there is no long-lived `NPM_TOKEN` secret to manage.
114
-
115
- **One-time bootstrap** (because npm can only attach a trusted publisher to a package that already exists):
47
+ ## What's inside
116
48
 
117
- 1. Publish once manually to claim the name and create the package:
118
- ```bash
119
- npm publish --access public
120
- ```
121
- 2. On npmjs.com the package's **Settings Trusted Publisher**, add this repo's GitHub Actions workflow (`.github/workflows/release-please.yml`).
122
- 3. From then on, merging the release-please PR publishes hands-free via OIDC.
49
+ - **`eslint-config-next`** official Core Web Vitals + TypeScript rules.
50
+ - **Prettier** (`eslint-plugin-prettier` + `eslint-config-prettier`) — formatting as a lint rule.
51
+ - **`perfectionist`** import grouping (side-effects → React/Next/Node → third-party → `@/` alias → relative, with `import type` intermixed by path) plus sorted JSX props, named imports/exports, types, and arrays.
52
+ - **`unused-imports`** — removes unused imports, warns on unused vars.
53
+ - Core rules: `no-console` (allows `warn`/`error`), `curly`, and blank lines around `if`/`for`/`try`/`return`.
54
+ - Ignores `.next/`, `out/`, `build/`, `next-env.d.ts`.
123
55
 
124
56
  ## License
125
57
 
package/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { defineConfig, globalIgnores } from 'eslint/config';
2
1
  import nextVitals from 'eslint-config-next/core-web-vitals';
3
2
  import nextTs from 'eslint-config-next/typescript';
4
3
  import pluginPerfectionist from 'eslint-plugin-perfectionist';
5
4
  import prettierRecommended from 'eslint-plugin-prettier/recommended';
6
- import simpleImportSort from 'eslint-plugin-simple-import-sort';
7
5
  import pluginUnusedImports from 'eslint-plugin-unused-imports';
6
+ import { defineConfig, globalIgnores } from 'eslint/config';
8
7
 
9
8
  const PERFECTIONIST_DEFAULT_ARGS = {
10
9
  type: 'alphabetical',
@@ -26,7 +25,6 @@ const eslintConfig = defineConfig([
26
25
  plugins: {
27
26
  perfectionist: pluginPerfectionist,
28
27
  'unused-imports': pluginUnusedImports,
29
- 'simple-import-sort': simpleImportSort,
30
28
  },
31
29
  rules: {
32
30
  'prettier/prettier': 'error',
@@ -44,21 +42,28 @@ const eslintConfig = defineConfig([
44
42
  { blankLine: 'always', prev: 'try', next: '*' },
45
43
  { blankLine: 'always', prev: '*', next: 'return' },
46
44
  ],
47
- 'simple-import-sort/exports': 'error',
48
- 'simple-import-sort/imports': [
45
+ 'perfectionist/sort-imports': [
49
46
  'error',
50
47
  {
48
+ ...PERFECTIONIST_DEFAULT_ARGS,
49
+ sortSideEffects: true,
50
+ customGroups: [
51
+ { groupName: 'side-effects', selector: 'side-effect' },
52
+ {
53
+ groupName: 'react-next-node',
54
+ elementNamePattern: ['^react', '^next', '^node:'],
55
+ },
56
+ { groupName: 'third-party', elementNamePattern: ['^@?\\w'] },
57
+ { groupName: 'internal', elementNamePattern: ['^@/'] },
58
+ { groupName: 'relative', elementNamePattern: ['^\\.'] },
59
+ ],
51
60
  groups: [
52
- // 1. Side effect imports (e.g. import 'style.css')
53
- ['^\\u0000'],
54
- // 2. React, Next.js, and other node built-ins
55
- ['^react', '^next', '^node:'],
56
- // 3. Third-party packages (starting with a letter or @)
57
- ['^@?\\w'],
58
- // 4. Internal imports (using your @/ alias)
59
- ['^@/'],
60
- // 5. Relative imports (starting with .)
61
- ['^\\.'],
61
+ 'side-effects',
62
+ 'react-next-node',
63
+ 'third-party',
64
+ 'internal',
65
+ 'relative',
66
+ 'unknown',
62
67
  ],
63
68
  },
64
69
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drazenbebic/eslint-config-next",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Opinionated, shareable ESLint flat config for personal Next.js projects (Next + TypeScript + Prettier + import sorting + perfectionist).",
5
5
  "keywords": [
6
6
  "eslint",
@@ -50,7 +50,6 @@
50
50
  "eslint-config-prettier": "^10.1.8",
51
51
  "eslint-plugin-perfectionist": "^5.9.1",
52
52
  "eslint-plugin-prettier": "^5.5.6",
53
- "eslint-plugin-simple-import-sort": "^13.0.0",
54
53
  "eslint-plugin-unused-imports": "^4.4.1"
55
54
  },
56
55
  "peerDependencies": {