Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(vscode): enable JSON formatting
  • Loading branch information
ematipico committed Jan 10, 2023
commit 5d9a9ee0c2e285cf62a9409a8ec1e3fdaa2514ba
2 changes: 1 addition & 1 deletion editors/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
"onLanguage:javascriptreact",
"onLanguage:typescript",
"onLanguage:typescriptreact",
"onLanguage:json",
"onCommand:rome.syntaxTree"
],
"main": "./out/main.js",
"repository": {
"type": "git",
"url": "https://github.com/rome/tools.git"
"url": "https://github.com/rome/tools.git",
"directory": "editors/vscode"
},
"bugs": {
"url": "https://github.com/rome/tools/issues"
},
"engines": {
"vscode": "^1.70.0",
"npm": "^8"
"npm": "^8 || ^9"
},
"capabilities": {
"untrustedWorkspaces": {
Expand Down Expand Up @@ -150,4 +152,4 @@
"resolve": "^1.22.1",
"vscode-languageclient": "^8.0.2"
}
}
}
16 changes: 15 additions & 1 deletion npm/js-api/tests/formatContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Rome WebAssembly formatContent", () => {
rome.shutdown();
});

it("should format content", () => {
it("should format JavaScript content", () => {
const result = rome.formatContent("function f () { }", {
filePath: "example.js",
});
Expand All @@ -22,6 +22,20 @@ describe("Rome WebAssembly formatContent", () => {
expect(result.diagnostics).toEqual([]);
});

it("should format JSON content", () => {
const result = rome.formatContent(
'{ "lorem": "ipsum", "foo": false, "bar": 23, "lorem": "ipsum", "foo": false, "bar": 23 }',
{
filePath: "example.json",
},
);

expect(result.content).toEqual(
'{\n\t"lorem": "ipsum",\n\t"foo": false,\n\t"bar": 23,\n\t"lorem": "ipsum",\n\t"foo": false,\n\t"bar": 23\n}\n',
);
expect(result.diagnostics).toEqual([]);
});

it("should not format and have diagnostics", () => {
const content = "function () { }";
const result = rome.formatContent(content, {
Expand Down
3 changes: 2 additions & 1 deletion npm/js-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"lib": ["ES2021"]
},
"exclude": [
"./tests",
Expand Down