Skip to content

Commit

Permalink
Merge branch 'next' into 146-checkout-depth-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld authored Nov 16, 2020
2 parents d805bbf + c6964c9 commit e3157aa
Show file tree
Hide file tree
Showing 95 changed files with 3,719 additions and 3,086 deletions.
162 changes: 3 additions & 159 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,164 +1,8 @@
const error = 2;
const warn = 1;
const ignore = 0;

module.exports = {
root: true,
extends: [
'airbnb',
'plugin:jest/recommended',
'plugin:import/react-native',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
plugins: [
'@typescript-eslint',
'prettier',
'jest',
'import',
'react',
'jsx-a11y',
'json',
'simple-import-sort',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
env: { es6: true, node: true, 'jest/globals': true },
settings: {
'import/core-modules': ['enzyme'],
'import/ignore': ['node_modules\\/(?!@storybook)'],
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx', '.mjs', '.d.ts'],
paths: ['node_modules/', 'node_modules/@types/'],
},
},
},
extends: ['@storybook/eslint-config-storybook'],
rules: {
'simple-import-sort/sort': 'error',
'sort-imports': 'off',
'import/order': 'off',
'no-useless-constructor': ignore,
'@typescript-eslint/no-useless-constructor': error,
'no-restricted-imports': [
error,
{
paths: [
{
name: 'lodash.isequal',
message:
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
},
{
name: 'lodash.mergewith',
message:
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
},
{
name: 'lodash.pick',
message:
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
},
],
// catch-all for any lodash modularised. The CVE is listed against the entire family for lodash < 4.17.11
patterns: ['lodash.*'],
},
],
'prettier/prettier': [warn],
'no-debugger': process.env.NODE_ENV === 'production' ? error : ignore,
'class-methods-use-this': ignore,
'import/extensions': [
error,
'always',
{
js: 'never',
ts: 'never',
tsx: 'never',
mjs: 'never',
},
],
'import/no-extraneous-dependencies': [
error,
{
devDependencies: [
'examples/**',
'examples-native/**',
'**/example/**',
'*.js',
'**/*.test.js',
'**/*.stories.*',
'**/scripts/*.js',
'**/stories/**/*.js',
'**/__tests__/**/*.js',
'**/.storybook/**/*.*',
],
peerDependencies: true,
},
],
'import/prefer-default-export': ignore,
'import/default': error,
'import/named': error,
'import/namespace': error,
'react/jsx-filename-extension': [
warn,
{
extensions: ['.js', '.jsx', '.tsx'],
},
],
'react/jsx-no-bind': [
error,
{
ignoreDOMComponents: true,
ignoreRefs: true,
allowArrowFunctions: true,
allowFunctions: true,
allowBind: true,
},
],
'jsx-a11y/accessible-emoji': ignore,
'jsx-a11y/label-has-associated-control': [
warn,
{
labelComponents: ['CustomInputLabel'],
labelAttributes: ['label'],
controlComponents: ['CustomInput'],
depth: 3,
},
],
'react/no-unescaped-entities': ignore,
'jsx-a11y/label-has-for': [error, { required: { some: ['nesting', 'id'] } }],
'jsx-a11y/anchor-is-valid': [
error,
{
components: ['A', 'LinkTo', 'Link'],
specialLink: ['overrideParams', 'kind', 'story', 'to'],
},
],
'no-underscore-dangle': [
error,
{
allow: [
'__STORYBOOK_CLIENT_API__',
'__STORYBOOK_ADDONS_CHANNEL__',
'__STORYBOOK_STORY_STORE__',
],
},
],
'@typescript-eslint/no-var-requires': ignore,
'@typescript-eslint/camelcase': ignore,
'@typescript-eslint/no-unused-vars': ignore,
'@typescript-eslint/explicit-member-accessibility': ignore,
'@typescript-eslint/explicit-function-return-type': ignore,
'@typescript-eslint/no-explicit-any': ignore, // would prefer to enable this
'@typescript-eslint/no-use-before-define': ignore, // this is duplicated
'@typescript-eslint/interface-name-prefix': ignore, // I don't agree
'no-use-before-define': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
2 changes: 2 additions & 0 deletions .github/workflows/action-run.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: "self test development-like"
on:
pull_request:
pull_request_target:
pull_request_review:
push:
branches:
- master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic-action-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Chromatic via action-test"
on: [push, pull_request]
on: [push, pull_request, pull_request_target, pull_request_review]

jobs:
chromatic:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic-action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Chromatic via action"
on: [push, pull_request]
on: [push, pull_request, pull_request_review, pull_request_target]

jobs:
chromatic:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic-staging-action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "[Staging] Chromatic via action"
on: [push, pull_request]
on: [push, pull_request, pull_request_target, pull_request_review]

jobs:
chromatic:
Expand Down
6 changes: 5 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env browser */
import { addDecorator } from '@storybook/react';
import { addDecorator, addParameters } from '@storybook/react';
import ansiHTML from 'ansi-html';
import chalk from 'chalk';
import React from 'react';
Expand Down Expand Up @@ -29,6 +29,10 @@ const style = {
color: '#c0c4cd',
};

addParameters({
layout: 'fullscreen'
})

addDecorator((storyFn, { kind }) => {
if (kind.startsWith('CLI/')) {
document.body.style.backgroundColor = '#16242c';
Expand Down
4 changes: 3 additions & 1 deletion action/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const maybe = (a: string, b: any = undefined) => {

const getCommit = (event: typeof context) => {
switch (event.eventName) {
case 'pull_request': {
case 'pull_request':
case 'pull_request_review':
case 'pull_request_target': {
return {
// @ts-ignore
owner: event.payload.repository.owner.login,
Expand Down
6 changes: 2 additions & 4 deletions bin/git/generateGitRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ function nextDate() {
}

async function generateCommit(runGit, [name, parentNames], commitMap) {
const parentCommits = [...(parentNames || [])].map(parentName => commitMap[parentName].hash);
const parentCommits = [...(parentNames || [])].map((parentName) => commitMap[parentName].hash);

const randomBranchName = `temp-${Math.random()
.toString()
.substring(2)}`;
const randomBranchName = `temp-${Math.random().toString().substring(2)}`;
const commitEnv = `GIT_COMMITTER_DATE='${nextDate()}'`;
// No parent, check out nothing
if (parentCommits.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion bin/git/getCommitAndBranch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import missingTravisInfo from '../ui/messages/errors/missingTravisInfo';
import travisInternalBuild from '../ui/messages/warnings/travisInternalBuild';
import { getBranch, getCommit, hasPreviousCommit } from './git';

const notHead = b => {
const notHead = (b) => {
if (!b || b === 'HEAD') {
return false;
}
Expand Down
20 changes: 10 additions & 10 deletions bin/git/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async function commitExists(commit) {
}

function commitsForCLI(commits) {
return commits.map(c => c.trim()).join(' ');
return commits.map((c) => c.trim()).join(' ');
}

// git rev-list in a basic form gives us a list of commits reaching back to
Expand Down Expand Up @@ -147,14 +147,14 @@ async function nextCommits(
${firstCommittedAtSeconds ? `--since ${firstCommittedAtSeconds}` : ''} \
-n ${limit + commitsWithoutBuilds.length} --not ${commitsForCLI(commitsWithBuilds)}`;
log.debug(`running ${command}`);
const commits = (await execGitCommand(command)).split('\n').filter(c => !!c);
const commits = (await execGitCommand(command)).split('\n').filter((c) => !!c);
log.debug(`command output: ${commits}`);

return (
commits
// No sense in checking commits we already know about
.filter(c => !commitsWithBuilds.includes(c))
.filter(c => !commitsWithoutBuilds.includes(c))
.filter((c) => !commitsWithBuilds.includes(c))
.filter((c) => !commitsWithoutBuilds.includes(c))
.slice(0, limit)
);
}
Expand All @@ -167,12 +167,12 @@ async function maximallyDescendentCommits({ log }, commits) {
}

// <commit>^@ expands to all parents of commit
const parentCommits = commits.map(c => `"${c}^@"`);
const parentCommits = commits.map((c) => `"${c}^@"`);
// List the tree from <commits> not including the tree from <parentCommits>
// This just filters any commits that are ancestors of other commits
const command = `git rev-list ${commitsForCLI(commits)} --not ${commitsForCLI(parentCommits)}`;
log.debug(`running ${command}`);
const maxCommits = (await execGitCommand(command)).split('\n').filter(c => !!c);
const maxCommits = (await execGitCommand(command)).split('\n').filter((c) => !!c);
log.debug(`command output: ${maxCommits}`);

return maxCommits;
Expand Down Expand Up @@ -210,7 +210,7 @@ async function step(
log.debug(`step: newCommitsWithBuilds: ${newCommitsWithBuilds}`);

const newCommitsWithoutBuilds = candidateCommits.filter(
commit => !newCommitsWithBuilds.find(c => c === commit)
(commit) => !newCommitsWithBuilds.find((c) => c === commit)
);

return step({ client, log }, limit * 2, {
Expand Down Expand Up @@ -354,7 +354,7 @@ export async function getUpdateMessage() {
return status
.split(EOL + EOL)[0] // drop the 'nothing to commit' part
.split(EOL)
.filter(line => !line.startsWith('On branch')) // drop the 'On branch x' part
.filter((line) => !line.startsWith('On branch')) // drop the 'On branch x' part
.join(EOL)
.trim();
}
Expand Down Expand Up @@ -398,12 +398,12 @@ export async function findMergeBase(headRef, baseRef) {
// If we find multiple merge bases, look for one on the base branch.
// If we don't find a merge base on the base branch, just return the first one.
const branchNames = await Promise.all(
mergeBases.map(async sha => {
mergeBases.map(async (sha) => {
const name = await execGitCommand(`git name-rev --name-only --exclude="tags/*" ${sha}`);
return name.replace(/~[0-9]+$/, ''); // Drop the potential suffix
})
);
const baseRefIndex = branchNames.findIndex(branch => branch === baseRef);
const baseRefIndex = branchNames.findIndex((branch) => branch === baseRef);
return mergeBases[baseRefIndex] || mergeBases[0];
}

Expand Down
8 changes: 4 additions & 4 deletions bin/git/git.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable jest/expect-expect */
import { exec } from 'child_process';
import process from 'process';
import { dirSync } from 'tmp';
import tmp from 'tmp-promise';
import { promisify } from 'util';

import generateGitRepository from './generateGitRepository';
Expand Down Expand Up @@ -35,8 +35,8 @@ function makeRunGit(directory) {
const repositories = {};
beforeAll(async () =>
Promise.all(
Object.keys(descriptions).map(async key => {
const dirname = dirSync().name;
Object.keys(descriptions).map(async (key) => {
const dirname = (await tmp.dir({ unsafeCleanup: true, prefix: `chromatictest-` })).path;
const runGit = makeRunGit(dirname);
const commitMap = await generateGitRepository(runGit, descriptions[key]);
repositories[key] = { dirname, runGit, commitMap };
Expand All @@ -55,7 +55,7 @@ function createClient(repository, builds, prs) {
}

function expectCommitsToEqualNames(hashes, names, { commitMap }) {
return expect(hashes).toEqual(names.map(n => commitMap[n].hash));
return expect(hashes).toEqual(names.map((n) => commitMap[n].hash));
}

async function checkoutCommit(name, branch, { dirname, runGit, commitMap }) {
Expand Down
6 changes: 3 additions & 3 deletions bin/git/mocks/mock-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const mocks = {
return builds
.slice()
.reverse()
.find(b => b.branch === findingBranch);
.find((b) => b.branch === findingBranch);
}

const lastBuild = lastBuildOnBranch(branch);
const pr = prs.find(p => p.mergeCommitHash === commit);
const pr = prs.find((p) => p.mergeCommitHash === commit);
const prLastBuild = pr && lastBuildOnBranch(pr.headBranch);
return {
app: {
Expand All @@ -43,7 +43,7 @@ const mocks = {
},
TesterHasBuildsWithCommitsQuery: (builds, _prs, { commits }) => ({
app: {
hasBuildsWithCommits: commits.filter(commit => !!builds.find(b => b.commit === commit)),
hasBuildsWithCommits: commits.filter((commit) => !!builds.find((b) => b.commit === commit)),
},
}),
};
Expand Down
4 changes: 2 additions & 2 deletions bin/io/GraphQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export default class GraphQLClient {

if (errors) {
if (Array.isArray(errors)) {
errors.forEach(err => {
errors.forEach((err) => {
// eslint-disable-next-line no-param-reassign
err.name = err.name || 'GraphQLError';
// eslint-disable-next-line no-param-reassign
err.at = `${err.path.join('.')} ${err.locations
.map(l => `${l.line}:${l.column}`)
.map((l) => `${l.line}:${l.column}`)
.join(', ')}`;
});
throw errors.length === 1 ? errors[0] : errors;
Expand Down
1 change: 0 additions & 1 deletion bin/io/HTTPClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-classes-per-file */
import retry from 'async-retry';
import fetch from 'node-fetch';

Expand Down
Loading

0 comments on commit e3157aa

Please sign in to comment.