Skip to content

Commit d8537fa

Browse files
committed
feat: enable ESLint plugin in migrate
1 parent bf01f10 commit d8537fa

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

lib/controllers/migrate-controller.ts

+23-10
Original file line numberDiff line numberDiff line change
@@ -1640,16 +1640,29 @@ export class MigrateController
16401640
}
16411641

16421642
private async runESLint(projectDir: string) {
1643-
// todo: run @nativescript/eslint-plugin on project folder to update imports
1644-
// const childProcess = injector.resolve('childProcess') as IChildProcess;
1645-
// const args = [
1646-
// 'npx',
1647-
// '--package typescript',
1648-
// '--package @nativescript/eslint-plugin',
1649-
// '-c eslint-plugin',
1650-
// projectDir
1651-
// ]
1652-
// await childProcess.exec(args.join(' '))
1643+
this.spinner.start(`Running ESLint fixes`);
1644+
try {
1645+
const childProcess = injector.resolve("childProcess") as IChildProcess;
1646+
const npxVersion = await childProcess.exec("npx -v");
1647+
1648+
const npxFlags = [];
1649+
1650+
if (semver.gt(semver.coerce(npxVersion), "7.0.0")) {
1651+
npxFlags.push("-y");
1652+
}
1653+
1654+
const args = [
1655+
"npx",
1656+
...npxFlags,
1657+
"@nativescript/eslint-plugin",
1658+
projectDir,
1659+
];
1660+
await childProcess.exec(args.join(" "));
1661+
this.spinner.succeed(`Applied ESLint fixes`);
1662+
} catch (err) {
1663+
this.spinner.fail(`Failed to apply ESLint fixes`);
1664+
this.$logger.trace("Failed to apply ESLint fixes. Error is:", err);
1665+
}
16531666
}
16541667
}
16551668

0 commit comments

Comments
 (0)