Skip to content

Commit d09b393

Browse files
weirdwatermlaponder
authored andcommitted
Apply linting and formatting
1 parent 8937906 commit d09b393

39 files changed

Lines changed: 1412 additions & 1294 deletions

packages/command-tests/commands.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import chalk from "chalk";
1111
import helpers from "yeoman-test";
1212

1313
const { copy, existsSync, readJson, writeJson } = fsExtra;
14-
const { ls, mkdir, rm, tempdir } = shelljs
14+
const { ls, mkdir, rm, tempdir } = shelljs;
1515

1616
const LIMIT_TESTS = !!process.env.LIMIT_TESTS;
1717
const PARALLELISM = 4;
@@ -30,16 +30,16 @@ const CONFIGS = [
3030
];
3131

3232
const COLORS = [
33-
'green',
34-
'yellow',
35-
'blue',
36-
'magenta',
37-
'cyan',
38-
'greenBright',
39-
'yellowBright',
40-
'blueBright',
41-
'magentaBright',
42-
'cyanBright',
33+
"green",
34+
"yellow",
35+
"blue",
36+
"magenta",
37+
"cyan",
38+
"greenBright",
39+
"yellowBright",
40+
"blueBright",
41+
"magentaBright",
42+
"cyanBright"
4343
];
4444

