chore(v2): Fix more linter warnings (#4450)

This commit is contained in:
Sam Zhou 2021-03-18 13:05:09 -04:00 committed by GitHub
parent 3422f80a9a
commit 83d043ecb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 116 additions and 85 deletions

View file

@ -14,7 +14,7 @@ export function getAllDuplicateRoutes(
const allRoutes: string[] = getAllFinalRoutes(pluginsRouteConfigs).map(
(routeConfig) => routeConfig.path,
);
const seenRoutes: Record<string, any> = {};
const seenRoutes: Record<string, boolean> = {};
return allRoutes.filter((route) => {
if (Object.prototype.hasOwnProperty.call(seenRoutes, route)) {
return true;

View file

@ -23,7 +23,7 @@ export function getAllFinalRoutes(routeConfig: RouteConfig[]): RouteConfig[] {
export async function safeGlobby(
patterns: string[],
options?: globby.GlobbyOptions,
) {
): Promise<string[]> {
// Required for Windows support, as paths using \ should not be used by globby
// (also using the windows hard drive prefix like c: is not a good idea)
const globPaths = patterns.map((dirPath) =>

View file

@ -273,8 +273,24 @@ export function compile(config: Configuration[]): Promise<Stats.ToJsonOutput> {
type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
type FileLoaderUtils = {
loaders: {
file: (options: {folder: AssetFolder}) => Loader;
url: (options: {folder: AssetFolder}) => Loader;
inlineMarkdownImageFileLoader: string;
inlineMarkdownLinkFileLoader: string;
};
rules: {
images: () => RuleSetRule;
fonts: () => RuleSetRule;
media: () => RuleSetRule;
svg: () => RuleSetRule;
otherAssets: () => RuleSetRule;
};
};
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
export function getFileLoaderUtils(): Record<string, any> {
export function getFileLoaderUtils(): FileLoaderUtils {
// files/images < 10kb will be inlined as base64 strings directly in the html
const urlLoaderLimit = 10000;