@pob/root 27.16.0 → 28.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/createLintStagedConfig.js +56 -59
- package/package.json +3 -3
|
@@ -74,7 +74,8 @@ const hasOxlint = fs.existsSync(path.resolve(".oxlintrc.json"));
|
|
|
74
74
|
const isOxlintSupportedFile = (filename) =>
|
|
75
75
|
/\.[cm]?[jt]sx?$/.test(filename) && !filename.endsWith(".d.ts");
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
// oxfmt runs after the linters, as their fixes are not formatted.
|
|
78
|
+
const CODE_COMMANDS = [hasOxlint && OXLINT_FIX, ESLINT_FIX, OXFMT].filter(
|
|
78
79
|
Boolean,
|
|
79
80
|
);
|
|
80
81
|
|
|
@@ -172,10 +173,10 @@ const createLegacyConfig = ({
|
|
|
172
173
|
return [
|
|
173
174
|
...installAndDedupe,
|
|
174
175
|
pkg.scripts?.checks ? `${pm.name} run checks` : undefined,
|
|
176
|
+
ESLINT_FIX,
|
|
175
177
|
packagejsonFilenames.length === 0
|
|
176
178
|
? undefined
|
|
177
179
|
: withFilenames("oxfmt", packagejsonFilenames),
|
|
178
|
-
ESLINT_FIX,
|
|
179
180
|
getGitAddPmFilesCommand(),
|
|
180
181
|
].filter(Boolean);
|
|
181
182
|
},
|
|
@@ -223,65 +224,61 @@ const createConfig = ({
|
|
|
223
224
|
);
|
|
224
225
|
const matchesTscTrigger = createMatcher([tscTriggerPattern]);
|
|
225
226
|
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
: [];
|
|
227
|
+
// Both build the whole project, in parallel.
|
|
228
|
+
const buildCommands = (
|
|
229
|
+
hasRollup
|
|
230
|
+
? ["rollup --config rollup.config.mjs", hasTsconfig && "tsc -b"]
|
|
231
|
+
: [hasTsconfig && "tsc"]
|
|
232
|
+
).filter(Boolean);
|
|
233
233
|
|
|
234
|
+
// A single function at the top level: lint-staged runs its commands
|
|
235
|
+
// sequentially and does not append the matched filenames. A function inside a
|
|
236
|
+
// list of tasks would have its commands run in parallel.
|
|
234
237
|
return defineConfig({
|
|
235
|
-
"*":
|
|
236
|
-
(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
? [
|
|
280
|
-
createBuildTask("rollup --config rollup.config.mjs"),
|
|
281
|
-
hasTsconfig && createBuildTask("tsc -b"),
|
|
282
|
-
].filter(Boolean)
|
|
283
|
-
: hasTsconfig && createBuildTask("tsc"),
|
|
284
|
-
].filter(Boolean),
|
|
238
|
+
"*": (allStagedFiles) => {
|
|
239
|
+
const filenames = allStagedFiles.map(toRelativePosixPath);
|
|
240
|
+
const hasPmFiles = filenames.some(matchesPmFiles);
|
|
241
|
+
const eslintFilenames = filenames.filter(matchesEslint);
|
|
242
|
+
|
|
243
|
+
// Running on the whole project is simpler and avoids too long command
|
|
244
|
+
// lines when many files are staged.
|
|
245
|
+
const withFilenamesOrWholeProject = (command, commandFilenames) => {
|
|
246
|
+
if (commandFilenames.length === 0) return undefined;
|
|
247
|
+
if (commandFilenames.length > MAX_FILENAMES) return command;
|
|
248
|
+
return withFilenames(command, commandFilenames);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const getOxlintCommand = () => {
|
|
252
|
+
if (!hasOxlint) return undefined;
|
|
253
|
+
return withFilenamesOrWholeProject(
|
|
254
|
+
OXLINT_FIX,
|
|
255
|
+
eslintFilenames.filter(isOxlintSupportedFile),
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const getEslintCommand = () => {
|
|
260
|
+
// eslint runs on the whole project when a package.json, the lockfile
|
|
261
|
+
// or the package manager config changed, like in the legacy config,
|
|
262
|
+
// as lint rules depend on the dependencies themselves.
|
|
263
|
+
if (hasPmFiles) return ESLINT_FIX;
|
|
264
|
+
return withFilenamesOrWholeProject(ESLINT_FIX, eslintFilenames);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
return [
|
|
268
|
+
...(hasPmFiles ? installAndDedupe : []),
|
|
269
|
+
hasPmFiles && pkg.scripts?.checks ? `${pm.name} run checks` : undefined,
|
|
270
|
+
getOxlintCommand(),
|
|
271
|
+
getEslintCommand(),
|
|
272
|
+
// after the linters, as their fixes are not formatted
|
|
273
|
+
withFilenamesOrWholeProject(OXFMT, filenames),
|
|
274
|
+
hasPmFiles ? getGitAddPmFilesCommand() : undefined,
|
|
275
|
+
// after the tasks above, so that the build sees the formatted and
|
|
276
|
+
// fixed files
|
|
277
|
+
buildCommands.length > 0 && filenames.some(matchesTscTrigger)
|
|
278
|
+
? buildCommands
|
|
279
|
+
: undefined,
|
|
280
|
+
].filter(Boolean);
|
|
281
|
+
},
|
|
285
282
|
});
|
|
286
283
|
};
|
|
287
284
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/root",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "28.0.0",
|
|
4
4
|
"description": "root package",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/christophehurpeau/pob",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@commitlint/format": "21.2.3",
|
|
67
67
|
"@commitlint/lint": "21.2.3",
|
|
68
68
|
"@commitlint/types": "21.2.3",
|
|
69
|
-
"@pob/version": "
|
|
69
|
+
"@pob/version": "8.0.0",
|
|
70
70
|
"conventional-changelog-conventionalcommits": "^10.0.0",
|
|
71
71
|
"conventional-changelog-writer": "^9.0.0",
|
|
72
72
|
"conventional-commits-parser": "^7.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"oxlint": "1.85.0",
|
|
77
77
|
"oxlint-tsgolint": "7.0.2003",
|
|
78
78
|
"picomatch": "^4.0.7",
|
|
79
|
-
"pob-dependencies": "
|
|
79
|
+
"pob-dependencies": "28.0.0",
|
|
80
80
|
"semver": "^7.7.3"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|