Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: Reformat JS files with Rome 0.6.0 (#2669)
Browse files Browse the repository at this point in the history
Upgrade rome to 0.6.0 and reformat the playground and website files
  • Loading branch information
MichaReiser committed Jun 7, 2022
1 parent 480d4e0 commit f687573
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 294 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_request_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
format-js:
name: Format JS Files
name: Check JS Files
runs-on: ubuntu-latest
steps:
- name: Install Rome
Expand All @@ -27,4 +27,4 @@ jobs:
uses: actions/checkout@v3

- name: Run Rome Format
run: rome format --ci editors website
run: rome ci editors website
4 changes: 2 additions & 2 deletions editors/vscode/scripts/updateVersionForPrerelease.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ readFile(manifestPath, "utf8")
console.log("Could not write the package.json file at " + manifestPath);
process.exit(1);
}
})
},)
.catch(() => {
console.log("Could not read the package.json file at " + manifestPath);
process.exit(1);
});
},);
34 changes: 18 additions & 16 deletions editors/vscode/src/commands/syntaxTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ class SyntaxTreeProvider
}
}

provideTextDocumentContent(uri: Uri, token: CancellationToken): ProviderResult<
string
> {
provideTextDocumentContent(
uri: Uri,
token: CancellationToken,
): ProviderResult<string> {
let documentUri = this.session.editor.document.uri.toString();
// if the document is already cached, we show it
const document = this.documents.get(documentUri);
Expand All @@ -93,16 +94,16 @@ class SyntaxTreeProvider
};

// send request to the server and store its content in the cache if successful
return this.session.client
.sendRequest(syntaxTreeRequest, params, token)
.then(
(result) => {
const document = new SyntaxTreeDocument(uri, result);
this.documents.set(documentUri, document);

return document.value;
},
);
return this.session.client.sendRequest(
syntaxTreeRequest,
params,
token,
).then((result) => {
const document = new SyntaxTreeDocument(uri, result);
this.documents.set(documentUri, document);

return document.value;
},);
}

dispose(): any {
Expand All @@ -113,9 +114,10 @@ class SyntaxTreeProvider
return this.eventEmitter.event;
}

provideDocumentLinks(document: TextDocument, token: CancellationToken): ProviderResult<
DocumentLink[]
> {
provideDocumentLinks(
document: TextDocument,
token: CancellationToken,
): ProviderResult<DocumentLink[]> {
const doc = this.documents.get(document.uri.toString());
if (doc) {
return [];
Expand Down
18 changes: 13 additions & 5 deletions editors/vscode/src/lsp_requests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { RequestType, TextDocumentIdentifier, Range } from "vscode-languageclient";
import {
RequestType,
TextDocumentIdentifier,
Range,
} from "vscode-languageclient";

export interface SyntaxTreeParams { textDocument: TextDocumentIdentifier }
export interface SyntaxTreeParams {
textDocument: TextDocumentIdentifier;
}

/**
* Request to send to the server when showing the syntax tree of a document
*/
export const syntaxTreeRequest = new RequestType<SyntaxTreeParams, string, void>(
"rome/syntaxTree",
);
export const syntaxTreeRequest = new RequestType<
SyntaxTreeParams,
string,
void
>("rome/syntaxTree");
7 changes: 6 additions & 1 deletion editors/vscode/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { ExtensionContext, Uri, window, workspace } from "vscode";
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from "vscode-languageclient/node";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from "vscode-languageclient/node";
import { setContextValue } from "./utils";
import { Session } from "./session";
import { syntaxTree } from "./commands/syntaxTree";
Expand Down
67 changes: 31 additions & 36 deletions website/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const isProduction = process.env.ELEVENTY_ENV === "production";

module.exports =
function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({ "static": "." });
eleventyConfig.addPassthroughCopy({ static: "." });
eleventyConfig.setUseGitIgnore(false);

eleventyConfig.setLiquidOptions({ cache: true });
Expand Down Expand Up @@ -55,11 +55,10 @@ module.exports =
permalinkAttrs: (slug) => ({ "aria-label": slug }),
slugify: (title) => {
return encodeURIComponent(
String(title)
.trim()
.toLowerCase()
.replace(/[^a-zA-Z\s0-9]/g, "")
.replace(/\s+/g, "-"),
String(title).trim().toLowerCase().replace(
/[^a-zA-Z\s0-9]/g,
"",
).replace(/\s+/g, "-"),
);
},
},
Expand All @@ -72,31 +71,29 @@ module.exports =
"tagList",
function (collection) {
let tagSet = new Set();
collection
.getAll()
.forEach(function (item) {
if ("tags" in item.data) {
let tags = item.data.tags;

tags =
tags.filter(function (item) {
switch (item) {
// This list should match the `filter` list in tags.liquid
case "all":
case "nav":
case "post":
case "posts":
return false;
}

return true;
});

for (const tag of tags) {
tagSet.add(tag);
}
collection.getAll().forEach(function (item) {
if ("tags" in item.data) {
let tags = item.data.tags;

tags =
tags.filter(function (item) {
switch (item) {
// This list should match the `filter` list in tags.liquid
case "all":
case "nav":
case "post":
case "posts":
return false;
}

return true;
},);

for (const tag of tags) {
tagSet.add(tag);
}
});
}
},);

// Returning an array in addCollection works in Eleventy 0.5.3
return [...tagSet];
Expand Down Expand Up @@ -194,11 +191,9 @@ module.exports =
"blogSummary",
(val) => {
const lines = val.split("<!-- DESCRIPTION_END -->")[0].split("\n");
return lines
.filter((line) => {
return line.startsWith("<p>");
})
.join("\n");
return lines.filter((line) => {
return line.startsWith("<p>");
},).join("\n");
},
);

Expand Down Expand Up @@ -251,7 +246,7 @@ module.exports =
},
},
},
});
},);

return {
dir: { input: "src", output: "build" },
Expand Down
Loading

0 comments on commit f687573

Please sign in to comment.