Skip to content

Commit

Permalink
Avoid parentheses in single argument lambda functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Jul 24, 2024
1 parent 418f818 commit 362915b
Show file tree
Hide file tree
Showing 29 changed files with 148 additions and 147 deletions.
3 changes: 3 additions & 0 deletions js/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ overrides:
- files: [".eslintrc.js", "*.json"]
options:
quoteProps: preserve
- files: ["*.js"]
options:
arrowParens: avoid
8 changes: 4 additions & 4 deletions js/dts-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ function collectReferences(filePath) {
const fileContent = fs.readFileSync(filePath, "utf-8");
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);

sourceFile.referencedFiles.forEach((reference) => {
sourceFile.referencedFiles.forEach(reference => {
const referencePath = path.resolve(path.dirname(filePath), reference.fileName);
collectReferences(referencePath);
});

sourceFile.forEachChild((node) => {
sourceFile.forEachChild(node => {
if (ts.isModuleDeclaration(node)) {
const moduleName = node.name.getText();
const moduleBody = node.body;

if (moduleBody && ts.isModuleBlock(moduleBody)) {
const moduleContent = moduleBody.statements
.filter((stmt) => !ts.isImportEqualsDeclaration(stmt))
.map((stmt) => stmt.getText())
.filter(stmt => !ts.isImportEqualsDeclaration(stmt))
.map(stmt => stmt.getText())
.join("\n");

if (!moduleDeclarations.has(moduleName)) {
Expand Down
48 changes: 24 additions & 24 deletions js/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import tsc from "gulp-typescript";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const iceBinDist = (process.env.ICE_BIN_DIST || "").split(" ");
const useBinDist = iceBinDist.find((v) => v == "js" || v == "all") !== undefined;
const useBinDist = iceBinDist.find(v => v == "js" || v == "all") !== undefined;

function parseArg(argv, key) {
for (let i = 0; i < argv.length; ++i) {
Expand Down Expand Up @@ -80,14 +80,14 @@ const excludes = {
};

function createCleanTask(taskName, patterns, extension, dest = undefined) {
gulp.task(taskName, async (cb) => {
gulp.task(taskName, async cb => {
const pumpArgs = [gulp.src(patterns), extReplace(extension)];
if (dest !== undefined) {
pumpArgs.push(gulp.dest(dest));
}
pumpArgs.push(vinylPaths(deleteAsync));
return new Promise((resolve, reject) => {
pump(pumpArgs, (err) => {
pump(pumpArgs, err => {
if (err) {
reject(err);
} else {
Expand All @@ -100,7 +100,7 @@ function createCleanTask(taskName, patterns, extension, dest = undefined) {

for (const lib of libs) {
const slicePatterns = [`../slice/${lib}/*.ice`, ...(excludes[lib] || [])];
gulp.task(libTask(lib, "generate"), (cb) => {
gulp.task(libTask(lib, "generate"), cb => {
pump(
[
gulp.src(slicePatterns),
Expand All @@ -122,20 +122,20 @@ for (const lib of libs) {
}

if (useBinDist) {
gulp.task("ice:module", (cb) => cb());
gulp.task("ice:module:clean", (cb) => cb());
gulp.task("dist", (cb) => cb());
gulp.task("dist:clean", (cb) => cb());
gulp.task("ice:module", cb => cb());
gulp.task("ice:module:clean", cb => cb());
gulp.task("dist", cb => cb());
gulp.task("dist:clean", cb => cb());
} else {
gulp.task("dist", gulp.parallel(libs.map((libName) => libTask(libName, "generate"))));
gulp.task("dist", gulp.parallel(libs.map(libName => libTask(libName, "generate"))));

gulp.task("dist:clean", gulp.parallel(libs.map((libName) => libTask(libName, "clean"))));
gulp.task("dist:clean", gulp.parallel(libs.map(libName => libTask(libName, "clean"))));

gulp.task("ice:module:package", () => gulp.src(["package.json"]).pipe(gulp.dest("node_modules/ice")));

gulp.task(
"ice:module",
gulp.series("ice:module:package", (cb) => {
gulp.series("ice:module:package", cb => {
pump([gulp.src([`${root}/src/**/*`]), gulp.dest(`${root}/node_modules/ice/src`)], cb);
}),
);
Expand Down Expand Up @@ -175,7 +175,7 @@ const tests = [
"test/Slice/macros",
];

gulp.task("test:common:generate", (cb) => {
gulp.task("test:common:generate", cb => {
pump([gulp.src(["../scripts/Controller.ice"]), slice2js(), gulp.dest("test/Common")], cb);
});

Expand All @@ -194,7 +194,7 @@ function NodeMockupResolver() {
};
}

gulp.task("ice:bundle", (cb) => {
gulp.task("ice:bundle", cb => {
return new Promise(async (resolve, reject) => {
try {
let bundle = await rollup({
Expand Down Expand Up @@ -225,7 +225,7 @@ function IceResolver() {
};
}

gulp.task("test:common:bundle", (cb) => {
gulp.task("test:common:bundle", cb => {
return new Promise(async (resolve, reject) => {
try {
let bundle = await rollup({
Expand All @@ -245,15 +245,15 @@ gulp.task("test:common:bundle", (cb) => {
});
});

gulp.task("test:common:clean", (cb) => {
gulp.task("test:common:clean", cb => {
deleteAsync(["test/Common/Controller.js", "test/Common/.depend"]);
cb();
});

const testTask = (testName, taskName) => testName.replace(/\//g, "_") + ":" + taskName;

for (const name of tests) {
gulp.task(testTask(name, "build"), (cb) => {
gulp.task(testTask(name, "build"), cb => {
const outputDirectory = `${root}/${name}`;
pump(
[
Expand All @@ -270,7 +270,7 @@ for (const name of tests) {
);
});

gulp.task(testTask(name, "ts-compile"), (cb) => {
gulp.task(testTask(name, "ts-compile"), cb => {
pump(
[
gulp.src([`${root}/${name}/*.ts`, `!${root}/${name}/*.d.ts`]),
Expand All @@ -287,7 +287,7 @@ for (const name of tests) {
);
});

gulp.task(testTask(name, "bundle"), async (cb) => {
gulp.task(testTask(name, "bundle"), async cb => {
let input = fs.existsSync(`${name}/index.js`) ? `${name}/index.js` : `${name}/Client.js`;

let bundle = await rollup({
Expand All @@ -300,7 +300,7 @@ for (const name of tests) {
});
});

gulp.task(testTask(name, "copy:assets"), async (cb) => {
gulp.task(testTask(name, "copy:assets"), async cb => {
pump([gulp.src("test/Common/controller.html"), gulp.dest(`dist/${name}`)], cb);
});

Expand All @@ -320,10 +320,10 @@ gulp.task(
"ice:bundle",
"test:common:generate",
"test:common:bundle",
gulp.series(tests.map((testName) => testTask(testName, "build"))),
gulp.series(tests.map((testName) => testTask(testName, "ts-compile"))),
gulp.series(tests.map((testName) => testTask(testName, "bundle"))),
gulp.series(tests.map((testName) => testTask(testName, "copy:assets"))),
gulp.series(tests.map(testName => testTask(testName, "build"))),
gulp.series(tests.map(testName => testTask(testName, "ts-compile"))),
gulp.series(tests.map(testName => testTask(testName, "bundle"))),
gulp.series(tests.map(testName => testTask(testName, "copy:assets"))),
),
);

Expand All @@ -334,7 +334,7 @@ gulp.task(
gulp.series(
"test:common:clean",
"test:bundle:clean",
tests.map((testName) => testTask(testName, "clean")),
tests.map(testName => testTask(testName, "clean")),
),
);

Expand Down
2 changes: 1 addition & 1 deletion js/src/Ice/ConnectRequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class ConnectRequestHandler {
ri.addProxy(this._reference).then(
// The proxy was added to the router info, we're now ready to send the queued requests.
() => this.flushRequests(),
(ex) => this.setException(ex),
ex => this.setException(ex),
);
return; // The request handler will be initialized once addProxy completes.
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/Ice/ConnectionI.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class ConnectionI {
//
Timer.setImmediate(() => {
this.setState(StateClosing, new ConnectionManuallyClosedException(true));
this._closePromises.forEach((p) => p.resolve());
this._closePromises.forEach(p => p.resolve());
this._closePromises = [];
});
}
Expand Down Expand Up @@ -1512,7 +1512,7 @@ export class ConnectionI {
// Clear the OA. See bug 1673 for the details of why this is necessary.
//
this._adapter = null;
this._finishedPromises.forEach((p) => p.resolve());
this._finishedPromises.forEach(p => p.resolve());
this._finishedPromises = [];
}
}
Expand Down
6 changes: 3 additions & 3 deletions js/src/Ice/EndpointFactoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class EndpointFactoryManager {
}

add(factory) {
Debug.assert(this._factories.find((f) => factory.type() == f.type()) === undefined);
Debug.assert(this._factories.find(f => factory.type() == f.type()) === undefined);
this._factories.push(factory);
}

get(type) {
return this._factories.find((f) => type == f.type()) || null;
return this._factories.find(f => type == f.type()) || null;
}

create(str, oaEndpoint) {
Expand Down Expand Up @@ -113,7 +113,7 @@ export class EndpointFactoryManager {
}

destroy() {
this._factories.forEach((factory) => factory.destroy());
this._factories.forEach(factory => factory.destroy());
this._factories = [];
}
}
2 changes: 1 addition & 1 deletion js/src/Ice/IncomingAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export class IncomingAsync {
if (promise !== null) {
promise.then(
() => this.completed(null),
(ex) => this.completed(ex),
ex => this.completed(ex),
);
return;
}
Expand Down
10 changes: 5 additions & 5 deletions js/src/Ice/InstanceExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Instance.prototype.destroy = function () {
}

if (this._objectFactoryMap !== null) {
this._objectFactoryMap.forEach((factory) => factory.destroy());
this._objectFactoryMap.forEach(factory => factory.destroy());
this._objectFactoryMap.clear();
}

Expand All @@ -413,7 +413,7 @@ Instance.prototype.destroy = function () {
if (unusedProperties.length > 0) {
const message = [];
message.push("The following properties were set but never read:");
unusedProperties.forEach((p) => message.push("\n ", p));
unusedProperties.forEach(p => message.push("\n ", p));
this._initData.logger.warning(message.join(""));
}
}
Expand All @@ -431,13 +431,13 @@ Instance.prototype.destroy = function () {
this._state = StateDestroyed;

if (this._destroyPromises) {
this._destroyPromises.forEach((p) => p.resolve());
this._destroyPromises.forEach(p => p.resolve());
}
promise.resolve();
})
.catch((ex) => {
.catch(ex => {
if (this._destroyPromises) {
this._destroyPromises.forEach((p) => p.reject(ex));
this._destroyPromises.forEach(p => p.reject(ex));
}
promise.reject(ex);
});
Expand Down
16 changes: 8 additions & 8 deletions js/src/Ice/LocatorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class LocatorInfo {
return Promise.resolve(this._locatorRegistry);
}

return this._locator.getRegistry().then((reg) => {
return this._locator.getRegistry().then(reg => {
//
// The locator registry can't be located. We use ordered
// endpoint selection in case the locator returned a proxy
Expand Down Expand Up @@ -157,7 +157,7 @@ export class LocatorInfo {
}

s.push("endpoints = ");
s.push(endpoints.map((e) => e.toString()).join(":"));
s.push(endpoints.map(e => e.toString()).join(":"));
ref.getInstance().initializationData().logger.trace(ref.getInstance().traceLevels().locationCat, s.join(""));
}

Expand Down Expand Up @@ -378,12 +378,12 @@ class RequestCallback {
);
}
locatorInfo.getEndpoints(r, this._ref, this._ttl).then(
(values) => {
values => {
if (this._promise !== null) {
this._promise.resolve(values);
}
},
(ex) => {
ex => {
if (this._promise !== null) {
this._promise.reject(ex);
}
Expand Down Expand Up @@ -475,8 +475,8 @@ class ObjectRequest extends Request {
.getLocator()
.findObjectById(this._ref.getIdentity())
.then(
(proxy) => this.response(proxy),
(ex) => this.exception(ex),
proxy => this.response(proxy),
ex => this.exception(ex),
);
} catch (ex) {
this.exception(ex);
Expand All @@ -496,8 +496,8 @@ class AdapterRequest extends Request {
.getLocator()
.findAdapterById(this._ref.getAdapterId())
.then(
(proxy) => this.response(proxy),
(ex) => this.exception(ex),
proxy => this.response(proxy),
ex => this.exception(ex),
);
} catch (ex) {
this.exception(ex);
Expand Down
Loading

0 comments on commit 362915b

Please sign in to comment.