-
Notifications
You must be signed in to change notification settings - Fork 1
/
node-settings.ts
111 lines (102 loc) · 2.68 KB
/
node-settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { GitPrecommitScript } from "./git-settings.ts";
import type { Extension, Settings } from "./vscode-settings.ts";
import { commonExtensions, commonSettings } from "./vscode-settings.ts";
export const nodeSettings: Settings = {
...commonSettings,
};
export const nodeExtensions: Extension[] = [
...commonExtensions,
];
export interface NodePackageConfig {
name: string;
version: string;
description: string;
main: string;
types: string;
files: string[];
scripts: NodePackageScriptsConfig;
repository: {
url: string;
};
publishConfig: {
registry: string;
};
keywords: string[];
author: string;
license: string;
dependencies: Record<string, string>;
bugs: {
url?: string;
};
homepage: string;
devDependencies: Record<string, string>;
}
export interface NodePackageScriptsConfig {
prepublishOnly: string;
build: string;
test: string;
lint: string;
}
export function nodeConfig(
config: Partial<NodePackageConfig>,
): NodePackageConfig {
return {
name: config.name || "<no name provided>",
version: config.version || "<no version provided>",
description: config.description || "<no description provided>",
main: "",
types: "",
files: [
"dist",
],
scripts: config.scripts || {
prepublishOnly: "tsc --project tsconfig.json",
build: "tsc --project tsconfig.json",
test: "alsatian './**/*.spec.ts'",
lint: "eslint . --ext .ts",
},
repository: config.repository || {
url: "<no repository provided>",
},
publishConfig: config.publishConfig || {
registry: "https://npm.pkg.github.com/",
},
keywords: config.keywords || [],
author: config.author || "<no author provided>",
license: config.license || "MIT",
dependencies: config.dependencies || {
"npm-package-name": "npm-package-version",
},
bugs: config.bugs || {},
homepage: config.homepage || "<no-homepage-provided>",
devDependencies: config.devDependencies || {
"npm-package-name": "npm-package-version",
},
};
}
export const nodeGitPrecommitScript: GitPrecommitScript = `eslint . --ext .ts`;
export interface NodeESLintSettings {
root: true;
parser: string;
parserOptions: {
project: string;
};
plugins: string[];
extends: string[];
}
export const nodeESLintSettings: NodeESLintSettings = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
plugins: [
"@typescript-eslint",
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
};
export const nodeESLintIgnoreDirs: string[] = ["node_modules", "dist"];