Skip to content

Commit

Permalink
Merge pull request #16 from eslint-kit/fix/lint-scripts-and-typo
Browse files Browse the repository at this point in the history
Lint scripts and typo
  • Loading branch information
Evgeny Zakharov authored Apr 30, 2023
2 parents f7346d2 + 937a331 commit 72f8be1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/modules/commands/init.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class InitCommand implements CommandRunner {
console.info()
const proceed = await confirmDependencies()
if (!proceed) return
console.info()

if (dependenciesToDelete.length > 0) {
await this.manager.delete(dependenciesToDelete)
Expand Down Expand Up @@ -123,15 +124,15 @@ export class InitCommand implements CommandRunner {

if (await this.meta.hasTypeScript()) {
presets.push(builder.preset('typescript'))
extensions.add('.js').add('.ts')
extensions.add('js').add('ts')
}

if (await this.meta.hasReact()) {
presets.push(builder.preset('react'))
extensions.add('.jsx')
extensions.add('jsx')

if (await this.meta.hasTypeScript()) {
extensions.add('.tsx')
extensions.add('tsx')
}
}

Expand All @@ -147,21 +148,21 @@ export class InitCommand implements CommandRunner {

if (await this.meta.hasVue()) {
presets.push(builder.preset('vue'))
extensions.add('.vue')
extensions.add('vue')
}

if (await this.meta.hasSolidJs()) {
presets.push(builder.preset('solidJs'))
extensions.add('.jsx')
extensions.add('jsx')

if (await this.meta.hasTypeScript()) {
extensions.add('.tsx')
extensions.add('tsx')
}
}

if (await this.meta.hasSvelte()) {
presets.push(builder.preset('svelte'))
extensions.add('.svelte')
extensions.add('svelte')
}

if (await this.meta.hasEffector()) {
Expand All @@ -170,10 +171,11 @@ export class InitCommand implements CommandRunner {

if (canAddLintScripts) {
const scripts = packageJson.scripts ?? {}
const dir = Array.from(directories).join(',')
const ext = Array.from(extensions).join(',')
const dir = Array.from(directories).join(' ')
scripts.lint = `eslint --ext ${ext} ${dir}`
scripts['lint:fix'] = `eslint --ext ${ext} ${dir} --fix`
const glob = `"{${dir}}/**/*.{${ext}}"`
scripts.lint = `eslint ${glob}`
scripts['lint:fix'] = `eslint ${glob} --fix`
await this.meta.updatePackageJsonField('scripts', scripts)
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/commands/init.questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function askAboutPackageJsonScripts(
name,
type: 'confirm',
default: canSafelyAdd,
message: `Do you want to ${action} "lint" and "lint:fix" scripts to your package.json?`,
message: `Do you want to ${action} "lint" and "lint:fix" package.json scripts?`,
},
])
.then((answers) => answers[name])
Expand Down

0 comments on commit 72f8be1

Please sign in to comment.