4545
if (LIMIT_TESTS) {
@@ -56,9 +56,9 @@ main().catch(e => {
5656
async function main() {
5757
console.log("Preparing...");
5858

59-
const pluggableWidgetsToolsPath = join(DIR_COMMAND_TESTS, "../pluggable-widgets-tools")
60-
const pluggableWidgetsToolsVersion = (await readJson(join(pluggableWidgetsToolsPath, "package.json"))).version
61-
console.log("Preparing: Packaging @mendix/pluggable-widgets-tools version %s", pluggableWidgetsToolsVersion)
59+
const pluggableWidgetsToolsPath = join(DIR_COMMAND_TESTS, "../pluggable-widgets-tools");
60+
const pluggableWidgetsToolsVersion = (await readJson(join(pluggableWidgetsToolsPath, "package.json"))).version;
61+
console.log("Preparing: Packaging @mendix/pluggable-widgets-tools version %s", pluggableWidgetsToolsVersion);
6262
const { stdout: packOutput } = await execAsync("npm pack", pluggableWidgetsToolsPath, m => console.log(m));
6363
const toolsPackagePath = join(pluggableWidgetsToolsPath, packOutput.trim().split(/\n/g).pop());
6464

@@ -68,7 +68,7 @@ async function main() {
6868
await Promise.all(
6969
CONFIGS.map(async (config, index) => {
7070
const logger = getWidgetLogger(index, ...config);
71-
logger("Scheduled, waiting for lock")
71+
logger("Scheduled, waiting for lock");
7272
const [, release] = await workDirSemaphore.acquire();
7373
let workDir;
7474
try {
@@ -83,7 +83,7 @@ async function main() {
8383
await runTest(workDir, logger, ...config);
8484
return undefined;
8585
} catch (e) {
86-
logger(chalk.bold.red("Stopped with error"))
86+
logger(chalk.bold.red("Stopped with error"));
8787
return [config, e];
8888
} finally {
8989
workDirs.push(workDir);
@@ -93,7 +93,7 @@ async function main() {
9393
)
9494
).filter(f => f);
9595

96-
console.log("Cleaning up temporary files")
96+
console.log("Cleaning up temporary files");
9797
try {
9898
rm("-rf", toolsPackagePath, ...workDirs);
9999
} catch (error) {
@@ -109,7 +109,7 @@ async function main() {
109109

110110
async function runTest(workDir, logger, platform, boilerplate, lang, version) {
111111
const isNative = platform === "native";
112-
const widgetName = getWidgetName(platform, boilerplate, lang, version)
112+
const widgetName = getWidgetName(platform, boilerplate, lang, version);
113113
let widgetPackageJson;
114114

115115
logger(`Preparing widget...`);
@@ -275,8 +275,8 @@ async function main() {
275275
? "@mendix/pluggable-widgets-tools"
276276
: null
277277
: boilerplate === "full"
278-
? "classnames"
279-
: null;
278+
? "classnames"
279+
: null;
280280

281281
if (
282282
packageName &&
@@ -323,15 +323,15 @@ async function main() {
323323
} finally {
324324
try {
325325
await promisify(kill)(startProcess.pid, "SIGKILL");
326-
} catch (_) {
327-
console.warn(`[${widgetName}] Error while killing start process`);
326+
} catch (e) {
327+
console.warn(`[${widgetName}] Error while killing start process: ${e}`);
328328
}
329329
await new Promise(resolve => setTimeout(resolve, 5000)); // give time for processes to die
330330
}
331331
}
332332

333333
async function testNativeDependencyManagement() {
334-
const NATIVE_MAPS_VERSION = "0.31.1"
334+
const NATIVE_MAPS_VERSION = "0.31.1";
335335
await execAsync(`npm install react-native-maps@${NATIVE_MAPS_VERSION}`, workDir, logger);
336336
const entryPointPath = join(workDir, "src", `Generated.${lang}x`);
337337
const jsonPath = join(workDir, `/dist/tmp/widgets/${widgetPackageJson.widgetName}.json`);
@@ -368,14 +368,13 @@ async function main() {
368368
}
369369
}
370370

371-
372371
function getWidgetName(platform, boilerplate, lang, version) {
373372
return `[generated_${version.replace(".", "_")}_${lang}_${platform}_${boilerplate}]`;
374373
}
375374

376375
function getWidgetLogger(index, platform, boilerplate, lang, version) {
377-
const color = chalk[COLORS[index % COLORS.length]]
378-
return (...msgs) => console.log(color(getWidgetName(platform, boilerplate, lang, version)), ...msgs)
376+
const color = chalk[COLORS[index % COLORS.length]];
377+
return (...msgs) => console.log(color(getWidgetName(platform, boilerplate, lang, version)), ...msgs);
379378
}
380379

381380
/**
@@ -388,7 +387,7 @@ function getWidgetLogger(index, platform, boilerplate, lang, version) {
388387
* ```
389388
*/
390389
function resolveModule(packageName) {
391-
return fileURLToPath(import.meta.resolve(packageName))
390+
return fileURLToPath(import.meta.resolve(packageName));
392391
}
393392

394393
async function execAsync(command, workDir, logger) {
@@ -407,6 +406,7 @@ async function execAsync(command, workDir, logger) {
407406
async function execFailedAsync(command, workDir) {
408407
try {
409408
await promisify(exec)(command, { cwd: workDir });
409+
// eslint-disable-next-line no-unused-vars
410410
} catch (_) {
411411
return;
412412
}
@@ -422,7 +422,7 @@ function fixPackageJson(json) {
422422
"@types/react-test-renderer": "~18.0.0"
423423
};
424424
const overrides = {
425-
"react": "^19.0.0",
425+
react: "^19.0.0",
426426
"react-dom": "^19.0.0",
427427
"react-native": "0.78.2"
428428
};

packages/generator-widget/bin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ const env = createEnv();
1212
env.register(join(__dirname, "./generators/app/index.js"), "@mendix/widget");
1313

1414
const args = process.argv.slice(2);
15-
env.run(['@mendix/widget', ...args].join(" "))
16-
17-
15+
env.run(["@mendix/widget", ...args].join(" "));

packages/generator-widget/generators/app/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,8 @@ class MxGenerator extends Generator {
245245
}
246246

247247
_copyTemplate(source, destination, replaceVariable = this.widget) {
248-
this.fs.copyTpl(
249-
this.templatePath(source),
250-
this.destinationPath(destination),
251-
replaceVariable,
252-
{},
253-
{}
254-
);
248+
this.fs.copyTpl(this.templatePath(source), this.destinationPath(destination), replaceVariable, {}, {});
255249
}
256250
}
257251

258-
259252
export default MxGenerator;

packages/pluggable-widgets-tools/bin/mx-scripts.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ checkNodeVersion();
1313
try {
1414
await checkMigration();
1515
} catch (e) {
16-
console.log(red("An error occurred while checking migration dependencies"));
16+
console.log(red("An error occurred while checking migration dependencies: ", e));
1717
}
1818

19-
2019
const [, currentScriptPath, cmd, ...args] = process.argv;
2120
const toolsRoot = currentScriptPath.endsWith("pluggable-widgets-tools")
2221
? join(dirname(currentScriptPath), "../@mendix/pluggable-widgets-tools")
@@ -54,7 +53,7 @@ checkNodeVersion();
5453
// Hack for Windows using NTFS Filesystem, we cannot add platform specific check otherwise GitBash or other linux based terminal on windows will also fail.
5554
Path: [process.env.Path].concat(nodeModulesBins).join(delimiter),
5655
// ESLint 9 compatibility: use legacy config format until flat config migration is complete
57-
ESLINT_USE_FLAT_CONFIG: "false",
56+
ESLINT_USE_FLAT_CONFIG: "false"
5857
},
5958
shell: true,
6059
stdio: "inherit"
@@ -158,19 +157,19 @@ function checkNodeVersion() {
158157
if (!nodeRange.test(nodeVersion)) {
159158
console.error(
160159
red(`To build this widget a minimum node version ${nodeRange} is required.\n`) +
161-
bold(whiteBright("Please upgrade your node version!"))
160+
bold(whiteBright("Please upgrade your node version!"))
162161
);
163162
process.exit(1);
164163
}
165164
if (npmVersion < 8) {
166165
console.error(
167166
red("To build this widget a minimum npm version 8.0.0 is required.\n") +
168-
bold(whiteBright("Please upgrade your npm version!"))
167+
bold(whiteBright("Please upgrade your npm version!"))
169168
);
170169
process.exit(1);
171170
}
172171
} catch (e) {
173-
throw new Error("Cannot find node or npm to determine the version:" + e);
172+
throw new Error("Cannot find node or npm to determine the version:", { cause: e });
174173
}
175174
}
176175

packages/pluggable-widgets-tools/configs/helpers/rollup-helper.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2-
31
import { existsSync, mkdirSync } from "fs";
42
import { join } from "path";
53
import fg from "fast-glob";

packages/pluggable-widgets-tools/configs/rollup-plugin-collect-dependencies.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2-
31
import fg from "fast-glob";
42
import fsExtra from "fs-extra";
53
import { existsSync, readFileSync, writeFileSync } from "fs";

packages/pluggable-widgets-tools/configs/rollup.config.mjs

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2-
31
import { existsSync } from "node:fs";
42
import { join } from "node:path";
53
import { fileURLToPath } from "node:url";
@@ -122,7 +120,7 @@ export default async args => {
122120
postCssPlugin(outputFormat, production),
123121
alias({
124122
entries: {
125-
"react-hot-loader/root": fileURLToPath(new URL("hot", import.meta.url)),
123+
"react-hot-loader/root": fileURLToPath(new URL("hot", import.meta.url))
126124
}
127125
}),
128126
...getCommonPlugins({
@@ -160,7 +158,7 @@ export default async args => {
160158
sourceMap: !production ? "inline" : false,
161159
use: {
162160
sass: {
163-
silenceDeprecations: ['legacy-js-api']
161+
silenceDeprecations: ["legacy-js-api"]
164162
}
165163
}
166164
}),
@@ -203,7 +201,7 @@ export default async args => {
203201
setTimeout(() => process.exit(0));
204202
}
205203
},
206-
name: 'force-close'
204+
name: "force-close"
207205
}
208206
],
209207
onwarn: onwarn(args)
@@ -212,10 +210,11 @@ export default async args => {
212210

213211
const customConfigPathJS = join(sourcePath, "rollup.config.js");
214212
const customConfigPathESM = join(sourcePath, "rollup.config.mjs");
215-
const existingConfigPath =
216-
existsSync(customConfigPathJS) ? customConfigPathJS
217-
: existsSync(customConfigPathESM) ? customConfigPathESM
218-
: null;
213+
const existingConfigPath = existsSync(customConfigPathJS)
214+
? customConfigPathJS
215+
: existsSync(customConfigPathESM)
216+
? customConfigPathESM
217+
: null;
219218
if (existingConfigPath != null) {
220219
const customConfig = await loadConfigFile(existingConfigPath, { ...args, configDefaultConfig: result });
221220
customConfig.warnings.flush();
@@ -229,12 +228,12 @@ export default async args => {
229228
nodeResolve({ preferBuiltins: false, mainFields: ["module", "browser", "main"] }),
230229
isTypescript
231230
? typescript({
232-
noEmitOnError: !args.watch,
233-
sourceMap: config.sourceMaps,
234-
inlineSources: config.sourceMaps,
235-
target: "es2022", // we transpile the result with babel anyway, see below
236-
exclude: ["**/__tests__/**/*"]
237-
})
231+
noEmitOnError: !args.watch,
232+
sourceMap: config.sourceMaps,
233+
inlineSources: config.sourceMaps,
234+
target: "es2022", // we transpile the result with babel anyway, see below
235+
exclude: ["**/__tests__/**/*"]
236+
})
238237
: null,
239238
// Babel can transpile source JS and resulting JS, hence are input/output plugins. The good
240239
// practice is to do the most of conversions on resulting code, since then we ensure that
@@ -271,29 +270,29 @@ export default async args => {
271270
}),
272271
config.transpile
273272
? getBabelOutputPlugin({
274-
sourceMaps: config.sourceMaps,
275-
babelrc: false,
276-
compact: false,
277-
...(config.babelConfig || {})
278-
})
273+
sourceMaps: config.sourceMaps,
274+
babelrc: false,
275+
compact: false,
276+
...(config.babelConfig || {})
277+
})
279278
: null,
280279
image(),
281280
production ? terser() : null,
282281
config.licenses
283282
? license({
284-
thirdParty: {
285-
includePrivate: true,
286-
output: [
287-
{
288-
file: join(outDir, "dependencies.txt")
289-
},
290-
{
291-
file: join(outDir, "dependencies.json"),
292-
template: licenseCustomTemplate
293-
}
294-
]
295-
}
296-
})
283+
thirdParty: {
284+
includePrivate: true,
285+
output: [
286+
{
287+
file: join(outDir, "dependencies.txt")
288+
},
289+
{
290+
file: join(outDir, "dependencies.json"),
291+
template: licenseCustomTemplate
292+
}
293+
]
294+
}
295+
})
297296
: null,
298297
// We need to create .mpk and copy results to test project after bundling is finished.
299298
// In case of a regular build is it is on `writeBundle` of the last config we define
@@ -360,7 +359,7 @@ export function postCssPlugin(outputFormat, production, postcssPlugins = []) {
360359
sourceMap: !production ? "inline" : false,
361360
use: {
362361
sass: {
363-
silenceDeprecations: ['legacy-js-api']
362+
silenceDeprecations: ["legacy-js-api"]
364363
}
365364
},
366365
to: join(outDir, `${outWidgetFile}.css`)

0 commit comments

Comments
 (0)