Skip to content

Commit 4cfdceb

Browse files
committed
Fix linting and formatting issues
1 parent 86e0872 commit 4cfdceb

39 files changed

Lines changed: 1385 additions & 1275 deletions

eslint.config.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@ import prettierRecommended from "eslint-plugin-prettier/recommended";
77

88
export default defineConfig([
99
{
10-
files: [
11-
"**/*.js",
12-
"**/*.mjs"
13-
],
10+
files: ["**/*.js", "**/*.mjs"],
1411
ignores: [
1512
"packages/generator-widget/generators/app/templates/**",
1613
"packages/release-tools/utils/changelog-parser/changelog.js",
17-
"packages/pluggable-widgets-tools/dist/**",
14+
"packages/pluggable-widgets-tools/dist/**"
1815
],
1916
plugins: { js },
2017
extends: ["js/recommended"],
2118
languageOptions: { globals: globals.node },
2219
rules: {
23-
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
20+
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }]
2421
}
2522
},
2623
{
@@ -34,13 +31,9 @@ export default defineConfig([
3431
}
3532
},
3633
{
37-
files: [
38-
"**/__mocks__/**/*.js",
39-
"**/__tests__/**/*.js",
40-
"packages/pluggable-widgets-tools/test-config/**",
41-
],
34+
files: ["**/__mocks__/**/*.js", "**/__tests__/**/*.js", "packages/pluggable-widgets-tools/test-config/**"],
4235
plugins: { jest },
4336
languageOptions: { globals: jest.environments.globals.globals }
4437
},
45-
prettierRecommended,
38+
prettierRecommended
4639
]);

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
@@ -244,15 +244,8 @@ class MxGenerator extends Generator {
244244
}
245245

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

