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

chore: eslint remove the space between the bracket #10

Merged
merged 2 commits into from
Mar 31, 2024
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
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ pnpm-lock.yaml
!.*.cjs
!.*.mjs
!.*.ts

.github
.eslintrc
.lintstagedrc.mjs
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"useTabs": false,
"singleQuote": true,
"editorconfig": true,
"bracketSpacing": true,
"bracketSpacing": false,
"jsxSingleQuote": false,
"bracketSameLine": false,
"pluginSearchDirs": false,
Expand Down
10 changes: 5 additions & 5 deletions src/actions/env-action.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { outputComponents, outputInfo } from '@helpers/output-info';
import { getPackageInfo } from '@helpers/package';
import { resolver } from 'src/constants/path';
import {outputComponents, outputInfo} from '@helpers/output-info';
import {getPackageInfo} from '@helpers/package';
import {resolver} from 'src/constants/path';

interface EnvActionOptions {
packagePath?: string;
}

export async function envAction(options: EnvActionOptions) {
const { packagePath = resolver('package.json') } = options;
const {packagePath = resolver('package.json')} = options;

const { currentComponents } = await getPackageInfo(packagePath);
const {currentComponents} = await getPackageInfo(packagePath);

/** ======================== Output the current components ======================== */
outputComponents(currentComponents);
Expand Down
16 changes: 8 additions & 8 deletions src/actions/init-action.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { rename } from 'fs';
import {rename} from 'fs';

import chalk from 'chalk';
import { oraPromise } from 'ora';
import {oraPromise} from 'ora';

import { downloadTemplate } from '@helpers/fetch';
import { Logger } from '@helpers/logger';
import {downloadTemplate} from '@helpers/fetch';
import {Logger} from '@helpers/logger';

import { ROOT } from '../../src/constants/path';
import { APP_DIR, APP_REPO, PAGES_DIR, PAGES_REPO } from '../../src/constants/templates';
import { getSelect } from '../../src/prompts';
import {ROOT} from '../../src/constants/path';
import {APP_DIR, APP_REPO, PAGES_DIR, PAGES_REPO} from '../../src/constants/templates';
import {getSelect} from '../../src/prompts';

export interface InitActionOptions {
template?: 'app' | 'pages';
package?: 'npm' | 'yarn' | 'pnpm';
}

export async function initAction(projectName: string, options: InitActionOptions) {
let { package: packageName, template } = options;
let {package: packageName, template} = options;

if (!template) {
template = await getSelect('Select a template', [
Expand Down
14 changes: 7 additions & 7 deletions src/actions/list-action.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Logger } from '@helpers/logger';
import { outputComponents } from '@helpers/output-info';
import { getPackageInfo } from '@helpers/package';
import {Logger} from '@helpers/logger';
import {outputComponents} from '@helpers/output-info';
import {getPackageInfo} from '@helpers/package';

import { type NextUIComponents, nextUIComponents } from '../../src/constants/component';
import { resolver } from '../../src/constants/path';
import {type NextUIComponents, nextUIComponents} from '../../src/constants/component';
import {resolver} from '../../src/constants/path';

interface ListActionOptions {
current?: boolean;
packagePath?: string;
}

export async function listAction(options: ListActionOptions) {
const { current, packagePath = resolver('package.json') } = options;
const {current, packagePath = resolver('package.json')} = options;

let components = nextUIComponents as NextUIComponents;

try {
/** ======================== Get the installed components ======================== */
if (current) {
const { currentComponents } = await getPackageInfo(packagePath);
const {currentComponents} = await getPackageInfo(packagePath);

components = currentComponents;
}
Expand Down
2 changes: 1 addition & 1 deletion src/constants/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'path';
import {resolve} from 'path';

export const ROOT = process.cwd();
export const resolver = (path: string) => resolve(ROOT, path);
4 changes: 2 additions & 2 deletions src/helpers/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Readable } from 'stream';
import { pipeline } from 'stream/promises';
import {Readable} from 'stream';
import {pipeline} from 'stream/promises';

import retry from 'async-retry';
import tar from 'tar';
Expand Down
9 changes: 3 additions & 6 deletions src/helpers/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-console */

import type { SAFE_ANY } from './type';
import type {SAFE_ANY} from './type';

import chalk from 'chalk';
import { default as _gradientString } from 'gradient-string';
import {default as _gradientString} from 'gradient-string';

export const defaultColors = ['#F54180', '#338EF7'] as const;

Expand Down Expand Up @@ -31,10 +31,7 @@ export class Logger {
console.error(...args.map((item) => chalk.red(item)));
}

static gradient(
content: string | number | boolean,
options?: { colors?: tinycolor.ColorInput[] }
) {
static gradient(content: string | number | boolean, options?: {colors?: tinycolor.ColorInput[]}) {
this.log(gradientString(...(options?.colors ?? defaultColors))(String(content)));
}

Expand Down
6 changes: 3 additions & 3 deletions src/helpers/output-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CommandName } from './type';
import type {CommandName} from './type';

import chalk from 'chalk';

Expand All @@ -8,8 +8,8 @@ import {
orderNextUIComponentKeys
} from 'src/constants/component';

import { Logger } from './logger';
import { PasCalCase } from './utils';
import {Logger} from './logger';
import {PasCalCase} from './utils';

const rounded = {
bl: 'β•°',
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/package.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readFileSync } from 'fs';
import {readFileSync} from 'fs';

import { type NextUIComponents, nextUIComponents } from 'src/constants/component';
import {type NextUIComponents, nextUIComponents} from 'src/constants/component';

import { Logger } from './logger';
import {Logger} from './logger';

/**
* Get the package information
Expand All @@ -19,7 +19,7 @@ export async function getPackageInfo(packagePath: string) {

const devDependencies = pkg.devDependencies || {};
const dependencies = pkg.dependencies || {};
const allDependencies = { ...devDependencies, ...dependencies };
const allDependencies = {...devDependencies, ...dependencies};
const dependenciesKeys = new Set(Object.keys(allDependencies));

const currentComponents = (nextUIComponents as unknown as NextUIComponents).filter(
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PascalCase } from './type';
import type {PascalCase} from './type';

import { Logger } from './logger';
import {Logger} from './logger';

export function getCommandDescAndLog(log: string, desc: string) {
Logger.gradient(log);
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import chalk from 'chalk';
import { Command } from 'commander';
import {Command} from 'commander';

import { Logger } from '@helpers/logger';
import { getCommandDescAndLog } from '@helpers/utils';
import {Logger} from '@helpers/logger';
import {getCommandDescAndLog} from '@helpers/utils';

import pkg from '../package.json';

import { envAction } from './actions/env-action';
import { initAction } from './actions/init-action';
import { listAction } from './actions/list-action';
import {envAction} from './actions/env-action';
import {initAction} from './actions/init-action';
import {listAction} from './actions/list-action';

const nextui = new Command();

Expand Down
6 changes: 3 additions & 3 deletions src/prompts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import prompts from 'prompts';

import { Logger } from '@helpers/logger';
import {Logger} from '@helpers/logger';

const defaultPromptOptions: prompts.Options = {
onCancel: () => {
Expand All @@ -15,7 +15,7 @@ export async function getInput(message: string, choices?: prompts.Choice[]) {
message,
name: 'value',
type: 'autocomplete',
...(choices ? { choices } : {})
...(choices ? {choices} : {})
},
defaultPromptOptions
);
Expand All @@ -29,7 +29,7 @@ export async function getSelect(message: string, choices: prompts.Choice[]) {
message,
name: 'value',
type: 'select',
...(choices ? { choices } : {})
...(choices ? {choices} : {})
},
defaultPromptOptions
);
Expand Down
4 changes: 2 additions & 2 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig } from 'tsup';
import {defineConfig} from 'tsup';

export default defineConfig((options) => {
return {
banner: { js: '#!/usr/bin/env node' },
banner: {js: '#!/usr/bin/env node'},
clean: true,
dts: true,
entry: ['src/index.ts'],
Expand Down
Loading