Skip to content

Commit

Permalink
fix(linter): ensure tslint converter works with pnp (#18323)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Jul 28, 2023
1 parent eb39210 commit f4b7ec2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
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

1 comment on commit f4b7ec2

@vercel
Copy link

@vercel vercel bot commented on f4b7ec2 Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.