pob 19.1.1 → 20.0.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/CHANGELOG.md +22 -0
- package/lib/generators/app/PobAppGenerator.js +120 -120
- package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +11 -11
- package/lib/generators/app/ignorePaths.js +24 -24
- package/lib/generators/app/nextjs/AppNextjsGenerator.js +9 -9
- package/lib/generators/app/remix/AppRemixGenerator.js +7 -7
- package/lib/generators/common/babel/CommonBabelGenerator.js +146 -146
- package/lib/generators/common/format-lint/CommonLintGenerator.js +185 -185
- package/lib/generators/common/format-lint/updateEslintConfig.js +14 -15
- package/lib/generators/common/husky/CommonHuskyGenerator.js +44 -44
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +44 -44
- package/lib/generators/common/release/CommonReleaseGenerator.js +40 -40
- package/lib/generators/common/testing/CommonTestingGenerator.js +190 -190
- package/lib/generators/common/testing/templates/index.js +3 -3
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +163 -163
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +79 -79
- package/lib/generators/common/typescript/templates/tsconfig.js.json.ejs +12 -0
- package/lib/generators/core/ci/CoreCIGenerator.js +72 -72
- package/lib/generators/core/clean/CoreCleanGenerator.js +4 -4
- package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +3 -3
- package/lib/generators/core/git/CoreGitGenerator.js +43 -43
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +43 -43
- package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +19 -19
- package/lib/generators/core/npm/CoreNpmGenerator.js +20 -20
- package/lib/generators/core/package/CorePackageGenerator.js +98 -98
- package/lib/generators/core/package/askName.js +4 -4
- package/lib/generators/core/renovate/CoreRenovateGenerator.js +28 -28
- package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +6 -6
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +43 -43
- package/lib/generators/core/yarn/CoreYarnGenerator.js +70 -70
- package/lib/generators/lib/PobLibGenerator.js +111 -111
- package/lib/generators/lib/doc/LibDocGenerator.js +45 -45
- package/lib/generators/lib/readme/LibReadmeGenerator.js +21 -21
- package/lib/generators/monorepo/PobMonorepoGenerator.js +89 -89
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +47 -47
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +38 -38
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +57 -57
- package/lib/generators/pob/PobBaseGenerator.js +81 -81
- package/lib/pob-dirname.cjs +1 -1
- package/lib/pob.js +143 -143
- package/lib/utils/dependenciesPackages.cjs +4 -4
- package/lib/utils/ensureJsonFileFormatted.js +5 -5
- package/lib/utils/inMonorepo.js +8 -8
- package/lib/utils/json5.js +1 -1
- package/lib/utils/package.js +43 -43
- package/lib/utils/packagejson.cjs +2 -2
- package/lib/utils/templateUtils.js +1 -1
- package/lib/utils/writeAndFormat.js +9 -10
- package/package.json +10 -10
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import Generator from
|
|
4
|
-
import ensureJsonFileFormatted from
|
|
5
|
-
import inMonorepo from
|
|
6
|
-
import * as packageUtils from
|
|
7
|
-
import { writeAndFormatJson } from
|
|
8
|
-
import { appIgnorePaths } from
|
|
9
|
-
import updateEslintConfig from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import Generator from "yeoman-generator";
|
|
4
|
+
import ensureJsonFileFormatted from "../../../utils/ensureJsonFileFormatted.js";
|
|
5
|
+
import inMonorepo from "../../../utils/inMonorepo.js";
|
|
6
|
+
import * as packageUtils from "../../../utils/package.js";
|
|
7
|
+
import { writeAndFormatJson } from "../../../utils/writeAndFormat.js";
|
|
8
|
+
import { appIgnorePaths } from "../../app/ignorePaths.js";
|
|
9
|
+
import updateEslintConfig from "./updateEslintConfig.js";
|
|
10
10
|
|
|
11
11
|
export default class CommonLintGenerator extends Generator {
|
|
12
12
|
constructor(args, opts) {
|
|
13
13
|
super(args, opts);
|
|
14
14
|
|
|
15
|
-
this.option(
|
|
15
|
+
this.option("monorepo", {
|
|
16
16
|
type: Boolean,
|
|
17
17
|
required: false,
|
|
18
18
|
default: false,
|
|
19
|
-
description:
|
|
19
|
+
description: "Is root monorepo",
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
this.option(
|
|
22
|
+
this.option("isApp", {
|
|
23
23
|
type: Boolean,
|
|
24
24
|
required: false,
|
|
25
25
|
default: false,
|
|
26
|
-
description:
|
|
26
|
+
description: "Is app",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
this.option(
|
|
29
|
+
this.option("babel", {
|
|
30
30
|
type: String,
|
|
31
31
|
required: false,
|
|
32
|
-
default:
|
|
33
|
-
desc:
|
|
32
|
+
default: "undefined",
|
|
33
|
+
desc: "Use babel.",
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
this.option(
|
|
36
|
+
this.option("documentation", {
|
|
37
37
|
type: Boolean,
|
|
38
38
|
required: false,
|
|
39
39
|
default: false,
|
|
40
|
-
desc:
|
|
40
|
+
desc: "Documentation enabled",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
this.option(
|
|
43
|
+
this.option("testing", {
|
|
44
44
|
type: Boolean,
|
|
45
45
|
required: true,
|
|
46
|
-
desc:
|
|
46
|
+
desc: "Testing enabled",
|
|
47
47
|
});
|
|
48
|
-
this.option(
|
|
48
|
+
this.option("testRunner", {
|
|
49
49
|
type: String,
|
|
50
50
|
required: false,
|
|
51
|
-
default:
|
|
52
|
-
desc:
|
|
51
|
+
default: "jest",
|
|
52
|
+
desc: "test runner: jest | node",
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
this.option(
|
|
55
|
+
this.option("typescript", {
|
|
56
56
|
type: Boolean,
|
|
57
57
|
required: false,
|
|
58
58
|
default: false,
|
|
59
|
-
desc:
|
|
59
|
+
desc: "Typescript enabled",
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
this.option(
|
|
62
|
+
this.option("enableSrcResolver", {
|
|
63
63
|
type: Boolean,
|
|
64
64
|
required: false,
|
|
65
65
|
default: false,
|
|
66
|
-
desc:
|
|
66
|
+
desc: "Enable resolving from src directory",
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
this.option(
|
|
69
|
+
this.option("rootAsSrc", {
|
|
70
70
|
type: Boolean,
|
|
71
71
|
required: false,
|
|
72
72
|
default: false,
|
|
73
|
-
desc:
|
|
73
|
+
desc: "src directory is root",
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
this.option(
|
|
76
|
+
this.option("appTypes", {
|
|
77
77
|
type: String,
|
|
78
78
|
required: false,
|
|
79
|
-
desc:
|
|
79
|
+
desc: "list of app types",
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
this.option(
|
|
82
|
+
this.option("rootIgnorePaths", {
|
|
83
83
|
type: String,
|
|
84
84
|
required: false,
|
|
85
|
-
default:
|
|
86
|
-
desc:
|
|
85
|
+
default: "",
|
|
86
|
+
desc: "list of ignore paths to add",
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
this.option(
|
|
89
|
+
this.option("ignorePaths", {
|
|
90
90
|
type: String,
|
|
91
91
|
required: false,
|
|
92
|
-
default:
|
|
93
|
-
desc:
|
|
92
|
+
default: "",
|
|
93
|
+
desc: "list of ignore paths to add",
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
this.option(
|
|
96
|
+
this.option("packageManager", {
|
|
97
97
|
type: String,
|
|
98
|
-
default:
|
|
99
|
-
desc:
|
|
98
|
+
default: "yarn",
|
|
99
|
+
desc: "yarn or npm",
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
this.option(
|
|
102
|
+
this.option("yarnNodeLinker", {
|
|
103
103
|
type: String,
|
|
104
104
|
required: false,
|
|
105
|
-
default:
|
|
106
|
-
desc:
|
|
105
|
+
default: "node-modules",
|
|
106
|
+
desc: "Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
this.option(
|
|
109
|
+
this.option("srcDirectory", {
|
|
110
110
|
type: String,
|
|
111
|
-
default:
|
|
112
|
-
desc:
|
|
111
|
+
default: "src",
|
|
112
|
+
desc: "customize src directory. Default to src",
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
this.option(
|
|
115
|
+
this.option("buildDirectory", {
|
|
116
116
|
type: String,
|
|
117
117
|
required: false,
|
|
118
|
-
default:
|
|
118
|
+
default: "dist",
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
writing() {
|
|
123
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
123
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
124
124
|
const babelEnvs = (pkg.pob && pkg.pob.babelEnvs) || [];
|
|
125
125
|
// const typescriptTargets = (pkg.pob && pkg.pob.typescriptTargets) || [];
|
|
126
126
|
const useBabel =
|
|
127
|
-
this.options.babel !==
|
|
128
|
-
? this.options.babel ===
|
|
127
|
+
this.options.babel !== "undefined"
|
|
128
|
+
? this.options.babel === "true"
|
|
129
129
|
: babelEnvs.length > 0;
|
|
130
130
|
const useTypescript = useBabel || pkg.pob?.typescript;
|
|
131
131
|
const hasReact = useTypescript && packageUtils.hasReact(pkg);
|
|
132
|
-
const useNode = !useBabel || babelEnvs.some((env) => env.target ===
|
|
132
|
+
const useNode = !useBabel || babelEnvs.some((env) => env.target === "node");
|
|
133
133
|
const useNodeOnly =
|
|
134
134
|
(!useBabel && !useTypescript) ||
|
|
135
135
|
(useTypescript &&
|
|
136
136
|
(!pkg.pob?.envs ||
|
|
137
|
-
pkg.pob?.envs?.every((env) => env.target ===
|
|
137
|
+
pkg.pob?.envs?.every((env) => env.target === "node")) &&
|
|
138
138
|
(!pkg.pob?.entries ||
|
|
139
139
|
pkg.pob?.entries.every(
|
|
140
140
|
(entry) =>
|
|
141
|
-
typeof entry ===
|
|
142
|
-
(entry.target && entry.target !==
|
|
141
|
+
typeof entry === "string" ||
|
|
142
|
+
(entry.target && entry.target !== "node")
|
|
143
143
|
))) ||
|
|
144
|
-
(babelEnvs.length > 0 && babelEnvs.every((env) => env.target ===
|
|
144
|
+
(babelEnvs.length > 0 && babelEnvs.every((env) => env.target === "node"));
|
|
145
145
|
|
|
146
|
-
if (this.fs.exists(this.destinationPath(
|
|
147
|
-
this.fs.delete(this.destinationPath(
|
|
146
|
+
if (this.fs.exists(this.destinationPath(".eslintignore"))) {
|
|
147
|
+
this.fs.delete(this.destinationPath(".eslintignore"));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if (pkg.scripts) {
|
|
@@ -161,14 +161,14 @@ export default class CommonLintGenerator extends Generator {
|
|
|
161
161
|
|
|
162
162
|
delete pkg.standard;
|
|
163
163
|
|
|
164
|
-
pkg.prettier =
|
|
164
|
+
pkg.prettier = "@pob/root/prettier-config";
|
|
165
165
|
|
|
166
166
|
if (!inMonorepo || inMonorepo.root || this.options.monorepo) {
|
|
167
167
|
const rootIgnorePatterns = new Set(
|
|
168
|
-
this.options.rootIgnorePaths.split(
|
|
168
|
+
this.options.rootIgnorePaths.split("\n").filter(Boolean)
|
|
169
169
|
);
|
|
170
170
|
const ignorePatterns = new Set(
|
|
171
|
-
this.options.ignorePaths.split(
|
|
171
|
+
this.options.ignorePaths.split("\n").filter(Boolean)
|
|
172
172
|
);
|
|
173
173
|
|
|
174
174
|
if (this.options.appTypes) {
|
|
@@ -177,15 +177,15 @@ export default class CommonLintGenerator extends Generator {
|
|
|
177
177
|
appIgnorePaths[appType]({})
|
|
178
178
|
.filter(Boolean)
|
|
179
179
|
.forEach((ignorePath) => {
|
|
180
|
-
if (ignorePath.startsWith(
|
|
180
|
+
if (ignorePath.startsWith("#")) return;
|
|
181
181
|
ignorePatterns.add(ignorePath);
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
this.fs.copyTpl(
|
|
187
|
-
this.templatePath(
|
|
188
|
-
this.destinationPath(
|
|
187
|
+
this.templatePath("prettierignore.ejs"),
|
|
188
|
+
this.destinationPath(".prettierignore"),
|
|
189
189
|
{
|
|
190
190
|
inRoot: !inMonorepo || inMonorepo.root || this.options.monorepo,
|
|
191
191
|
documentation: this.options.documentation,
|
|
@@ -195,42 +195,42 @@ export default class CommonLintGenerator extends Generator {
|
|
|
195
195
|
hasApp: this.options.hasApp,
|
|
196
196
|
rootIgnorePatterns: [...rootIgnorePatterns],
|
|
197
197
|
ignorePatterns: [...ignorePatterns],
|
|
198
|
-
}
|
|
198
|
+
}
|
|
199
199
|
);
|
|
200
|
-
} else if (this.fs.exists(this.destinationPath(
|
|
201
|
-
this.fs.delete(this.destinationPath(
|
|
200
|
+
} else if (this.fs.exists(this.destinationPath(".prettierignore"))) {
|
|
201
|
+
this.fs.delete(this.destinationPath(".prettierignore"));
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
if (pkg.devDependencies) {
|
|
205
|
-
if (pkg.devDependencies[
|
|
206
|
-
packageUtils.addDevDependencies(pkg, [
|
|
205
|
+
if (pkg.devDependencies["@pob/eslint-config-babel"]) {
|
|
206
|
+
packageUtils.addDevDependencies(pkg, ["@pob/eslint-config-typescript"]);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
packageUtils.removeDevDependencies(pkg, [
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
"@pob/eslint-config-babel",
|
|
212
|
+
"@pob/eslint-config-babel-node",
|
|
213
|
+
"@pob/eslint-config-node",
|
|
214
|
+
"@pob/eslint-config-typescript-node",
|
|
215
|
+
"babel-eslint",
|
|
216
|
+
"eslint-config-pob",
|
|
217
|
+
"typescript-eslint-parser",
|
|
218
|
+
"standard",
|
|
219
|
+
"eslint-import-resolver-node",
|
|
220
220
|
]);
|
|
221
221
|
|
|
222
|
-
if (!pkg.name.startsWith(
|
|
222
|
+
if (!pkg.name.startsWith("@pob/eslint-config")) {
|
|
223
223
|
packageUtils.removeDevDependencies(pkg, [
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
"eslint-plugin-jsx-a11y",
|
|
225
|
+
"eslint-config-airbnb",
|
|
226
|
+
"eslint-config-airbnb-base",
|
|
227
|
+
"eslint-config-prettier",
|
|
228
|
+
"eslint-plugin-babel",
|
|
229
|
+
"eslint-plugin-flowtype",
|
|
230
|
+
"eslint-plugin-prefer-class-properties",
|
|
231
|
+
"eslint-plugin-prettier",
|
|
232
|
+
"eslint-plugin-react",
|
|
233
|
+
"eslint-plugin-react-hooks",
|
|
234
234
|
]);
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -247,164 +247,164 @@ export default class CommonLintGenerator extends Generator {
|
|
|
247
247
|
inMonorepo.pobConfig.project.type;
|
|
248
248
|
|
|
249
249
|
if (this.options.monorepo && !globalEslint) {
|
|
250
|
-
throw new Error(
|
|
250
|
+
throw new Error("Please enable global eslint");
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
if (
|
|
254
254
|
globalEslint &&
|
|
255
255
|
!((inMonorepo && inMonorepo.root) || this.options.monorepo)
|
|
256
256
|
) {
|
|
257
|
-
if (!pkg.name.startsWith(
|
|
257
|
+
if (!pkg.name.startsWith("@pob/eslint-config")) {
|
|
258
258
|
packageUtils.removeDevDependencies(
|
|
259
259
|
pkg,
|
|
260
260
|
[
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
261
|
+
"eslint",
|
|
262
|
+
"prettier",
|
|
263
|
+
"@pob/eslint-config",
|
|
264
|
+
"@pob/eslint-config-typescript",
|
|
265
|
+
"@pob/eslint-config-typescript-react",
|
|
266
|
+
"@pob/eslint-config-react",
|
|
267
|
+
"@typescript-eslint/eslint-plugin",
|
|
268
|
+
"@typescript-eslint/parser",
|
|
269
|
+
"eslint-plugin-node",
|
|
270
|
+
"eslint-plugin-unicorn",
|
|
271
|
+
"eslint-plugin-import",
|
|
272
272
|
],
|
|
273
|
-
true
|
|
273
|
+
true
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
276
|
} else {
|
|
277
|
-
if (pkg.name !==
|
|
278
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
277
|
+
if (pkg.name !== "pob-monorepo") {
|
|
278
|
+
packageUtils.removeDevDependencies(pkg, ["prettier"]);
|
|
279
279
|
}
|
|
280
280
|
packageUtils.addOrRemoveDevDependencies(
|
|
281
281
|
pkg,
|
|
282
282
|
!globalEslint ||
|
|
283
283
|
(inMonorepo && inMonorepo.root) ||
|
|
284
284
|
this.options.monorepo ||
|
|
285
|
-
lernaProjectType ===
|
|
286
|
-
(rootPackageManager ===
|
|
287
|
-
rootYarnNodeLinker !==
|
|
285
|
+
lernaProjectType === "app" ||
|
|
286
|
+
(rootPackageManager === "yarn" &&
|
|
287
|
+
rootYarnNodeLinker !== "node-modules") ||
|
|
288
288
|
!!(pkg.peerDependencies && pkg.peerDependencies.eslint),
|
|
289
|
-
[
|
|
289
|
+
["eslint"]
|
|
290
290
|
);
|
|
291
291
|
const shouldHavePluginsDependencies =
|
|
292
|
-
rootPackageManager ===
|
|
292
|
+
rootPackageManager === "yarn" && rootYarnNodeLinker !== "node-modules";
|
|
293
293
|
|
|
294
294
|
if (
|
|
295
|
-
!pkg.name.startsWith(
|
|
296
|
-
!pkg.name.startsWith(
|
|
297
|
-
pkg.name !==
|
|
295
|
+
!pkg.name.startsWith("eslint-config") &&
|
|
296
|
+
!pkg.name.startsWith("@pob/eslint-config") &&
|
|
297
|
+
pkg.name !== "@pob/use-eslint-plugin"
|
|
298
298
|
) {
|
|
299
|
-
packageUtils.addDevDependencies(pkg, [
|
|
299
|
+
packageUtils.addDevDependencies(pkg, ["@pob/eslint-config"]);
|
|
300
300
|
packageUtils.addOrRemoveDevDependencies(
|
|
301
301
|
pkg,
|
|
302
302
|
shouldHavePluginsDependencies,
|
|
303
|
-
[
|
|
303
|
+
["eslint-plugin-import", "eslint-plugin-unicorn"]
|
|
304
304
|
);
|
|
305
305
|
|
|
306
306
|
packageUtils.addOrRemoveDevDependencies(
|
|
307
307
|
pkg,
|
|
308
308
|
shouldHavePluginsDependencies,
|
|
309
|
-
[
|
|
309
|
+
["eslint-plugin-node"]
|
|
310
310
|
);
|
|
311
311
|
|
|
312
312
|
if ((inMonorepo && inMonorepo.root) || this.options.monorepo) {
|
|
313
313
|
if (this.options.typescript) {
|
|
314
314
|
packageUtils.updateDevDependenciesIfPresent(pkg, [
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
"@pob/eslint-config-typescript",
|
|
316
|
+
"@pob/eslint-config-typescript-react",
|
|
317
317
|
]);
|
|
318
|
-
} else if (pkg.name !==
|
|
318
|
+
} else if (pkg.name !== "@pob/eslint-config-monorepo") {
|
|
319
319
|
packageUtils.removeDevDependencies(pkg, [
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
"@pob/eslint-config-typescript",
|
|
321
|
+
"@pob/eslint-config-typescript-react",
|
|
322
322
|
]);
|
|
323
323
|
}
|
|
324
324
|
packageUtils.addOrRemoveDevDependencies(
|
|
325
325
|
pkg,
|
|
326
326
|
this.options.typescript && shouldHavePluginsDependencies,
|
|
327
|
-
[
|
|
327
|
+
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]
|
|
328
328
|
);
|
|
329
329
|
} else {
|
|
330
330
|
packageUtils.addOrRemoveDevDependencies(pkg, useTypescript, [
|
|
331
|
-
|
|
331
|
+
"@pob/eslint-config-typescript",
|
|
332
332
|
]);
|
|
333
333
|
packageUtils.addOrRemoveDevDependencies(
|
|
334
334
|
pkg,
|
|
335
335
|
useTypescript && shouldHavePluginsDependencies,
|
|
336
|
-
[
|
|
336
|
+
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]
|
|
337
337
|
);
|
|
338
338
|
|
|
339
339
|
packageUtils.addOrRemoveDevDependencies(pkg, hasReact, [
|
|
340
|
-
|
|
340
|
+
"@pob/eslint-config-typescript-react",
|
|
341
341
|
]);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
const isPobEslintConfig =
|
|
347
|
-
pkg.name ===
|
|
348
|
-
pkg.name.startsWith(
|
|
349
|
-
pkg.name ===
|
|
347
|
+
pkg.name === "eslint-config-pob" ||
|
|
348
|
+
pkg.name.startsWith("@pob/eslint-config") ||
|
|
349
|
+
pkg.name === "@pob/use-eslint-plugin";
|
|
350
350
|
|
|
351
351
|
const extendsConfigRoot = (() => {
|
|
352
352
|
if (isPobEslintConfig) {
|
|
353
|
-
if (pkg.name ===
|
|
353
|
+
if (pkg.name === "@pob/eslint-config-monorepo") {
|
|
354
354
|
return [
|
|
355
|
-
pkg.type ===
|
|
356
|
-
?
|
|
357
|
-
:
|
|
355
|
+
pkg.type === "commonjs"
|
|
356
|
+
? "./@pob/eslint-config/lib/root-commonjs.js"
|
|
357
|
+
: "./@pob/eslint-config/lib/root-module.js",
|
|
358
358
|
];
|
|
359
359
|
}
|
|
360
360
|
return [
|
|
361
|
-
pkg.type ===
|
|
362
|
-
?
|
|
363
|
-
:
|
|
361
|
+
pkg.type === "commonjs"
|
|
362
|
+
? "../eslint-config/lib/root-commonjs.js"
|
|
363
|
+
: "../eslint-config/lib/root-module.js",
|
|
364
364
|
];
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
return [
|
|
368
|
-
pkg.type ===
|
|
369
|
-
?
|
|
370
|
-
:
|
|
368
|
+
pkg.type === "commonjs"
|
|
369
|
+
? "@pob/eslint-config/root-commonjs"
|
|
370
|
+
: "@pob/eslint-config/root-module",
|
|
371
371
|
];
|
|
372
372
|
})();
|
|
373
373
|
|
|
374
374
|
const extendsConfigSrc = (() => {
|
|
375
375
|
if (isPobEslintConfig) {
|
|
376
376
|
return [
|
|
377
|
-
pkg.type ===
|
|
378
|
-
?
|
|
379
|
-
:
|
|
377
|
+
pkg.type === "commonjs"
|
|
378
|
+
? "../../eslint-config/lib/node-commonjs"
|
|
379
|
+
: "../../eslint-config/lib/node-module",
|
|
380
380
|
];
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
if (useTypescript) {
|
|
384
384
|
return [
|
|
385
|
-
|
|
386
|
-
useNodeOnly &&
|
|
385
|
+
"@pob/eslint-config-typescript",
|
|
386
|
+
useNodeOnly && "@pob/eslint-config-typescript/node",
|
|
387
387
|
// useTypescript &&
|
|
388
388
|
// pkg.pob?.rollup === false &&
|
|
389
389
|
// '@pob/eslint-config-typescript/tsc-emit',
|
|
390
|
-
this.options.isApp &&
|
|
390
|
+
this.options.isApp && "@pob/eslint-config-typescript/app",
|
|
391
391
|
hasReact &&
|
|
392
392
|
`@pob/eslint-config-typescript-react${
|
|
393
|
-
pkg.dependencies?.[
|
|
393
|
+
pkg.dependencies?.["react-native-web"] ? "/react-native-web" : ""
|
|
394
394
|
}`,
|
|
395
395
|
].filter(Boolean);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
return [
|
|
399
|
-
pkg.type ===
|
|
400
|
-
?
|
|
401
|
-
:
|
|
399
|
+
pkg.type === "commonjs"
|
|
400
|
+
? "@pob/eslint-config/node-commonjs"
|
|
401
|
+
: "@pob/eslint-config/node-module",
|
|
402
402
|
];
|
|
403
403
|
})();
|
|
404
404
|
|
|
405
405
|
const ext = !useTypescript
|
|
406
|
-
? `{${pkg.type ===
|
|
407
|
-
: `${hasReact ?
|
|
406
|
+
? `{${pkg.type === "commonjs" ? "mjs" : "cjs"},js}`
|
|
407
|
+
: `${hasReact ? "{ts,tsx}" : "ts"}`;
|
|
408
408
|
|
|
409
409
|
const testRunner = globalTesting
|
|
410
410
|
? inMonorepo.pobConfig.monorepo.testRunner
|
|
@@ -413,12 +413,12 @@ export default class CommonLintGenerator extends Generator {
|
|
|
413
413
|
this.options.testing || globalTesting
|
|
414
414
|
? {
|
|
415
415
|
files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
|
|
416
|
-
...(testRunner == null || testRunner ===
|
|
416
|
+
...(testRunner == null || testRunner === "jest"
|
|
417
417
|
? { env: { jest: true } }
|
|
418
418
|
: {}),
|
|
419
419
|
rules: {
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
"import/no-extraneous-dependencies": [
|
|
421
|
+
"error",
|
|
422
422
|
{ devDependencies: true },
|
|
423
423
|
],
|
|
424
424
|
},
|
|
@@ -431,37 +431,37 @@ export default class CommonLintGenerator extends Generator {
|
|
|
431
431
|
// }
|
|
432
432
|
|
|
433
433
|
if (useTypescript) {
|
|
434
|
-
testsOverride.extends = [
|
|
435
|
-
delete testsOverride.rules[
|
|
434
|
+
testsOverride.extends = ["@pob/eslint-config-typescript/test"];
|
|
435
|
+
delete testsOverride.rules["import/no-extraneous-dependencies"];
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
const eslintrcBadPath = this.destinationPath(
|
|
439
|
+
const eslintrcBadPath = this.destinationPath(".eslintrc");
|
|
440
440
|
this.fs.delete(eslintrcBadPath);
|
|
441
441
|
this.fs.delete(`${eslintrcBadPath}.yml`);
|
|
442
442
|
this.fs.delete(`${eslintrcBadPath}.js`);
|
|
443
443
|
|
|
444
444
|
const rootEslintrcPath = this.options.rootAsSrc
|
|
445
445
|
? false
|
|
446
|
-
: this.destinationPath(
|
|
446
|
+
: this.destinationPath(".eslintrc.json");
|
|
447
447
|
|
|
448
448
|
const srcEslintrcPath = this.options.rootAsSrc
|
|
449
|
-
? this.destinationPath(
|
|
449
|
+
? this.destinationPath(".eslintrc.json")
|
|
450
450
|
: this.destinationPath(
|
|
451
451
|
`${
|
|
452
|
-
useTypescript ? `${this.options.srcDirectory}/` :
|
|
453
|
-
}.eslintrc.json
|
|
452
|
+
useTypescript ? `${this.options.srcDirectory}/` : "lib/"
|
|
453
|
+
}.eslintrc.json`
|
|
454
454
|
);
|
|
455
455
|
|
|
456
456
|
const getRootIgnorePatterns = () => {
|
|
457
457
|
const ignorePatterns = new Set();
|
|
458
458
|
|
|
459
459
|
if (inMonorepo && !inMonorepo.root && (useTypescript || pkg.types)) {
|
|
460
|
-
ignorePatterns.add(
|
|
460
|
+
ignorePatterns.add("*.d.ts");
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
if (inMonorepo && inMonorepo.root && this.options.documentation) {
|
|
464
|
-
ignorePatterns.add(
|
|
464
|
+
ignorePatterns.add("/docs");
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
if ((!inMonorepo || !inMonorepo.root) && useTypescript) {
|
|
@@ -474,15 +474,15 @@ export default class CommonLintGenerator extends Generator {
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
if (inMonorepo && inMonorepo.root && this.options.typescript) {
|
|
477
|
-
ignorePatterns.add(
|
|
477
|
+
ignorePatterns.add("/rollup.config.mjs");
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
if (this.options.rootIgnorePaths) {
|
|
481
481
|
this.options.rootIgnorePaths
|
|
482
|
-
.split(
|
|
482
|
+
.split("\n")
|
|
483
483
|
.filter(Boolean)
|
|
484
484
|
.forEach((ignorePath) => {
|
|
485
|
-
if (ignorePath.startsWith(
|
|
485
|
+
if (ignorePath.startsWith("#")) return;
|
|
486
486
|
ignorePatterns.add(ignorePath);
|
|
487
487
|
});
|
|
488
488
|
}
|
|
@@ -506,7 +506,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
506
506
|
rootIgnorePatterns.size === 0
|
|
507
507
|
? undefined
|
|
508
508
|
: [...rootIgnorePatterns],
|
|
509
|
-
}
|
|
509
|
+
}
|
|
510
510
|
);
|
|
511
511
|
|
|
512
512
|
writeAndFormatJson(this.fs, rootEslintrcPath, rootEslintrcConfig);
|
|
@@ -530,7 +530,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
530
530
|
? getRootIgnorePatterns()
|
|
531
531
|
: new Set();
|
|
532
532
|
if (useTypescript || pkg.types) {
|
|
533
|
-
ignorePatterns.add(
|
|
533
|
+
ignorePatterns.add("*.d.ts");
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
const srcEslintrcConfig = updateEslintConfig(
|
|
@@ -543,11 +543,11 @@ export default class CommonLintGenerator extends Generator {
|
|
|
543
543
|
ignorePatterns:
|
|
544
544
|
ignorePatterns.size === 0 ? undefined : [...ignorePatterns],
|
|
545
545
|
settings: {
|
|
546
|
-
|
|
546
|
+
"import/resolver": this.options.enableSrcResolver
|
|
547
547
|
? {
|
|
548
548
|
node: {
|
|
549
549
|
moduleDirectory: [
|
|
550
|
-
|
|
550
|
+
"node_modules",
|
|
551
551
|
this.options.srcDirectory,
|
|
552
552
|
],
|
|
553
553
|
},
|
|
@@ -555,7 +555,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
555
555
|
: false,
|
|
556
556
|
},
|
|
557
557
|
relativePath: inMonorepo ? inMonorepo.relative : undefined,
|
|
558
|
-
}
|
|
558
|
+
}
|
|
559
559
|
);
|
|
560
560
|
|
|
561
561
|
writeAndFormatJson(this.fs, srcEslintrcPath, srcEslintrcConfig);
|
|
@@ -567,44 +567,44 @@ export default class CommonLintGenerator extends Generator {
|
|
|
567
567
|
// see monorepo/lerna/index.js
|
|
568
568
|
if (!(inMonorepo && inMonorepo.root) && !this.options.monorepo) {
|
|
569
569
|
const srcDirectory =
|
|
570
|
-
useBabel || this.options.typescript ? this.options.srcDirectory :
|
|
570
|
+
useBabel || this.options.typescript ? this.options.srcDirectory : "lib";
|
|
571
571
|
const lintRootJsFiles = (useBabel && useNode) || !inMonorepo;
|
|
572
572
|
|
|
573
|
-
const lintPaths = [srcDirectory,
|
|
574
|
-
(dir) => fs.existsSync(this.destinationPath(dir))
|
|
573
|
+
const lintPaths = [srcDirectory, "bin", "scripts", "migrations"].filter(
|
|
574
|
+
(dir) => fs.existsSync(this.destinationPath(dir))
|
|
575
575
|
);
|
|
576
576
|
|
|
577
577
|
if (lintRootJsFiles) {
|
|
578
|
-
lintPaths.unshift(
|
|
578
|
+
lintPaths.unshift("*.{js,cjs,mjs}");
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
const args =
|
|
582
|
-
|
|
582
|
+
"--report-unused-disable-directives --resolve-plugins-relative-to . --quiet";
|
|
583
583
|
|
|
584
584
|
packageUtils.addScripts(pkg, {
|
|
585
|
-
|
|
585
|
+
"lint:eslint": globalEslint
|
|
586
586
|
? `yarn ../.. run eslint ${args} ${path
|
|
587
|
-
.relative(
|
|
588
|
-
.replace(
|
|
589
|
-
: `eslint ${args} ${lintPaths.join(
|
|
587
|
+
.relative("../..", ".")
|
|
588
|
+
.replace("\\", "/")}`
|
|
589
|
+
: `eslint ${args} ${lintPaths.join(" ")}`,
|
|
590
590
|
lint: `${
|
|
591
|
-
useTypescript && !composite ?
|
|
591
|
+
useTypescript && !composite ? "tsc && " : ""
|
|
592
592
|
}yarn run lint:eslint`,
|
|
593
593
|
});
|
|
594
594
|
|
|
595
595
|
if (!inMonorepo) {
|
|
596
596
|
pkg.scripts.lint = `yarn run lint:prettier && ${pkg.scripts.lint}`;
|
|
597
597
|
packageUtils.addScripts(pkg, {
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
"lint:prettier": "pob-root-prettier --check .",
|
|
599
|
+
"lint:prettier:fix": "pob-root-prettier --write .",
|
|
600
600
|
});
|
|
601
601
|
} else {
|
|
602
|
-
delete pkg.scripts[
|
|
602
|
+
delete pkg.scripts["lint:prettier"];
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
-
delete pkg.scripts[
|
|
605
|
+
delete pkg.scripts["typescript-check"];
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
this.fs.writeJSON(this.destinationPath(
|
|
608
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
609
609
|
}
|
|
610
610
|
}
|