@yoshinani/style-guide 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -175,17 +175,17 @@ module.exports = {
175
175
 
176
176
  このスタイルガイドは複数の TypeScript 設定を提供しています。これらの設定は LTS の Node.js バージョンに対応しており、それぞれに適した `lib`、`module`、`target`、`moduleResolution` 設定が含まれています。利用可能な設定は以下の通りです。
177
177
 
178
- | Node.js バージョン | TypeScript 設定 |
179
- | ------------------ | ----------------------------------------- |
180
- | v16 | `@yoshinani/style-guide/typescript/node16` |
181
- | v18 | `@yoshinani/style-guide/typescript/node18` |
182
- | v20 | `@yoshinani/style-guide/typescript/node20` |
178
+ | 種類 | 設定パッケージ名 |
179
+ | -------------- | --------------------------------------------------- |
180
+ | base | `@yoshinani/style-guide/typescript/base` |
181
+ | nextjs | `@yoshinani/style-guide/typescript/nextjs` |
182
+ | react-library | `@yoshinani/style-guide/typescript/react-library` |
183
183
 
184
184
  共有 TypeScript 設定を使うには、`tsconfig.json` に以下のように記載します。
185
185
 
186
186
  ```json
187
187
  {
188
- "extends": "@yoshinani/style-guide/typescript/node16"
188
+ "extends": "@yoshinani/style-guide/typescript"
189
189
  }
190
190
  ```
191
191
 
package/eslint/base.js ADDED
@@ -0,0 +1,133 @@
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", "eslint-plugin-import"],
15
+ rules: {
16
+ eqeqeq: ["error", "always", { null: "ignore" }],
17
+ "@typescript-eslint/no-confusing-void-expression": [
18
+ "error",
19
+ { ignoreArrowShorthand: true },
20
+ ],
21
+ "@typescript-eslint/no-shadow": "off",
22
+ "@typescript-eslint/no-misused-promises": [
23
+ "error",
24
+ { checksVoidReturn: { attributes: false } },
25
+ ],
26
+ "@typescript-eslint/restrict-template-expressions": [
27
+ "error",
28
+ {
29
+ allowAny: false,
30
+ allowBoolean: false,
31
+ allowNullish: false,
32
+ allowRegExp: false,
33
+ allowNever: false,
34
+ },
35
+ ],
36
+ // sort import statements
37
+ "import/order": [
38
+ "warn",
39
+ {
40
+ groups: [
41
+ "builtin",
42
+ "external",
43
+ "internal",
44
+ "parent",
45
+ "sibling",
46
+ "index",
47
+ ],
48
+ "newlines-between": "always",
49
+ alphabetize: { order: "asc" },
50
+ },
51
+ ],
52
+ // sort named imports within an import statement
53
+ "sort-imports": ["warn", { ignoreDeclarationSort: true }],
54
+ "no-restricted-syntax": [
55
+ "error",
56
+ {
57
+ selector: "TSEnumDeclaration",
58
+ message:
59
+ "TSのenumには様々な問題があります。enum as constを使用してください。",
60
+ },
61
+ {
62
+ selector: "ForInStatement",
63
+ message: "for文は使わず、forEach、map、filterなどを使用してください。",
64
+ },
65
+ {
66
+ selector: "ForOfStatement",
67
+ message: "for文は使わず、forEach、map、filterなどを使用してください。",
68
+ },
69
+ {
70
+ selector: "LabeledStatement",
71
+ message:
72
+ "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
73
+ },
74
+ {
75
+ selector: "WithStatement",
76
+ message:
77
+ "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
78
+ },
79
+ ],
80
+ "no-process-env": "error",
81
+ "no-restricted-imports": [
82
+ "warn",
83
+ {
84
+ paths: [
85
+ {
86
+ name: "yup",
87
+ message: "valibotを使用してください。",
88
+ },
89
+ {
90
+ name: "@material-tailwind/react",
91
+ message: "shadcn/uiを使用してください。",
92
+ },
93
+ {
94
+ name: "dayjs",
95
+ message: "date-fnsを使用してください。",
96
+ },
97
+ ],
98
+ patterns: [
99
+ {
100
+ group: ["lodash/*"],
101
+ message: "remedaを使用してください。",
102
+ },
103
+ ],
104
+ },
105
+ ],
106
+ },
107
+ overrides: [
108
+ {
109
+ files: [
110
+ "*.config.{mjs,ts}",
111
+ "app/**/{page,layout,not-found,*error,opengraph-image,apple-icon}.tsx",
112
+ "app/**/{sitemap,robots}.ts",
113
+ ],
114
+ rules: {
115
+ "import/no-default-export": "off",
116
+ "import/prefer-default-export": ["error", { target: "any" }],
117
+ },
118
+ },
119
+ {
120
+ files: ["env.ts"],
121
+ rules: {
122
+ "@typescript-eslint/dot-notation": "off",
123
+ "no-process-env": "off",
124
+ },
125
+ },
126
+ {
127
+ files: ["*.ts", "*.tsx"],
128
+ rules: {
129
+ "func-names": "off",
130
+ },
131
+ },
132
+ ],
133
+ }
@@ -0,0 +1,40 @@
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
+ extends: [
8
+ "eslint:recommended",
9
+ "prettier",
10
+ require.resolve("@vercel/style-guide/eslint/node"),
11
+ require.resolve("@vercel/style-guide/eslint/typescript"),
12
+ require.resolve("./base"),
13
+ ],
14
+ plugins: ["only-warn"],
15
+ globals: {
16
+ React: true,
17
+ JSX: true,
18
+ },
19
+ env: {
20
+ node: true,
21
+ },
22
+ settings: {
23
+ "import/resolver": {
24
+ typescript: {
25
+ project,
26
+ },
27
+ },
28
+ },
29
+ ignorePatterns: [
30
+ // Ignore dotfiles
31
+ ".*.js",
32
+ "node_modules/",
33
+ "dist/",
34
+ ],
35
+ overrides: [
36
+ {
37
+ files: ["*.js?(x)", "*.ts?(x)"],
38
+ },
39
+ ],
40
+ }
package/eslint/next.js ADDED
@@ -0,0 +1,35 @@
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
+ extends: [
8
+ "eslint:recommended",
9
+ "prettier",
10
+ require.resolve("@vercel/style-guide/eslint/next"),
11
+ require.resolve("./base"),
12
+ ],
13
+ globals: {
14
+ React: true,
15
+ JSX: true,
16
+ },
17
+ env: {
18
+ node: true,
19
+ browser: true,
20
+ },
21
+ plugins: ["only-warn"],
22
+ settings: {
23
+ "import/resolver": {
24
+ typescript: {
25
+ project,
26
+ },
27
+ },
28
+ },
29
+ ignorePatterns: [
30
+ // Ignore dotfiles
31
+ ".*.js",
32
+ "node_modules/",
33
+ ],
34
+ overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }],
35
+ }
@@ -0,0 +1,44 @@
1
+ const { resolve } = require("node:path")
2
+
3
+ const project = resolve(process.cwd(), "tsconfig.json")
4
+
5
+ /*
6
+ * This is a custom ESLint configuration for use with
7
+ * internal (bundled by their consumer) libraries
8
+ * that utilize React.
9
+ */
10
+
11
+ /** @type {import("eslint").Linter.Config} */
12
+ module.exports = {
13
+ extends: [
14
+ "eslint:recommended",
15
+ "prettier",
16
+ "turbo",
17
+ require.resolve("@vercel/style-guide/eslint/react"),
18
+ require.resolve("./base"),
19
+ ],
20
+ plugins: ["only-warn"],
21
+ globals: {
22
+ React: true,
23
+ },
24
+ env: {
25
+ browser: true,
26
+ },
27
+ settings: {
28
+ "import/resolver": {
29
+ typescript: {
30
+ project,
31
+ },
32
+ },
33
+ },
34
+ ignorePatterns: [
35
+ // Ignore dotfiles
36
+ ".*.js",
37
+ "node_modules/",
38
+ "dist/",
39
+ ],
40
+ overrides: [
41
+ // Force ESLint to detect .tsx files
42
+ { files: ["*.js?(x)", "*.ts?(x)"] },
43
+ ],
44
+ }
package/package.json CHANGED
@@ -1,20 +1,34 @@
1
1
  {
2
2
  "name": "@yoshinani/style-guide",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Yoshinani's Style Guide",
5
5
  "exports": {
6
6
  "./typescript": "./typescript/base.json",
7
7
  "./typescript/nextjs": "./typescript/nextjs.json",
8
- "./typescript/react-library": "./typescript/react-library.json"
8
+ "./typescript/react-library": "./typescript/react-library.json",
9
+ "./eslint/*": "./eslint/*.js"
9
10
  },
10
11
  "files": [
11
- "typescript"
12
+ "typescript",
13
+ "eslint"
12
14
  ],
15
+ "dependencies": {
16
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
17
+ "@typescript-eslint/parser": "^8.18.2",
18
+ "@vercel/style-guide": "^6.0.0",
19
+ "eslint-config-prettier": "^9.1.0",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "eslint-plugin-only-warn": "^1.1.0",
22
+ "eslint-plugin-tailwindcss": "^3.17.5"
23
+ },
13
24
  "devDependencies": {
14
25
  "@commitlint/cli": "^19.8.0",
15
26
  "@commitlint/config-conventional": "^19.8.0",
16
27
  "husky": "^9.1.7"
17
28
  },
29
+ "peerDependencies": {
30
+ "eslint": "^8"
31
+ },
18
32
  "packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
19
33
  "scripts": {
20
34
  "prepare": "husky"