skuba 9.0.0-renovate-eslint-9.x-20240811012135 → 9.0.0-renovate-eslint-9.x-20240811060718
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/lib/cli/adapter/eslint.js +13 -2
- package/lib/cli/adapter/eslint.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +88 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +5 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +86 -23
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +3 -3
- package/lib/eslint.d.js +2 -0
- package/package.json +2 -2
- package/template/greeter/package.json +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +1 -1
- package/lib/why-is-node-running.d.js +0 -2
- /package/lib/{why-is-node-running.d.js.map → eslint.d.js.map} +0 -0
|
@@ -57,10 +57,21 @@ const runESLint = async (mode, logger, overrideConfigFile) => {
|
|
|
57
57
|
});
|
|
58
58
|
logger.debug("Processing files...");
|
|
59
59
|
const start = process.hrtime.bigint();
|
|
60
|
-
const [formatter, results] = await Promise.all([
|
|
60
|
+
const [formatter, { type, results }] = await Promise.all([
|
|
61
61
|
engine.loadFormatter(),
|
|
62
|
-
engine.lintFiles([])
|
|
62
|
+
engine.lintFiles([]).then((r) => ({ type: "results", results: r })).catch((error) => {
|
|
63
|
+
if (error instanceof Error && error.message === "Could not find config file.") {
|
|
64
|
+
return { type: "no-config", results: void 0 };
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
})
|
|
63
68
|
]);
|
|
69
|
+
if (type === "no-config") {
|
|
70
|
+
logger.plain(
|
|
71
|
+
"skuba could not find an eslint config file. Do you need to run format or configure?"
|
|
72
|
+
);
|
|
73
|
+
return { ok: false, fixable: false, errors: [], warnings: [], output: "" };
|
|
74
|
+
}
|
|
64
75
|
const end = process.hrtime.bigint();
|
|
65
76
|
logger.plain(
|
|
66
77
|
`Processed ${(0, import_logging.pluralise)(results.length, "file")} in ${logger.timing(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/adapter/eslint.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport { type ESLint, type Linter, loadESLint } from 'eslint';\n\nimport { type Logger, pluralise } from '../../utils/logging';\n\nconst symbolForResult = (result: ESLint.LintResult) => {\n if (result.errorCount) {\n return chalk.red('\u25CB');\n }\n\n return result.warningCount ? chalk.yellow('\u25CD') : chalk.green('\u25CB');\n};\n\nexport interface ESLintResult {\n messages: Linter.LintMessage[];\n filePath: string;\n}\n\nexport interface ESLintOutput {\n errors: ESLintResult[];\n fixable: boolean;\n ok: boolean;\n output: string;\n warnings: ESLintResult[];\n}\n\nexport const runESLint = async (\n mode: 'format' | 'lint',\n logger: Logger,\n overrideConfigFile?: string,\n): Promise<ESLintOutput> => {\n logger.debug('Initialising ESLint...');\n\n const cwd = process.cwd();\n\n const ESLint = await loadESLint({ useFlatConfig: true });\n const engine = new ESLint({\n cache: true,\n fix: mode === 'format',\n overrideConfigFile,\n overrideConfig: {\n linterOptions: {\n reportUnusedDisableDirectives: true,\n },\n },\n });\n\n logger.debug('Processing files...');\n\n const start = process.hrtime.bigint();\n\n const [formatter, results] = await Promise.all([\n engine.loadFormatter(),\n engine.lintFiles([]),\n ]);\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(results.length, 'file')} in ${logger.timing(\n start,\n end,\n )}.`,\n );\n\n const errors: ESLintResult[] = [];\n const warnings: ESLintResult[] = [];\n let fixable = false;\n\n for (const result of results) {\n const relativePath = path.relative(cwd, result.filePath);\n if (result.fixableErrorCount + result.fixableWarningCount) {\n fixable = true;\n }\n\n if (result.errorCount) {\n errors.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n if (result.warningCount) {\n warnings.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n logger.debug(symbolForResult(result), relativePath);\n }\n\n const ok = errors.length === 0;\n\n await ESLint.outputFixes(results);\n\n const output = await formatter.format(results, {\n cwd,\n rulesMeta: engine.getRulesMetaForResults(results),\n });\n\n if (output) {\n logger.plain(output);\n }\n\n return { errors, fixable, ok, output, warnings };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,oBAAqD;AAErD,qBAAuC;AAEvC,MAAM,kBAAkB,CAAC,WAA8B;AACrD,MAAI,OAAO,YAAY;AACrB,WAAO,aAAAA,QAAM,IAAI,QAAG;AAAA,EACtB;AAEA,SAAO,OAAO,eAAe,aAAAA,QAAM,OAAO,QAAG,IAAI,aAAAA,QAAM,MAAM,QAAG;AAClE;AAeO,MAAM,YAAY,OACvB,MACA,QACA,uBAC0B;AAC1B,SAAO,MAAM,wBAAwB;AAErC,QAAM,MAAM,QAAQ,IAAI;AAExB,QAAM,SAAS,UAAM,0BAAW,EAAE,eAAe,KAAK,CAAC;AACvD,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB,OAAO;AAAA,IACP,KAAK,SAAS;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,MACd,eAAe;AAAA,QACb,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,MAAM,qBAAqB;AAElC,QAAM,QAAQ,QAAQ,OAAO,OAAO;AAEpC,QAAM,CAAC,WAAW,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport { type ESLint, type Linter, loadESLint } from 'eslint';\n\nimport { type Logger, pluralise } from '../../utils/logging';\n\nconst symbolForResult = (result: ESLint.LintResult) => {\n if (result.errorCount) {\n return chalk.red('\u25CB');\n }\n\n return result.warningCount ? chalk.yellow('\u25CD') : chalk.green('\u25CB');\n};\n\nexport interface ESLintResult {\n messages: Linter.LintMessage[];\n filePath: string;\n}\n\nexport interface ESLintOutput {\n errors: ESLintResult[];\n fixable: boolean;\n ok: boolean;\n output: string;\n warnings: ESLintResult[];\n}\n\nexport const runESLint = async (\n mode: 'format' | 'lint',\n logger: Logger,\n overrideConfigFile?: string,\n): Promise<ESLintOutput> => {\n logger.debug('Initialising ESLint...');\n\n const cwd = process.cwd();\n\n const ESLint = await loadESLint({ useFlatConfig: true });\n const engine = new ESLint({\n cache: true,\n fix: mode === 'format',\n overrideConfigFile,\n overrideConfig: {\n linterOptions: {\n reportUnusedDisableDirectives: true,\n },\n },\n });\n\n logger.debug('Processing files...');\n\n const start = process.hrtime.bigint();\n\n const [formatter, { type, results }] = await Promise.all([\n engine.loadFormatter(),\n engine\n .lintFiles([])\n .then((r) => ({ type: 'results', results: r }) as const)\n .catch((error) => {\n if (\n error instanceof Error &&\n error.message === 'Could not find config file.'\n ) {\n return { type: 'no-config', results: undefined } as const;\n }\n throw error;\n }),\n ]);\n\n if (type === 'no-config') {\n logger.plain(\n 'skuba could not find an eslint config file. Do you need to run format or configure?',\n );\n return { ok: false, fixable: false, errors: [], warnings: [], output: '' };\n }\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(results.length, 'file')} in ${logger.timing(\n start,\n end,\n )}.`,\n );\n\n const errors: ESLintResult[] = [];\n const warnings: ESLintResult[] = [];\n let fixable = false;\n\n for (const result of results) {\n const relativePath = path.relative(cwd, result.filePath);\n if (result.fixableErrorCount + result.fixableWarningCount) {\n fixable = true;\n }\n\n if (result.errorCount) {\n errors.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n if (result.warningCount) {\n warnings.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n logger.debug(symbolForResult(result), relativePath);\n }\n\n const ok = errors.length === 0;\n\n await ESLint.outputFixes(results);\n\n const output = await formatter.format(results, {\n cwd,\n rulesMeta: engine.getRulesMetaForResults(results),\n });\n\n if (output) {\n logger.plain(output);\n }\n\n return { errors, fixable, ok, output, warnings };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,oBAAqD;AAErD,qBAAuC;AAEvC,MAAM,kBAAkB,CAAC,WAA8B;AACrD,MAAI,OAAO,YAAY;AACrB,WAAO,aAAAA,QAAM,IAAI,QAAG;AAAA,EACtB;AAEA,SAAO,OAAO,eAAe,aAAAA,QAAM,OAAO,QAAG,IAAI,aAAAA,QAAM,MAAM,QAAG;AAClE;AAeO,MAAM,YAAY,OACvB,MACA,QACA,uBAC0B;AAC1B,SAAO,MAAM,wBAAwB;AAErC,QAAM,MAAM,QAAQ,IAAI;AAExB,QAAM,SAAS,UAAM,0BAAW,EAAE,eAAe,KAAK,CAAC;AACvD,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB,OAAO;AAAA,IACP,KAAK,SAAS;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,MACd,eAAe;AAAA,QACb,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,MAAM,qBAAqB;AAElC,QAAM,QAAQ,QAAQ,OAAO,OAAO;AAEpC,QAAM,CAAC,WAAW,EAAE,MAAM,QAAQ,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACvD,OAAO,cAAc;AAAA,IACrB,OACG,UAAU,CAAC,CAAC,EACZ,KAAK,CAAC,OAAO,EAAE,MAAM,WAAW,SAAS,EAAE,EAAW,EACtD,MAAM,CAAC,UAAU;AAChB,UACE,iBAAi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|
|
6
6
|
"names": ["chalk", "path"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var collapseDuplicateMergeKeys_exports = {};
|
|
20
|
+
__export(collapseDuplicateMergeKeys_exports, {
|
|
21
|
+
tryCollapseDuplicateMergeKeys: () => tryCollapseDuplicateMergeKeys
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(collapseDuplicateMergeKeys_exports);
|
|
24
|
+
var import_util = require("util");
|
|
25
|
+
var import_fast_glob = require("fast-glob");
|
|
26
|
+
var import_fs_extra = require("fs-extra");
|
|
27
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
28
|
+
const collapseDuplicateMergeKeys = async ({
|
|
29
|
+
mode
|
|
30
|
+
}) => {
|
|
31
|
+
const buildkiteFiles = await (0, import_fast_glob.glob)(
|
|
32
|
+
[".buildkite/**/*.yml", ".buildkite/**/*.yaml"],
|
|
33
|
+
{ onlyFiles: true }
|
|
34
|
+
);
|
|
35
|
+
if (buildkiteFiles.length === 0) {
|
|
36
|
+
return { result: "skip", reason: "no Buildkite files found" };
|
|
37
|
+
}
|
|
38
|
+
const input = await Promise.all(
|
|
39
|
+
buildkiteFiles.map((name) => import_fs_extra.promises.readFile(name, "utf-8"))
|
|
40
|
+
);
|
|
41
|
+
const replaced = await Promise.all(
|
|
42
|
+
input.map(collapseDuplicateMergeKeysInFile)
|
|
43
|
+
);
|
|
44
|
+
if (replaced.every((r, i) => r === input[i])) {
|
|
45
|
+
return { result: "skip", reason: "no duplicate merge keys found" };
|
|
46
|
+
}
|
|
47
|
+
if (mode === "lint") {
|
|
48
|
+
return { result: "apply" };
|
|
49
|
+
}
|
|
50
|
+
await Promise.all(
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
52
|
+
buildkiteFiles.map((name, i) => import_fs_extra.promises.writeFile(name, replaced[i]))
|
|
53
|
+
);
|
|
54
|
+
return { result: "apply" };
|
|
55
|
+
};
|
|
56
|
+
const collapseDuplicateMergeKeysInFile = (input) => replaceAllUntilStable(
|
|
57
|
+
input,
|
|
58
|
+
/^([ \-]*)<<: \[?(\*[^\n\]]+)\]?$\n^( *)<<: \[?(\*[^\n\]]+)\]?$/gm,
|
|
59
|
+
(match, a, b, c, d) => {
|
|
60
|
+
if (a.length === c.length) {
|
|
61
|
+
return `${a}<<: [${b}, ${d}]`;
|
|
62
|
+
}
|
|
63
|
+
return match;
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const replaceAllUntilStable = (input, searchValue, replacer) => {
|
|
67
|
+
let output = input;
|
|
68
|
+
let previousOutput;
|
|
69
|
+
do {
|
|
70
|
+
previousOutput = output;
|
|
71
|
+
output = output.replace(searchValue, replacer);
|
|
72
|
+
} while (output !== previousOutput);
|
|
73
|
+
return output;
|
|
74
|
+
};
|
|
75
|
+
const tryCollapseDuplicateMergeKeys = async (config) => {
|
|
76
|
+
try {
|
|
77
|
+
return await collapseDuplicateMergeKeys(config);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
import_logging.log.warn("Failed to collapse duplicate merge keys.");
|
|
80
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
81
|
+
return { result: "skip", reason: "due to an error" };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
tryCollapseDuplicateMergeKeys
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=collapseDuplicateMergeKeys.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport { promises as fs } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\n\nconst collapseDuplicateMergeKeys: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const buildkiteFiles = await glob(\n ['.buildkite/**/*.yml', '.buildkite/**/*.yaml'],\n { onlyFiles: true },\n );\n\n if (buildkiteFiles.length === 0) {\n return { result: 'skip', reason: 'no Buildkite files found' };\n }\n\n const input = await Promise.all(\n buildkiteFiles.map((name) => fs.readFile(name, 'utf-8')),\n );\n\n const replaced = await Promise.all(\n input.map(collapseDuplicateMergeKeysInFile),\n );\n\n if (replaced.every((r, i) => r === input[i])) {\n return { result: 'skip', reason: 'no duplicate merge keys found' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await Promise.all(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n buildkiteFiles.map((name, i) => fs.writeFile(name, replaced[i]!)),\n );\n\n return { result: 'apply' };\n};\n\nconst collapseDuplicateMergeKeysInFile = (input: string) =>\n replaceAllUntilStable(\n input,\n /^([ \\-]*)<<: \\[?(\\*[^\\n\\]]+)\\]?$\\n^( *)<<: \\[?(\\*[^\\n\\]]+)\\]?$/gm,\n (match, a, b, c, d) => {\n if (a.length === c.length) {\n return `${a}<<: [${b}, ${d}]`;\n }\n return match;\n },\n );\n\nconst replaceAllUntilStable = (\n input: string,\n searchValue: RegExp,\n replacer: (substring: string, ...args: string[]) => string,\n): string => {\n let output = input;\n let previousOutput;\n\n do {\n previousOutput = output;\n output = output.replace(searchValue, replacer);\n } while (output !== previousOutput);\n\n return output;\n};\n\nexport const tryCollapseDuplicateMergeKeys: PatchFunction = async (config) => {\n try {\n return await collapseDuplicateMergeKeys(config);\n } catch (err) {\n log.warn('Failed to collapse duplicate merge keys.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAA+B;AAG/B,qBAAoB;AAEpB,MAAM,6BAA4C,OAAO;AAAA,EACvD;AACF,MAAgC;AAC9B,QAAM,iBAAiB,UAAM;AAAA,IAC3B,CAAC,uBAAuB,sBAAsB;AAAA,IAC9C,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,MAAI,eAAe,WAAW,GAAG;AAC/B,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,QAAM,QAAQ,MAAM,QAAQ;AAAA,IAC1B,eAAe,IAAI,CAAC,SAAS,gBAAAA,SAAG,SAAS,MAAM,OAAO,CAAC;AAAA,EACzD;AAEA,QAAM,WAAW,MAAM,QAAQ;AAAA,IAC7B,MAAM,IAAI,gCAAgC;AAAA,EAC5C;AAEA,MAAI,SAAS,MAAM,CAAC,GAAG,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG;AAC5C,WAAO,EAAE,QAAQ,QAAQ,QAAQ,gCAAgC;AAAA,EACnE;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,QAAQ;AAAA;AAAA,IAEZ,eAAe,IAAI,CAAC,MAAM,MAAM,gBAAAA,SAAG,UAAU,MAAM,SAAS,CAAC,CAAE,CAAC;AAAA,EAClE;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEA,MAAM,mCAAmC,CAAC,UACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA,CAAC,OAAO,GAAG,GAAG,GAAG,MAAM;AACrB,QAAI,EAAE,WAAW,EAAE,QAAQ;AACzB,aAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AACF;AAEF,MAAM,wBAAwB,CAC5B,OACA,aACA,aACW;AACX,MAAI,SAAS;AACb,MAAI;AAEJ,KAAG;AACD,qBAAiB;AACjB,aAAS,OAAO,QAAQ,aAAa,QAAQ;AAAA,EAC/C,SAAS,WAAW;AAEpB,SAAO;AACT;AAEO,MAAM,gCAA+C,OAAO,WAAW;AAC5E,MAAI;AACF,WAAO,MAAM,2BAA2B,MAAM;AAAA,EAChD,SAAS,KAAK;AACZ,uBAAI,KAAK,0CAA0C;AACnD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
|
+
}
|
|
@@ -21,8 +21,13 @@ __export(__exports, {
|
|
|
21
21
|
patches: () => patches
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(__exports);
|
|
24
|
+
var import_collapseDuplicateMergeKeys = require("./collapseDuplicateMergeKeys");
|
|
24
25
|
var import_upgradeESLint = require("./upgradeESLint");
|
|
25
26
|
const patches = [
|
|
27
|
+
{
|
|
28
|
+
apply: import_collapseDuplicateMergeKeys.tryCollapseDuplicateMergeKeys,
|
|
29
|
+
description: "Collapse duplicate merge keys in .buildkite files"
|
|
30
|
+
},
|
|
26
31
|
{
|
|
27
32
|
apply: import_upgradeESLint.tryUpgradeESLint,
|
|
28
33
|
description: "Upgrade to ESLint flat config"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.2.1/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryUpgradeESLint } from './upgradeESLint';\n\nexport const patches: Patches = [\n {\n apply: tryUpgradeESLint,\n description: 'Upgrade to ESLint flat config',\n },\n];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAAiC;AAE1B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryCollapseDuplicateMergeKeys } from './collapseDuplicateMergeKeys';\nimport { tryUpgradeESLint } from './upgradeESLint';\n\nexport const patches: Patches = [\n {\n apply: tryCollapseDuplicateMergeKeys,\n description: 'Collapse duplicate merge keys in .buildkite files',\n },\n {\n apply: tryUpgradeESLint,\n description: 'Upgrade to ESLint flat config',\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wCAA8C;AAC9C,2BAAiC;AAE1B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,55 +17,116 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var upgradeESLint_exports = {};
|
|
20
30
|
__export(upgradeESLint_exports, {
|
|
21
31
|
tryUpgradeESLint: () => tryUpgradeESLint
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(upgradeESLint_exports);
|
|
34
|
+
var fsp = __toESM(require("fs/promises"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
24
36
|
var import_util = require("util");
|
|
25
37
|
var import_fs_extra = require("fs-extra");
|
|
26
38
|
var import_exec = require("../../../../../../utils/exec");
|
|
27
39
|
var import_logging = require("../../../../../../utils/logging");
|
|
40
|
+
var import_project = require("../../../../../configure/analysis/project");
|
|
28
41
|
var import_configFile = require("../../../../../configure/processing/configFile");
|
|
42
|
+
var import_prettier = require("../../../../../configure/processing/prettier");
|
|
29
43
|
const upgradeESLint = async ({
|
|
30
|
-
mode
|
|
44
|
+
mode,
|
|
45
|
+
dir: cwd = process.cwd()
|
|
31
46
|
}) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
const readFile = (0, import_project.createDestinationFileReader)(cwd);
|
|
48
|
+
const [originalIgnoreContents, eslintConfig] = await Promise.all([
|
|
49
|
+
readFile(".eslintignore"),
|
|
50
|
+
readFile(".eslintrc.js")
|
|
51
|
+
]);
|
|
52
|
+
if (eslintConfig === void 0) {
|
|
53
|
+
return {
|
|
54
|
+
result: "skip",
|
|
55
|
+
reason: "no .eslintrc.js - have you already migrated?"
|
|
56
|
+
};
|
|
40
57
|
}
|
|
41
58
|
if (mode === "lint") {
|
|
42
59
|
return { result: "apply" };
|
|
43
60
|
}
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
);
|
|
61
|
+
const mergedIgnoreContent = (0, import_configFile.mergeWithConfigFile)(
|
|
62
|
+
"",
|
|
63
|
+
"ignore"
|
|
64
|
+
)(originalIgnoreContents);
|
|
48
65
|
const exec = (0, import_exec.createExec)({
|
|
49
66
|
cwd: process.cwd(),
|
|
50
67
|
stdio: "ignore"
|
|
51
68
|
});
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
const dir = await writeTemporaryFiles({
|
|
70
|
+
".eslintrc.js": eslintConfig,
|
|
71
|
+
...mergedIgnoreContent.trim().length > 0 ? { ".eslintignore": mergedIgnoreContent } : {}
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
await exec(
|
|
75
|
+
"eslint-migrate-config",
|
|
76
|
+
import_path.default.join(dir, ".eslintrc.js"),
|
|
77
|
+
"--commonjs"
|
|
78
|
+
);
|
|
79
|
+
const output = fiddleWithOutput(
|
|
80
|
+
await fsp.readFile(import_path.default.join(dir, "eslint.config.cjs"), "utf-8")
|
|
81
|
+
);
|
|
82
|
+
await import_fs_extra.promises.writeFile(
|
|
83
|
+
"eslint.config.js",
|
|
84
|
+
await (0, import_prettier.formatPrettier)(output, { filepath: "eslint.config.js" })
|
|
85
|
+
);
|
|
86
|
+
await Promise.all([
|
|
87
|
+
originalIgnoreContents === void 0 ? Promise.resolve() : import_fs_extra.promises.rm(".eslintignore"),
|
|
88
|
+
import_fs_extra.promises.rm(".eslintrc.js")
|
|
89
|
+
]);
|
|
90
|
+
return { result: "apply" };
|
|
91
|
+
} finally {
|
|
92
|
+
await fsp.rm(dir, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const writeTemporaryFiles = async (contents) => {
|
|
96
|
+
const dir = await fsp.mkdtemp("eslint-migrate-config");
|
|
97
|
+
for (const [file, content] of Object.entries(contents)) {
|
|
98
|
+
await fsp.writeFile(import_path.default.join(dir, file), content);
|
|
99
|
+
}
|
|
100
|
+
return dir;
|
|
101
|
+
};
|
|
102
|
+
const fiddleWithOutput = (input) => {
|
|
103
|
+
let output = input.replace(/compat.extends\(["']skuba["']\)/, "skuba");
|
|
104
|
+
if (!output.includes("eslint-config-skuba")) {
|
|
105
|
+
output = `const skuba = require('eslint-config-skuba');
|
|
106
|
+
|
|
107
|
+
${output}`;
|
|
108
|
+
}
|
|
109
|
+
if (!output.includes("compat.")) {
|
|
110
|
+
output = output.replace(/const compat = new FlatCompat\(\{[^}]+\}\);/m, "");
|
|
111
|
+
output = output.replace(
|
|
112
|
+
/const \{\s*FlatCompat,?\s*\}\s*=\s*require\(["']@eslint\/eslintrc["']\);/m,
|
|
113
|
+
""
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (!output.includes("js.")) {
|
|
117
|
+
output = output.replace(/const js = require\(['"]@eslint\/js['"]\);/, "");
|
|
118
|
+
}
|
|
119
|
+
output = output.replace(
|
|
120
|
+
/^const skuba = require\('eslint-config-skuba'\);\s*module.exports = \[...skuba\];$/m,
|
|
121
|
+
"module.exports = require('eslint-config-skuba');"
|
|
122
|
+
);
|
|
123
|
+
return output;
|
|
61
124
|
};
|
|
62
125
|
const tryUpgradeESLint = async (config) => {
|
|
63
126
|
try {
|
|
64
127
|
return await upgradeESLint(config);
|
|
65
128
|
} catch (err) {
|
|
66
|
-
import_logging.log.warn("Failed to upgrade ESLint to
|
|
129
|
+
import_logging.log.warn("Failed to upgrade ESLint to flat config.");
|
|
67
130
|
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
68
131
|
return { result: "skip", reason: "due to an error" };
|
|
69
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["// eslint-disable-next-line no-restricted-imports -- fs-extra is mocked\nimport * as fsp from 'fs/promises';\nimport path from 'path';\nimport { inspect } from 'util';\n\nimport { promises as fsExtra } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { createExec } from '../../../../../../utils/exec';\nimport { log } from '../../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\nimport { mergeWithConfigFile } from '../../../../../configure/processing/configFile';\nimport { formatPrettier } from '../../../../../configure/processing/prettier';\n\nconst upgradeESLint: PatchFunction = async ({\n mode,\n dir: cwd = process.cwd(),\n}): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(cwd);\n const [originalIgnoreContents, eslintConfig] = await Promise.all([\n readFile('.eslintignore'),\n readFile('.eslintrc.js'),\n ]);\n\n if (eslintConfig === undefined) {\n return {\n result: 'skip',\n reason: 'no .eslintrc.js - have you already migrated?',\n };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const mergedIgnoreContent = mergeWithConfigFile(\n '',\n 'ignore',\n )(originalIgnoreContents);\n\n const exec = createExec({\n cwd: process.cwd(),\n stdio: 'ignore',\n });\n\n // eslint-migrate-config require()s the file, so for testability, put it in a temporary location\n const dir = await writeTemporaryFiles({\n '.eslintrc.js': eslintConfig,\n ...(mergedIgnoreContent.trim().length > 0\n ? { '.eslintignore': mergedIgnoreContent }\n : {}),\n });\n try {\n await exec(\n 'eslint-migrate-config',\n path.join(dir, '.eslintrc.js'),\n '--commonjs',\n );\n\n const output = fiddleWithOutput(\n await fsp.readFile(path.join(dir, 'eslint.config.cjs'), 'utf-8'),\n );\n await fsExtra.writeFile(\n 'eslint.config.js',\n await formatPrettier(output, { filepath: 'eslint.config.js' }),\n );\n\n await Promise.all([\n originalIgnoreContents === undefined\n ? Promise.resolve()\n : fsExtra.rm('.eslintignore'),\n fsExtra.rm('.eslintrc.js'),\n ]);\n\n return { result: 'apply' };\n } finally {\n await fsp.rm(dir, { recursive: true });\n }\n};\n\nconst writeTemporaryFiles = async (contents: Record<string, string>) => {\n const dir = await fsp.mkdtemp('eslint-migrate-config');\n\n for (const [file, content] of Object.entries(contents)) {\n await fsp.writeFile(path.join(dir, file), content);\n }\n\n return dir;\n};\n\nconst fiddleWithOutput = (input: string) => {\n let output = input.replace(/compat.extends\\([\"']skuba[\"']\\)/, 'skuba');\n\n if (!output.includes('eslint-config-skuba')) {\n output = `const skuba = require('eslint-config-skuba');\\n\\n${output}`;\n }\n\n if (!output.includes('compat.')) {\n output = output.replace(/const compat = new FlatCompat\\(\\{[^}]+\\}\\);/m, '');\n output = output.replace(\n /const \\{\\s*FlatCompat,?\\s*\\}\\s*=\\s*require\\([\"']@eslint\\/eslintrc[\"']\\);/m,\n '',\n );\n }\n\n if (!output.includes('js.')) {\n output = output.replace(/const js = require\\(['\"]@eslint\\/js['\"]\\);/, '');\n }\n\n output = output.replace(\n /^const skuba = require\\('eslint-config-skuba'\\);\\s*module.exports = \\[...skuba\\];$/m,\n \"module.exports = require('eslint-config-skuba');\",\n );\n\n return output;\n};\n\nexport const tryUpgradeESLint: PatchFunction = async (config) => {\n try {\n return await upgradeESLint(config);\n } catch (err) {\n log.warn('Failed to upgrade ESLint to flat config.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,kBAAiB;AACjB,kBAAwB;AAExB,sBAAoC;AAGpC,kBAA2B;AAC3B,qBAAoB;AACpB,qBAA4C;AAC5C,wBAAoC;AACpC,sBAA+B;AAE/B,MAAM,gBAA+B,OAAO;AAAA,EAC1C;AAAA,EACA,KAAK,MAAM,QAAQ,IAAI;AACzB,MAAgC;AAC9B,QAAM,eAAW,4CAA4B,GAAG;AAChD,QAAM,CAAC,wBAAwB,YAAY,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC/D,SAAS,eAAe;AAAA,IACxB,SAAS,cAAc;AAAA,EACzB,CAAC;AAED,MAAI,iBAAiB,QAAW;AAC9B,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,0BAAsB;AAAA,IAC1B;AAAA,IACA;AAAA,EACF,EAAE,sBAAsB;AAExB,QAAM,WAAO,wBAAW;AAAA,IACtB,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACT,CAAC;AAGD,QAAM,MAAM,MAAM,oBAAoB;AAAA,IACpC,gBAAgB;AAAA,IAChB,GAAI,oBAAoB,KAAK,EAAE,SAAS,IACpC,EAAE,iBAAiB,oBAAoB,IACvC,CAAC;AAAA,EACP,CAAC;AACD,MAAI;AACF,UAAM;AAAA,MACJ;AAAA,MACA,YAAAA,QAAK,KAAK,KAAK,cAAc;AAAA,MAC7B;AAAA,IACF;AAEA,UAAM,S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AAW;AAC/D,MAAI;AACF,WAAO,MAAM,cAAc,MAAM;AAAA,EACnC,SAAS,KAAK;AACZ,uBAAI,KAAK,0CAA0C;AACnD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["path", "fsExtra"]
|
|
7
7
|
}
|
package/lib/eslint.d.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuba",
|
|
3
|
-
"version": "9.0.0-renovate-eslint-9.x-
|
|
3
|
+
"version": "9.0.0-renovate-eslint-9.x-20240811060718",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SEEK development toolkit for backend applications and packages",
|
|
6
6
|
"homepage": "https://github.com/seek-oss/skuba#readme",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"typescript": "~5.5.4",
|
|
102
102
|
"validate-npm-package-name": "^5.0.0",
|
|
103
103
|
"zod": "^3.22.4",
|
|
104
|
-
"eslint-config-skuba": "5.0.0-renovate-eslint-9.x-
|
|
104
|
+
"eslint-config-skuba": "5.0.0-renovate-eslint-9.x-20240811060718"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@changesets/cli": "2.27.7",
|
|
File without changes
|