Skip to content

Commit

Permalink
Fix hasPkg checks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Mar 14, 2021
1 parent 35c5f21 commit 52fe441
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
11 changes: 4 additions & 7 deletions detect/configs.js
Original file line number Diff line number Diff line change
@@ -1,14 1,11 @@
const { settings = {} } = require('../lib/config')
const { hasAnyDep } = require('../lib/utils')

const hasBabel = hasAnyDep('babel') || hasAnyDep('@babel/core') || settings.babel
const { hasBabel, hasTypeScript, hasReact } = require('../lib/hasPackage')

const configs = []

if (hasAnyDep('typescript')) configs.push('@typescript-eslint/eslint-plugin')
if (hasTypeScript) configs.push('@typescript-eslint/eslint-plugin')

configs.push(hasAnyDep('react') ? 'airbnb' : 'airbnb-base')
if (hasAnyDep('typescript')) configs.push('airbnb-typescript')
configs.push(hasReact ? 'airbnb' : 'airbnb-base')
if (hasTypeScript) configs.push('airbnb-typescript')
if (hasBabel) configs.push('airbnb-babel')

configs.push('adjunct')
Expand Down
7 changes: 2 additions & 5 deletions detect/parsers.js
Original file line number Diff line number Diff line change
@@ -1,12 1,9 @@
const isModuleAvailable = require('../lib/is-module-available')

const hasBabel = isModuleAvailable('babel') || isModuleAvailable('@babel/core')
const hasTypescript = isModuleAvailable('typescript')
const { hasBabel, hasTypeScript } = require('../lib/hasPackage')

const parsers = []

if (hasBabel) parsers.push('babel-eslint')

if (hasTypescript) parsers.push('@typescript-eslint/parser')
if (hasTypeScript) parsers.push('@typescript-eslint/parser')

module.exports = parsers
2 changes: 0 additions & 2 deletions detect/plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 1,5 @@
const { env = {}, settings = {} } = require('../lib/config')

const { hasAnyDep } = require('../lib/utils')

const { hasBabel } = require('../lib/hasPackage')

const plugins = []
Expand Down
3 changes: 3 additions & 0 deletions lib/hasPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,10 @@ const hasBabel =

const hasTypeScript = settings.typescript || hasAnyDep('typescript')

const hasReact = hasAnyDep('react')

module.exports = {
hasBabel,
hasTypeScript,
hasReact,
}

0 comments on commit 52fe441

Please sign in to comment.