fix(linter): dependency checks should respect pnpm workspace versions (#26709)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26707
This commit is contained in:
parent
5843068d3b
commit
7f8bb4ba1f
@ -1580,9 +1580,65 @@ describe('Dependency checks (eslint)', () => {
|
|||||||
- external1"
|
- external1"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should require swc if @nx/js:swc executor', () => {
|
it('should not report * and workspace:*', () => {
|
||||||
|
const packageJson = {
|
||||||
|
name: '@mycompany/liba',
|
||||||
|
dependencies: {
|
||||||
|
external1: '*',
|
||||||
|
external2: 'workspace:*',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileSys = {
|
||||||
|
'./libs/liba/package.json': JSON.stringify(packageJson, null, 2),
|
||||||
|
'./libs/liba/src/index.ts': '',
|
||||||
|
'./package.json': JSON.stringify(rootPackageJson, null, 2),
|
||||||
|
};
|
||||||
|
vol.fromJSON(fileSys, '/root');
|
||||||
|
|
||||||
|
const failures = runRule(
|
||||||
|
{},
|
||||||
|
`/root/libs/liba/package.json`,
|
||||||
|
JSON.stringify(packageJson, null, 2),
|
||||||
|
{
|
||||||
|
nodes: {
|
||||||
|
liba: {
|
||||||
|
name: 'liba',
|
||||||
|
type: 'lib',
|
||||||
|
data: {
|
||||||
|
root: 'libs/liba',
|
||||||
|
targets: {
|
||||||
|
build: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
externalNodes,
|
||||||
|
dependencies: {
|
||||||
|
liba: [
|
||||||
|
{ source: 'liba', target: 'npm:external1', type: 'static' },
|
||||||
|
{ source: 'liba', target: 'npm:external2', type: 'static' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
liba: [
|
||||||
|
createFile(`libs/liba/src/main.ts`, [
|
||||||
|
'npm:external1',
|
||||||
|
'npm:external2',
|
||||||
|
]),
|
||||||
|
createFile(`libs/liba/package.json`, [
|
||||||
|
'npm:external1',
|
||||||
|
'npm:external2',
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect(failures.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should require swc if @nx/js:swc executor', () => {
|
||||||
const packageJson = {
|
const packageJson = {
|
||||||
name: '@mycompany/liba',
|
name: '@mycompany/liba',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
@ -1642,6 +1698,7 @@ it('should require swc if @nx/js:swc executor', () => {
|
|||||||
- @swc/helpers"
|
- @swc/helpers"
|
||||||
`);
|
`);
|
||||||
expect(failures[0].line).toEqual(3);
|
expect(failures[0].line).toEqual(3);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function createFile(f: string, deps?: FileDataDependency[]): FileData {
|
function createFile(f: string, deps?: FileDataDependency[]): FileData {
|
||||||
|
|||||||
@ -219,6 +219,7 @@ export default ESLintUtils.RuleCreator(
|
|||||||
packageRange.startsWith('file:') ||
|
packageRange.startsWith('file:') ||
|
||||||
npmDependencies[packageName] === '*' ||
|
npmDependencies[packageName] === '*' ||
|
||||||
packageRange === '*' ||
|
packageRange === '*' ||
|
||||||
|
packageRange === 'workspace:*' ||
|
||||||
satisfies(npmDependencies[packageName], packageRange, {
|
satisfies(npmDependencies[packageName], packageRange, {
|
||||||
includePrerelease: true,
|
includePrerelease: true,
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user