257-
258251
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: %s"), 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: 31 additions & 32 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({
@@ -199,7 +197,7 @@ export default async args => {
199197
setTimeout(() => process.exit(0));
200198
}
201199
},
202-
name: 'force-close'
200+
name: "force-close"
203201
}
204202
],
205203
onwarn: onwarn(args)
@@ -208,10 +206,11 @@ export default async args => {
208206

209207
const customConfigPathJS = join(sourcePath, "rollup.config.js");
210208
const customConfigPathESM = join(sourcePath, "rollup.config.mjs");
211-
const existingConfigPath =
212-
existsSync(customConfigPathJS) ? customConfigPathJS
213-
: existsSync(customConfigPathESM) ? customConfigPathESM
214-
: null;
209+
const existingConfigPath = existsSync(customConfigPathJS)
210+
? customConfigPathJS
211+
: existsSync(customConfigPathESM)
212+
? customConfigPathESM
213+
: null;
215214
if (existingConfigPath != null) {
216215
const customConfig = await loadConfigFile(existingConfigPath, { ...args, configDefaultConfig: result });
217216
customConfig.warnings.flush();
@@ -225,12 +224,12 @@ export default async args => {
225224
nodeResolve({ preferBuiltins: false, mainFields: ["module", "browser", "main"] }),
226225
isTypescript
227226
? typescript({
228-
noEmitOnError: !args.watch,
229-
sourceMap: config.sourceMaps,
230-
inlineSources: config.sourceMaps,
231-
target: "es2022", // we transpile the result with babel anyway, see below
232-
exclude: ["**/__tests__/**/*"]
233-
})
227+
noEmitOnError: !args.watch,
228+
sourceMap: config.sourceMaps,
229+
inlineSources: config.sourceMaps,
230+
target: "es2022", // we transpile the result with babel anyway, see below
231+
exclude: ["**/__tests__/**/*"]
232+
})
234233
: null,
235234
// Babel can transpile source JS and resulting JS, hence are input/output plugins. The good
236235
// practice is to do the most of conversions on resulting code, since then we ensure that
@@ -267,29 +266,29 @@ export default async args => {
267266
}),
268267
config.transpile
269268
? getBabelOutputPlugin({
270-
sourceMaps: config.sourceMaps,
271-
babelrc: false,
272-
compact: false,
273-
...(config.babelConfig || {})
274-
})
269+
sourceMaps: config.sourceMaps,
270+
babelrc: false,
271+
compact: false,
272+
...(config.babelConfig || {})
273+
})
275274
: null,
276275
image(),
277276
production ? terser() : null,
278277
config.licenses
279278
? license({
280-
thirdParty: {
281-
includePrivate: true,
282-
output: [
283-
{
284-
file: join(outDir, "dependencies.txt")
285-
},
286-
{
287-
file: join(outDir, "dependencies.json"),
288-
template: licenseCustomTemplate
289-
}
290-
]
291-
}
292-
})
279+
thirdParty: {
280+
includePrivate: true,
281+
output: [
282+
{
283+
file: join(outDir, "dependencies.txt")
284+
},
285+
{
286+
file: join(outDir, "dependencies.json"),
287+
template: licenseCustomTemplate
288+
}
289+
]
290+
}
291+
})
293292
: null,
294293
// We need to create .mpk and copy results to test project after bundling is finished.
295294
// In case of a regular build is it is on `writeBundle` of the last config we define

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2-
31
import { existsSync } from "fs";
4-
import { join, relative } from "path";
2+
import { join } from "path";
53
import { getBabelInputPlugin, getBabelOutputPlugin } from "@rollup/plugin-babel";
64
import commonjs from "@rollup/plugin-commonjs";
75
import image from "@rollup/plugin-image";
@@ -105,20 +103,20 @@ export default async args => {
105103
widgetName,
106104
...(production && i === 0
107105
? {
108-
licenseOptions: {
109-
thirdParty: {
110-
output: [
111-
{
112-
file: join(outDir, "dependencies.txt")
113-
},
114-
{
115-
file: join(outDir, "dependencies.json"),
116-
template: licenseCustomTemplate
117-
}
118-
]
119-
}
120-
}
121-
}
106+
licenseOptions: {
107+
thirdParty: {
108+
output: [
109+
{
110+
file: join(outDir, "dependencies.txt")
111+
},
112+
{
113+
file: join(outDir, "dependencies.json"),
114+
template: licenseCustomTemplate
115+
}
116+
]
117+
}
118+
}
119+
}
122120
: null)
123121
}),
124122
...getCommonPlugins({
@@ -165,10 +163,11 @@ export default async args => {
165163

166164
const customConfigPathJS = join(sourcePath, "rollup.config.js");
167165
const customConfigPathESM = join(sourcePath, "rollup.config.mjs");
168-
const existingConfigPath =
169-
existsSync(customConfigPathJS) ? customConfigPathJS
170-
: existsSync(customConfigPathESM) ? customConfigPathESM
171-
: null;
166+
const existingConfigPath = existsSync(customConfigPathJS)
167+
? customConfigPathJS
168+
: existsSync(customConfigPathESM)
169+
? customConfigPathESM
170+
: null;
172171
if (existingConfigPath != null) {
173172
const customConfig = await loadConfigFile(existingConfigPath, { ...args, configDefaultConfig: result });
174173
customConfig.warnings.flush();
@@ -182,12 +181,12 @@ export default async args => {
182181
nodeResolve({ preferBuiltins: false, mainFields: ["module", "browser", "main"] }),
183182
isTypescript
184183
? typescript({
185-
noEmitOnError: !args.watch,
186-
sourceMap: config.sourceMaps,
187-
inlineSources: config.sourceMaps,
188-
target: "es2022", // we transpile the result with babel anyway, see below
189-
exclude: ["**/__tests__/**/*"]
190-
})
184+
noEmitOnError: !args.watch,
185+
sourceMap: config.sourceMaps,
186+
inlineSources: config.sourceMaps,
187+
target: "es2022", // we transpile the result with babel anyway, see below
188+
exclude: ["**/__tests__/**/*"]
189+
})
191190
: null,
192191
// Babel can transpile source JS and resulting JS, hence are input/output plugins. The good
193192
// practice is to do the most of conversions on resulting code, since then we ensure that
@@ -224,11 +223,11 @@ export default async args => {
224223
}),
225224
config.transpile
226225
? getBabelOutputPlugin({
227-
sourceMaps: config.sourceMaps,
228-
babelrc: false,
229-
compact: false,
230-
...(config.babelConfig || {})
231-
})
226+
sourceMaps: config.sourceMaps,
227+
babelrc: false,
228+
compact: false,
229+
...(config.babelConfig || {})
230+
})
232231
: null,
233232
image(),
234233
production ? terser({ mangle: false }) : null,

