refactor: introduce type-only imports (#5462)

This commit is contained in:
Vladislav Shkodin
2021-05-31 14:23:16 +02:00
committed by GitHub
parent e4a29d5991
commit fc07ce6854
81 changed files with 398 additions and 362 deletions

View File

@ -1,23 +1,27 @@
import { Base64 } from 'js-base64';
import semaphore, { Semaphore } from 'semaphore';
import type { Semaphore } from 'semaphore';
import semaphore from 'semaphore';
import { initial, last, partial, result, trimStart, trim } from 'lodash';
import { oneLine } from 'common-tags';
import type {
AssetProxy,
DataFile,
PersistOptions,
FetchError,
ApiRequest,
} from 'netlify-cms-lib-util';
import {
getAllResponses,
APIError,
EditorialWorkflowError,
localForage,
basename,
AssetProxy,
DataFile,
PersistOptions,
readFileMetadata,
CMS_BRANCH_PREFIX,
generateContentKey,
DEFAULT_PR_BODY,
MERGE_COMMIT_MESSAGE,
PreviewState,
FetchError,
parseContentKey,
branchFromContentKey,
isCMSLabel,
@ -26,11 +30,10 @@ import {
contentKeyFromBranch,
requestWithBackoff,
unsentRequest,
ApiRequest,
throwOnConflictingBranches,
} from 'netlify-cms-lib-util';
import { dirname } from 'path';
import { Octokit } from '@octokit/rest';
import type { Octokit } from '@octokit/rest';
type GitHubUser = Octokit.UsersGetAuthenticatedResponse;
type GitCreateTreeParamsTree = Octokit.GitCreateTreeParamsTree;
@ -492,7 +495,6 @@ export default class API {
...(head ? { head: await this.getHeadReference(head) } : {}),
base: this.branch,
state,
// eslint-disable-next-line @typescript-eslint/camelcase
per_page: 100,
},
},
@ -858,7 +860,6 @@ export default class API {
);
return resp.statuses.map(s => ({
context: s.context,
// eslint-disable-next-line @typescript-eslint/camelcase
target_url: s.target_url,
state:
s.state === GitHubCommitStatusState.Success ? PreviewState.Success : PreviewState.Other,
@ -1306,10 +1307,8 @@ export default class API {
{
method: 'PUT',
body: JSON.stringify({
// eslint-disable-next-line @typescript-eslint/camelcase
commit_message: MERGE_COMMIT_MESSAGE,
sha: pullrequest.head.sha,
// eslint-disable-next-line @typescript-eslint/camelcase
merge_method: this.mergeMethod,
}),
},
@ -1415,7 +1414,6 @@ export default class API {
async createTree(baseSha: string, tree: TreeEntry[]) {
const result: Octokit.GitCreateTreeResponse = await this.request(`${this.repoURL}/git/trees`, {
method: 'POST',
// eslint-disable-next-line @typescript-eslint/camelcase
body: JSON.stringify({ base_tree: baseSha, tree }),
});
return result;

View File

@ -1,9 +1,10 @@
import { ApolloClient, QueryOptions, MutationOptions, OperationVariables } from 'apollo-client';
import type { QueryOptions, MutationOptions, OperationVariables } from 'apollo-client';
import { ApolloClient } from 'apollo-client';
import type { NormalizedCacheObject } from 'apollo-cache-inmemory';
import {
InMemoryCache,
defaultDataIdFromObject,
IntrospectionFragmentMatcher,
NormalizedCacheObject,
} from 'apollo-cache-inmemory';
import { createHttpLink } from 'apollo-link-http';
import { setContext } from 'apollo-link-context';
@ -18,11 +19,12 @@ import {
} from 'netlify-cms-lib-util';
import { trim, trimStart } from 'lodash';
import introspectionQueryResultData from './fragmentTypes';
import API, { Config, BlobArgs, API_NAME, PullRequestState, MOCK_PULL_REQUEST } from './API';
import type { Config, BlobArgs } from './API';
import API, { API_NAME, PullRequestState, MOCK_PULL_REQUEST } from './API';
import * as queries from './queries';
import * as mutations from './mutations';
import { GraphQLError } from 'graphql';
import { Octokit } from '@octokit/rest';
import type { GraphQLError } from 'graphql';
import type { Octokit } from '@octokit/rest';
const NO_CACHE = 'no-cache';
const CACHE_FIRST = 'cache-first';

View File

@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from 'graphql-tag';
export const repository = gql`
fragment RepositoryParts on Repository {

View File

@ -1,39 +1,42 @@
import * as React from 'react';
import semaphore, { Semaphore } from 'semaphore';
import type { Semaphore } from 'semaphore';
import semaphore from 'semaphore';
import trimStart from 'lodash/trimStart';
import { stripIndent } from 'common-tags';
import {
CURSOR_COMPATIBILITY_SYMBOL,
Cursor,
asyncLock,
basename,
import type {
AsyncLock,
Implementation,
AssetProxy,
PersistOptions,
DisplayURL,
User,
Credentials,
Config,
ImplementationFile,
UnpublishedEntryMediaFile,
Entry,
} from 'netlify-cms-lib-util';
import {
CURSOR_COMPATIBILITY_SYMBOL,
Cursor,
asyncLock,
basename,
getBlobSHA,
entriesByFolder,
entriesByFiles,
unpublishedEntries,
User,
getMediaDisplayURL,
getMediaAsBlob,
Credentials,
filterByExtension,
Config,
ImplementationFile,
getPreviewStatus,
UnpublishedEntryMediaFile,
runWithLock,
blobToFileObj,
contentKeyFromBranch,
unsentRequest,
branchFromContentKey,
Entry,
} from 'netlify-cms-lib-util';
import AuthenticationPage from './AuthenticationPage';
import { Octokit } from '@octokit/rest';
import type { Octokit } from '@octokit/rest';
import API, { API_NAME } from './API';
import GraphQLAPI from './GraphQLAPI';
@ -391,7 +394,7 @@ export default class GitHub implements Implementation {
this.api!.readFileMetadata.bind(this.api),
API_NAME,
);
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
files[CURSOR_COMPATIBILITY_SYMBOL] = cursor;
return files;

View File

@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from 'graphql-tag';
import * as fragments from './fragments';
// updateRef only works for branches at the moment

View File

@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from 'graphql-tag';
import { oneLine } from 'common-tags';
import * as fragments from './fragments';