Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): ensure tslint converter works with pnp #18323

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ import { conversionGenerator } from './convert-tslint-to-eslint';
/**
* Don't run actual child_process implementation of installPackagesTask()
*/
jest.mock('child_process');
jest.mock('child_process', () => {
return {
...jest.requireActual<any>('child_process'),
execSync: jest.fn((command: string) => {
if (command.includes('pnpm --version')) {
return '8.2.0';
}
return;
}),
};
});

const appProjectName = 'angular-app-1';
const appProjectRoot = `apps/${appProjectName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ import { conversionGenerator } from './convert-tslint-to-eslint';
/**
* Don't run actual child_process implementation of installPackagesTask()
*/
jest.mock('child_process');
jest.mock('child_process', () => {
return {
...jest.requireActual<any>('child_process'),
execSync: jest.fn((command: string) => {
if (command.includes('pnpm --version')) {
return '8.2.0';
}
return;
}),
};
});

const projectName = 'e2e-app-1';
const projectRoot = `apps/${projectName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export async function convertToESLintConfig(
*/
writeJsonFile(pathToTslintJson, updatedTSLintJson);
}
const pm = getPackageManagerCommand();
const reportedConfiguration = await findReportedConfiguration(
'npx tslint --print-config',
`${pm.exec} tslint --print-config`,
pathToTslintJson
);

Expand All @@ -121,8 +122,7 @@ export async function convertToESLintConfig(
* This error could occur if, for example, the user does not have a TSLint plugin installed correctly that they
* reference in their config.
*/
const printConfigFailureMessageStart =
'Command failed: npx tslint --print-config "tslint.json"';
const printConfigFailureMessageStart = `Command failed: ${pm.exec} tslint --print-config "tslint.json"`;
if (
reportedConfiguration.message.startsWith(printConfigFailureMessageStart)
) {
Expand Down