Skip to content

Commit

Permalink
fix(eslint-config): remove isSrcAppDirAvailable which seems useless
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Nov 1, 2019
1 parent 932f230 commit 7906321
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
12 changes: 4 additions & 8 deletions packages/eslint-config/_util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable node/no-extraneous-require */
const fs = require('fs')
const { resolve } = require('path')

const { tryFile, tryPkg } = require('@pkgr/utils')
const { isPkgAvailable, tryFile } = require('@pkgr/utils')
const isGlob = require('is-glob')
const globSync = require('tiny-glob/sync')

Expand Down Expand Up @@ -53,11 +52,7 @@ try {
exports.isSrcDirAvailable = fs.statSync(resolve('src')).isDirectory()
} catch (e) {}

try {
exports.isSrcAppDirAvailable = fs.statSync(resolve('src/app')).isDirectory()
} catch (e) {}

exports.isWebpackAvailable = tryPkg('webpack')
exports.isWebpackAvailable = isPkgAvailable('webpack')

// https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific
exports.webpackSpecVars = [
Expand All @@ -76,7 +71,7 @@ exports.camelCaseRule = [
{
properties: 'never',
ignoreDestructuring: true,
allow: exports.isWebpackAvailable && exports.webpackSpecVars,
allow: exports.isWebpackAvailable ? exports.webpackSpecVars : undefined,
},
]

Expand All @@ -98,6 +93,7 @@ exports.magicNumbers = [
100,
365,
500,
768,
1000,
1024,
3600,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
],
},
},
globals: isWebpackAvailable && getGlobals(webpackSpecVars),
globals: isWebpackAvailable ? getGlobals(webpackSpecVars) : undefined,
rules: {
camelcase: camelCaseRule,
'import/order': [
Expand Down
10 changes: 2 additions & 8 deletions packages/eslint-config/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ const {
tryPkg,
} = require('@pkgr/utils')

const {
camelCaseRule,
isSrcDirAvailable,
isSrcAppDirAvailable,
magicNumbers,
} = require('./_util')
const { camelCaseRule, isSrcDirAvailable, magicNumbers } = require('./_util')

const configFile =
tryFile(resolve('babel.config.js')) ||
Expand Down Expand Up @@ -75,8 +70,7 @@ const resolveSettings = {
resolvePaths: [
tryFile('node_modules/@d-ts', true),
tryFile('node_modules/@types', true),
isSrcDirAvailable && !isAngularAvailable && 'src',
isAngularAvailable && isSrcAppDirAvailable && 'src/app',
isSrcDirAvailable && 'src',
].filter(Boolean),
tryExtensions: [
'.ts',
Expand Down

0 comments on commit 7906321

Please sign in to comment.