Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Feb 6, 2024
1 parent b9a710f commit a31255e
Show file tree
Hide file tree
Showing 47 changed files with 184 additions and 185 deletions.
4 changes: 2 additions & 2 deletions packages/android-jsc-intl/src/withAndroidJscIntl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const withAndroidJscIntl: ConfigPlugin = (config) => {
return withAppBuildGradle(config, (config) => {
if (config.modResults.language !== "groovy") {
throw new Error(
"[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy."
"[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy.",
);
}

config.modResults.contents = config.modResults.contents.replace(
"org.webkit:android-jsc:+",
"org.webkit:android-jsc-intl:+"
"org.webkit:android-jsc-intl:+",
);

return config;
Expand Down
8 changes: 4 additions & 4 deletions packages/apple-settings/src/base-mods/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function parse(data: string, wantComments?: boolean): ParsedStrings {
if (data.indexOf("\n") === -1) {
data += "\n";
}
const re = /(?:\/\*(.+)\*\/\n)?(.+)\s*\=\s*\"(.+)\"\;\n/gim;
const re = /(?:\/\*(.+)\*\/\n)?(.+)\s*=\s*"(.+)";\n/gim;
const res: ParsedStrings = {};
let m: RegExpExecArray | null;

Expand Down Expand Up @@ -44,7 +44,7 @@ export function build(obj: ParsedStrings): string {
data += "\n/*" + obj[i]["comment"] + "*/\n";
}
// @ts-expect-error
data += '"' + i + '" = ' + '"' + escapeString(obj[i]["value"]) + '";\n';
data += '"' + i + '" = "' + escapeString(obj[i]["value"]) + '";\n';
} else if (typeof obj[i] === "string") {
data +=
'\n"' +
Expand All @@ -53,7 +53,7 @@ export function build(obj: ParsedStrings): string {
'"' +
escapeString(
// @ts-expect-error
obj[i]
obj[i],
) +
'";\n';
}
Expand All @@ -78,6 +78,6 @@ export function writeAsync(filename: string, data: ParsedStrings) {
return fs.promises.writeFile(
filename,
iconv.encode(build(data), "utf-16"),
"binary"
"binary",
);
}
8 changes: 4 additions & 4 deletions packages/apple-settings/src/base-mods/withSettingsPlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createModSetForSettingsPage({ name }: { name: string }) {

const withSettingsPlist: ConfigPlugin<Mod<SettingsPlist>> = (
config,
action
action,
) => {
return withMod(config, {
platform: "ios",
Expand All @@ -40,7 +40,7 @@ export function createModSetForSettingsPage({ name }: { name: string }) {
return path.join(
modRequest.platformProjectRoot,
modRequest.projectName!,
`Settings.bundle/${name}.plist`
`Settings.bundle/${name}.plist`,
);
},
async read(filePath) {
Expand All @@ -51,11 +51,11 @@ export function createModSetForSettingsPage({ name }: { name: string }) {
};
}
return plist.default.parse(
await fs.promises.readFile(filePath, "utf-8")
await fs.promises.readFile(filePath, "utf-8"),
);
} catch (error: any) {
throw new Error(
`Failed to parse the iOS Settings.bundle/${name}.plist: "${filePath}". ${error.message}}`
`Failed to parse the iOS Settings.bundle/${name}.plist: "${filePath}". ${error.message}}`,
);
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/apple-settings/src/base-mods/withSettingsStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function createModSetForSettingsStrings({
return path.join(
modRequest.platformProjectRoot,
modRequest.projectName!,
`Settings.bundle/${lang}.lproj/${name}.strings`
`Settings.bundle/${lang}.lproj/${name}.strings`,
);
},
async read(filePath) {
Expand All @@ -49,7 +49,7 @@ export function createModSetForSettingsStrings({
>;
} catch (error: any) {
throw new Error(
`Failed to parse the Settings.bundle/${lang}.lproj/${name}.strings: "${filePath}". ${error.message}}`
`Failed to parse the Settings.bundle/${lang}.lproj/${name}.strings: "${filePath}". ${error.message}}`,
);
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/apple-settings/src/base-mods/withXcparse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const customModName = "xcodeProjectBeta-apple-settings";

export const withXcodeProjectBeta: ConfigPlugin<Mod<XcodeProject>> = (
config,
action
action,
) => {
return withMod(config, {
platform: "ios",
Expand All @@ -41,7 +41,7 @@ const withXcodeProjectBetaBaseModInternal: ConfigPlugin = (config) => {
return XcodeProject.open(filePath);
} catch (error: any) {
throw new Error(
`Failed to parse the Xcode project: "${filePath}". ${error.message}}`
`Failed to parse the Xcode project: "${filePath}". ${error.message}}`,
);
}
},
Expand All @@ -61,5 +61,5 @@ const withXcodeProjectBetaBaseModInternal: ConfigPlugin = (config) => {

export const withXcodeProjectBetaBaseMod = createRunOncePlugin(
withXcodeProjectBetaBaseModInternal,
"withXcodeProjectBetaBaseMod"
"withXcodeProjectBetaBaseMod",
);
10 changes: 5 additions & 5 deletions packages/apple-settings/src/withLinkedSettingsBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getMainAppTarget(project: XcodeProject): PBXNativeTarget {
console.warn(
`Multiple main app targets found, using first one: ${mainAppTarget
.map((t) => t.getDisplayName())
.join(", ")}}`
.join(", ")}}`,
);
}

Expand All @@ -39,7 +39,7 @@ function getDefaultBuildConfigurationForTarget(target: PBXNativeTarget) {
return target.props.buildConfigurationList.props.buildConfigurations.find(
(config) =>
config.props.name ===
target.props.buildConfigurationList.props.defaultConfigurationName
target.props.buildConfigurationList.props.defaultConfigurationName,
);
}

Expand All @@ -54,17 +54,17 @@ export const withLinkedSettingsBundle: ConfigPlugin = (config) => {

async function applyXcodeChanges(
project: XcodeProject,
props: { projectName: string }
props: { projectName: string },
) {
const mainAppTarget = getMainAppTarget(project);
const mainResourceBuildPhase = mainAppTarget.getBuildPhase(
PBXResourcesBuildPhase
PBXResourcesBuildPhase,
);

// Prevent duplicate.
if (
mainResourceBuildPhase?.props.files.find(
(file) => file.props.fileRef.props.name === "Settings.bundle"
(file) => file.props.fileRef.props.name === "Settings.bundle",
)
) {
return project;
Expand Down
4 changes: 2 additions & 2 deletions packages/detox/src/__tests__/withDetoxTestAppGradle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { setGradleAndroidTestImplementation } from "../withDetoxTestAppGradle";
describe(setGradleAndroidTestImplementation, () => {
it(`appends`, () => {
const result = setGradleAndroidTestImplementation(
getFixture("app-build.gradle")
getFixture("app-build.gradle"),
);
expect(result).toContain("androidTestImplementation('com.wix:detox:+')");
expect(result).toContain(
"implementation 'androidx.appcompat:appcompat:1.6.1'"
"implementation 'androidx.appcompat:appcompat:1.6.1'",
);
expect(result).toMatchSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/detox/src/__tests__/withProguardGradle-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe(addDetoxProguardRules, () => {
});
it(`doesn't add proguard rules to gradle if proguard is missing from the template`, () => {
expect(
addDetoxProguardRules(buildGradleWithoutProguardFixture)
addDetoxProguardRules(buildGradleWithoutProguardFixture),
).not.toMatch(/detox/);
});
it(`doesn't duplicate`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/detox/src/withDetox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const withDetox: ConfigPlugin<
[withNetworkSecurityConfigManifest, { subdomains }],
// 7.
!skipProguard && withProguardGradle,
].filter(Boolean) as ([ConfigPlugin, any] | ConfigPlugin)[]
].filter(Boolean) as ([ConfigPlugin, any] | ConfigPlugin)[],
);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/detox/src/withDetoxProjectGradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const withDetoxProjectGradle: ConfigPlugin = (config) => {
return withProjectBuildGradle(config, (config) => {
if (config.modResults.language === "groovy") {
config.modResults.contents = addDetoxImport(
config.modResults.contents
config.modResults.contents,
).contents;
} else {
throw new Error(
"Cannot add Detox maven gradle because the project build.gradle is not groovy"
"Cannot add Detox maven gradle because the project build.gradle is not groovy",
);
}
return config;
Expand Down
18 changes: 9 additions & 9 deletions packages/detox/src/withDetoxTestAppGradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ const withDetoxTestAppGradle: ConfigPlugin = (config) => {
return withAppBuildGradle(config, (config) => {
if (config.modResults.language === "groovy") {
config.modResults.contents = setGradleAndroidTestImplementation(
config.modResults.contents
config.modResults.contents,
);
config.modResults.contents = addDetoxDefaultConfigBlock(
config.modResults.contents
config.modResults.contents,
);
} else {
throw new Error(
"Cannot add Detox maven gradle because the project build.gradle is not groovy"
"Cannot add Detox maven gradle because the project build.gradle is not groovy",
);
}
return config;
});
};

export function setGradleAndroidTestImplementation(
buildGradle: string
buildGradle: string,
): string {
buildGradle = pushGradleDependency(
buildGradle,
// SDK 50 https://github.com/wix/Detox/blob/700b750e8a09b2eff2d26c0dbf3c50b70130fc9b/examples/demo-react-native/android/app/build.gradle#L61
"implementation 'androidx.appcompat:appcompat:1.6.1'"
"implementation 'androidx.appcompat:appcompat:1.6.1'",
);
buildGradle = pushGradleDependency(
buildGradle,
"androidTestImplementation('com.wix:detox:+')"
"androidTestImplementation('com.wix:detox:+')",
);
return buildGradle;
}
Expand All @@ -46,7 +46,7 @@ function escapeStringRegexp(str: string) {

export function pushGradleDependency(
buildGradle: string,
dependency: string
dependency: string,
): string {
const pattern = new RegExp(escapeStringRegexp(dependency), "g");
if (buildGradle.match(pattern)) {
Expand All @@ -55,7 +55,7 @@ export function pushGradleDependency(
return buildGradle.replace(
/dependencies\s?{/,
`dependencies {
${dependency}`
${dependency}`,
);
}

Expand All @@ -70,7 +70,7 @@ export function addDetoxDefaultConfigBlock(buildGradle: string): string {
`defaultConfig {
// detox-plugin-default-config
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'`
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'`,
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/detox/src/withDetoxTestClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export const withDetoxTestClass: ConfigPlugin = (config) => {
assert(packageName, "android.package must be defined");
const folder = path.join(
config.modRequest.platformProjectRoot,
`app/src/androidTest/java/${packageName.split(".").join("/")}`
`app/src/androidTest/java/${packageName.split(".").join("/")}`,
);
fs.mkdirSync(folder, { recursive: true });
fs.writeFileSync(
path.join(folder, "DetoxTest.java"),
getTemplateFile(packageName),
{ encoding: "utf8" }
{ encoding: "utf8" },
);
return config;
},
Expand Down
8 changes: 4 additions & 4 deletions packages/detox/src/withKotlinGradle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withBuildProperties } from "expo-build-properties";
import { ConfigPlugin, withProjectBuildGradle } from "expo/config-plugins";
import { withBuildProperties } from "expo-build-properties";

const kotlinClassPath =
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion";
Expand All @@ -21,11 +21,11 @@ const withKotlinGradle: ConfigPlugin<string> = (config, version) => {
// Add the classpath to the project build.gradle
if (config.modResults.language === "groovy") {
config.modResults.contents = setKotlinClassPath(
config.modResults.contents
config.modResults.contents,
);
} else {
throw new Error(
"Cannot setup kotlin because the build.gradle is not groovy"
"Cannot setup kotlin because the build.gradle is not groovy",
);
}
return config;
Expand All @@ -40,7 +40,7 @@ function setKotlinClassPath(buildGradle: string): string {
return buildGradle.replace(
/dependencies\s?{/,
`dependencies {
classpath "${kotlinClassPath}"`
classpath "${kotlinClassPath}"`,
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/detox/src/withNetworkSecurityConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getTemplateConfigContent(subdomains: SubdomainsType) {
${subdomains
.map(
(subdomain) =>
`<domain includeSubdomains="true">${subdomain}</domain>`
`<domain includeSubdomains="true">${subdomain}</domain>`,
)
.join("")}
</domain-config>
Expand Down Expand Up @@ -53,13 +53,13 @@ const withNetworkSecurityConfigFile: ConfigPlugin<{
assert(packageName, "android.package must be defined");
const folder = path.join(
config.modRequest.platformProjectRoot,
`app/src/main/res/xml`
`app/src/main/res/xml`,
);
fs.mkdirSync(folder, { recursive: true });
fs.writeFileSync(
path.join(folder, "network_security_config.xml"),
getTemplateFile(subdomains),
{ encoding: "utf8" }
{ encoding: "utf8" },
);
return config;
},
Expand Down Expand Up @@ -88,7 +88,7 @@ export const withNetworkSecurityConfigManifest: ConfigPlugin<
config = withNetworkSecurityConfigFile(config, props);
return withAndroidManifest(config, (config) => {
const application = AndroidConfig.Manifest.getMainApplicationOrThrow(
config.modResults
config.modResults,
);
application.$["android:networkSecurityConfig"] =
"@xml/network_security_config";
Expand Down
6 changes: 3 additions & 3 deletions packages/detox/src/withProguardGradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const withProguardGradle: ConfigPlugin = (config) => {
return withAppBuildGradle(config, (config) => {
if (config.modResults.language === "groovy") {
config.modResults.contents = addDetoxProguardRules(
config.modResults.contents
config.modResults.contents,
);
} else {
throw new Error(
"Cannot add Detox maven gradle because the project build.gradle is not groovy"
"Cannot add Detox maven gradle because the project build.gradle is not groovy",
);
}
return config;
Expand All @@ -34,7 +34,7 @@ export function addDetoxProguardRules(buildGradle: string): string {
// Detox-specific additions to pro-guard
def detoxProguardRulesPath = new File(["node", "--print", "require.resolve('detox/package.json')"].execute(null, rootDir).text.trim(), "../android/detox/proguard-rules-app.pro")
proguardFile(detoxProguardRulesPath)
`
`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addPackageName } from "../withAndroidFFMPEGPackage";
describe(addPackageName, () => {
it(`adds undefined package`, () => {
expect(
addPackageName(getFixture("build.gradle"), undefined)
addPackageName(getFixture("build.gradle"), undefined),
).toMatchSnapshot();
});
it(`redefines the package`, () => {
Expand Down
Loading

0 comments on commit a31255e

Please sign in to comment.