Skip to content

Commit

Permalink
fix: review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Feb 28, 2024
1 parent 8ddf82a commit 1c235b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
8 changes: 0 additions & 8 deletions .editorconfig

This file was deleted.

26 changes: 13 additions & 13 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import enquirer from "enquirer";
import { isPackageTypeModule, installSyncSaveDev, checkPackageJson, fetchPeerDependencies } from "./utils/npm-utils.js";
import * as log from "./utils/logging.js";

// TODO: need to specify the package version - they may export flat configs in the future.
const jsStyleGuides = [
{ message: "Airbnb: https://github.com/airbnb/javascript", name: "airbnb", value: { packageName: "eslint-config-airbnb", type: "eslintrc" } },
{ message: "Standard: https://github.com/standard/standard", name: "standard", value: { packageName: "eslint-config-standard", type: "eslintrc" } },
{ message: "XO: https://github.com/xojs/eslint-config-xo", name: "xo", value: { packageName: "eslint-config-xo", type: "eslintrc" } }
];
const tsStyleGuides = [
{ message: "Standard: https://github.com/standard/eslint-config-standard-with-typescript", name: "standard", value: { packageName: "eslint-config-standard-with-typescript", type: "eslintrc" } },
{ message: "XO: https://github.com/xojs/eslint-config-xo-typescript", name: "xo", value: { packageName: "eslint-config-xo-typescript", type: "eslintrc" } }
];

/**
* Class representing a ConfigGenerator.
*/
Expand Down Expand Up @@ -105,17 +116,6 @@ export class ConfigGenerator {
Object.assign(this.answers, answers);

if (answers.purpose === "style") {

// TODO: need to specify the package version - they may export flat configs in the future.
const jsStyleGuides = [
{ message: "Airbnb: https://github.com/airbnb/javascript", name: "airbnb", value: { packageName: "eslint-config-airbnb", type: "eslintrc" } },
{ message: "Standard: https://github.com/standard/standard", name: "standard", value: { packageName: "eslint-config-standard", type: "eslintrc" } },
{ message: "XO: https://github.com/xojs/eslint-config-xo", name: "xo", value: { packageName: "eslint-config-xo", type: "eslintrc" } }
];
const tsStyleGuides = [
{ message: "Standard: https://github.com/standard/eslint-config-standard-with-typescript", name: "standard", value: { packageName: "eslint-config-standard-with-typescript", type: "eslintrc" } },
{ message: "XO: https://github.com/xojs/eslint-config-xo-typescript", name: "xo", value: { packageName: "eslint-config-xo-typescript", type: "eslintrc" } }
];
const choices = this.answers.language === "javascript" ? jsStyleGuides : tsStyleGuides;
const styleguideAnswer = await enquirer.prompt({
type: "select",
Expand All @@ -134,9 +134,9 @@ export class ConfigGenerator {
* @returns {void}
*/
calc() {
const isModule = isPackageTypeModule(this.cwd);
const isESMModule = isPackageTypeModule(this.cwd);

this.result.configFilename = isModule ? "eslint.config.js" : "eslint.config.mjs";
this.result.configFilename = isESMModule ? "eslint.config.js" : "eslint.config.mjs";

let importContent = "";
const helperContent = `import path from "path";
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/npm-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function fetchPeerDependencies(packageName) {
const fetchedText = npmProcess.stdout.trim();

const peers = JSON.parse(fetchedText || "{}");
const ret = [];
const dependencies = [];

Object.keys(peers).forEach(pkgName => {
ret.push(`${pkgName}@${peers[pkgName]}`);
dependencies.push(`${pkgName}@${peers[pkgName]}`);
});

return ret;
return dependencies;
}

/**
Expand Down

0 comments on commit 1c235b0

Please sign in to comment.