@slashnephy/eslint-config 3.0.357 → 3.0.358
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/package.json +1 -2
- package/src/base/javascript.js +15 -11
- package/src/base/javascript.ts +15 -11
- package/src/base/typescript.js +7 -0
- package/src/base/typescript.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slashnephy/eslint-config",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.358",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"eslint",
|
|
6
6
|
"eslintconfig"
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"@typescript-eslint/utils": "8.59.3",
|
|
30
30
|
"@vitest/eslint-plugin": "1.6.17",
|
|
31
31
|
"eslint-config-flat-gitignore": "2.3.0",
|
|
32
|
-
"eslint-import-resolver-node": "0.4.0",
|
|
33
32
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
34
33
|
"eslint-plugin-import-x": "4.16.2",
|
|
35
34
|
"eslint-plugin-jest": "29.15.2",
|
package/src/base/javascript.js
CHANGED
|
@@ -2,7 +2,8 @@ import eslint from '@eslint/js';
|
|
|
2
2
|
import eslintCommentsConfig from '@eslint-community/eslint-plugin-eslint-comments/configs';
|
|
3
3
|
import stylisticPlugin from '@stylistic/eslint-plugin';
|
|
4
4
|
import { defineConfig } from 'eslint/config';
|
|
5
|
-
import {
|
|
5
|
+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
6
|
+
import { createNodeResolver, importX } from 'eslint-plugin-import-x';
|
|
6
7
|
// @ts-expect-error 型定義ファイルがない
|
|
7
8
|
import promisePlugin from 'eslint-plugin-promise';
|
|
8
9
|
import unusedImportsPlugin from 'eslint-plugin-unused-imports';
|
|
@@ -156,20 +157,23 @@ export const javaScript = defineConfig({
|
|
|
156
157
|
importX.flatConfigs.recommended,
|
|
157
158
|
],
|
|
158
159
|
settings: {
|
|
159
|
-
'import-x/resolver'
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
// flat config 専用の新しい resolver API。旧 'import-x/resolver' は解決チェーンごとに
|
|
161
|
+
// resolver を作り直すためキャッシュが効かず、TypeScript の exports condition も評価できない
|
|
162
|
+
// (ESM import が CJS の型定義に解決され、tsc と ESLint で見えるモジュール形状がずれる)。
|
|
163
|
+
// resolver-next が設定されている場合、import-x は旧 'import-x/resolver' を一切参照しない。
|
|
164
|
+
'import-x/resolver-next': [
|
|
165
|
+
// alwaysTryTypes は v4 以降デフォルトで有効なため指定しない
|
|
166
|
+
createTypeScriptImportResolver(),
|
|
167
|
+
// tsconfig を持たないプロジェクト向けのフォールバック
|
|
168
|
+
createNodeResolver(),
|
|
169
|
+
],
|
|
167
170
|
},
|
|
168
171
|
rules: {
|
|
169
172
|
'import-x/no-import-module-exports': 'off',
|
|
170
173
|
'import-x/no-extraneous-dependencies': 'off',
|
|
171
|
-
// 循環 import
|
|
172
|
-
|
|
174
|
+
// 循環 import を禁止する。node_modules 側の循環は利用者が修正できず、
|
|
175
|
+
// 依存グラフを外部モジュールまで展開するコストだけが大きいため対象外にする
|
|
176
|
+
'import-x/no-cycle': ['error', { ignoreExternal: true }],
|
|
173
177
|
// default export を優先しない
|
|
174
178
|
'import-x/prefer-default-export': 'off',
|
|
175
179
|
// default export を禁止
|
package/src/base/javascript.ts
CHANGED
|
@@ -2,7 +2,8 @@ import eslint from '@eslint/js'
|
|
|
2
2
|
import eslintCommentsConfig from '@eslint-community/eslint-plugin-eslint-comments/configs'
|
|
3
3
|
import stylisticPlugin from '@stylistic/eslint-plugin'
|
|
4
4
|
import { defineConfig } from 'eslint/config'
|
|
5
|
-
import {
|
|
5
|
+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
|
|
6
|
+
import { createNodeResolver, importX } from 'eslint-plugin-import-x'
|
|
6
7
|
// @ts-expect-error 型定義ファイルがない
|
|
7
8
|
import promisePlugin from 'eslint-plugin-promise'
|
|
8
9
|
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
|
|
@@ -164,20 +165,23 @@ export const javaScript = defineConfig(
|
|
|
164
165
|
importX.flatConfigs.recommended,
|
|
165
166
|
],
|
|
166
167
|
settings: {
|
|
167
|
-
'import-x/resolver'
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
// flat config 専用の新しい resolver API。旧 'import-x/resolver' は解決チェーンごとに
|
|
169
|
+
// resolver を作り直すためキャッシュが効かず、TypeScript の exports condition も評価できない
|
|
170
|
+
// (ESM import が CJS の型定義に解決され、tsc と ESLint で見えるモジュール形状がずれる)。
|
|
171
|
+
// resolver-next が設定されている場合、import-x は旧 'import-x/resolver' を一切参照しない。
|
|
172
|
+
'import-x/resolver-next': [
|
|
173
|
+
// alwaysTryTypes は v4 以降デフォルトで有効なため指定しない
|
|
174
|
+
createTypeScriptImportResolver(),
|
|
175
|
+
// tsconfig を持たないプロジェクト向けのフォールバック
|
|
176
|
+
createNodeResolver(),
|
|
177
|
+
],
|
|
175
178
|
},
|
|
176
179
|
rules: {
|
|
177
180
|
'import-x/no-import-module-exports': 'off',
|
|
178
181
|
'import-x/no-extraneous-dependencies': 'off',
|
|
179
|
-
// 循環 import
|
|
180
|
-
|
|
182
|
+
// 循環 import を禁止する。node_modules 側の循環は利用者が修正できず、
|
|
183
|
+
// 依存グラフを外部モジュールまで展開するコストだけが大きいため対象外にする
|
|
184
|
+
'import-x/no-cycle': ['error', { ignoreExternal: true }],
|
|
181
185
|
// default export を優先しない
|
|
182
186
|
'import-x/prefer-default-export': 'off',
|
|
183
187
|
// default export を禁止
|
package/src/base/typescript.js
CHANGED
|
@@ -231,6 +231,13 @@ export const typeScript = defineConfig({
|
|
|
231
231
|
ignorePackages: true,
|
|
232
232
|
},
|
|
233
233
|
],
|
|
234
|
+
// 以下は tsc が同等以上の検査をする一方、import-x 側は対象モジュールを再パースして
|
|
235
|
+
// export 表を組み立てるため高価。importX.flatConfigs.typescript が同じ理由で
|
|
236
|
+
// 'import-x/named' を無効化しているのに倣い、TypeScript では残りも無効化する。
|
|
237
|
+
// namespace は TS2339、default は TS1192/TS2613、export は TS2323/TS2308 で検出される
|
|
238
|
+
'import-x/namespace': 'off',
|
|
239
|
+
'import-x/default': 'off',
|
|
240
|
+
'import-x/export': 'off',
|
|
234
241
|
},
|
|
235
242
|
}, {
|
|
236
243
|
name: '@susisu/eslint-plugin-safe-typescript',
|
package/src/base/typescript.ts
CHANGED
|
@@ -239,6 +239,13 @@ export const typeScript = defineConfig(
|
|
|
239
239
|
ignorePackages: true,
|
|
240
240
|
},
|
|
241
241
|
],
|
|
242
|
+
// 以下は tsc が同等以上の検査をする一方、import-x 側は対象モジュールを再パースして
|
|
243
|
+
// export 表を組み立てるため高価。importX.flatConfigs.typescript が同じ理由で
|
|
244
|
+
// 'import-x/named' を無効化しているのに倣い、TypeScript では残りも無効化する。
|
|
245
|
+
// namespace は TS2339、default は TS1192/TS2613、export は TS2323/TS2308 で検出される
|
|
246
|
+
'import-x/namespace': 'off',
|
|
247
|
+
'import-x/default': 'off',
|
|
248
|
+
'import-x/export': 'off',
|
|
242
249
|
},
|
|
243
250
|
},
|
|
244
251
|
{
|