From f803d7954fa04ff569cc1f023db59ee2ff7bcfae Mon Sep 17 00:00:00 2001 From: Nazar Kornienko Date: Sun, 27 Oct 2024 21:33:28 +0100 Subject: [PATCH] 0.7.0: improve dx, prepare cli for next steps --- eslint.config.js | 2494 +--- knip.json | 6 +- package.json | 60 +- pnpm-lock.yaml | 11949 +++++----------- src/index.ts | 4 +- src/prompts/00-displayMainReliverseMenu.ts | 30 - src/prompts/00-showReliverseMenu.ts | 28 + src/prompts/01-buildRelivatorTemplateMenu.ts | 75 - src/prompts/01-justInstallRelivator.ts | 70 + src/prompts/02-buildAnotherTemplateMenu.ts | 78 - src/prompts/02-buildOwnRelivator.ts | 75 + ...brariesMenu.ts => 03-installAnyGitRepo.ts} | 24 +- .../{05-appName.ts => 04-askAppName.ts} | 2 +- ...{04-buildTemplate.ts => 05-askTemplate.ts} | 35 +- .../{06-gitUsername.ts => 06-askUserName.ts} | 3 +- .../{07-userWebsite.ts => 07-askAppDomain.ts} | 5 +- ...lization.ts => 08-askGitInitialization.ts} | 2 +- ...encies.ts => 09-askInstallDependencies.ts} | 10 +- ...mation.ts => 10-askSummaryConfirmation.ts} | 4 +- ....ts => 11-askInternationalizationSetup.ts} | 2 +- ....ts => 12-askToResolveProjectConflicts.ts} | 1 - ...iles.ts => 13-askCheckAndDownloadFiles.ts} | 10 +- ...onMenu.ts => 14-showCongratulationMenu.ts} | 30 +- src/prompts/utils/app.ts | 2 +- src/prompts/utils/appts.ts | 11 +- src/prompts/utils/configure.ts | 2 - src/prompts/utils/console.ts | 30 + src/prompts/utils/downloadI18nFiles.ts | 4 +- src/prompts/utils/env.ts | 4 +- src/prompts/utils/eslint.ts | 2 +- src/prompts/utils/installTemplate.ts | 56 +- src/prompts/utils/metadata.ts | 3 +- src/settings.ts | 2 +- tsup.config.ts | 2 +- 34 files changed, 4014 insertions(+), 11101 deletions(-) delete mode 100644 src/prompts/00-displayMainReliverseMenu.ts create mode 100644 src/prompts/00-showReliverseMenu.ts delete mode 100644 src/prompts/01-buildRelivatorTemplateMenu.ts create mode 100644 src/prompts/01-justInstallRelivator.ts delete mode 100644 src/prompts/02-buildAnotherTemplateMenu.ts create mode 100644 src/prompts/02-buildOwnRelivator.ts rename src/prompts/{03-installLibrariesMenu.ts => 03-installAnyGitRepo.ts} (78%) rename src/prompts/{05-appName.ts => 04-askAppName.ts} (88%) rename src/prompts/{04-buildTemplate.ts => 05-askTemplate.ts} (77%) rename src/prompts/{06-gitUsername.ts => 06-askUserName.ts} (81%) rename src/prompts/{07-userWebsite.ts => 07-askAppDomain.ts} (66%) rename src/prompts/{08-gitInitialization.ts => 08-askGitInitialization.ts} (88%) rename src/prompts/{09-installDependencies.ts => 09-askInstallDependencies.ts} (50%) rename src/prompts/{10-confirmation.ts => 10-askSummaryConfirmation.ts} (89%) rename src/prompts/{11-internationalization.ts => 11-askInternationalizationSetup.ts} (83%) rename src/prompts/{12-resolveProjectConflicts.ts => 12-askToResolveProjectConflicts.ts} (98%) rename src/prompts/{13-checkAndDownloadFiles.ts => 13-askCheckAndDownloadFiles.ts} (91%) rename src/prompts/{14-congratulationMenu.ts => 14-showCongratulationMenu.ts} (79%) create mode 100644 src/prompts/utils/console.ts diff --git a/eslint.config.js b/eslint.config.js index 2455558..cb5117c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,101 +1,19 @@ // @ts-check -import js from "@eslint/js"; -import reactCommunity from "@eslint-react/eslint-plugin"; -// @ts-expect-error missing types -import nextPlugin from "@next/eslint-plugin-next"; -import stylistic from "@stylistic/eslint-plugin"; -import tanstack from "@tanstack/eslint-plugin-query"; -// @ts-expect-error missing types -import barrel from "eslint-plugin-barrel-files"; -// @ts-expect-error missing types -import drizzle from "eslint-plugin-drizzle"; -// @ts-expect-error missing types -import eslintComments from "eslint-plugin-eslint-comments"; -import importX from "eslint-plugin-import-x"; -import jsonc from "eslint-plugin-jsonc"; -// @ts-expect-error missing types -import jsxA11yPlugin from "eslint-plugin-jsx-a11y"; -// @ts-expect-error missing types -import markdown from "eslint-plugin-markdown"; -import nodePlugin from "eslint-plugin-n"; -// @ts-expect-error missing types -import noComments from "eslint-plugin-no-comments"; -// @ts-expect-error missing types -import noRelative from "eslint-plugin-no-relative-import-paths"; -import perfectionist from "eslint-plugin-perfectionist"; -// @ts-expect-error missing types -import promisePlugin from "eslint-plugin-promise"; -// @ts-expect-error missing types -import reactJsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js"; -// @ts-expect-error missing types -import reactRecommended from "eslint-plugin-react/configs/recommended.js"; -// @ts-expect-error missing types -import reactHooks from "eslint-plugin-react-hooks"; -// @ts-expect-error missing types -import reactRefresh from "eslint-plugin-react-refresh"; -import tailwindReadable from "eslint-plugin-readable-tailwind"; -import * as regexp from "eslint-plugin-regexp"; -import sonarjs from "eslint-plugin-sonarjs"; -// @ts-expect-error missing types -import eslintPluginSort from "eslint-plugin-sort"; -// @ts-expect-error missing types -import sortExports from "eslint-plugin-sort-exports"; -// @ts-expect-error missing types -import tailwindcss from "eslint-plugin-tailwindcss"; -import unicorn from "eslint-plugin-unicorn"; -import yaml from "eslint-plugin-yml"; -import globals from "globals"; +import eslint from "@eslint/js"; import tseslint from "typescript-eslint"; +import globals from "globals"; -// The current Relivator 1.2.6 version comes with many predefined ESLint configs. -// Run the `bun reli:setup` to easily switch between them and set up other tooling. -// Current: addons\scripts\reliverse\relicon\setup\configs\eslint.config.ultimate.ts -// -const stylisticConfig = stylistic.configs.customize({ - indent: 2, - jsx: true, - quoteProps: "as-needed", - quotes: "double", - semi: true, -}); - -// =================================================================== -// Steps if you want to use the new React Compiler: -// - npx nypm add -D babel-plugin-react-compiler -// - npx nypm add -D eslint-plugin-react-compiler -// - import compiler from "eslint-plugin-react-compiler"; -// - Add the compiler plugin to the plugins object (["react-compiler": compiler,]) -// - Add the compiler rules to the rules object -// - Set experimental.reactCompiler to true in next.config.js -// @see https://react.dev/learn/react-compiler -// =================================================================== -// -// @see https://eslint.org -// @see https://typescript-eslint.io -// @see https://github.com/blefnk/relivator -// export default tseslint.config( - js.configs.recommended, + eslint.configs.recommended, { - ignores: [ - "**/.{git,next,astro,turbo,million,output}/", - "**/{node_modules,build,dist,drizzle}/", - "**/{cluster,public}/", - "pnpm-lock.yaml", - ], + ignores: ["**/.{git,next}/", "**/{dist,node_modules,drizzle,public}/"], }, { name: "@reliverse/eslint-config/core", extends: [ ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked, - sonarjs.configs.recommended, - nodePlugin.configs["flat/recommended-module"], - reactCommunity.configs["recommended-type-checked"], - eslintPluginSort.configs["flat/recommended"], - unicorn.configs["flat/recommended"], - regexp.configs["flat/recommended"], ], files: ["**/*.{js,ts,tsx}"], languageOptions: { @@ -107,8 +25,6 @@ export default tseslint.config( }, parser: tseslint.parser, parserOptions: { - // TODO: `projectService` throws an error when creating new files not implicitly - // TODO: included in tsconfig.json (thats we are using `project: true` for now) ecmaFeatures: { impliedStrict: true, jsx: true, @@ -118,565 +34,34 @@ export default tseslint.config( warnOnUnsupportedTypeScriptVersion: false, }, }, - linterOptions: { - reportUnusedDisableDirectives: "warn", - }, plugins: { - ...reactRecommended.plugins, - "@next/next": nextPlugin, - "@stylistic": stylistic, - "@tanstack/query": tanstack, "@typescript-eslint": tseslint.plugin, - "barrel-files": { rules: barrel.rules }, - drizzle: drizzle, - "eslint-comments": eslintComments, - "import-x": importX, - "jsx-a11y": { - rules: jsxA11yPlugin.rules, - }, - "no-relative-import-paths": noRelative, - perfectionist: perfectionist, - promise: promisePlugin, - "react/jsx-runtime": reactJsxRuntime, - "react-hooks": reactHooks, - "react-refresh": reactRefresh, - "readable-tailwind": tailwindReadable, - sort: eslintPluginSort, - "sort-exports": sortExports, - tailwindcss: tailwindcss, }, rules: { - // @see https://eslint.org/docs/latest/use/configure - ...perfectionist.configs["recommended-natural"].rules, - ...stylisticConfig.rules, - ...importX.configs.recommended.rules, - ...jsxA11yPlugin.configs.recommended.rules, - ...nextPlugin.configs.recommended.rules, - ...promisePlugin.configs.recommended.rules, - ...reactHooks.configs.recommended.rules, - ...reactJsxRuntime.rules, - ...reactRecommended.rules, - ...tailwindReadable.configs.error.rules, - ...tailwindReadable.configs.warning.rules, - ...tailwindcss.configs.recommended.rules, - - // @see https://eslint-react.xyz/rules/overview - "@eslint-react/dom/no-dangerously-set-innerhtml": "off", - "@eslint-react/hooks-extra/ensure-custom-hooks-using-other-hooks": "off", - "@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "off", - "@eslint-react/hooks-extra/no-redundant-custom-hook": "off", - "@eslint-react/no-array-index-key": "off", - "@eslint-react/no-duplicate-key": "off", - "@eslint-react/no-leaked-conditional-rendering": "off", - "@eslint-react/no-unstable-context-value": "off", - "@eslint-react/no-unstable-default-props": "off", - "@eslint-react/prefer-destructuring-assignment": "off", - "@eslint-react/prefer-read-only-props": "off", - - // @see https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-plugin - "@next/next/no-duplicate-head": "off", - "@next/next/no-html-link-for-pages": "off", - - // @see https://eslint.style/rules - "@stylistic/array-bracket-newline": [ - "off", - { - minItems: 10, - multiline: true, - }, - ], - "@stylistic/array-bracket-spacing": [ - "warn", - "never", - { - arraysInArrays: false, - objectsInArrays: false, - singleValue: false, - }, - ], - "@stylistic/arrow-parens": ["warn", "always"], - - // { requireForBlockBody: true }, - "@stylistic/arrow-spacing": [ - "warn", - { - after: true, - before: true, - }, - ], - "@stylistic/block-spacing": ["warn", "always"], - "@stylistic/brace-style": [ - "off", - "1tbs", - { - allowSingleLine: true, - }, - ], - "@stylistic/comma-dangle": [ - "warn", - { - // TODO: fix `Unexpected trailing comma.` when `type<>` - arrays: "always-multiline", - enums: "always-multiline", - exports: "always-multiline", - functions: "always-multiline", - generics: "always-multiline", - imports: "always-multiline", - objects: "always-multiline", - tuples: "always-multiline", - }, - ], - "@stylistic/comma-spacing": [ - "warn", - { - after: true, - before: false, - }, - ], - "@stylistic/comma-style": ["warn", "last"], - "@stylistic/computed-property-spacing": ["off", "always"], - "@stylistic/dot-location": ["warn", "property"], - "@stylistic/eol-last": "warn", - "@stylistic/function-call-argument-newline": ["warn", "consistent"], - "@stylistic/function-call-spacing": ["warn", "never"], - "@stylistic/function-paren-newline": [ - // TODO: fix incompatibility with biome (or with something else) - "off", - "multiline-arguments", - ], - "@stylistic/generator-star-spacing": [ - "warn", - { - after: true, - before: false, - method: { - after: false, - before: true, - }, - }, - ], - "@stylistic/implicit-arrow-linebreak": ["off", "beside"], - "@stylistic/indent": [ - // TODO: fix incompatibility with biome (or with something else) - "off", - 2, - { - ignoredNodes: [ - "TSTypeLiteral > TSPropertySignature", - "TSUnionType > TSTypeLiteral", - ], - SwitchCase: 1, - }, - ], - "@stylistic/indent-binary-ops": ["off", 2], - - // @see https://eslint.style/rules - "@stylistic/jsx-child-element-spacing": "off", - "@stylistic/jsx-closing-bracket-location": "off", - "@stylistic/jsx-closing-tag-location": "off", - "@stylistic/jsx-curly-newline": "off", - "@stylistic/jsx-indent": [ - "off", - 2, - { - checkAttributes: true, - indentLogicalExpressions: true, - }, - ], - "@stylistic/jsx-indent-props": ["warn", 2], - "@stylistic/jsx-one-expression-per-line": "off", - "@stylistic/jsx-pascal-case": "off", - "@stylistic/jsx-self-closing-comp": "off", - "@stylistic/jsx-wrap-multilines": [ - "warn", - { - arrow: "parens", - assignment: "parens", - condition: "ignore", - declaration: "parens", - logical: "ignore", - prop: "ignore", - return: "parens", - }, - ], - "@stylistic/key-spacing": [ - "warn", - { - afterColon: true, - beforeColon: false, - }, - ], - "@stylistic/keyword-spacing": [ - "warn", - { - after: true, - before: true, - }, - ], - "@stylistic/linebreak-style": ["warn", "unix"], - "@stylistic/lines-around-comment": [ - "warn", - { - afterBlockComment: false, - afterHashbangComment: true, - afterLineComment: false, - allowArrayEnd: true, - allowArrayStart: true, - allowBlockEnd: true, - allowBlockStart: true, - allowClassEnd: true, - allowClassStart: true, - allowEnumEnd: true, - allowEnumStart: true, - allowInterfaceEnd: true, - allowInterfaceStart: true, - allowModuleEnd: true, - allowModuleStart: true, - allowObjectEnd: true, - allowObjectStart: true, - allowTypeEnd: true, - allowTypeStart: true, - applyDefaultIgnorePatterns: true, - beforeBlockComment: true, - beforeLineComment: true, - ignorePattern: - "@type\\s.+|@ts-expect-error|biome-ignore|TODO:|import", - }, - ], - - // @see https://eslint.style/rules/default/max-len - "@stylistic/max-len": [ - // @see https://github.com/eslint/eslint/issues/11325 - "warn", - { - // TODO: change to 80 in 1.3.0 GA release (@see https://github.com/prettier/prettier/issues) - code: 120, - ignoreComments: false, - ignorePattern: "^[\\s]*(//|