Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint): move .eslintrc.js to package.json #278

Merged
merged 1 commit into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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