From be9a697b380d9f998605df02b29de8297dfea1a3 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Sun, 18 Nov 2018 08:18:56 -0800 Subject: [PATCH] feat(prettier): format CHANGELOG.md (#274) BREAKING CHANGE: remove `.prettierignore` file --- .prettierignore | 1 - lib/init.js | 3 +-- package.json | 12 +++++++----- test/fixtures/package-empty_expected.json | 10 +++++++--- test/fixtures/package-normal_expected.json | 10 +++++++--- test/init.test.js | 2 +- 6 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1b763b1b..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -CHANGELOG.md diff --git a/lib/init.js b/lib/init.js index 033f91f7..b8f96f33 100644 --- a/lib/init.js +++ b/lib/init.js @@ -54,7 +54,7 @@ class Init { }); // update other keys - const keys = ["husky", "lint-staged"]; + const keys = ["husky", "lint-staged", "standard-version"]; keys.forEach(key => { if (!(key in packageInfo)) { packageInfo[key] = {}; @@ -83,7 +83,6 @@ module.exports = async function init({ const cmd = new Init(cwd, logger); await cmd.updatePackageFile(); await cmd.writePackageFile(".editorconfig"); - await cmd.writePackageFile(".prettierignore"); await cmd.writePackageFile(".markdownlint.json"); await cmd.writeTemplateFile(".eslintrc.js"); await cmd.writeTemplateFile(".commitlintrc.js"); diff --git a/package.json b/package.json index 30c2fe01..52f01b61 100644 --- a/package.json +++ b/package.json @@ -69,20 +69,22 @@ "git add" ], "*.md": [ - "markdownlint" + "markdownlint --ignore CHANGELOG.md" ], "*.{html,json,md,yaml,yml}": [ "prettier --write", "git add" ] - }, - "ignore": [ - "CHANGELOG.md" - ] + } }, "prettier": { "trailingComma": "es5" }, + "standard-version": { + "scripts": { + "postchangelog": "prettier --write CHANGELOG.md" + } + }, "browserslist": [ "> 1%", "not ie 11", diff --git a/test/fixtures/package-empty_expected.json b/test/fixtures/package-empty_expected.json index b04a0d1e..1d4a14ea 100644 --- a/test/fixtures/package-empty_expected.json +++ b/test/fixtures/package-empty_expected.json @@ -20,9 +20,13 @@ "lint-staged": { "linters": { "*.{js,jsx,mjs}": ["eslint --fix --no-ignore", "git add"], - "*.md": ["markdownlint"], + "*.md": ["markdownlint --ignore CHANGELOG.md"], "*.{html,json,md,yaml,yml}": ["prettier --write", "git add"] - }, - "ignore": ["CHANGELOG.md"] + } + }, + "standard-version": { + "scripts": { + "postchangelog": "prettier --write CHANGELOG.md" + } } } diff --git a/test/fixtures/package-normal_expected.json b/test/fixtures/package-normal_expected.json index fbf66afd..c0871922 100644 --- a/test/fixtures/package-normal_expected.json +++ b/test/fixtures/package-normal_expected.json @@ -21,9 +21,13 @@ "*.css": "xyz", "linters": { "*.{js,jsx,mjs}": ["eslint --fix --no-ignore", "git add"], - "*.md": ["markdownlint"], + "*.md": ["markdownlint --ignore CHANGELOG.md"], "*.{html,json,md,yaml,yml}": ["prettier --write", "git add"] - }, - "ignore": ["CHANGELOG.md"] + } + }, + "standard-version": { + "scripts": { + "postchangelog": "prettier --write CHANGELOG.md" + } } } diff --git a/test/init.test.js b/test/init.test.js index 9725689b..9faa7112 100644 --- a/test/init.test.js +++ b/test/init.test.js @@ -64,7 +64,7 @@ test("init", t => { t.end(); }); - [".editorconfig", ".prettierignore", ".markdownlint.json"].forEach(file => { + [".editorconfig", ".markdownlint.json"].forEach(file => { testInSandbox(`write "${file}"`, async (t, ctx) => { await ctx.fixture("package-normal.json"); await init(ctx.initArgs);