@kirill.konshin/eslint-config-next-custom 0.3.2 → 0.4.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @kirill.konshin/eslint-config-next-custom
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ESLint 10 & Next.js 16
8
+
3
9
  ## 0.3.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -3,32 +3,47 @@
3
3
  ## Installation
4
4
 
5
5
  ```bash
6
- $ yarn add -D eslint @eslint-compat prettier @kirill.konshin/eslint-config-next-custom husky lint-staged
6
+ $ yarn add -D eslint prettier @kirill.konshin/eslint-config-next-custom husky lint-staged
7
7
  ```
8
8
 
9
- `eslint.config.mjs`:
9
+ ### PNPM
10
10
 
11
- ```js
12
- import { dirname, resolve } from 'node:path';
13
- import { fileURLToPath } from 'node:url';
11
+ https://eslint.org/docs/latest/use/getting-started#manual-set-up
12
+
13
+ ```dotenv
14
+ auto-install-peers=true
15
+ node-linker=hoisted
16
+ ```
14
17
 
15
- import { includeIgnoreFile } from '@eslint/compat';
16
- import customConfig from '@kirill.konshin/eslint-config-next-custom';
18
+ ## Settings
17
19
 
18
- const gitignorePath = resolve(dirname(fileURLToPath(import.meta.url)), '.prettierignore'); // <----- !!!
20
+ `eslint.config.mjs`:
21
+
22
+ ```js
23
+ import { defineConfig } from 'eslint/config';
24
+ import customConfig, { nextPlugin, includeIgnoreFile } from '@kirill.konshin/eslint-config-next-custom';
19
25
 
20
- const config = [
26
+ export default defineConfig([
21
27
  ...customConfig,
28
+ {
29
+ files: ['**/*.{js,jsx,ts,tsx}'],
30
+ plugins: {
31
+ next: nextPlugin,
32
+ },
33
+ settings: {
34
+ next: {
35
+ rootDir: process.cwd() + '/path/to/next-app',
36
+ },
37
+ },
38
+ },
22
39
  {
23
40
  name: 'Custom rules',
24
41
  rules: {
25
42
  // overrides
26
43
  },
27
44
  },
28
- includeIgnoreFile(gitignorePath),
29
- ];
30
-
31
- export default config;
45
+ includeIgnoreFile(import.meta.url, '.prettierignore'),
46
+ ]);
32
47
  ```
33
48
 
34
49
  `.prettierrc.mjs`:
@@ -47,20 +62,23 @@ export default {
47
62
  ```json5
48
63
  {
49
64
  scripts: {
50
- eslint: 'DEBUG=eslint:eslint eslint --cache --cache-location node_modules/.cache/eslint --fix',
51
- prettier: 'prettier --write',
65
+ eslint: 'eslint --fix --concurrency=auto --cache --cache-location node_modules/.cache/eslint', // to see files use --debug
66
+ prettier: 'prettier --write --log-level=warn', // to see files use --log-level=log
52
67
  'lint:all': 'yarn eslint . && yarn prettier .',
68
+ 'lint:staged': 'lint-staged',
53
69
  },
54
70
  }
55
71
  ```
56
72
 
57
- IDEA settings:
73
+ ## IDEA settings:
58
74
 
59
75
  - Eslint: `**/*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,htm,html,md,mdx,vue}`
60
76
  - Prettier: `{**/*}.{js,jsx,ts,tsx,cjs,cts,mjs,mts,htm,html,md,mdx,css,scss,sass,less,yml,yaml,json}`
61
77
 
62
78
  ## Lint Staged
63
79
 
80
+ `.lintstagedrc`
81
+
64
82
  ```json5
