@shun-shobon/style-guide 1.2.0 → 1.3.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/dist/eslint/index.d.mts +4448 -0
- package/dist/eslint/index.mjs +519 -0
- package/dist/eslint/index.mjs.map +1 -0
- package/dist/prettier/index.d.mts +61 -0
- package/dist/prettier/index.mjs +103 -0
- package/dist/prettier/index.mjs.map +1 -0
- package/package.json +19 -18
- package/dist/eslint/index.d.ts +0 -4995
- package/dist/eslint/index.js +0 -831
- package/dist/eslint/index.js.map +0 -1
- package/dist/prettier/index.d.ts +0 -53
- package/dist/prettier/index.js +0 -127
- package/dist/prettier/index.js.map +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Options } from "prettier";
|
|
2
|
+
import { Options as Options$1 } from "prettier-plugin-jsdoc";
|
|
3
|
+
import { PluginOptions } from "prettier-plugin-tailwindcss";
|
|
4
|
+
|
|
5
|
+
//#region src/prettier/types.d.ts
|
|
6
|
+
interface Options$2 extends Options, Options$1, PluginOptions {}
|
|
7
|
+
interface Config extends Options$2 {
|
|
8
|
+
overrides?: {
|
|
9
|
+
files: string | string[];
|
|
10
|
+
excludeFiles?: string | string[];
|
|
11
|
+
options?: Options$2;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
interface OptionsConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Enable Tailwind CSS support.
|
|
17
|
+
*
|
|
18
|
+
* @default auto-detect based on the dependencies
|
|
19
|
+
*/
|
|
20
|
+
tailwindcss?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Enable Astro support.
|
|
23
|
+
*
|
|
24
|
+
* @default auto-detect based on the dependencies
|
|
25
|
+
*/
|
|
26
|
+
astro?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Ignore files.
|
|
29
|
+
*/
|
|
30
|
+
ignoreFiles?: string[];
|
|
31
|
+
}
|
|
32
|
+
interface OptionsIgnores {
|
|
33
|
+
/**
|
|
34
|
+
* Ignore files.
|
|
35
|
+
*/
|
|
36
|
+
ignoreFiles?: string[];
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/prettier/configs/astro.d.ts
|
|
40
|
+
declare function astro(): Config;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/prettier/configs/base.d.ts
|
|
43
|
+
declare function base(): Config;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/prettier/configs/ignores.d.ts
|
|
46
|
+
declare function ignores(options?: OptionsIgnores): Config;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/prettier/configs/jsdoc.d.ts
|
|
49
|
+
declare function jsdoc(): Config;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/prettier/configs/package-json.d.ts
|
|
52
|
+
declare function packageJson(): Config;
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/prettier/configs/tailwindcss.d.ts
|
|
55
|
+
declare function tailwindcss(): Config;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/prettier/factory.d.ts
|
|
58
|
+
declare function shun_shobon(options?: OptionsConfig, userConfig?: Config): Config;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { astro, base, ignores, jsdoc, packageJson, shun_shobon, tailwindcss };
|
|
61
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { isPackageExists } from "local-pkg";
|
|
2
|
+
import * as url from "node:url";
|
|
3
|
+
|
|
4
|
+
//#region src/prettier/utils.ts
|
|
5
|
+
function resolve(pkg) {
|
|
6
|
+
return url.fileURLToPath(import.meta.resolve(pkg));
|
|
7
|
+
}
|
|
8
|
+
function mergeConfig(...configs) {
|
|
9
|
+
return configs.reduce((acc, config) => {
|
|
10
|
+
return {
|
|
11
|
+
...acc,
|
|
12
|
+
...config,
|
|
13
|
+
overrides: [...acc.overrides ?? [], ...config.overrides ?? []],
|
|
14
|
+
plugins: [...acc.plugins ?? [], ...config.plugins ?? []]
|
|
15
|
+
};
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/prettier/configs/astro.ts
|
|
21
|
+
function astro() {
|
|
22
|
+
return {
|
|
23
|
+
plugins: [resolve("prettier-plugin-astro")],
|
|
24
|
+
overrides: [{
|
|
25
|
+
files: ["*.astro"],
|
|
26
|
+
options: { parser: "astro" }
|
|
27
|
+
}]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/prettier/configs/base.ts
|
|
33
|
+
function base() {
|
|
34
|
+
return {
|
|
35
|
+
useTabs: true,
|
|
36
|
+
quoteProps: "consistent",
|
|
37
|
+
trailingComma: "all",
|
|
38
|
+
overrides: [{
|
|
39
|
+
files: ["tsconfig.json", "jsconfig.json"],
|
|
40
|
+
options: { parser: "jsonc" }
|
|
41
|
+
}]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/prettier/configs/ignores.ts
|
|
47
|
+
const DEFAULT_IGNORES = [
|
|
48
|
+
"**/package-lock.json",
|
|
49
|
+
"**/pnpm-lock.yaml",
|
|
50
|
+
"**/.yarn/**"
|
|
51
|
+
];
|
|
52
|
+
function ignores(options = {}) {
|
|
53
|
+
const { ignoreFiles = [] } = options;
|
|
54
|
+
return { overrides: [{
|
|
55
|
+
files: [...DEFAULT_IGNORES, ...ignoreFiles],
|
|
56
|
+
options: { requirePragma: true }
|
|
57
|
+
}] };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/prettier/configs/jsdoc.ts
|
|
62
|
+
function jsdoc() {
|
|
63
|
+
return {
|
|
64
|
+
plugins: [resolve("prettier-plugin-jsdoc")],
|
|
65
|
+
tsdoc: true,
|
|
66
|
+
jsdocPreferCodeFences: true,
|
|
67
|
+
jsdocCommentLineStrategy: "multiline"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/prettier/configs/package-json.ts
|
|
73
|
+
function packageJson() {
|
|
74
|
+
return { plugins: [resolve("prettier-plugin-pkg")] };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/prettier/configs/tailwindcss.ts
|
|
79
|
+
function tailwindcss() {
|
|
80
|
+
return {
|
|
81
|
+
plugins: [resolve("prettier-plugin-tailwindcss")],
|
|
82
|
+
tailwindFunctions: ["twMerge", "clsx"]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/prettier/factory.ts
|
|
88
|
+
function shun_shobon(options = {}, userConfig = {}) {
|
|
89
|
+
const { tailwindcss: enableTailwindcss = isPackageExists("tailwindcss"), astro: enableAstro = isPackageExists("astro"), ignoreFiles = [] } = options;
|
|
90
|
+
const configs = [
|
|
91
|
+
base(),
|
|
92
|
+
packageJson(),
|
|
93
|
+
jsdoc(),
|
|
94
|
+
ignores({ ignoreFiles })
|
|
95
|
+
];
|
|
96
|
+
if (enableAstro) configs.push(astro());
|
|
97
|
+
if (enableTailwindcss) configs.push(tailwindcss());
|
|
98
|
+
return mergeConfig(...configs, userConfig);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { astro, base, ignores, jsdoc, packageJson, shun_shobon, tailwindcss };
|
|
103
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["configs: Config[]"],"sources":["../../src/prettier/utils.ts","../../src/prettier/configs/astro.ts","../../src/prettier/configs/base.ts","../../src/prettier/configs/ignores.ts","../../src/prettier/configs/jsdoc.ts","../../src/prettier/configs/package-json.ts","../../src/prettier/configs/tailwindcss.ts","../../src/prettier/factory.ts"],"sourcesContent":["import * as url from \"node:url\";\n\nimport type { Config } from \"./types\";\n\nexport function resolve(pkg: string): string {\n\treturn url.fileURLToPath(import.meta.resolve(pkg));\n}\n\nexport function mergeConfig(...configs: Config[]): Config {\n\treturn configs.reduce<Config>((acc, config) => {\n\t\treturn {\n\t\t\t...acc,\n\t\t\t...config,\n\t\t\toverrides: [...(acc.overrides ?? []), ...(config.overrides ?? [])],\n\t\t\tplugins: [...(acc.plugins ?? []), ...(config.plugins ?? [])],\n\t\t};\n\t}, {});\n}\n","import type { Config } from \"../types\";\nimport { resolve } from \"../utils\";\n\nexport function astro(): Config {\n\treturn {\n\t\tplugins: [resolve(\"prettier-plugin-astro\")],\n\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: [\"*.astro\"],\n\t\t\t\toptions: {\n\t\t\t\t\tparser: \"astro\",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n}\n","import type { Config } from \"../types\";\n\nexport function base(): Config {\n\treturn {\n\t\tuseTabs: true,\n\t\tquoteProps: \"consistent\",\n\n\t\t// This is the default, but VSCode's Prettier plugin doesn't respect it.\n\t\ttrailingComma: \"all\",\n\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: [\"tsconfig.json\", \"jsconfig.json\"],\n\t\t\t\toptions: {\n\t\t\t\t\tparser: \"jsonc\",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n}\n","import type { Config, OptionsIgnores } from \"../types\";\n\nconst DEFAULT_IGNORES = [\n\t\"**/package-lock.json\",\n\t\"**/pnpm-lock.yaml\",\n\t\"**/.yarn/**\",\n];\n\nexport function ignores(options: OptionsIgnores = {}): Config {\n\tconst { ignoreFiles = [] } = options;\n\n\treturn {\n\t\toverrides: [\n\t\t\t// https://github.com/prettier/prettier/issues/4708#issuecomment-1448705672\n\t\t\t{\n\t\t\t\tfiles: [...DEFAULT_IGNORES, ...ignoreFiles],\n\t\t\t\toptions: {\n\t\t\t\t\trequirePragma: true,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n}\n","import type { Config } from \"../types\";\nimport { resolve } from \"../utils\";\n\nexport function jsdoc(): Config {\n\treturn {\n\t\tplugins: [resolve(\"prettier-plugin-jsdoc\")],\n\n\t\ttsdoc: true,\n\t\tjsdocPreferCodeFences: true,\n\t\tjsdocCommentLineStrategy: \"multiline\",\n\t};\n}\n","import type { Config } from \"../types\";\nimport { resolve } from \"../utils\";\n\nexport function packageJson(): Config {\n\treturn {\n\t\tplugins: [resolve(\"prettier-plugin-pkg\")],\n\t};\n}\n","import type { Config } from \"../types\";\nimport { resolve } from \"../utils\";\n\nexport function tailwindcss(): Config {\n\treturn {\n\t\tplugins: [resolve(\"prettier-plugin-tailwindcss\")],\n\n\t\ttailwindFunctions: [\"twMerge\", \"clsx\"],\n\t};\n}\n","import { isPackageExists } from \"local-pkg\";\n\nimport {\n\tastro,\n\tbase,\n\tignores,\n\tjsdoc,\n\tpackageJson,\n\ttailwindcss,\n} from \"./configs\";\nimport type { Config, OptionsConfig } from \"./types\";\nimport { mergeConfig } from \"./utils\";\n\nexport function shun_shobon(\n\toptions: OptionsConfig = {},\n\tuserConfig: Config = {},\n): Config {\n\tconst {\n\t\ttailwindcss: enableTailwindcss = isPackageExists(\"tailwindcss\"),\n\t\tastro: enableAstro = isPackageExists(\"astro\"),\n\t\tignoreFiles = [],\n\t} = options;\n\n\t// basic configs\n\tconst configs: Config[] = [\n\t\tbase(),\n\t\tpackageJson(),\n\t\tjsdoc(),\n\t\tignores({ ignoreFiles }),\n\t];\n\n\tif (enableAstro) {\n\t\tconfigs.push(astro());\n\t}\n\n\t// パーサの都合上、Tailwind CSSは一番最後に追加する\n\tif (enableTailwindcss) {\n\t\tconfigs.push(tailwindcss());\n\t}\n\n\treturn mergeConfig(...configs, userConfig);\n}\n"],"mappings":";;;;AAIA,SAAgB,QAAQ,KAAqB;AAC5C,QAAO,IAAI,cAAc,OAAO,KAAK,QAAQ,IAAI,CAAC;;AAGnD,SAAgB,YAAY,GAAG,SAA2B;AACzD,QAAO,QAAQ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C/D,OAAO,cAAc,gBAAgB,QAAQ,EAC7C,cAAc,EAAE,KACb;CAGJ,MAAMA,UAAoB;EACzB,MAAM;EACN,aAAa;EACb,OAAO;EACP,QAAQ,EAAE,aAAa,CAAC;EACxB;AAED,KAAI,YACH,SAAQ,KAAK,OAAO,CAAC;AAItB,KAAI,kBACH,SAAQ,KAAK,aAAa,CAAC;AAG5B,QAAO,YAAY,GAAG,SAAS,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shun-shobon/style-guide",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "shun-shobon's engineering style guide",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/shun-shobon/
|
|
8
|
+
"url": "https://github.com/shun-shobon/style-guide.git"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/shun-shobon/style-guide#readme",
|
|
11
11
|
"author": "NISHIZAWA Shuntaro <me@s2n.tech> (https://s2n.tech/)",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"exports": {
|
|
14
14
|
"./eslint": {
|
|
15
|
-
"import": "./dist/eslint/index.
|
|
15
|
+
"import": "./dist/eslint/index.mjs"
|
|
16
16
|
},
|
|
17
17
|
"./prettier": {
|
|
18
|
-
"import": "./dist/prettier/index.
|
|
18
|
+
"import": "./dist/prettier/index.mjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@eslint/core": "1.0.0",
|
|
40
|
-
"@eslint/js": "9.39.
|
|
41
|
-
"@next/eslint-plugin-next": "16.0.
|
|
42
|
-
"@typescript-eslint/parser": "8.
|
|
40
|
+
"@eslint/js": "9.39.2",
|
|
41
|
+
"@next/eslint-plugin-next": "16.0.10",
|
|
42
|
+
"@typescript-eslint/parser": "8.50.0",
|
|
43
43
|
"astro-eslint-parser": "1.2.2",
|
|
44
44
|
"eslint-config-flat-gitignore": "2.1.0",
|
|
45
45
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
@@ -52,31 +52,32 @@
|
|
|
52
52
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
53
53
|
"eslint-plugin-regexp": "2.10.0",
|
|
54
54
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
55
|
-
"eslint-plugin-storybook": "10.1.
|
|
55
|
+
"eslint-plugin-storybook": "10.1.10",
|
|
56
56
|
"eslint-plugin-unicorn": "62.0.0",
|
|
57
57
|
"globals": "16.5.0",
|
|
58
58
|
"local-pkg": "1.1.2",
|
|
59
59
|
"prettier-plugin-astro": "0.14.1",
|
|
60
|
-
"prettier-plugin-jsdoc": "1.
|
|
60
|
+
"prettier-plugin-jsdoc": "1.8.0",
|
|
61
61
|
"prettier-plugin-pkg": "0.21.2",
|
|
62
|
-
"prettier-plugin-tailwindcss": "0.7.
|
|
63
|
-
"typescript-eslint": "8.
|
|
62
|
+
"prettier-plugin-tailwindcss": "0.7.2",
|
|
63
|
+
"typescript-eslint": "8.50.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@changesets/cli": "2.29.
|
|
67
|
-
"@types/node": "24.10.
|
|
68
|
-
"eslint": "9.39.
|
|
66
|
+
"@changesets/cli": "2.29.8",
|
|
67
|
+
"@types/node": "24.10.4",
|
|
68
|
+
"eslint": "9.39.2",
|
|
69
69
|
"eslint-typegen": "2.3.0",
|
|
70
|
-
"prettier": "3.7.
|
|
71
|
-
"
|
|
70
|
+
"prettier": "3.7.4",
|
|
71
|
+
"tsdown": "0.18.0",
|
|
72
72
|
"typescript": "5.9.3"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
|
-
"access": "public"
|
|
75
|
+
"access": "public",
|
|
76
|
+
"registry": "https://registry.npmjs.org"
|
|
76
77
|
},
|
|
77
78
|
"sideEffects": false,
|
|
78
79
|
"scripts": {
|
|
79
|
-
"build": "
|
|
80
|
+
"build": "tsdown",
|
|
80
81
|
"format": "prettier --write .",
|
|
81
82
|
"format:check": "prettier --check .",
|
|
82
83
|
"lint": "eslint",
|