@geckou/eslint-config 0.1.1 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Geckou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @geckou/eslint-config
2
+
3
+ geckou のプロジェクト共通の ESLint 設定(flat config)。各プロジェクトは参照 1 行だけを持ち、
4
+ ルール本体はこのパッケージが持つ。
5
+
6
+ ## インストール
7
+
8
+ ```bash
9
+ yarn add -D @geckou/eslint-config eslint
10
+ ```
11
+
12
+ `eslint` は peerDependency。プラグイン類はこのパッケージが依存として持つので、個別に入れる必要はない。
13
+
14
+ ## 使い方
15
+
16
+ プリセットは 5 つ。**重ねて使わない**(それぞれ単独で完結する。重ねると同じプラグインを
17
+ 別々の実体で登録することになり、ESLint が `Cannot redefine plugin` で落ちる)。
18
+
19
+ | サブパス | 対象 |
20
+ | --- | --- |
21
+ | `.` | TypeScript パッケージ(Cloud Functions・共有パッケージ等) |
22
+ | `./next` | Next.js アプリ |
23
+ | `./expo` | Expo アプリ |
24
+ | `./vue` | Vue 3 パッケージ |
25
+ | `./react` | React パッケージ(Next.js を使わないコンポーネントライブラリ等) |
26
+
27
+ ```js
28
+ // eslint.config.mjs(TypeScript パッケージ)
29
+ import geckou from '@geckou/eslint-config'
30
+
31
+ export default geckou
32
+ ```
33
+
34
+ ```js
35
+ // apps/web/eslint.config.mjs
36
+ import next from '@geckou/eslint-config/next'
37
+
38
+ export default next
39
+ ```
40
+
41
+ ```js
42
+ // apps/mobile/eslint.config.mjs
43
+ import expo from '@geckou/eslint-config/expo'
44
+
45
+ export default expo
46
+ ```
47
+
48
+ ```js
49
+ // Vue パッケージの eslint.config.mjs
50
+ import vue from '@geckou/eslint-config/vue'
51
+
52
+ export default vue
53
+ ```
54
+
55
+ Vue と React が同居するリポジトリでは、**それぞれのディレクトリに絞って**並べる。
56
+ 対象が重なると同じファイルに 2 つのプリセットが当たる。
57
+
58
+ ```js
59
+ // リポジトリ直下の eslint.config.mjs
60
+ import react from '@geckou/eslint-config/react'
61
+ import vue from '@geckou/eslint-config/vue'
62
+
63
+ export default [
64
+ ...vue.map((config) => ({ ...config, files: ['packages/vue/**/*.{vue,ts}'] })),
65
+ ...react.map((config) => ({ ...config, files: ['packages/react/**/*.{ts,tsx}'] })),
66
+ ]
67
+ ```
68
+
69
+ ## 方針
70
+
71
+ - **フォーマット系のルールは持たない。** Prettier に委譲する(`eslint-config-prettier` で無効化済み)。
72
+ フォーマットは [`@geckou/prettier-config`](https://www.npmjs.com/package/@geckou/prettier-config) を使う
73
+ - 共通の値(無視するパス・共有ルール)は `rules.js` に置き、各プリセットから参照する。
74
+ `rules.js` はプラグインを読み込まないので、どのプリセットから参照しても多重定義にならない
75
+
76
+ ルールを変えるときは [`geckou/project-starter`](https://github.com/geckou/project-starter) の
77
+ `packages/eslint-config/` を直す。
package/package.json CHANGED
@@ -1,21 +1,26 @@
1
1
  {
2
2
  "name": "@geckou/eslint-config",
3
- "version": "0.1.1",
4
- "description": "Shared ESLint flat config for geckou projects (base / next / expo)",
3
+ "version": "0.2.0",
4
+ "description": "Shared ESLint flat config for geckou projects (base / next / expo / vue / react)",
5
5
  "type": "module",
6
6
  "main": "./index.js",
7
7
  "exports": {
8
8
  ".": "./index.js",
9
9
  "./next": "./next.js",
10
10
  "./expo": "./expo.js",
11
+ "./vue": "./vue.js",
12
+ "./react": "./react.js",
11
13
  "./package.json": "./package.json"
12
14
  },
13
15
  "files": [
14
16
  "index.js",
15
17
  "next.js",
16
18
  "expo.js",
19
+ "vue.js",
20
+ "react.js",
17
21
  "rules.js",
18
- "README.md"
22
+ "README.md",
23
+ "LICENSE"
19
24
  ],
20
25
  "repository": {
21
26
  "type": "git",
@@ -39,7 +44,10 @@
39
44
  "eslint-config-next": "^15.5.23",
40
45
  "eslint-config-prettier": "^9.0.0",
41
46
  "eslint-plugin-import": "^2.31.0",
42
- "typescript-eslint": "^8.67.0"
47
+ "eslint-plugin-react-hooks": "^5.0.0",
48
+ "eslint-plugin-vue": "^10.0.0",
49
+ "typescript-eslint": "^8.67.0",
50
+ "vue-eslint-parser": "^10.0.0"
43
51
  },
44
52
  "peerDependencies": {
45
53
  "eslint": ">=9"
package/react.js ADDED
@@ -0,0 +1,33 @@
1
+ // React パッケージ向けのプリセット(Next.js を使わないコンポーネント
2
+ // ライブラリ等)。Next.js アプリは ./next を使う。
3
+ //
4
+ // // eslint.config.mjs
5
+ // import react from '@geckou/eslint-config/react'
6
+ //
7
+ // export default react
8
+ //
9
+ // Hooks のルール(依存配列の漏れ・条件付き呼び出し)はテストで拾えない
10
+ // ため、このプリセットの主目的はそこにある。
11
+ import reactHooks from 'eslint-plugin-react-hooks'
12
+ import prettier from 'eslint-config-prettier'
13
+ import tseslint from 'typescript-eslint'
14
+
15
+ import { commonIgnores, sharedRules } from './rules.js'
16
+
17
+ export default [
18
+ { ignores: commonIgnores },
19
+ ...tseslint.configs.recommended,
20
+ prettier,
21
+ {
22
+ files: ['**/*.{ts,tsx,js,jsx}'],
23
+ plugins: { 'react-hooks': reactHooks },
24
+ // v5 の configs.recommended は eslintrc 形式(plugins を含む)なので、
25
+ // そのまま flat config に展開できない。ルール定義だけを取り出して使う。
26
+ // v7 の recommended は React Compiler のルール群まで含み内容が別物なので、
27
+ // 依存は ^5.0.0 に固定している
28
+ rules: reactHooks.configs.recommended.rules,
29
+ },
30
+ {
31
+ rules: sharedRules,
32
+ },
33
+ ]
package/rules.js CHANGED
@@ -29,3 +29,15 @@ export const typescriptRules = {
29
29
  },
30
30
  ],
31
31
  }
32
+
33
+ // Vue のテンプレート記法に関する規約。属性・イベント名はケバブケースへ
34
+ // 変換せず、コンポーネント側の props / emits 名のまま書く
35
+ export const vueRules = {
36
+ // 'multi-line' は Prettier の折り返しと衝突する(1 行だった if が
37
+ // 折り返された瞬間に違反になる)。行の形に依存しない 'all' を使う
38
+ curly: ['error', 'all'],
39
+ // 1 語のコンポーネント名(Button.vue 等)を許可する
40
+ 'vue/multi-word-component-names': 'off',
41
+ 'vue/attribute-hyphenation': ['error', 'never', { ignore: ['custom-prop'] }],
42
+ 'vue/v-on-event-hyphenation': ['error', 'never', { autofix: false }],
43
+ }
package/vue.js ADDED
@@ -0,0 +1,41 @@
1
+ // Vue 3 パッケージ向けのプリセット。
2
+ //
3
+ // // eslint.config.mjs
4
+ // import vue from '@geckou/eslint-config/vue'
5
+ //
6
+ // export default vue
7
+ //
8
+ // .vue / .ts の両方を検査する。React と Vue が同居するリポジトリでは
9
+ // ./react を配列で後ろに並べる(プラグインの実体は各プリセットで
10
+ // 別々に登録されるため、files で対象を分けている限り衝突しない)。
11
+ import pluginVue from 'eslint-plugin-vue'
12
+ import prettier from 'eslint-config-prettier'
13
+ import tseslint from 'typescript-eslint'
14
+ import vueParser from 'vue-eslint-parser'
15
+
16
+ import { commonIgnores, sharedRules, vueRules } from './rules.js'
17
+
18
+ export default [
19
+ { ignores: commonIgnores },
20
+ ...tseslint.configs.recommended,
21
+ ...pluginVue.configs['flat/recommended'],
22
+ prettier,
23
+ {
24
+ files: ['**/*.vue'],
25
+ languageOptions: {
26
+ parser: vueParser,
27
+ parserOptions: {
28
+ parser: tseslint.parser,
29
+ ecmaVersion: 'latest',
30
+ sourceType: 'module',
31
+ extraFileExtensions: ['.vue'],
32
+ },
33
+ },
34
+ },
35
+ {
36
+ rules: {
37
+ ...sharedRules,
38
+ ...vueRules,
39
+ },
40
+ },
41
+ ]