Skip to content

Commit

Permalink
fix: remove eslint (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn authored Mar 27, 2024
1 parent 45e2ecc commit 65bc28d
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 53 deletions.
2 changes: 0 additions & 2 deletions create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function createApp({
ui,
appPath,
packageManager,
eslint,
frontend,
openAiKey,
llamaCloudKey,
Expand Down Expand Up @@ -78,7 +77,6 @@ export async function createApp({
ui,
packageManager,
isOnline,
eslint,
openAiKey,
llamaCloudKey,
model,
Expand Down
1 change: 0 additions & 1 deletion e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export async function runCreateLlama(
"--open-ai-key",
process.env.OPENAI_API_KEY,
appType,
"--eslint",
"--use-pnpm",
"--port",
port,
Expand Down
1 change: 0 additions & 1 deletion helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface InstallTemplateArgs {
framework: TemplateFramework;
ui: TemplateUI;
dataSources: TemplateDataSource[];
eslint: boolean;
customApiPath?: string;
openAiKey?: string;
llamaCloudKey?: string;
Expand Down
10 changes: 0 additions & 10 deletions helpers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const installTSTemplate = async ({
template,
framework,
ui,
eslint,
customApiPath,
vectorDb,
postInstallAction,
Expand All @@ -75,7 +74,6 @@ export const installTSTemplate = async ({
console.log("\nInitializing project with template:", template, "\n");
const templatePath = path.join(templatesDir, "types", template, framework);
const copySource = ["**"];
if (!eslint) copySource.push("!eslintrc.json");

await copy(copySource, root, {
parents: true,
Expand Down Expand Up @@ -287,14 +285,6 @@ export const installTSTemplate = async ({
};
}

if (!eslint) {
// Remove packages starting with "eslint" from devDependencies
packageJson.devDependencies = Object.fromEntries(
Object.entries(packageJson.devDependencies).filter(
([key]) => !key.startsWith("eslint"),
),
);
}
await fs.writeFile(
packageJsonFile,
JSON.stringify(packageJson, null, 2) + os.EOL,
Expand Down
11 changes: 0 additions & 11 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ const program = new Commander.Command(packageJson.name)
.action((name) => {
projectPath = name;
})
.option(
"--eslint",
`
Initialize with eslint config.
`,
)
.option(
"--use-npm",
`
Expand Down Expand Up @@ -189,9 +182,6 @@ const program = new Commander.Command(packageJson.name)
if (process.argv.includes("--no-frontend")) {
program.frontend = false;
}
if (process.argv.includes("--no-eslint")) {
program.eslint = false;
}
if (process.argv.includes("--tools")) {
if (program.tools === "none") {
program.tools = [];
Expand Down Expand Up @@ -296,7 +286,6 @@ async function run(): Promise<void> {
ui: program.ui,
appPath: resolvedProjectPath,
packageManager,
eslint: program.eslint,
frontend: program.frontend,
openAiKey: program.openAiKey,
llamaCloudKey: program.llamaCloudKey,
Expand Down
20 changes: 0 additions & 20 deletions questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const defaults: QuestionArgs = {
template: "streaming",
framework: "nextjs",
ui: "html",
eslint: true,
frontend: false,
openAiKey: "",
llamaCloudKey: "",
Expand Down Expand Up @@ -784,24 +783,5 @@ export const askQuestions = async (
}
}

if (program.framework !== "fastapi" && program.eslint === undefined) {
if (ciInfo.isCI) {
program.eslint = getPrefOrDefault("eslint");
} else {
const styledEslint = blue("ESLint");
const { eslint } = await prompts({
onState: onPromptState,
type: "toggle",
name: "eslint",
message: `Would you like to use ${styledEslint}?`,
initial: getPrefOrDefault("eslint"),
active: "Yes",
inactive: "No",
});
program.eslint = Boolean(eslint);
preferences.eslint = Boolean(eslint);
}
}

await askPostInstallAction();
};
6 changes: 5 additions & 1 deletion templates/types/streaming/express/eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "eslint:recommended"
"extends": ["eslint:recommended", "prettier"],
"rules": {
"max-params": ["error", 4],
"prefer-const": "error"
}
}
14 changes: 9 additions & 5 deletions templates/types/streaming/express/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "llama-index-express-streaming",
"version": "1.0.0",
"main": "dist/index.js",
"type": "module",
"main": "dist/index.mjs",
"scripts": {
"format": "prettier --ignore-unknown --cache --check .",
"format:write": "prettier --ignore-unknown --write .",
"build": "tsup index.ts --format esm --dts",
"start": "node dist/index.js",
"dev": "concurrently \"tsup index.ts --format esm --dts --watch\" \"nodemon -q dist/index.js\""
"start": "node dist/index.mjs",
"dev": "concurrently \"tsup index.ts --format esm --dts --watch\" \"nodemon -q dist/index.mjs\""
},
"dependencies": {
"ai": "^2.2.25",
Expand All @@ -23,6 +24,9 @@
"eslint": "^8.54.0",
"nodemon": "^3.0.1",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
"typescript": "^5.3.2",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"eslint-config-prettier": "^8.10.0"
}
}
3 changes: 3 additions & 0 deletions templates/types/streaming/express/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ["prettier-plugin-organize-imports"],
};
6 changes: 5 additions & 1 deletion templates/types/streaming/nextjs/eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "prettier"],
"rules": {
"max-params": ["error", 4],
"prefer-const": "error"
}
}
7 changes: 6 additions & 1 deletion templates/types/streaming/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "llama-index-nextjs-streaming",
"version": "1.0.0",
"scripts": {
"format": "prettier --ignore-unknown --cache --check .",
"format:write": "prettier --ignore-unknown --write .",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand Down Expand Up @@ -38,6 +40,9 @@
"tailwindcss": "^3.3.6",
"typescript": "^5.3.2",
"@types/react-syntax-highlighter": "^15.5.11",
"cross-env": "^7.0.3"
"cross-env": "^7.0.3",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"eslint-config-prettier": "^8.10.0"
}
}
3 changes: 3 additions & 0 deletions templates/types/streaming/nextjs/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ["prettier-plugin-organize-imports"],
};

0 comments on commit 65bc28d

Please sign in to comment.