-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy patheslint.config.js
More file actions
134 lines (125 loc) · 3.74 KB
/
Copy patheslint.config.js
File metadata and controls
134 lines (125 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import nextPlugin from '@next/eslint-plugin-next';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import tseslint from 'typescript-eslint';
// __dirname の代替
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default tseslint.config(
// 0. グローバルな無視設定
{
ignores: [
'node_modules/',
'.next/',
'**/.next/**',
'dist/',
'**/dist/**',
'build/',
'**/build/**',
],
},
// 1. 基本設定: ESLint推奨 + TypeScript推奨 + Node/Browserグローバル + カスタムルール
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
// ...tseslint.configs.recommendedTypeChecked,
],
languageOptions: {
parserOptions: {
project: true,
// tsconfigRootDir: __dirname,
},
globals: {
...globals.node,
...globals.browser,
},
},
plugins: {
import: importPlugin,
},
rules: {
// --- TypeScript カスタムルール ---
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, argsIgnorePattern: '^_' }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// --- import/order ルール (TSファイル内) ---
'import/order': [
'error', // Severity
{ // Options
alphabetize: { order: 'asc' },
'newlines-between': 'always',
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [{ pattern: '@flow/**', group: 'internal' }],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'import/no-anonymous-default-export': 'off',
// --- その他のカスタムルール (TSファイル内) ---
'no-empty': 'off',
},
settings: {
// 'import/resolver': { typescript: {} },
},
},
// 2. JavaScript ファイル用の基本設定
{
files: ['**/*.{js,mjs,cjs}'],
languageOptions: {
globals: {
...globals.node,
},
},
plugins: {
import: importPlugin,
},
rules: {
// --- import/order ルール (JSファイル内) ---
// ***** ここを修正しました *****
'import/order': [
'error', // Severity
{ // Options (TSファイル用と同じ設定をコピー)
alphabetize: { order: 'asc' },
'newlines-between': 'always',
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [{ pattern: '@flow/**', group: 'internal' }],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
// ***** 修正ここまで *****
'import/no-anonymous-default-export': 'off',
'no-empty': 'off',
},
settings: {
// 'import/resolver': { node: {} },
},
},
// 3. Next.js 用の設定
{
files: ['apps/reader/**/*.{js,jsx,ts,tsx}'],
plugins: {
'@next/next': nextPlugin,
},
rules: {
...nextPlugin.configs.recommended.rules,
// ...nextPlugin.configs['core-web-vitals'].rules,
},
settings: {
next: {
rootDir: path.join(__dirname, 'apps/reader'),
},
},
},
// 4. Prettier 連携 (必ず最後に記述)
prettierConfig,
);