Skip to content

Commit

Permalink
feat(commitlint): move .commitlintrc.js to package.json (#277)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove `.commitlintrc.js` file
  • Loading branch information
ybiquitous authored Nov 18, 2018
1 parent c8796fb commit 0884342
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 20 deletions.
5 changes: 3 additions & 2 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Init {
}
Object.assign(packageInfo[key], originalPackage[key]);
});
packageInfo.commitlint = {
extends: ["@commitlint/config-conventional"],
};

await this.writeFile("package.json", JSON.stringify(packageInfo, null, 2));
}
Expand All @@ -85,11 +88,9 @@ module.exports = async function init({
await cmd.writePackageFile(".editorconfig");
await cmd.writePackageFile(".markdownlint.json");
await cmd.writeTemplateFile(".eslintrc.js");
await cmd.writeTemplateFile(".commitlintrc.js");
};

module.exports.desc = `Setup npm project:
- Update 'package.json'
- Create '.commitlintrc.js'
- Create '.editorconfig'
- Create '.eslintrc.js'`;
3 changes: 0 additions & 3 deletions templates/.commitlintrc.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/.commitlintrc_expected.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/fixtures/package-empty_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"scripts": {
"postchangelog": "prettier --write CHANGELOG.md"
}
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
}
}
3 changes: 3 additions & 0 deletions test/fixtures/package-normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
},
"lint-staged": {
"*.css": "xyz"
},
"commitlint": {
"extends": []
}
}
3 changes: 3 additions & 0 deletions test/fixtures/package-normal_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
"scripts": {
"postchangelog": "prettier --write CHANGELOG.md"
}
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
}
}
1 change: 0 additions & 1 deletion test/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ cli.js <command>
Commands:
cli.js init Setup npm project:
- Update 'package.json'
- Create '.commitlintrc.js'
- Create '.editorconfig'
- Create '.eslintrc.js'
Expand Down
11 changes: 0 additions & 11 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@ test("init", t => {
t.end();
});

testInSandbox('write ".commitlintrc.js"', async (t, ctx) => {
await ctx.fixture("package-normal.json");
await init(ctx.initArgs);
t.ok(ctx.logMessage().includes(".commitlintrc.js was updated."));

const actual = await ctx.readWorkFile(".commitlintrc.js");
const expected = await ctx.readFixture(".commitlintrc_expected.js");
t.is(actual, expected);
t.end();
});

testInSandbox("throw error if no package.json", async (t, ctx) => {
const error = await init(ctx.initArgs).catch(err => err);
t.ok(error instanceof Error);
Expand Down

0 comments on commit 0884342

Please sign in to comment.