@yoshinani/style-guide 0.0.8 → 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.
@@ -0,0 +1,199 @@
1
+ // @ts-check
2
+
3
+ import eslint from "@eslint/js";
4
+ import tseslint from "typescript-eslint";
5
+ import * as importPlugin from "eslint-plugin-import";
6
+ import comments from "@eslint-community/eslint-plugin-eslint-comments";
7
+ import functional from "eslint-plugin-functional";
8
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
9
+
10
+ export default tseslint.config(
11
+ eslint.configs.recommended,
12
+ tseslint.configs.recommendedTypeChecked,
13
+ eslintConfigPrettier,
14
+ {
15
+ settings: {
16
+ "import/resolver": {
17
+ typescript: true,
18
+ },
19
+ },
20
+ plugins: {
21
+ import: importPlugin,
22
+ functional,
23
+ "@eslint-community/eslint-comments": comments,
24
+ },
25
+ extends: [
26
+ functional.configs.externalTypeScriptRecommended,
27
+ functional.configs.stylistic,
28
+ ],
29
+ languageOptions: {
30
+ parserOptions: {
31
+ projectService: true,
32
+ tsconfigRootDir: import.meta.dirname,
33
+ },
34
+ },
35
+ rules: {
36
+ "functional/immutable-data": "error",
37
+ // [比較演算子禁止](https://www.notion.so/yoshinani-note/1dff5577f5838145acfcca9176913b79)
38
+ eqeqeq: [
39
+ "error",
40
+ "always",
41
+ {
42
+ null: "ignore",
43
+ },
44
+ ],
45
+ // [any禁止](https://www.notion.so/yoshinani-note/any-1dff5577f5838174907ae6b2cfaf72ea)
46
+ "@typescript-eslint/no-explicit-any": "error",
47
+ // [混乱を招くvoidの使用禁止](https://www.notion.so/yoshinani-note/void-1dff5577f5838144bf0dc90e4bdffcb3)
48
+ "@typescript-eslint/no-confusing-void-expression": [
49
+ "error",
50
+ {
51
+ ignoreArrowShorthand: true,
52
+ },
53
+ ],
54
+
55
+ // [awaitつけ忘れ防止](https://www.notion.so/yoshinani-note/await-1dff5577f58381e5ab40f29d8d3f0be4)
56
+ "@typescript-eslint/no-floating-promises": "error",
57
+ "@typescript-eslint/no-shadow": "off",
58
+ // [誤ったpromiseの使用禁止](https://www.notion.so/yoshinani-note/promise-1dff5577f58381ae86c0d8c5b83f052a)
59
+ "@typescript-eslint/no-misused-promises": [
60
+ "error",
61
+ {
62
+ checksVoidReturn: {
63
+ attributes: false,
64
+ },
65
+ },
66
+ ],
67
+
68
+ // [不要なオプショナルチェーン禁止](https://www.notion.so/yoshinani-note/1dff5577f583816e8b5eec9963add23d)
69
+ "@typescript-eslint/no-unnecessary-condition": "error",
70
+
71
+ // [nullなどをそのまま文字列にするのを禁止](https://www.notion.so/yoshinani-note/null-1dff5577f5838104b3b9db6eee64f106)
72
+ "@typescript-eslint/restrict-template-expressions": [
73
+ "error",
74
+ {
75
+ allowAny: false,
76
+ allowBoolean: false,
77
+ allowNullish: false,
78
+ allowRegExp: false,
79
+ allowNever: false,
80
+ },
81
+ ],
82
+
83
+ // [ルール無効化の際に理由を添える](https://www.notion.so/yoshinani-note/1dff5577f583818b913fec991d5e8b46)
84
+ "@eslint-community/eslint-comments/require-description": [
85
+ "error",
86
+ { ignore: [] },
87
+ ],
88
+ // sort import statements
89
+ "import/order": [
90
+ "warn",
91
+ {
92
+ groups: [
93
+ "builtin",
94
+ "external",
95
+ "internal",
96
+ "parent",
97
+ "sibling",
98
+ "index",
99
+ ],
100
+ "newlines-between": "always",
101
+ alphabetize: { order: "asc" },
102
+ },
103
+ ],
104
+ // sort named imports within an import statement
105
+ "sort-imports": ["warn", { ignoreDeclarationSort: true }],
106
+ "no-restricted-syntax": [
107
+ "error",
108
+ {
109
+ // [enum禁止](https://www.notion.so/yoshinani-note/enum-1dff5577f58381a2b809d81ddc486701)
110
+ selector: "TSEnumDeclaration",
111
+ message:
112
+ "TSのenumには様々な問題があります。enum as constを使用してください。",
113
+ },
114
+ {
115
+ selector: "ForInStatement",
116
+ message:
117
+ "for文は使わず、forEach、map、filterなどを使用してください。",
118
+ },
119
+ {
120
+ selector: "ForOfStatement",
121
+ message:
122
+ "for文は使わず、forEach、map、filterなどを使用してください。",
123
+ },
124
+ {
125
+ selector: "LabeledStatement",
126
+ message:
127
+ "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
128
+ },
129
+ {
130
+ selector: "WithStatement",
131
+ message:
132
+ "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
133
+ },
134
+ ],
135
+ // [process.envの乱用禁止](https://www.notion.so/yoshinani-note/process-env-1dff5577f58381f4ba04f06cac13d334)
136
+ "no-process-env": "error",
137
+ // [インポートを制限](https://www.notion.so/yoshinani-note/1dff5577f58381a7bd81ef0805696e2b)
138
+ "no-restricted-imports": [
139
+ "warn",
140
+ {
141
+ paths: [
142
+ {
143
+ name: "yup",
144
+ message: "valibotを使用してください。",
145
+ },
146
+ {
147
+ name: "@material-tailwind/react",
148
+ message: "shadcn/uiを使用してください。",
149
+ },
150
+ {
151
+ name: "dayjs",
152
+ message: "date-fnsを使用してください。",
153
+ },
154
+ ],
155
+
156
+ patterns: [
157
+ {
158
+ group: ["lodash/*"],
159
+ message: "remedaを使用してください。",
160
+ },
161
+ ],
162
+ },
163
+ ],
164
+ },
165
+ },
166
+ {
167
+ files: [
168
+ "**/*.config.{mjs,ts}",
169
+ "app/**/{page,layout,not-found,*error,opengraph-image,apple-icon}.tsx",
170
+ "app/**/{sitemap,robots}.ts",
171
+ ],
172
+
173
+ rules: {
174
+ "import/no-default-export": "off",
175
+
176
+ "import/prefer-default-export": [
177
+ "error",
178
+ {
179
+ target: "any",
180
+ },
181
+ ],
182
+ },
183
+ },
184
+ {
185
+ files: ["**/env.ts"],
186
+
187
+ rules: {
188
+ "@typescript-eslint/dot-notation": "off",
189
+ "no-process-env": "off",
190
+ },
191
+ },
192
+ {
193
+ files: ["**/*.ts", "**/*.tsx"],
194
+
195
+ rules: {
196
+ "func-names": "off",
197
+ },
198
+ }
199
+ );
@@ -0,0 +1,19 @@
1
+ // @ts-check
2
+
3
+ import base from "./base.mjs";
4
+ import globals from "globals";
5
+
6
+ const eslintConfig = [
7
+ ...base,
8
+ {
9
+ languageOptions: {
10
+ globals: {
11
+ ...globals.node,
12
+ ...globals.es2021,
13
+ },
14
+ },
15
+ ignores: ["node_modules/", "dist/", "*.js"],
16
+ },
17
+ ];
18
+
19
+ export default eslintConfig;
@@ -0,0 +1,20 @@
1
+ // @ts-check
2
+
3
+ import base from "./base.mjs";
4
+ import globals from "globals";
5
+
6
+ const eslintConfig = [
7
+ ...base,
8
+ {
9
+ languageOptions: {
10
+ globals: {
11
+ ...globals.browser,
12
+ ...globals.node,
13
+ ...globals.es2021,
14
+ },
15
+ },
16
+ ignores: ["node_modules/", "dist/"],
17
+ },
18
+ ];
19
+
20
+ export default eslintConfig;
@@ -0,0 +1,18 @@
1
+ // @ts-check
2
+
3
+ import base from "./base.mjs";
4
+ import globals from "globals";
5
+
6
+ const eslintConfig = [
7
+ ...base,
8
+ {
9
+ languageOptions: {
10
+ globals: {
11
+ ...globals.browser,
12
+ },
13
+ },
14
+ ignores: ["node_modules/", "dist/", "*.js"],
15
+ },
16
+ ];
17
+
18
+ export default eslintConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoshinani/style-guide",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "Yoshinani's Style Guide",
5
5
  "homepage": "https://github.com/yoshinani-dev/style-guide#readme",
