Add newline to end of formatted JSON files
MODIFY
packages/@romejs/compiler/lint/rules/js/preferTemplate.test.ts
packages/@romejs/compiler/lint/rules/js/preferTemplate.test.ts
@@ -14,7 +14,7 @@ test(
await testLint(
t,
{
- valid: [`console.log('foo' + 'bar')`],
+ valid: [`console.log('foo' + 'bar')`, `console.log(foo() + '\n')`],
invalid: [
`const foo = 'bar'; console.log(foo + 'baz')`,
`console.log((1 * 2) + 'foo')`,

MODIFY
packages/@romejs/compiler/lint/rules/js/preferTemplate.ts
packages/@romejs/compiler/lint/rules/js/preferTemplate.ts
@@ -51,11 +51,19 @@ function isUnnecessaryStringConcatExpression(
}
}
- if (node.left.type === "JSStringLiteral" && !node.left.value.includes("`")) {
+ if (
+ node.left.type === "JSStringLiteral" &&
+ !node.left.value.includes("`") &&
+ !node.left.value.includes("\n")
+ ) {
return true;
}
- if (node.right.type === "JSStringLiteral" && !node.right.value.includes("`")) {
+ if (
+ node.right.type === "JSStringLiteral" &&
+ !node.right.value.includes("`") &&
+ !node.right.value.includes("\n")
+ ) {
return true;
}

MODIFY
packages/@romejs/core/common/file-handlers/json.ts
packages/@romejs/core/common/file-handlers/json.ts
@@ -49,9 +49,9 @@ export const jsonHandler: ExtensionHandler = {
});
if (hasExtensions) {
- formatted = stringifyRJSONFromConsumer({consumer, comments});
+ formatted = stringifyRJSONFromConsumer({consumer, comments}) + "\n";
} else {
- formatted = String(stringifyJSON(consumer.asUnknown()));
+ formatted = String(stringifyJSON(consumer.asUnknown())) + "\n";
}
}

MODIFY
packages/@romejs/core/integrationTestHelpers.ts
packages/@romejs/core/integrationTestHelpers.ts
@@ -98,7 +98,7 @@ export function createIntegrationTest(
// Add serialized project config. We skip this if there's already a project config files entry to allow
// some flexibility if we want invalid project config tests.
if (files["rome.json"] === undefined && files["rome.rjson"] === undefined) {
- files["rome.json"] = stringifyJSON(projectConfig);
+ files["rome.json"] = stringifyJSON(projectConfig) + "\n";
}
// Materialize files

MODIFY
packages/@romejs/core/server/fs/runtime-modules.ts
packages/@romejs/core/server/fs/runtime-modules.ts
@@ -18,7 +18,7 @@ modules.set(
],
[
"package.json",
- '{\n\t"name": "@romejs-runtime/rome",\n\t"type": "module",\n\t"private": true,\n\t"main": "index.ts"\n}',
+ '{\n\t"name": "@romejs-runtime/rome",\n\t"type": "module",\n\t"private": true,\n\t"main": "index.ts"\n}\n',
],
[
"test.ts",

Add newline to end of formatted JSON files (#691)