diff --git a/packages/config-danger/src/adr.ts b/packages/config-danger/src/adr.ts index 591b56f..72541eb 100644 --- a/packages/config-danger/src/adr.ts +++ b/packages/config-danger/src/adr.ts @@ -15,13 +15,13 @@ export function checkForADR(docsPath: string, options: CheckAdrOptions = {}) { } const { changeThreshold = 200, docsUrl = '', exclusions = [] } = options; - const hasDocsFiles = touchedFiles.some(file => file.includes(docsPath)); + const hasDocsFiles = touchedFiles.some((file) => file.includes(docsPath)); const docsExclusions = [...exclusions, 'package-lock.json', 'yarn.lock', TEST_EXT, SNAP_EXT]; - const modifiedExclusions = danger.git.modified_files.filter(file => - docsExclusions.some(ex => !!file.match(ex)), + const modifiedExclusions = danger.git.modified_files.filter((file) => + docsExclusions.some((ex) => !!file.match(ex)), ); - Promise.all(modifiedExclusions.map(countChangesInFile)).then(vals => { + Promise.all(modifiedExclusions.map(countChangesInFile)).then((vals) => { const totalChangeCount = danger.github.pr.additions + danger.github.pr.deletions; const exclusionChangeCount = vals.reduce((acc, val) => acc + val, 0); const changeCount = totalChangeCount - exclusionChangeCount; diff --git a/packages/config-danger/src/code.ts b/packages/config-danger/src/code.ts index ffd1247..befc21f 100644 --- a/packages/config-danger/src/code.ts +++ b/packages/config-danger/src/code.ts @@ -12,7 +12,7 @@ import { } from './helpers'; import { CommonOptions } from './types'; -const changedSrcFiles = updatedFiles.filter(file => IS_SRC.test(file) && SRC_EXT.test(file)); +const changedSrcFiles = updatedFiles.filter((file) => IS_SRC.test(file) && SRC_EXT.test(file)); export type TestOptions = { ignorePattern?: RegExp; @@ -21,7 +21,7 @@ export type TestOptions = { // Check for invalid NPM/Yarn installs by verifying the lock files. export function checkForInvalidLocks() { - const fileNames = touchedFiles.map(file => path.basename(file)); + const fileNames = touchedFiles.map((file) => path.basename(file)); if (fileNames.includes('package-lock.json') && !fileNames.includes('package.json')) { fail('Your PR contains changes to package-lock.json, but not package.json.'); @@ -38,9 +38,9 @@ export function checkForAnyTests({ root, ...options }: TestOptions = {}) { return; } - const hasTestFiles = touchedFiles.some(file => !!file.match(TEST_EXT)); + const hasTestFiles = touchedFiles.some((file) => !!file.match(TEST_EXT)); const srcFiles = root - ? changedSrcFiles.filter(srcFile => srcFile.startsWith(root)) + ? changedSrcFiles.filter((srcFile) => srcFile.startsWith(root)) : changedSrcFiles; if (srcFiles.length > 0 && !hasTestFiles) { @@ -62,10 +62,10 @@ export function checkSourceFilesHaveTests({ ignorePattern, root, ...options }: T const missingTestFiles: string[] = []; const srcFiles = root - ? changedSrcFiles.filter(srcFile => srcFile.startsWith(root)) + ? changedSrcFiles.filter((srcFile) => srcFile.startsWith(root)) : changedSrcFiles; - srcFiles.forEach(srcFile => { + srcFiles.forEach((srcFile) => { if ((ignorePattern && srcFile.match(ignorePattern)) || srcFile.match(GLOBAL_IGNORE)) { return; } @@ -84,7 +84,7 @@ export function checkSourceFilesHaveTests({ ignorePattern, root, ...options }: T const regex = new RegExp(testFile); - updatedFiles.forEach(file => { + updatedFiles.forEach((file) => { if (file.match(regex)) { missingTestFiles.push(`- ${srcFile.split(IS_SRC)[1]}`); } @@ -138,7 +138,7 @@ export function disableComponentSnapshots(options: SnapshotOptions = {}) { // Disable new JavaScript files from being created. export function disableNewJavaScript() { const hasJS = danger.git.created_files.some( - file => (IS_SRC.test(file) || IS_TEST.test(file)) && JS_EXT.test(file), + (file) => (IS_SRC.test(file) || IS_TEST.test(file)) && JS_EXT.test(file), ); if (hasJS) { diff --git a/packages/config-danger/src/helpers.ts b/packages/config-danger/src/helpers.ts index cab1429..39039f1 100644 --- a/packages/config-danger/src/helpers.ts +++ b/packages/config-danger/src/helpers.ts @@ -28,8 +28,8 @@ export function isRevert(): boolean { } export async function countChangesInFile(file: string): Promise { - return new Promise(resolve => { - danger.git.diffForFile(file).then(d => { + return new Promise((resolve) => { + danger.git.diffForFile(file).then((d) => { const added = (d?.added && d.added.split('\n').length) || 0; const removed = (d?.removed && d.removed.split('\n').length) || 0; diff --git a/packages/config-jest/src/index.ts b/packages/config-jest/src/index.ts index b0dd9fd..8fdf9d8 100644 --- a/packages/config-jest/src/index.ts +++ b/packages/config-jest/src/index.ts @@ -17,8 +17,8 @@ export interface JestOptions { workspaces?: string[]; } -const exts = EXTS.map(ext => ext.slice(1)); -const extsWithoutJSON = exts.filter(ext => ext !== 'json'); +const exts = EXTS.map((ext) => ext.slice(1)); +const extsWithoutJSON = exts.filter((ext) => ext !== 'json'); function fromHere(filePath: string): string { return `/${new Path(process.cwd()).relativeTo( @@ -46,7 +46,7 @@ export function getConfig({ const setupFilesAfterEnv = [fromHere('bootstrap/consumer.js')]; if (workspaces.length > 0) { - workspaces.forEach(wsPath => { + workspaces.forEach((wsPath) => { roots.push(new Path('', wsPath.replace('/*', '')).path()); }); } else { @@ -66,7 +66,7 @@ export function getConfig({ bail: false, collectCoverageFrom: [createCoveragePattern(srcFolder), createCoveragePattern(testFolder)], coverageDirectory: './coverage', - coveragePathIgnorePatterns: IGNORE_PATHS.filter(ignore => !ignore.startsWith('*')), + coveragePathIgnorePatterns: IGNORE_PATHS.filter((ignore) => !ignore.startsWith('*')), coverageReporters: ['lcov', 'json-summary', 'html'], coverageThreshold: { global: { diff --git a/packages/config-webpack/src/helpers.ts b/packages/config-webpack/src/helpers.ts index 4548996..1fed8f3 100644 --- a/packages/config-webpack/src/helpers.ts +++ b/packages/config-webpack/src/helpers.ts @@ -47,7 +47,7 @@ export function getESMAliases(): AliasMap { onlyDirectories: true, onlyFiles: false, }) - .forEach(modulePath => { + .forEach((modulePath) => { const packageName = modulePath.split('/node_modules/')[1]; const esLessName = packageName.replace(/-es$/, ''); const esPath = new Path(modulePath, 'es'); @@ -57,7 +57,7 @@ export function getESMAliases(): AliasMap { // optimal/lib -> optimal/esm if (esPath.exists() || esmPath.exists()) { const aliasPath = esPath.exists() ? `${packageName}/es` : `${packageName}/esm`; - const aliased = buildTargets.some(targetFolder => { + const aliased = buildTargets.some((targetFolder) => { if (new Path(modulePath, targetFolder).exists()) { aliases[`${packageName}/${targetFolder}`] = aliasPath; diff --git a/packages/nimbus-common/src/git.ts b/packages/nimbus-common/src/git.ts index 1d9ec95..e8adc95 100644 --- a/packages/nimbus-common/src/git.ts +++ b/packages/nimbus-common/src/git.ts @@ -1,13 +1,13 @@ import execa from 'execa'; export function getLastTag(): Promise { - return execa('git', ['describe', '--tags', '--abbrev=0', '@^']).then(response => + return execa('git', ['describe', '--tags', '--abbrev=0', '@^']).then((response) => response.stdout.trim(), ); } export function getCommitsSince(since: string): Promise { - return execa('git', ['log', '--oneline', `${since}..@`]).then(response => + return execa('git', ['log', '--oneline', `${since}..@`]).then((response) => response.stdout.trim().split('\n'), ); } diff --git a/packages/nimbus/hooks/checkNodeVersion.js b/packages/nimbus/hooks/checkNodeVersion.js index b8dbf67..8314d55 100644 --- a/packages/nimbus/hooks/checkNodeVersion.js +++ b/packages/nimbus/hooks/checkNodeVersion.js @@ -6,7 +6,7 @@ const { getPackage } = require('@airbnb/nimbus-common'); // Only run if the engines block is defined if (getPackage().engines) { - execa('check-node-version', ['--package'], { preferLocal: true }).catch(error => { + execa('check-node-version', ['--package'], { preferLocal: true }).catch((error) => { console.error(); console.error(chalk.red(error.stderr.trim())); console.error(); diff --git a/packages/nimbus/hooks/detectModuleChanges.js b/packages/nimbus/hooks/detectModuleChanges.js index b24c02d..dfad571 100644 --- a/packages/nimbus/hooks/detectModuleChanges.js +++ b/packages/nimbus/hooks/detectModuleChanges.js @@ -31,6 +31,6 @@ execa('git', ['diff-tree', '-r', '--name-only', remoteHead, branchHead]) ); } }) - .catch(error => { + .catch((error) => { console.log('\n ', chalk.red(`🛑 Failed to detect module changes: ${error.message}`), ' \n'); }); diff --git a/packages/nimbus/src/bins/eject.ts b/packages/nimbus/src/bins/eject.ts index 24c906b..9770e56 100755 --- a/packages/nimbus/src/bins/eject.ts +++ b/packages/nimbus/src/bins/eject.ts @@ -30,7 +30,7 @@ async function copyAndInstallDepsFromModule( ) { const pkg = require(`${moduleName}/package.json`); const deps = Object.keys(pkg.dependencies).filter( - dep => !dep.includes('@beemo') && !dep.includes('@airbnb/nimbus'), + (dep) => !dep.includes('@beemo') && !dep.includes('@airbnb/nimbus'), ); await installDeps(deps, isYarn, isMonorepo); @@ -63,7 +63,7 @@ function migrateDotfiles() { const dotPath = Path.resolve('.gitignore').path(); let data = fs.readFileSync(dotPath, 'utf8'); - toRemove.forEach(value => { + toRemove.forEach((value) => { data = data.replace(new RegExp(`${escapeRegExp(value)}\n?`, 'g'), ''); }); @@ -87,7 +87,7 @@ function migratePackageScripts(nimbus: NimbusPackage['nimbus']) { delete scripts.release; } - Object.keys(scripts).forEach(key => { + Object.keys(scripts).forEach((key) => { const value = scripts[key]; const esm = value.includes('--esm'); @@ -119,7 +119,7 @@ function migrateEslint() { const { extends: extendPaths, ...rootConfig } = require(configPath); let config: { extends: string[]; parserOptions?: object } = { extends: [] }; - (extendPaths as string[]).forEach(extendPath => { + (extendPaths as string[]).forEach((extendPath) => { if (extendPath.startsWith('.')) { config = { ...config, @@ -236,7 +236,7 @@ export async function eject() { pkg.set( 'nimbus.drivers', - (pkg.get('nimbus.drivers') as string[]).filter(d => d !== driver), + (pkg.get('nimbus.drivers') as string[]).filter((d) => d !== driver), ); pkg.save(); } diff --git a/packages/nimbus/src/bins/setup.ts b/packages/nimbus/src/bins/setup.ts index 7dbfc98..aef7b0c 100644 --- a/packages/nimbus/src/bins/setup.ts +++ b/packages/nimbus/src/bins/setup.ts @@ -183,7 +183,7 @@ export async function setup() { console.log(`${chalk.cyan('[3/6]')} Installing dependencies`); await installDeps( - ['@airbnb/nimbus', ...response.drivers.map(driver => `@airbnb/config-${driver}`)], + ['@airbnb/nimbus', ...response.drivers.map((driver) => `@airbnb/config-${driver}`)], response.yarn, response.type === 'monolib', ); diff --git a/packages/nimbus/src/index.ts b/packages/nimbus/src/index.ts index fdc27a4..ca2295c 100644 --- a/packages/nimbus/src/index.ts +++ b/packages/nimbus/src/index.ts @@ -9,7 +9,7 @@ function hasNoPositionalArgs(context: DriverContext, name: string): boolean { } function createWorkspacesGlob(workspaces: string[]): string { - const paths = workspaces.map(p => p.replace('./', '')); + const paths = workspaces.map((p) => p.replace('./', '')); return paths.length === 1 ? `${paths[0]}/` : `{${paths.join(',')}}/`; } @@ -67,7 +67,7 @@ export default function nimbus(tool: Beemo) { } // Create a specialized tsconfig for ESLint - driver.onCreateConfigFile.listen(createContext => { + driver.onCreateConfigFile.listen((createContext) => { if (!usingTypeScript) { return; } @@ -81,7 +81,7 @@ export default function nimbus(tool: Beemo) { } else { extendsFrom = './tsconfig.options.json'; - workspaces.forEach(ws => { + workspaces.forEach((ws) => { const wsPath = new Path(ws); include.push( @@ -139,7 +139,7 @@ export default function nimbus(tool: Beemo) { * - Always write files. * - Glob a ton of files by default. */ - tool.onRunDriver.listen(context => { + tool.onRunDriver.listen((context) => { context.addOption('--write'); if (hasNoPositionalArgs(context, 'prettier')) { diff --git a/packages/nimbus/src/scripts/AutoRelease.ts b/packages/nimbus/src/scripts/AutoRelease.ts index c58b3ec..2764e8c 100644 --- a/packages/nimbus/src/scripts/AutoRelease.ts +++ b/packages/nimbus/src/scripts/AutoRelease.ts @@ -81,7 +81,7 @@ export default class AutoReleaseScript extends Script { handleCommand(promise: Promise): Promise { return promise - .then(response => { + .then((response) => { const out = response.stdout.trim(); if (out) { @@ -90,7 +90,7 @@ export default class AutoReleaseScript extends Script { return response; }) - .catch(error => { + .catch((error) => { this.tool.log.error(error.stderr); throw error; diff --git a/packages/nimbus/src/scripts/PullRequestChecks.ts b/packages/nimbus/src/scripts/PullRequestChecks.ts index 3491b4d..55fcc51 100644 --- a/packages/nimbus/src/scripts/PullRequestChecks.ts +++ b/packages/nimbus/src/scripts/PullRequestChecks.ts @@ -40,7 +40,7 @@ export default class PullRequestChecksScript extends Script { pull_number: Number(TRAVIS_PULL_REQUEST), }); - const fileNames = new Set(files.map(file => path.basename(file.filename))); + const fileNames = new Set(files.map((file) => path.basename(file.filename))); const hasPackageChanges = fileNames.has('package.json'); // this.tool.log('Changed files: %s', Array.from(fileNames).join(', '));