Skip to content

Commit

Permalink
feat(eslint): move .eslintrc.js to package.json (#278)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove `.eslintrc.js` file
  • Loading branch information
ybiquitous authored Nov 18, 2018
1 parent 0884342 commit 5077193
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 30 deletions.
13 changes: 4 additions & 9 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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'`;
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"files": [
"bin",
"lib",
"templates",
".editorconfig",
".markdownlint.json"
],
Expand Down
4 changes: 0 additions & 4 deletions templates/.eslintrc.js

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/.eslintrc_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 @@ -31,5 +31,8 @@
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
},
"eslintConfig": {
"extends": ["ybiquitous"]
}
}
3 changes: 3 additions & 0 deletions test/fixtures/package-normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
},
"commitlint": {
"extends": []
},
"eslintConfig": {
"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 @@ -32,5 +32,8 @@
},
"commitlint": {
"extends": ["@commitlint/config-conventional"]
},
"eslintConfig": {
"extends": ["ybiquitous"]
}
}
1 change: 0 additions & 1 deletion test/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 0 additions & 11 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5077193

Please sign in to comment.