Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
{
]
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,
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,
{
const { resolve } = require('path')
const {
isMonorepo,
isPkgAvailable,
monorepoPkgs,
tryRequirePkg,
} = require('@pkgr/utils')
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.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)
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
'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
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
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
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'))
}