How to use the @pkgr/utils.isPkgAvailable function in @pkgr/utils

To help you get started, we’ve selected a few @pkgr/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1stG / configs / packages / eslint-config / _util.js View on Github external
if (isMonorepo) {
  exports.allowModules = monorepoPkgs.reduce((acc, pkg) => {
    const pkgJson = tryRequirePkg(resolve(pkg, 'package.json'))
    if (!pkgJson) {
      return acc
    }
    const { name, peerDependencies = {}, dependencies = {} } = pkgJson
    return acc.concat(
      name,
      Object.keys(peerDependencies),
      Object.keys(dependencies),
    )
  }, [])
}

exports.isWebpackAvailable = isPkgAvailable('webpack')

// https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific
exports.webpackSpecVars = [
  '__resourceQuery',
  '__non_webpack_require__',
  '__webpack_chunk_load__',
  '__webpack_hash__',
  '__webpack_modules__',
  '__webpack_public_path__',
  '__webpack_require__',
  'DEBUG',
]

exports.camelCaseRule = [
  2,
  {
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
exports.stories = {
  files: '**/stories/**/*.{js,jsx,mdx,ts,tsx,vue}',
  rules: nonSourceRules,
}

exports.config = {
  files: ['.*rc.js', '*.config.{js,ts}'],
  rules: nonSourceRules,
}

exports.overrides = []
  .concat(
    isPkgAvailable('@babel/core') && exports.js,
    isTsAvailable && exports.ts,
    isPkgAvailable('tslint') && lintFile && exports.tslint,
    isReactAvailable && exports.react,
    isReactAvailable && exports.reactHooks,
    isReactAvailable && exports.reactTs,
    isVueAvailable && exports.vue,
    isAngularAvailable && exports.angular,
    exports.mdx,
    exports.jest,
    exports.test,
    exports.stories,
    exports.config,
    exports.dTs,
  )
  .filter(Boolean)
github 1stG / configs / packages / lint-staged / base.js View on Github external
'prettier --write',
    'git add',
  ],
  '.!(*browserslist|npm|yarn)rc': ['prettier --write', 'git add'],
  '.{editorconfig|browserslistrc|npmrc|yarnrc}': [
    'prettier --write --parser sh',
    'git add',
  ],
  Dockerfile: ['prettier --write', 'git add'],
}

if (isPkgAvailable('stylelint')) {
  config['*.{css,less,sass,scss,vue}'] = ['stylelint --cache --fix', 'git add']
}

if (isPkgAvailable('@pkgr/imagemin')) {
  config['*.{gif,jpeg,jpg,png,svg,webp}'] = ['i', 'git add']
}

module.exports = config
github 1stG / configs / packages / lint-staged / base.js View on Github external
const { isPkgAvailable } = require('@pkgr/utils')

const config = {
  '*.{*ignore,*sh,env,env.*,gql,html,json,properties,pug,rb,vue,toml,yaml,yml}': [
    'prettier --write',
    'git add',
  ],
  '.!(*browserslist|npm|yarn)rc': ['prettier --write', 'git add'],
  '.{editorconfig|browserslistrc|npmrc|yarnrc}': [
    'prettier --write --parser sh',
    'git add',
  ],
  Dockerfile: ['prettier --write', 'git add'],
}

if (isPkgAvailable('stylelint')) {
  config['*.{css,less,sass,scss,vue}'] = ['stylelint --cache --fix', 'git add']
}

if (isPkgAvailable('@pkgr/imagemin')) {
  config['*.{gif,jpeg,jpg,png,svg,webp}'] = ['i', 'git add']
}

module.exports = config
github 1stG / configs / packages / commitlint-config / index.js View on Github external
const { isPkgAvailable } = require('@pkgr/utils')
const conventionalConfig = require('@commitlint/config-conventional')
const lernaScopesConfig = require('@commitlint/config-lerna-scopes')

const MERGE_PROPERTIES = ['rules', 'utils']

module.exports = isPkgAvailable('lerna')
  ? Object.assign(
      {},
      conventionalConfig,
      MERGE_PROPERTIES.reduce((config, property) => {
        config[property] = Object.assign(
          {},
          conventionalConfig[property],
          lernaScopesConfig[property],
        )
        return config
      }, {}),
    )
  : conventionalConfig
github 1stG / configs / packages / lint-staged / index.js View on Github external
const { isPkgAvailable, tryFile } = require('@pkgr/utils')

const config = Object.assign({}, require('./base'))

if (isPkgAvailable('eslint')) {
  Object.assign(
    config,
    {
      '*.{js,jsx,md,mdx,mjs,vue}': [
        'eslint --cache -f friendly --fix',
        'git add',
      ],
    },
    require('./ts-eslint'),
  )
}

if (isPkgAvailable('tslint') && tryFile('tslint.json')) {
  Object.assign(config, require('./ts-tslint'))
}
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
rules: exports.test.rules,
}

exports.stories = {
  files: '**/stories/**/*.{js,jsx,mdx,ts,tsx,vue}',
  rules: nonSourceRules,
}

exports.config = {
  files: ['.*rc.js', '*.config.{js,ts}'],
  rules: nonSourceRules,
}

exports.overrides = []
  .concat(
    isPkgAvailable('@babel/core') && exports.js,
    isTsAvailable && exports.ts,
    isPkgAvailable('tslint') && lintFile && exports.tslint,
    isReactAvailable && exports.react,
    isReactAvailable && exports.reactHooks,
    isReactAvailable && exports.reactTs,
    isVueAvailable && exports.vue,
    isAngularAvailable && exports.angular,
    exports.mdx,
    exports.jest,
    exports.test,
    exports.stories,
    exports.config,
    exports.dTs,
  )
  .filter(Boolean)

@pkgr/utils

Shared utils for `@pkgr` packages or any package else

MIT
Latest version published 12 months ago

Package Health Score

74 / 100
Full package analysis

Similar packages