Skip to content

Commit

Permalink
refactor: type imports
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMartel committed Jul 31, 2023
1 parent 97115ec commit 7c7feaf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion node.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
],
rules: {
indent: 'off',
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
'@typescript-eslint/consistent-type-imports': 'error',
'no-use-before-define': 'off',
'no-else-return': [
'error',
Expand Down
6 changes: 2 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import type { PackageManagerRecord } from './types'

export const PACKAGE_NAME = '@monogram/eslint-config'

export const ESLINT_FILENAME = '.eslintrc.js'

export const AVAILABLE_CONFIGS = ['next', 'node'] as const
export type AvailableConfig = (typeof AVAILABLE_CONFIGS)[number]

export const PACKAGE_MANAGERS = ['yarn', 'pnpm', 'npm'] as const
export type PackageManager = (typeof PACKAGE_MANAGERS)[number]

type PackageManagerRecord = Record<PackageManager, string>

export const LOCK_FILES: PackageManagerRecord = {
yarn: `${process.cwd()}/yarn.lock`,
Expand Down
10 changes: 2 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
import { existsSync, writeFileSync } from 'node:fs'
import { execSync } from 'node:child_process'
import { select, confirm } from '@inquirer/prompts'
import {
type PackageManager,
type AvailableConfig,
AVAILABLE_CONFIGS,
ESLINT_FILENAME,
PACKAGE_NAME,
INSTALL_PREFIXES
} from './constants'
import { AVAILABLE_CONFIGS, ESLINT_FILENAME, PACKAGE_NAME, INSTALL_PREFIXES } from './constants'
import { choosePackageManager } from './package-manager'
import type { AvailableConfig, PackageManager } from './types'

if (existsSync(`${process.cwd()}/${ESLINT_FILENAME}`)) {
confirm({ message: `Do you want to replace the current ${ESLINT_FILENAME} file?` }).then(
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { AVAILABLE_CONFIGS, PACKAGE_MANAGERS } from './constants'

export type AvailableConfig = (typeof AVAILABLE_CONFIGS)[number]
export type PackageManager = (typeof PACKAGE_MANAGERS)[number]

export type PackageManagerRecord = Record<PackageManager, string>

0 comments on commit 7c7feaf

Please sign in to comment.