65
83
  {
66
84
  '*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,htm,html,md,mdx,vue}': 'yarn eslint',
@@ -70,6 +88,8 @@ IDEA settings:
70
88
 
71
89
  ## Husky
72
90
 
91
+ `package.json`:
92
+
73
93
  ```json5
74
94
  {
75
95
  scripts: {
@@ -88,5 +108,8 @@ yarn lint:staged
88
108
 
89
109
  ## Issues
90
110
 
91
- - [x] https://github.com/microsoft/rushstack/issues/4635 Failed to patch ESLint because the calling module was not recognized
92
- - [x] https://github.com/microsoft/rushstack/issues/4965 Failed to patch ESLint because the calling module was not recognized
111
+ - ESLint 9
112
+ - [x] https://github.com/microsoft/rushstack/issues/4635 Failed to patch ESLint because the calling module was not recognized
113
+ - [x] https://github.com/microsoft/rushstack/issues/4965 Failed to patch ESLint because the calling module was not recognized
114
+ - ESLint 10
115
+ - [ ] https://github.com/vercel/next.js/issues/89764 TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function
package/index.js CHANGED
@@ -1,22 +1,17 @@
1
- // @see https://blog.linotte.dev/eslint-9-next-js-935c2b6d0371
2
- import { dirname } from 'node:path';
1
+ import { dirname, resolve } from 'node:path';
3
2
  import { fileURLToPath } from 'node:url';
4
-
3
+ import { includeIgnoreFile as includeIgnoreFileCompat } from '@eslint/compat';
5
4
  import js from '@eslint/js';
6
- import { FlatCompat } from '@eslint/eslintrc';
7
- import { fixupConfigRules } from '@eslint/compat';
8
5
  import prettierConfigRecommended from 'eslint-config-prettier';
9
6
  import globals from 'globals';
10
-
11
- const flatCompat = new FlatCompat({
12
- baseDirectory: dirname(fileURLToPath(import.meta.url)),
13
- recommendedConfig: js.configs.recommended,
14
- allConfig: js.configs.all,
15
- });
7
+ import next from 'eslint-config-next';
8
+ import nextTs from 'eslint-config-next/typescript';
9
+ import nextPlugin from '@next/eslint-plugin-next';
16
10
 
17
11
  const index = [
18
12
  js.configs.recommended,
19
- ...fixupConfigRules([...flatCompat.extends('next', 'next/typescript')]), // https://nextjs.org/docs/app/api-reference/config/eslint#with-typescript
13
+ ...next,
14
+ ...nextTs,
20
15
  {
21
16
  // Plugin is not recommended by Prettier, they suggest to just use config, and disable all the rules, except for these two in plugin:
22
17
  // 'arrow-body-style': 'off'
@@ -51,8 +46,29 @@ const index = [
51
46
  'import/no-anonymous-default-export': 'off',
52
47
  'import/no-unresolved': 'off',
53
48
  'import/no-webpack-loader-syntax': 'off',
49
+ 'jsx-a11y/alt-text': 'off',
50
+ },
51
+ },
52
+ //FIXME ESLint 10 + Next fix
53
+ // https://github.com/vercel/next.js/issues/89764
54
+ // https://gist.github.com/OscarGauss/1f305edf5b7c103bb2ee32ba479f4261
55
+ {
56
+ settings: {
57
+ react: { version: '19' },
54
58
  },
55
59
  },
56
60
  ];
57
61
 
58
62
  export default index;
63
+
64
+ export { nextPlugin };
65
+
66
+ /**
67
+ * @param {string} importMetaUrl
68
+ * @param {string} ignoreFile
69
+ * @returns {import('@eslint/core').ConfigObject}
70
+ */
71
+ export function includeIgnoreFile(importMetaUrl, ignoreFile) {
72
+ // @see https://blog.linotte.dev/eslint-9-next-js-935c2b6d0371
73
+ return includeIgnoreFileCompat(resolve(dirname(fileURLToPath(importMetaUrl)), ignoreFile));
74
+ }
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@kirill.konshin/eslint-config-next-custom",
3
- "version": "0.3.2",
3
+ "description": "",
4
+ "version": "0.4.0",
4
5
  "type": "module",
6
+ "skipGenerate": true,
5
7
  "main": "index.js",
6
8
  "module": "index.js",
7
9
  "exports": {
@@ -9,27 +11,28 @@
9
11
  "./prettier": "./prettier.js"
10
12
  },
11
13
  "dependencies": {
12
- "@eslint/compat": "^1.2.5",
13
- "@eslint/eslintrc": "^3.2.0",
14
- "@eslint/js": "^9.18.0",
15
- "@next/eslint-plugin-next": "^15.1.6",
16
- "@typescript-eslint/eslint-plugin": "^8.21.0",
17
- "@typescript-eslint/parser": "^8.21.0",
18
- "eslint-config-next": "^15.1.6",
19
- "eslint-config-prettier": "^10.0.1",
20
- "eslint-plugin-react-hooks": "^5.1.0",
21
- "globals": "^15.14.0"
22
- },
23
- "devDependencies": {
24
- "typescript": "^5.7.3"
14
+ "@eslint/compat": "^2.0.3",
15
+ "@eslint/js": "^10.0.1",
16
+ "@next/eslint-plugin-next": "^16.2.1",
17
+ "@typescript-eslint/eslint-plugin": "^8.57.2",
18
+ "@typescript-eslint/parser": "^8.57.2",
19
+ "eslint-config-next": "^16.2.1",
20
+ "eslint-config-prettier": "^10.1.8",
21
+ "eslint-plugin-react-hooks": "^7.0.1",
22
+ "globals": "^16.4.0"
25
23
  },
26
24
  "peerDependencies": {
27
- "next": "^15"
25
+ "eslint": "^10",
26
+ "next": "^16"
28
27
  },
29
28
  "publishConfig": {
30
29
  "access": "public"
31
30
  },
32
31
  "author": "Kirill Konshin <kirill@konshin.org> (https://konshin.org)",
33
32
  "license": "MIT",
34
- "description": ""
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/kirill-konshin/utils.git",
36
+ "directory": "packages/eslint-config-next-custom"
37
+ }
35
38
  }
package/prettier.js CHANGED
@@ -4,7 +4,7 @@ export default {
4
4
  singleQuote: true,
5
5
  overrides: [
6
6
  {
7
- files: '*.{js,jsx,ts,tsx,html,md,mdx}',
7
+ files: '*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,html,md,mdx}',
8
8
  options: {
9
9
  tabWidth: 4,
10
10
  },