How to use the @pkgr/utils.tryFile 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 / overrides.js View on Github external
]

exports.dTs = {
  files: '*.d.ts',
  rules: {
    '@typescript-eslint/no-explicit-any': 0,
    '@typescript-eslint/no-extraneous-class': 0,
    '@typescript-eslint/no-namespace': 0,
    '@typescript-eslint/no-unused-vars': 0,
    'import/no-duplicates': 0,
    'import/order': 0,
    'node/no-extraneous-import': 0,
  },
}

const TSLINT_CONFIG = tryFile(resolve('tslint.json'))
const lintFile = TSLINT_CONFIG || tryPkg('@1stg/tslint-config')

exports.tslint = {
  files: '*.{ts,tsx}',
  excludedFiles: '*.d.ts',
  plugins: TSLINT_CONFIG ? ['@typescript-eslint/tslint'] : undefined,
  rules: Object.assign(
    {
      // `ordered-imports` of tslint is better for now
      'import/order': 0,
    },
    TSLINT_CONFIG
      ? undefined
      : {
          '@typescript-eslint/tslint/config': [
            2,
github 1stG / configs / packages / lint-staged / index.js View on Github external
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'))
}

module.exports = config
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
const {
  isAngularAvailable,
  isReactAvailable,
  isPkgAvailable,
  isTsAvailable,
  isVueAvailable,
  tryFile,
  tryPkg,
} = require('@pkgr/utils')

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

const configFile =
  tryFile(resolve('babel.config.js')) ||
  tryFile(resolve('.babelrc.js')) ||
  tryPkg('@1stg/babel-preset/config')

const jsBase = {
  files: '*.{mjs,js,jsx}',
  parser: 'babel-eslint',
  parserOptions: configFile && {
    babelOptions: {
      configFile,
    },
  },
  plugins: ['babel'],
  rules: {
    camelcase: 0,
    'new-cap': 0,
    'no-invalid-this': 0,
    'no-unused-expressions': 0,
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
const resolveSettings = {
  'import/external-module-folders': [
    'node_modules',
    'node_modules/@d-ts',
    'node_modules/@types',
  ],
  'import/resolver': {
    ts: {
      alwaysTryTypes: true,
      directory: project,
    },
  },
  node: {
    resolvePaths: [
      tryFile('node_modules/@d-ts', true),
      tryFile('node_modules/@types', true),
    ].filter(Boolean),
    tryExtensions: [
      '.ts',
      '.tsx',
      '.d.ts',
      '.vue',
      '.mjs',
      '.js',
      '.jsx',
      '.json',
      '.node',
      '.mdx',
    ],
  },
}
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
ignoreDestructuring: true,
      },
    ],
    'babel/new-cap': 2,
    'babel/no-invalid-this': 2,
    'babel/no-unused-expressions': 2,
    'babel/valid-typeof': 2,
  },
}

exports.js = jsBase

const project =
  tryFile(resolve('tsconfig.eslint.json')) ||
  tryFile(resolve('tsconfig.base.json')) ||
  tryFile(resolve('tsconfig.json')) ||
  tryPkg('@1stg/tsconfig')

const resolveSettings = {
  'import/external-module-folders': [
    'node_modules',
    'node_modules/@d-ts',
    'node_modules/@types',
  ],
  'import/resolver': {
    ts: {
      alwaysTryTypes: true,
      directory: project,
    },
  },
  node: {
    resolvePaths: [
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
{
        properties: 'never',
        ignoreDestructuring: true,
      },
    ],
    'babel/new-cap': 2,
    'babel/no-invalid-this': 2,
    'babel/no-unused-expressions': 2,
    'babel/valid-typeof': 2,
  },
}

exports.js = jsBase

const project =
  tryFile(resolve('tsconfig.eslint.json')) ||
  tryFile(resolve('tsconfig.base.json')) ||
  tryFile(resolve('tsconfig.json')) ||
  tryPkg('@1stg/tsconfig')

const resolveSettings = {
  'import/external-module-folders': [
    'node_modules',
    'node_modules/@d-ts',
    'node_modules/@types',
  ],
  'import/resolver': {
    ts: {
      alwaysTryTypes: true,
      directory: project,
    },
  },
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
const resolveSettings = {
  'import/external-module-folders': [
    'node_modules',
    'node_modules/@d-ts',
    'node_modules/@types',
  ],
  'import/resolver': {
    ts: {
      alwaysTryTypes: true,
      directory: project,
    },
  },
  node: {
    resolvePaths: [
      tryFile('node_modules/@d-ts', true),
      tryFile('node_modules/@types', true),
    ].filter(Boolean),
    tryExtensions: [
      '.ts',
      '.tsx',
      '.d.ts',
      '.vue',
      '.mjs',
      '.js',
      '.jsx',
      '.json',
      '.node',
      '.mdx',
    ],
  },
}
github 1stG / configs / packages / eslint-config / overrides.js View on Github external
const { resolve } = require('path')

const {
  isAngularAvailable,
  isReactAvailable,
  isPkgAvailable,
  isTsAvailable,
  isVueAvailable,
  tryFile,
  tryPkg,
} = require('@pkgr/utils')

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

const configFile =
  tryFile(resolve('babel.config.js')) ||
  tryFile(resolve('.babelrc.js')) ||
  tryPkg('@1stg/babel-preset/config')

const jsBase = {
  files: '*.{mjs,js,jsx}',
  parser: 'babel-eslint',
  parserOptions: configFile && {
    babelOptions: {
      configFile,
    },
  },
  plugins: ['babel'],
  rules: {
    camelcase: 0,
    'new-cap': 0,
    'no-invalid-this': 0,

@pkgr/utils

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

MIT
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages