Skip to content

Commit

Permalink
chore(eslint): show eslint warnings and errors on projects using Flas…
Browse files Browse the repository at this point in the history
…hlight as a submodule (#193)

* chore(.eslintrc.js): replace .eslintignore with ignore patterns

Why? Because only one .eslintignore file is used by the ESLint command, whereas all .eslintrc files are used. So it is a better practice to use "ignorePatterns" in .eslintrc

* chore(.eslintrc.js): match files in rule even from parent

* chore(ServerApp): add dependencies in useEffect

* refacto(processVideoFile): avoid using switch fallthrough to get FFmpeg binary

* chore(AppiumDriver): remove unused variable

* chore(MDXComponents): extract module contents to variable

* chore(MDXComponents): remove unused import

* chore(AppiumDriver): use correct type for error

* chore(shell): use correct type for error

* feat(processVideoFile): use FFmpeg-osx-64 for darwin all archs
  • Loading branch information
hduprat authored Jan 18, 2024
1 parent c406600 commit 9bd2dd6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 31 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module.exports = {
devDependencies: [
"**/__tests__/**",
// web app will be built with parcel in the dist folder, so we only package the final html/js files, not the deps
"packages/commands/measure/src/webapp/**",
"packages/core/web-reporter-ui/utils/testUtils.ts",
"packages/commands/report/src/**",
"**/packages/commands/measure/src/webapp/**",
"**/packages/core/web-reporter-ui/utils/testUtils.ts",
"**/packages/commands/report/src/**",
"**/*.config.js", // This is necessary for tailwind.config.js in both web-reporter and web-reporter-ui
],
},
Expand All @@ -29,6 +29,7 @@ module.exports = {
},
],
},
ignorePatterns: ["dist", "node_modules", "docs", "cpp-profiler", ".docusaurus", "report.js"],
overrides: [
{
files: ["**/__tests__/**", "**/*test.ts"],
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/measure/src/server/ServerApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const ServerApp = ({ port }: ServerAppProps) => {
server.close();
io.close();
};
}, []);
}, [port, webAppUrl]);
useCleanupOnManualExit();

return socket ? (
Expand Down
23 changes: 11 additions & 12 deletions packages/core/shell/src/processVideoFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ const execAsync = (command: string) =>
proc.on("error", reject);
});

const FFMPEG_VERSION = "4.4.1";
const archToExec: Partial<Record<`${NodeJS.Platform}-${NodeJS.Architecture}`, string>> = {
"darwin-arm64": "osx-64",
"darwin-x64": "osx-64",
"linux-x64": "linux-64",
};

const getFFMpegBinaryPath = () => {
switch (process.platform) {
case "darwin":
switch (process.arch) {
case "arm64":
return `https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.4.1/ffmpeg-4.4.1-osx-64.zip`;
}
case "linux":
switch (process.arch) {
case "x64":
return `https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.4.1/ffmpeg-4.4.1-linux-64.zip`;
}
}
const archKey = `${process.platform}-${process.arch}` as const;

if (archKey in archToExec)
return `https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v${FFMPEG_VERSION}/ffmpeg-${FFMPEG_VERSION}-${archToExec[archKey]}.zip`;

throw new Error(`Unsupported os ${process.platform}-${process.arch} to install FFMpeg`);
};
Expand Down
12 changes: 9 additions & 3 deletions packages/platforms/android/src/commands/shell.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { Logger } from "@perf-profiler/logger";
import { execSync, spawn, ChildProcess } from "child_process";
import { execSync, spawn, ChildProcess, SpawnSyncReturns } from "child_process";

export const executeCommand = (command: string): string => {
try {
return execSync(command, { stdio: "pipe" }).toString();
} catch (error: any) {
Logger.debug(`Error while executing command "${command}": ${error.stderr.toString()}`);
} catch (error: unknown) {
// The Error object will contain the entire result from child_process.spawnSync()
// (source: https://nodejs.org/api/child_process.html#child_processexecsynccommand-options)
Logger.debug(
`Error while executing command "${command}": ${(
error as SpawnSyncReturns<{ toString(): string }>
).stderr.toString()}`
);
throw error;
}
};
Expand Down
14 changes: 10 additions & 4 deletions packages/plugins/appium-helper/AppiumDriver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as webdriver from "webdriverio";
import { Logger } from "@perf-profiler/logger";
import { GestureHandler } from "./GestureHandler";
import { execSync } from "child_process";
import { execSync, SpawnSyncReturns } from "child_process";

export interface RemoteServerOptions {
hostName?: string;
Expand All @@ -10,8 +10,14 @@ export interface RemoteServerOptions {
const executeCommand = (command: string): string => {
try {
return execSync(command, { stdio: "pipe" }).toString();
} catch (error: any) {
Logger.debug(`Error while executing command "${command}": ${error.stderr.toString()}`);
} catch (error: unknown) {
// The Error object will contain the entire result from child_process.spawnSync()
// (source: https://nodejs.org/api/child_process.html#child_processexecsynccommand-options)
Logger.debug(
`Error while executing command "${command}": ${(
error as SpawnSyncReturns<{ toString(): string }>
).stderr.toString()}`
);
throw error;
}
};
Expand Down Expand Up @@ -115,7 +121,7 @@ export class AppiumDriver {
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout"
);
const id = screen.elementId;
const base64Image = await this.client.takeElementScreenshot(id);
await this.client.takeElementScreenshot(id);
// expect(base64Image).toMatchImageSnapshot({
// customSnapshotIdentifier: screenName,
// });
Expand Down
5 changes: 3 additions & 2 deletions website/src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint-disable import/no-unresolved */
import React from "react";
// Import the original mapper
import MDXComponents from "@theme-original/MDXComponents";
import Contact from "@site/src/components/Contact.mdx";

export default {
const _module = {
// Re-use the default mapping
...MDXComponents,
// Map the "<Highlight>" tag to our Highlight component
// `Highlight` will receive all props that were passed to `<Highlight>` in MDX
Contact,
};

export default _module;

0 comments on commit 9bd2dd6

Please sign in to comment.