6
6
  "bugs": {
@@ -14,21 +14,23 @@
14
14
  "./typescript": "./typescript/base.json",
15
15
  "./typescript/nextjs": "./typescript/nextjs.json",
16
16
  "./typescript/react-library": "./typescript/react-library.json",
17
- "./eslint/*": "./eslint/*.js"
17
+ "./eslint/*": "./eslint/*.mjs"
18
18
  },
19
19
  "files": [
20
20
  "typescript",
21
21
  "eslint"
22
22
  ],
23
23
  "dependencies": {
24
- "@typescript-eslint/eslint-plugin": "^8.18.2",
25
- "@typescript-eslint/parser": "^8.18.2",
26
- "@vercel/style-guide": "^6.0.0",
27
- "eslint-config-prettier": "^9.1.0",
28
- "eslint-plugin-eslint-comments": "^3.2.0",
29
- "eslint-plugin-functional": "6.6.3",
24
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
25
+ "@eslint/js": "^9.25.1",
26
+ "eslint": "^9.25.1",
27
+ "eslint-config-prettier": "^10.1.2",
28
+ "eslint-plugin-functional": "^9.0.1",
30
29
  "eslint-plugin-import": "^2.31.0",
31
- "eslint-plugin-tailwindcss": "^3.17.5"
30
+ "eslint-plugin-tailwindcss": "^3.18.0",
31
+ "globals": "^16.0.0",
32
+ "typescript": "^5.8.3",
33
+ "typescript-eslint": "^8.31.0"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@commitlint/cli": "^19.8.0",
@@ -36,7 +38,7 @@
36
38
  "husky": "^9.1.7"
37
39
  },
