Skip to content

Commit

Permalink
style: Configure eslint to behave more like deno fmt (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
jespertheend authored Mar 6, 2024
1 parent 83a086c commit d1acbaf
Show file tree
Hide file tree
Showing 603 changed files with 5,104 additions and 5,104 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "never",
functions: "always-multiline",
},
],
"comma-spacing": [
Expand Down Expand Up @@ -140,7 +140,7 @@ module.exports = {
consistent: true,
},
],
"object-curly-spacing": "error",
"object-curly-spacing": ["error", "always"],
"one-var": ["error", "never"],
"operator-linebreak": "error",
"padded-blocks": ["error", "never"],
Expand Down Expand Up @@ -178,7 +178,7 @@ module.exports = {
"switch-colon-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-parens": "error",
"arrow-spacing": "error",
"generator-star-spacing": "error",
"no-confusing-arrow": "error",
Expand Down
12 changes: 6 additions & 6 deletions scripts/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* tests.
*/

import {serveDir} from "std/http/file_server.ts";
import {Server} from "std/http/server.ts";
import {Application as DevSocket} from "../studio/devSocket/src/Application.js";
import {Application as StudioDiscovery} from "https://raw.githubusercontent.com/rendajs/studio-discovery-server/f11212158ce959f55713888eb7fb03679c186ef5/src/main.js";
import { serveDir } from "std/http/file_server.ts";
import { Server } from "std/http/server.ts";
import { Application as DevSocket } from "../studio/devSocket/src/Application.js";
import { Application as StudioDiscovery } from "https://raw.githubusercontent.com/rendajs/studio-discovery-server/f11212158ce959f55713888eb7fb03679c186ef5/src/main.js";
import * as path from "std/path/mod.ts";
import * as fs from "std/fs/mod.ts";

Expand Down Expand Up @@ -68,7 +68,7 @@ export class DevServer {
start() {
this.#devSocket.init();
this.#httpServer.listenAndServe();
const addrs = this.getAddrs().map(addr => ` - ${addr}`);
const addrs = this.getAddrs().map((addr) => ` - ${addr}`);
console.log(`Started ${this.#serverName} on:
${addrs.join("\n")}`);
}
Expand All @@ -82,7 +82,7 @@ ${addrs.join("\n")}`);
// TODO: use `isFile` when https://github.com/denoland/deno_std/pull/2785 lands.
let StudioDiscoveryConstructor = StudioDiscovery;
if (fs.existsSync(discoveryRepositoryEntryPoint)) {
const {Application} = await import(discoveryRepositoryEntryPoint);
const { Application } = await import(discoveryRepositoryEntryPoint);
StudioDiscoveryConstructor = Application;
}
return new StudioDiscoveryConstructor();
Expand Down
6 changes: 3 additions & 3 deletions scripts/buildEngine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "std/path/mod.ts";
import {rollup} from "rollup";
import { rollup } from "rollup";
import cleanup from "rollup-plugin-cleanup";
import jscc from "rollup-plugin-jscc";

Expand All @@ -17,7 +17,7 @@ async function createBundle() {
}),
cleanup(),
],
onwarn: message => {
onwarn: (message) => {
if (message.code == "CIRCULAR_DEPENDENCY") return;
console.error(message.message);
},
Expand All @@ -40,7 +40,7 @@ if (import.meta.main) {

export async function buildEngine() {
const bundle = await createBundle();
const {output} = await bundle.generate(outputOptions);
const { output } = await bundle.generate(outputOptions);
if (output.length != 1) {
throw new Error("Assertion failed, more than one file generated");
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/buildNpmPackage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "std/fs/mod.ts";
import * as path from "std/path/mod.ts";
import {buildEngine} from "./buildEngine.js";
import {setCwd} from "chdir-anywhere";
import { buildEngine } from "./buildEngine.js";
import { setCwd } from "chdir-anywhere";

setCwd();
const destination = path.resolve("..", "npmPackage");
Expand Down
24 changes: 12 additions & 12 deletions scripts/buildStudio.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {rollup} from "rollup";
import {copy, ensureDir, walk} from "std/fs/mod.ts";
import { rollup } from "rollup";
import { copy, ensureDir, walk } from "std/fs/mod.ts";
import * as path from "std/path/mod.ts";
import {minify} from "terser";
import {setCwd} from "chdir-anywhere";
import {importAssertionsPlugin} from "https://esm.sh/[email protected]?pin=v87";
import {importAssertions} from "https://esm.sh/[email protected]?pin=v87";
import { minify } from "terser";
import { setCwd } from "chdir-anywhere";
import { importAssertionsPlugin } from "https://esm.sh/[email protected]?pin=v87";
import { importAssertions } from "https://esm.sh/[email protected]?pin=v87";
import postcss from "https://deno.land/x/[email protected]/mod.js";
import postcssUrl from "npm:[email protected]";
import resolveUrlObjects from "npm:[email protected]";
import {dev} from "./dev.js";
import {buildEngine} from "./buildEngine.js";
import {toHashString} from "std/crypto/mod.ts";
import { dev } from "./dev.js";
import { buildEngine } from "./buildEngine.js";
import { toHashString } from "std/crypto/mod.ts";

await dev({
needsDependencies: true,
Expand All @@ -21,7 +21,7 @@ Deno.chdir("../studio");

const outputPath = path.resolve("dist/");
try {
await Deno.remove(outputPath, {recursive: true});
await Deno.remove(outputPath, { recursive: true });
} catch {
// Already removed
}
Expand Down Expand Up @@ -169,13 +169,13 @@ const bundle = await rollup({
importAssertionsPlugin(),
],
acornInjectPlugins: [importAssertions],
onwarn: message => {
onwarn: (message) => {
if (message.code == "CIRCULAR_DEPENDENCY") return;
console.error(message.message);
},
preserveEntrySignatures: false,
});
const {output} = await bundle.write({
const { output } = await bundle.write({
dir: outputPath,
format: "esm",
entryFileNames: "[name]-[hash].js",
Expand Down
2 changes: 1 addition & 1 deletion scripts/check.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {dev} from "./dev.js";
import { dev } from "./dev.js";

await dev({
needsTypes: true,
Expand Down
8 changes: 4 additions & 4 deletions scripts/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* On windows you can run this using `deno task dev`.
*/

import {setCwd} from "chdir-anywhere";
import { setCwd } from "chdir-anywhere";

/**
* @param {object} opts
Expand All @@ -34,7 +34,7 @@ export async function dev({
Deno.chdir("..");

if (needsTypes) {
const {generateTypes} = await import("https://deno.land/x/[email protected]/mod.js");
const { generateTypes } = await import("https://deno.land/x/[email protected]/mod.js");

const cwd = Deno.cwd();

Expand Down Expand Up @@ -104,7 +104,7 @@ export async function dev({
}

if (needsDependencies || needsDevDependencies) {
const {dev} = await import("https://deno.land/x/[email protected]/mod.js");
const { dev } = await import("https://deno.land/x/[email protected]/mod.js");

await dev({
actions: [
Expand Down Expand Up @@ -140,7 +140,7 @@ export async function dev({
}

if (serve) {
const {DevServer} = await import("./DevServer.js");
const { DevServer } = await import("./DevServer.js");
const server = new DevServer({
port: 8080,
serverName: "development server",
Expand Down
16 changes: 8 additions & 8 deletions scripts/lint.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {ESLint} from "eslint";
import { ESLint } from "eslint";
import jsdoc from "npm:[email protected]";
import {rule as noDefaultExportsRule} from "../.eslintrules/no-default-exports.js";
import {rule as noModImportsRule} from "../.eslintrules/no-mod-imports.js";
import {rule as noThisInStaticMethodRule} from "../.eslintrules/no-this-in-static-method.js";
import {setCwd} from "chdir-anywhere";
import {readAll} from "std/streams/mod.ts";
import { rule as noDefaultExportsRule } from "../.eslintrules/no-default-exports.js";
import { rule as noModImportsRule } from "../.eslintrules/no-mod-imports.js";
import { rule as noThisInStaticMethodRule } from "../.eslintrules/no-this-in-static-method.js";
import { setCwd } from "chdir-anywhere";
import { readAll } from "std/streams/mod.ts";

setCwd();
Deno.chdir("..");
Expand Down Expand Up @@ -111,13 +111,13 @@ if (useIo) {
}
i++;
}
files = files.map(f => {
files = files.map((f) => {
if (f.endsWith("/")) {
return f + "**/*.js";
}
return f;
});
files = files.filter(f => f.endsWith(".js"));
files = files.filter((f) => f.endsWith(".js"));
if (files.length == 0) {
console.log("No files have been modified, there's nothing to lint. Use --all if you wish to forcefully lint all files.");
Deno.exit();
Expand Down
14 changes: 7 additions & 7 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env -S deno run --unstable --no-check --allow-run --allow-read --allow-write --allow-env --allow-net

import {join} from "std/path/mod.ts";
import {setCwd} from "chdir-anywhere";
import {dev} from "./dev.js";
import {parseArgs} from "../test/shared/testArgs.js";
import { join } from "std/path/mod.ts";
import { setCwd } from "chdir-anywhere";
import { dev } from "./dev.js";
import { parseArgs } from "../test/shared/testArgs.js";

setCwd();
Deno.chdir("..");
Expand All @@ -16,7 +16,7 @@ const FAKE_IMPORTS_COVERAGE_DIR = ".coverage/fakeImportsCoverageMap";
*/
async function removeMaybeDirectory(path) {
try {
await Deno.remove(path, {recursive: true});
await Deno.remove(path, { recursive: true });
} catch (e) {
if (!(e instanceof Deno.errors.NotFound)) {
throw e;
Expand All @@ -40,7 +40,7 @@ await dev({
needsDependencies: needsE2eTests,
});

const {inspect} = parseArgs();
const { inspect } = parseArgs();

let needsCoverage = Deno.args.includes("--coverage") || Deno.args.includes("-c");
const needsHtmlCoverageReport = Deno.args.includes("--html");
Expand Down Expand Up @@ -83,7 +83,7 @@ if (needsE2eTests) {
for (const cmd of testCommands) {
console.log(`Running: ${cmd.join(" ")}`);
const [exec, ...args] = cmd;
const testCommand = new Deno.Command(exec, {args, stdout: "inherit", stderr: "inherit"});
const testCommand = new Deno.Command(exec, { args, stdout: "inherit", stderr: "inherit" });
const testOutput = await testCommand.output();
if (!testOutput.success) {
Deno.exit(testOutput.code);
Expand Down
10 changes: 5 additions & 5 deletions src/assets/AssetLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AssetLoaderType} from "./assetLoaderTypes/AssetLoaderType.js";
import {isUuid} from "../util/util.js";
import {RecursionTracker} from "./RecursionTracker.js";
import { AssetLoaderType } from "./assetLoaderTypes/AssetLoaderType.js";
import { isUuid } from "../util/util.js";
import { RecursionTracker } from "./RecursionTracker.js";

/**
* @template {new (...args: any[]) => import("./assetLoaderTypes/AssetLoaderType.js").AssetLoaderType<any, any>} [TLoaderType = new (...args: any[]) => import("./assetLoaderTypes/AssetLoaderType.js").AssetLoaderType<any, any>]
Expand Down Expand Up @@ -121,7 +121,7 @@ export class AssetLoader {
const searchCount = this.bundles.size;
let unavailableCount = 0;
for (const bundle of this.bundles) {
bundle.waitForAssetAvailable(uuid).then(available => {
bundle.waitForAssetAvailable(uuid).then((available) => {
if (available) {
resolve(bundle);
} else {
Expand All @@ -139,7 +139,7 @@ export class AssetLoader {
}
const assetData = await bundleWithAsset.getAsset(uuid);
if (!assetData) throw new Error("Assertion failed, expected bundle to return asset data.");
const {buffer, type} = assetData;
const { buffer, type } = assetData;

const loaderType = this.registeredLoaderTypes.get(type);
if (!loaderType) {
Expand Down
4 changes: 2 additions & 2 deletions src/assets/EngineAssetsManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ENGINE_ASSETS_LIVE_UPDATES_SUPPORT} from "../studioDefines.js";
import { ENGINE_ASSETS_LIVE_UPDATES_SUPPORT } from "../studioDefines.js";

/** @typedef {Parameters<import("./AssetLoader.js").AssetLoader["getAsset"]>} GetAssetArgs */
/** @typedef {(...args: GetAssetArgs) => any} GetEngineAssetHandler */
Expand Down Expand Up @@ -93,7 +93,7 @@ export class EngineAssetsManager {
if (!ENGINE_ASSETS_LIVE_UPDATES_SUPPORT) return;
const cbs = this.watchingAssetCbs.get(uuid);
if (cbs) {
for (const {cb, options} of cbs) {
for (const { cb, options } of cbs) {
const asset = await this.getAsset(uuid, /** @type {{}} */ (options));
cb(asset);
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/RecursionTracker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RecursionTrackerLoadingAsset} from "./RecursionTrackerLoadingAsset.js";
import { RecursionTrackerLoadingAsset } from "./RecursionTrackerLoadingAsset.js";

/**
* When two assets refer to each other with an uuid, we want `AssetLoader.getAsset()`
Expand Down
4 changes: 2 additions & 2 deletions src/assets/RecursionTrackerLoadingAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class RecursionTrackerLoadingAsset {
}

async waitForLoad() {
await new Promise(r => this.onLoad(r));
await new Promise((r) => this.onLoad(r));
}

/**
Expand All @@ -44,7 +44,7 @@ export class RecursionTrackerLoadingAsset {
setLoadedAsset(loadedAsset) {
this.loadedAsset = loadedAsset;
this.isLoaded = true;
this.onLoadCbs.forEach(cb => cb(this.loadedAsset));
this.onLoadCbs.forEach((cb) => cb(this.loadedAsset));
this.onLoadCbs.clear();
}
}
18 changes: 9 additions & 9 deletions src/assets/assetBundles/DownloadableAssetBundle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {AssetBundleRange} from "./DownloadableAssetBundleRange.js";
import {SingleInstancePromise} from "../../util/SingleInstancePromise.js";
import {PromiseWaitHelper} from "../../util/PromiseWaitHelper.js";
import {streamAsyncIterator} from "../../util/util.js";
import {binaryToUuid} from "../../util/binarySerialization.js";
import {AssetBundle} from "./AssetBundle.js";
import { AssetBundleRange } from "./DownloadableAssetBundleRange.js";
import { SingleInstancePromise } from "../../util/SingleInstancePromise.js";
import { PromiseWaitHelper } from "../../util/PromiseWaitHelper.js";
import { streamAsyncIterator } from "../../util/util.js";
import { binaryToUuid } from "../../util/binarySerialization.js";
import { AssetBundle } from "./AssetBundle.js";

/** @typedef {(progress: number) => void} OnProgressCallback */

Expand Down Expand Up @@ -34,7 +34,7 @@ export class DownloadableAssetBundle extends AssetBundle {
/** @private @type {Set<OnProgressCallback>} */
this.onProgressCbs = new Set();

this.downloadInstance = new SingleInstancePromise(async () => await this.downloadLogic(), {once: true});
this.downloadInstance = new SingleInstancePromise(async () => await this.downloadLogic(), { once: true });
this.headerWait = new PromiseWaitHelper();

this.downloadBuffer = null;
Expand Down Expand Up @@ -102,7 +102,7 @@ export class DownloadableAssetBundle extends AssetBundle {
const byteStart = prevAssetByteEnd;
const byteEnd = prevAssetByteEnd + assetSize;
prevAssetByteEnd = byteEnd;
this.assetRanges.set(uuid, new AssetBundleRange({typeUuid, byteStart, byteEnd}));
this.assetRanges.set(uuid, new AssetBundleRange({ typeUuid, byteStart, byteEnd }));
}
this.headerWait.fire();
}
Expand Down Expand Up @@ -169,6 +169,6 @@ export class DownloadableAssetBundle extends AssetBundle {
if (!this.downloadBuffer) throw new Error("Assertion failed, downloadbuffer is null");
const buffer = this.downloadBuffer.slice(range.byteStart, range.byteEnd);
const type = range.typeUuid;
return {buffer, type};
return { buffer, type };
}
}
4 changes: 2 additions & 2 deletions src/assets/assetBundles/DownloadableAssetBundleRange.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PromiseWaitHelper} from "../../util/PromiseWaitHelper.js";
import { PromiseWaitHelper } from "../../util/PromiseWaitHelper.js";

export class AssetBundleRange {
/**
Expand All @@ -7,7 +7,7 @@ export class AssetBundleRange {
* @param {number} options.byteStart
* @param {number} options.byteEnd
*/
constructor({typeUuid, byteStart, byteEnd}) {
constructor({ typeUuid, byteStart, byteEnd }) {
this.typeUuid = typeUuid;
this.byteStart = byteStart;
this.byteEnd = byteEnd;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/assetBundles/InspectorAssetBundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AssetBundle} from "./AssetBundle.js";
import { AssetBundle } from "./AssetBundle.js";

/**
* An InspectorAssetBundle serves as a replacement for bundles which are normally used in production.
Expand Down
Loading

0 comments on commit d1acbaf

Please sign in to comment.