@geckou/eslint-config 0.1.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/expo.js +50 -0
- package/index.js +26 -0
- package/next.js +45 -0
- package/package.json +47 -0
- package/rules.js +31 -0
package/expo.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Expo(React Native)アプリ向けのプリセット。
|
|
2
|
+
//
|
|
3
|
+
// // apps/mobile/eslint.config.mjs
|
|
4
|
+
// import expo from '@geckou/eslint-config/expo'
|
|
5
|
+
//
|
|
6
|
+
// export default expo
|
|
7
|
+
//
|
|
8
|
+
// next.js と同じく FlatCompat の baseDirectory はこのパッケージ自身を指す。
|
|
9
|
+
// mobile 層を外すとこのファイルごと落ちる(layers.json)。
|
|
10
|
+
import path from 'node:path'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
|
|
13
|
+
import { FlatCompat } from '@eslint/eslintrc'
|
|
14
|
+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
|
|
15
|
+
import tsParser from '@typescript-eslint/parser'
|
|
16
|
+
|
|
17
|
+
import { commonIgnores, sharedRules } from './rules.js'
|
|
18
|
+
|
|
19
|
+
const compat = new FlatCompat({
|
|
20
|
+
baseDirectory: path.dirname(fileURLToPath(import.meta.url)),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export default [
|
|
24
|
+
{ ignores: [...commonIgnores, '.expo/**'] },
|
|
25
|
+
...compat.extends('expo', 'prettier'),
|
|
26
|
+
{
|
|
27
|
+
plugins: {
|
|
28
|
+
'@typescript-eslint': typescriptEslint,
|
|
29
|
+
},
|
|
30
|
+
languageOptions: {
|
|
31
|
+
parser: tsParser,
|
|
32
|
+
ecmaVersion: 2020,
|
|
33
|
+
sourceType: 'module',
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
...sharedRules,
|
|
37
|
+
// 実行時にのみ存在する任意依存(層やプラットフォームで有無が変わる)
|
|
38
|
+
'import/no-unresolved': [
|
|
39
|
+
'error',
|
|
40
|
+
{
|
|
41
|
+
ignore: [
|
|
42
|
+
'^expo-notifications$',
|
|
43
|
+
'^expo-device$',
|
|
44
|
+
'^@sentry/react-native$',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
]
|
package/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// TypeScript パッケージ向けのプリセット(Cloud Functions・共有パッケージ等)。
|
|
2
|
+
//
|
|
3
|
+
// // eslint.config.mjs
|
|
4
|
+
// import geckou from '@geckou/eslint-config'
|
|
5
|
+
//
|
|
6
|
+
// export default geckou
|
|
7
|
+
//
|
|
8
|
+
// Next.js / Expo のアプリは ./next / ./expo を使う。プリセットは互いに
|
|
9
|
+
// 独立していて、重ねて使わない(同じプラグインを別々の実体で登録すると
|
|
10
|
+
// ESLint が Cannot redefine plugin で落ちるため)。
|
|
11
|
+
import prettier from 'eslint-config-prettier'
|
|
12
|
+
import tseslint from 'typescript-eslint'
|
|
13
|
+
|
|
14
|
+
import { commonIgnores, sharedRules, typescriptRules } from './rules.js'
|
|
15
|
+
|
|
16
|
+
export default tseslint.config(
|
|
17
|
+
{ ignores: commonIgnores },
|
|
18
|
+
...tseslint.configs.recommended,
|
|
19
|
+
prettier,
|
|
20
|
+
{
|
|
21
|
+
rules: {
|
|
22
|
+
...sharedRules,
|
|
23
|
+
...typescriptRules,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
)
|
package/next.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Next.js アプリ向けのプリセット。
|
|
2
|
+
//
|
|
3
|
+
// // apps/web/eslint.config.mjs
|
|
4
|
+
// import next from '@geckou/eslint-config/next'
|
|
5
|
+
//
|
|
6
|
+
// export default next
|
|
7
|
+
//
|
|
8
|
+
// FlatCompat の baseDirectory はこのパッケージ自身を指す。next / prettier の
|
|
9
|
+
// 設定と、それが持ち込むプラグインはこのパッケージの依存として解決するため、
|
|
10
|
+
// 参照する側は eslint-config-next 等を持たなくてよい。
|
|
11
|
+
import path from 'node:path'
|
|
12
|
+
import { fileURLToPath } from 'node:url'
|
|
13
|
+
|
|
14
|
+
import { FlatCompat } from '@eslint/eslintrc'
|
|
15
|
+
|
|
16
|
+
import { commonIgnores, sharedRules } from './rules.js'
|
|
17
|
+
|
|
18
|
+
const compat = new FlatCompat({
|
|
19
|
+
baseDirectory: path.dirname(fileURLToPath(import.meta.url)),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export default [
|
|
23
|
+
{ ignores: [...commonIgnores, '.next/**', 'next-env.d.ts'] },
|
|
24
|
+
...compat.extends('next/core-web-vitals', 'next/typescript', 'prettier'),
|
|
25
|
+
{
|
|
26
|
+
rules: {
|
|
27
|
+
...sharedRules,
|
|
28
|
+
'import/order': [
|
|
29
|
+
'warn',
|
|
30
|
+
{
|
|
31
|
+
groups: [
|
|
32
|
+
'builtin',
|
|
33
|
+
'external',
|
|
34
|
+
'internal',
|
|
35
|
+
'parent',
|
|
36
|
+
'sibling',
|
|
37
|
+
'index',
|
|
38
|
+
],
|
|
39
|
+
'newlines-between': 'always',
|
|
40
|
+
alphabetize: { order: 'asc' },
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
]
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geckou/eslint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared ESLint flat config for geckou projects (base / next / expo)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./next": "./next.js",
|
|
10
|
+
"./expo": "./expo.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"next.js",
|
|
16
|
+
"expo.js",
|
|
17
|
+
"rules.js",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/geckou/project-starter.git",
|
|
23
|
+
"directory": "packages/eslint-config"
|
|
24
|
+
},
|
|
25
|
+
"author": "geckou-shogo <shogo.nojima@geckou.net>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20.0.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@eslint/eslintrc": "^3.0.0",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
37
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
38
|
+
"eslint-config-expo": "~8.0.0",
|
|
39
|
+
"eslint-config-next": "^15.5.23",
|
|
40
|
+
"eslint-config-prettier": "^9.0.0",
|
|
41
|
+
"eslint-plugin-import": "^2.31.0",
|
|
42
|
+
"typescript-eslint": "^8.67.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"eslint": ">=9"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/rules.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// 各プリセットで共通の値。プラグインを読み込まないので、どのプリセットから
|
|
2
|
+
// 参照しても ESLint のプラグイン多重定義(Cannot redefine plugin)を起こさない。
|
|
3
|
+
|
|
4
|
+
// 生成物・ビルド成果物。どの構成でも検査しない
|
|
5
|
+
export const commonIgnores = [
|
|
6
|
+
'node_modules/**',
|
|
7
|
+
'dist/**',
|
|
8
|
+
'coverage/**',
|
|
9
|
+
'.turbo/**',
|
|
10
|
+
'eslint.config.mjs',
|
|
11
|
+
'.eslintrc.*',
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
// フォーマット系ルールは Prettier に委譲するため、ここには書かない
|
|
15
|
+
// (eslint-config-prettier で無効化済み。CLAUDE.md「コーディング規約」)
|
|
16
|
+
export const sharedRules = {
|
|
17
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 理由コメント付きの ts-ignore / ts-nocheck は許可する。
|
|
21
|
+
// next / expo のプリセットは各フレームワークの既定に任せるため、
|
|
22
|
+
// TypeScript 専用のプリセット(`.`)だけで使う
|
|
23
|
+
export const typescriptRules = {
|
|
24
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
25
|
+
'error',
|
|
26
|
+
{
|
|
27
|
+
'ts-ignore': 'allow-with-description',
|
|
28
|
+
'ts-nocheck': 'allow-with-description',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}
|