38
40
  "peerDependencies": {
39
- "eslint": ">=8 <9"
41
+ "eslint": ">=9 <10"
40
42
  },
41
43
  "packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
42
44
  "scripts": {
package/eslint/base.js DELETED
@@ -1,149 +0,0 @@
1
- const { resolve } = require("node:path")
2
-
3
- const project = resolve(process.cwd(), "tsconfig.json")
4
-
5
- /** @type {import("eslint").Linter.Config} */
6
- module.exports = {
7
- settings: {
8
- "import/resolver": {
9
- typescript: {
10
- project,
11
- },
12
- },
13
- },
14
- plugins: ["@typescript-eslint", "import", "eslint-comments", "functional"],
15
- rules: {
16
- // [比較演算子禁止](https://www.notion.so/yoshinani-note/1dff5577f5838145acfcca9176913b79)
17
- eqeqeq: ["error", "always", { null: "ignore" }],
18
- // [any禁止](https://www.notion.so/yoshinani-note/any-1dff5577f5838174907ae6b2cfaf72ea)
19
- "@typescript-eslint/no-explicit-any": "error",
20
- // [混乱を招くvoidの使用禁止](https://www.notion.so/yoshinani-note/void-1dff5577f5838144bf0dc90e4bdffcb3)
21
- "@typescript-eslint/no-confusing-void-expression": [
22
- "error",
23
- { ignoreArrowShorthand: true },
24
- ],
25
- // [awaitつけ忘れ防止](https://www.notion.so/yoshinani-note/await-1dff5577f58381e5ab40f29d8d3f0be4)
26
- "@typescript-eslint/no-floating-promises": "error",
27
- "@typescript-eslint/no-shadow": "off",
28
- // [誤ったpromiseの使用禁止](https://www.notion.so/yoshinani-note/promise-1dff5577f58381ae86c0d8c5b83f052a)
29
- "@typescript-eslint/no-misused-promises": [
30
- "error",
31
- { checksVoidReturn: { attributes: false } },
32
- ],
33
- // [不要なオプショナルチェーン禁止](https://www.notion.so/yoshinani-note/1dff5577f583816e8b5eec9963add23d)
34
- "@typescript-eslint/no-unnecessary-condition": "error",
35
- // [nullなどをそのまま文字列にするのを禁止](https://www.notion.so/yoshinani-note/null-1dff5577f5838104b3b9db6eee64f106)
36
- "@typescript-eslint/restrict-template-expressions": [
37
- "error",
38
- {
39
- allowAny: false,
40
- allowBoolean: false,
41
- allowNullish: false,
42
- allowRegExp: false,
43
- allowNever: false,
44
- },
45
- ],
46
- // [ルール無効化の際に理由を添える](https://www.notion.so/yoshinani-note/1dff5577f583818b913fec991d5e8b46)
47
- "eslint-comments/require-description": ["error", {"ignore": []}],
48
- "functional/immutable-data": "error",
49
- // sort import statements
50
- "import/order": [
51
- "warn",
52
- {
53
- groups: [
54
- "builtin",
55
- "external",
56
- "internal",
57
- "parent",
58
- "sibling",
59
- "index",
60
- ],
61
- "newlines-between": "always",
62
- alphabetize: { order: "asc" },
63
- },
64
- ],
65
- // sort named imports within an import statement
66
- "sort-imports": ["warn", { ignoreDeclarationSort: true }],
67
- "no-restricted-syntax": [
68
- "error",
69
- // [enum禁止](https://www.notion.so/yoshinani-note/enum-1dff5577f58381a2b809d81ddc486701)
70
- {
71
- selector: "TSEnumDeclaration",
72
- message:
73
- "TSのenumには様々な問題があります。enum as constを使用してください。",
74
- },
75
- {
76
- selector: "ForInStatement",
77
- message: "for文は使わず、forEach、map、filterなどを使用してください。",
78
- },
79
- {
80
- selector: "ForOfStatement",
81
- message: "for文は使わず、forEach、map、filterなどを使用してください。",
82
- },
83
- {
84
- selector: "LabeledStatement",
85
- message:
86
- "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
87
- },
88
- {
89
- selector: "WithStatement",
90
- message:
91
- "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
92
- },
93
- ],
94
- // [process.envの乱用禁止](https://www.notion.so/yoshinani-note/process-env-1dff5577f58381f4ba04f06cac13d334)
95
- "no-process-env": "error",
96
- // [インポートを制限](https://www.notion.so/yoshinani-note/1dff5577f58381a7bd81ef0805696e2b)
97
- "no-restricted-imports": [
98
- "warn",
99
- {
100
- paths: [
101
- {
102
- name: "yup",
103
- message: "valibotを使用してください。",
104
- },
105
- {
106
- name: "@material-tailwind/react",
107
- message: "shadcn/uiを使用してください。",
108
- },
109
- {
110
- name: "dayjs",
111
- message: "date-fnsを使用してください。",
112
- },
113
- ],
114
- patterns: [
115
- {
116
- group: ["lodash/*"],
117
- message: "remedaを使用してください。",
118
- },
119
- ],
120
- },
121
- ],
122
- },
123
- overrides: [
124
- {
125
- files: [
126
- "*.config.{mjs,ts}",
127
- "app/**/{page,layout,not-found,*error,opengraph-image,apple-icon}.tsx",
128
- "app/**/{sitemap,robots}.ts",
129
- ],
130
- rules: {
131
- "import/no-default-export": "off",
132
- "import/prefer-default-export": ["error", { target: "any" }],
133
- },
134
- },
135
- {
136
- files: ["env.ts"],
137
- rules: {
138
- "@typescript-eslint/dot-notation": "off",
139
- "no-process-env": "off",
140
- },
141
- },
142
- {
143
- files: ["*.ts", "*.tsx"],
144
- rules: {
145
- "func-names": "off",
146
- },
147
- },
148
- ],
149
- }
package/eslint/library.js DELETED
@@ -1,28 +0,0 @@
1
- /** @type {import("eslint").Linter.Config} */
2
- module.exports = {
3
- extends: [
4
- "eslint:recommended",
5
- "prettier",
6
- require.resolve("@vercel/style-guide/eslint/node"),
7
- require.resolve("@vercel/style-guide/eslint/typescript"),
8
- require.resolve("./base"),
9
- ],
10
- globals: {
11
- React: true,
12
- JSX: true,
13
- },
14
- env: {
15
- node: true,
16
- },
17
- ignorePatterns: [
18
- // Ignore dotfiles
19
- ".*.js",
20
- "node_modules/",
21
- "dist/",
22
- ],
23
- overrides: [
24
- {
25
- files: ["*.js?(x)", "*.ts?(x)"],
26
- },
27
- ],
28
- }
package/eslint/next.js DELETED
@@ -1,23 +0,0 @@
1
- /** @type {import("eslint").Linter.Config} */
2
- module.exports = {
3
- extends: [
4
- "eslint:recommended",
5
- "prettier",
6
- require.resolve("@vercel/style-guide/eslint/next"),
7
- require.resolve("./base"),
8
- ],
9
- globals: {
10
- React: true,
11
- JSX: true,
12
- },
13
- env: {
14
- node: true,
15
- browser: true,
16
- },
17
- ignorePatterns: [
18
- // Ignore dotfiles
19
- ".*.js",
20
- "node_modules/",
21
- ],
22
- overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }],
23
- }
@@ -1,25 +0,0 @@
1
- /** @type {import("eslint").Linter.Config} */
2
- module.exports = {
3
- extends: [
4
- "eslint:recommended",
5
- "prettier",
6
- require.resolve("@vercel/style-guide/eslint/react"),
7
- require.resolve("./base"),
8
- ],
9
- globals: {
10
- React: true,
11
- },
12
- env: {
13
- browser: true,
14
- },
15
- ignorePatterns: [
16
- // Ignore dotfiles
17
- ".*.js",
18
- "node_modules/",
19
- "dist/",
20
- ],
21
- overrides: [
22
- // Force ESLint to detect .tsx files
23
- { files: ["*.js?(x)", "*.ts?(x)"] },
24
- ],
25
- }