diff --git a/lib/init.js b/lib/init.js index fec859d6..a8b04ec0 100644 --- a/lib/init.js +++ b/lib/init.js @@ -6,8 +6,6 @@ const originalPackage = require("../package.json"); const packagePath = (...pathElements) => path.join(...[__dirname, "..", ...pathElements]); -const template = name => path.join(__dirname, "..", "templates", name); - class Init { constructor(baseDir, logger) { this.baseDir = baseDir; @@ -64,14 +62,13 @@ class Init { packageInfo.commitlint = { extends: ["@commitlint/config-conventional"], }; + packageInfo.eslintConfig = { + extends: ["ybiquitous"], + }; await this.writeFile("package.json", JSON.stringify(packageInfo, null, 2)); } - async writeTemplateFile(name) { - await this.copyFile(template(name), this.currentPath(name)); - } - async writePackageFile(name) { await this.copyFile(packagePath(name), this.currentPath(name)); } @@ -87,10 +84,8 @@ module.exports = async function init({ await cmd.updatePackageFile(); await cmd.writePackageFile(".editorconfig"); await cmd.writePackageFile(".markdownlint.json"); - await cmd.writeTemplateFile(".eslintrc.js"); }; module.exports.desc = `Setup npm project: - Update 'package.json' -- Create '.editorconfig' -- Create '.eslintrc.js'`; +- Create '.editorconfig'`; diff --git a/package.json b/package.json index e423871a..c0ad9478 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "files": [ "bin", "lib", - "templates", ".editorconfig", ".markdownlint.json" ], diff --git a/templates/.eslintrc.js b/templates/.eslintrc.js deleted file mode 100644 index c1cec76c..00000000 --- a/templates/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: ['ybiquitous'], -} diff --git a/test/fixtures/.eslintrc_expected.js b/test/fixtures/.eslintrc_expected.js deleted file mode 100644 index c1cec76c..00000000 --- a/test/fixtures/.eslintrc_expected.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: ['ybiquitous'], -} diff --git a/test/fixtures/package-empty_expected.json b/test/fixtures/package-empty_expected.json index cfb2455c..e9364714 100644 --- a/test/fixtures/package-empty_expected.json +++ b/test/fixtures/package-empty_expected.json @@ -31,5 +31,8 @@ }, "commitlint": { "extends": ["@commitlint/config-conventional"] + }, + "eslintConfig": { + "extends": ["ybiquitous"] } } diff --git a/test/fixtures/package-normal.json b/test/fixtures/package-normal.json index 4dd5247d..9df27067 100644 --- a/test/fixtures/package-normal.json +++ b/test/fixtures/package-normal.json @@ -8,5 +8,8 @@ }, "commitlint": { "extends": [] + }, + "eslintConfig": { + "extends": [] } } diff --git a/test/fixtures/package-normal_expected.json b/test/fixtures/package-normal_expected.json index 88c010da..7a242d7b 100644 --- a/test/fixtures/package-normal_expected.json +++ b/test/fixtures/package-normal_expected.json @@ -32,5 +32,8 @@ }, "commitlint": { "extends": ["@commitlint/config-conventional"] + }, + "eslintConfig": { + "extends": ["ybiquitous"] } } diff --git a/test/help.test.js b/test/help.test.js index 1cbb8b53..95b67a8b 100644 --- a/test/help.test.js +++ b/test/help.test.js @@ -8,7 +8,6 @@ Commands: cli.js init Setup npm project: - Update 'package.json' - Create '.editorconfig' - - Create '.eslintrc.js' Options: --help, -h Show help [boolean] diff --git a/test/init.test.js b/test/init.test.js index 2be9e542..99a14c8b 100644 --- a/test/init.test.js +++ b/test/init.test.js @@ -79,17 +79,6 @@ test("init", t => { }); }); - testInSandbox('write ".eslintrc.js"', async (t, ctx) => { - await ctx.fixture("package-normal.json"); - await init(ctx.initArgs); - t.ok(ctx.logMessage().includes(".eslintrc.js was updated.")); - - const actual = await ctx.readWorkFile(".eslintrc.js"); - const expected = await ctx.readFixture(".eslintrc_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);