Skip to content

Commit

Permalink
Lint scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RichDom2185 committed Apr 13, 2024
1 parent c29cfcc commit 9085574
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions scripts/scripts_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ const buildCommand = new Command('build')
* @returns {Promise<void>}
*/
function runJest(patterns) {
const [args, filePatterns] = _.partition(patterns ?? [], (arg) => arg.startsWith('-'));
const [args, filePatterns] = _.partition(patterns ?? [], arg => arg.startsWith('-'));

// command.args automatically includes the source directory option
// which is not supported by Jest, so we need to remove it
const toRemove = args.findIndex((arg) => arg.startsWith('--srcDir'));
const toRemove = args.findIndex(arg => arg.startsWith('--srcDir'));
if (toRemove !== -1) {
args.splice(toRemove, 1);
}

const jestArgs = args.concat(filePatterns.map((pattern) => pattern.split(pathlib.win32.sep)
const jestArgs = args.concat(filePatterns.map(pattern => pattern.split(pathlib.win32.sep)
.join(pathlib.posix.sep)));

return jest.run(jestArgs, './scripts/jest.config.js');
Expand Down
4 changes: 2 additions & 2 deletions scripts/src/build/__tests__/buildUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe('Test retrieveBundlesAndTabs', () => {
type TestCase = [
desc: string,
{
bundles?: string[] | null
tabs?: string[] | null
bundles?: string[] | null;
tabs?: string[] | null;
},
boolean,
Awaited<ReturnType<typeof retrieveBundlesAndTabs>>
Expand Down
6 changes: 3 additions & 3 deletions scripts/src/build/docs/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { AwaitedReturn } from '../utils';
import { initTypedoc, type TypedocResult } from './docsUtils';

export type HtmlResult = {
severity: 'error' | 'warn'
error: any
severity: 'error' | 'warn';
error: any;
} | {
severity: 'success'
severity: 'success';
};

export const buildHtml = wrapWithTimer(async (
Expand Down
6 changes: 3 additions & 3 deletions scripts/src/build/prebuild/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { findSeverity, divideAndRound, type Severity, type AwaitedReturn } from
import { createPrebuildCommand, createPrebuildCommandHandler, type PrebuildOptions } from './utils';

interface LintResults {
formatted: string
severity: Severity
formatted: string;
severity: Severity;
}

interface LintOptions extends Omit<PrebuildOptions, 'manifest'> {
fix?: boolean
fix?: boolean;
}

export const runEslint = wrapWithTimer(async ({ bundles, tabs, srcDir, fix }: LintOptions): Promise<LintResults> => {
Expand Down
20 changes: 10 additions & 10 deletions scripts/src/build/prebuild/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import { expandBundleNames, expandTabNames, divideAndRound, type AwaitedReturn }
import { createPrebuildCommand, createPrebuildCommandHandler, type PrebuildOptions } from './utils';

type TsconfigResult = {
severity: 'error',
results?: ts.Diagnostic[]
error?: any
severity: 'error';
results?: ts.Diagnostic[];
error?: any;
} | {
severity: 'success',
results: ts.CompilerOptions
severity: 'success';
results: ts.CompilerOptions;
};

type TscResult = {
severity: 'error'
results?: ts.Diagnostic[]
error?: any
severity: 'error';
results?: ts.Diagnostic[];
error?: any;
} | {
severity: 'success',
results: ts.Diagnostic[]
severity: 'success';
results: ts.Diagnostic[];
};

async function getTsconfig(srcDir: string): Promise<TsconfigResult> {
Expand Down
32 changes: 16 additions & 16 deletions scripts/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ import { htmlLogger, type buildHtml } from './docs/html';
import prebuild, { formatPrebuildResults } from './prebuild';

export interface BuildOptions {
srcDir: string
outDir: string
manifest: string
lint?: boolean
fix?: boolean
tsc?: boolean
verbose?: boolean
srcDir: string;
outDir: string;
manifest: string;
lint?: boolean;
fix?: boolean;
tsc?: boolean;
verbose?: boolean;
}

export interface SuccessResult {
name: string
severity: 'success',
name: string;
severity: 'success';
}

export interface WarnResult {
name: string,
severity: 'warn',
error: any
name: string;
severity: 'warn';
error: any;
}

export interface ErrorResult {
name: string,
severity: 'error',
error: any
name: string;
severity: 'error';
error: any;
}

export type OperationResult = ErrorResult | SuccessResult | WarnResult;
Expand Down Expand Up @@ -194,7 +194,7 @@ export function logInputs(
return output.join('\n');
}

type CommandHandler = (opts: BuildOptions & { bundles?: string[] | null, tabs?: string[] | null }) => Promise<void>;
type CommandHandler = (opts: BuildOptions & { bundles?: string[] | null; tabs?: string[] | null }) => Promise<void>;

export function createBuildCommandHandler(func: BuildTask, ignore?: 'bundles' | 'tabs'): CommandHandler {
return async opts => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/src/commandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export function promiseAll<T extends Promise<any>[]>(...args: T): Promise<{ [K i
}

export interface TimedResult<T> {
result: T
elapsed: number
result: T;
elapsed: number;
}

export function wrapWithTimer<T extends(...args: any[]) => Promise<any>>(func: T) {
Expand Down

0 comments on commit 9085574

Please sign in to comment.