From c432abfe06389d4ff9e9d0f972ebf3c5ea511ef8 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Wed, 21 Aug 2024 17:43:07 -0700 Subject: [PATCH] fix: prevent double newline --- lib/rules/validate-schema.js | 3 +-- tests/lib/rules/validate-schema.js | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/rules/validate-schema.js b/lib/rules/validate-schema.js index e0bc9d5..e16e691 100644 --- a/lib/rules/validate-schema.js +++ b/lib/rules/validate-schema.js @@ -2,7 +2,6 @@ const Ajv = require('ajv'); const { default: betterAjvErrors } = require('better-ajv-errors'); -const { EOL } = require('os'); let ajv; @@ -77,7 +76,7 @@ module.exports = { let validate = ajvFix.compile(schema); validate(packageJson); - return fixer.replaceText(packageJsonNode, JSON.stringify(packageJson, null, 2) + EOL); + return fixer.replaceText(packageJsonNode, JSON.stringify(packageJson, null, 2)); } }); } diff --git a/tests/lib/rules/validate-schema.js b/tests/lib/rules/validate-schema.js index 21bc412..1958da0 100644 --- a/tests/lib/rules/validate-schema.js +++ b/tests/lib/rules/validate-schema.js @@ -45,8 +45,7 @@ new RuleTester().run('validate-schema', rule, preprocess({ }], output: `{ "foo": "bar" -} -` +}` }, { code: '{"foo":"bar"}', @@ -63,8 +62,7 @@ new RuleTester().run('validate-schema', rule, preprocess({ }], output: `{ "foo": "bar" -} -` +}` }, { code: '{"foo":"bar","bar":"foo"}', @@ -89,8 +87,7 @@ new RuleTester().run('validate-schema', rule, preprocess({ }], output: `{ "foo": "bar" -} -` +}` } ] }));