packages/pluggable-widgets-tools/configs/shared.mjs

Lines changed: 7 additions & 12 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, readdirSync, promises as fs, readFileSync } from "node:fs";
42
import { join, relative } from "node:path";
53
import { config } from "dotenv";
@@ -18,17 +16,17 @@ export async function listDir(path) {
1816

1917
export const sourcePath = process.cwd();
2018

21-
const widgetPackageJson = JSON.parse(readFileSync(join(sourcePath, "package.json")))
19+
const widgetPackageJson = JSON.parse(readFileSync(join(sourcePath, "package.json")));
2220
export const widgetName = widgetPackageJson.widgetName;
2321
export const widgetPackage = widgetPackageJson.packagePath;
2422
export const widgetVersion = widgetPackageJson.version;
2523
if (!widgetName || !widgetPackageJson) {
2624
throw new Error("Widget does not define widgetName in its package.json");
2725
}
2826

29-
throwOnIllegalChars(widgetName, "a-zA-Z", "The `widgetName` property in package.json")
30-
throwOnIllegalChars(widgetPackage, "a-zA-Z0-9_.-", "The `packagePath` property in package.json")
31-
throwOnNoMatch(widgetPackage, /^([a-zA-Z0-9_-]+.)*[a-zA-Z0-9_-]+$/, "The `packagePath` property in package.json")
27+
throwOnIllegalChars(widgetName, "a-zA-Z", "The `widgetName` property in package.json");
28+
throwOnIllegalChars(widgetPackage, "a-zA-Z0-9_.-", "The `packagePath` property in package.json");
29+
throwOnNoMatch(widgetPackage, /^([a-zA-Z0-9_-]+.)*[a-zA-Z0-9_-]+$/, "The `packagePath` property in package.json");
3230

3331
const widgetSrcFiles = readdirSync(join(sourcePath, "src")).map(file => join(sourcePath, "src", file));
3432
export const widgetEntry = widgetSrcFiles.filter(file =>
@@ -53,7 +51,7 @@ export const projectPath = [
5351
join(sourcePath, "tests/testProject")
5452
].filter(path => path && existsSync(path))[0];
5553

56-
export const onwarn = (args) => (warning, warn) => {
54+
export const onwarn = args => (warning, warn) => {
5755
// Module level directives is ignored by Rollup since it causes error when bundled.
5856
// And to not pollute the terminal, the warning code "MODULE_LEVEL_DIRECTIVE" and "SOURCEMAP_ERROR"
5957
// should be ignored and handled separetely from the safe warning list.
@@ -68,17 +66,14 @@ export const onwarn = (args) => (warning, warn) => {
6866

6967
const error =
7068
(warning.plugin ? `(${warning.plugin} plugin) ` : "") +
71-
(warning.loc
72-
? `${relative(sourcePath, warning.loc.file)} (${warning.loc.line}:${warning.loc.column}) `
73-
: "") +
69+
(warning.loc ? `${relative(sourcePath, warning.loc.file)} (${warning.loc.line}:${warning.loc.column}) ` : "") +
7470
`Error: ${warning.message}` +
7571
(warning.frame ? warning.frame : "");
7672

7773
console.error(colors.red(error));
7874
process.exit(1);
79-
}
75+
};
8076

8177
function escape(str) {
8278
return str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
8379
}
84-

0 commit comments

Comments
 (0)