Skip to content

Commit 79ac44d

Browse files
authored
fix(misc): remove unnecessary bust property from plugin hashes (#32807)
Remove the manually maintained and unnecessary `bust` property from plugin hashes.
1 parent ec07bfb commit 79ac44d

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

packages/eslint/src/plugins/plugin.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createNodesFromFiles,
66
CreateNodesResult,
77
CreateNodesV2,
8+
detectPackageManager,
89
getPackageManagerCommand,
910
logger,
1011
readJsonFile,
@@ -15,17 +16,18 @@ import {
1516
calculateHashesForCreateNodes,
1617
calculateHashForCreateNodes,
1718
} from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';
19+
import { getLockFileName } from '@nx/js';
20+
import type { ESLint as ESLintType } from 'eslint';
1821
import { existsSync } from 'node:fs';
1922
import { basename, dirname, join, normalize, sep } from 'node:path/posix';
2023
import { hashObject } from 'nx/src/hasher/file-hasher';
2124
import { workspaceDataDirectory } from 'nx/src/utils/cache-directory';
2225
import { combineGlobPatterns } from 'nx/src/utils/globs';
2326
import { globWithWorkspaceContext } from 'nx/src/utils/workspace-context';
2427
import { gte } from 'semver';
25-
import type { ESLint as ESLintType } from 'eslint';
2628
import {
27-
baseEsLintConfigFile,
2829
BASE_ESLINT_CONFIG_FILENAMES,
30+
baseEsLintConfigFile,
2931
ESLINT_CONFIG_FILENAMES,
3032
isFlatConfig,
3133
} from '../utils/config-file';
@@ -135,14 +137,13 @@ const internalCreateNodes = async (
135137
);
136138
const hash = await calculateHashForCreateNodes(
137139
childProjectRoot,
138-
{
139-
...options,
140-
// change this to bust the cache when making changes that would yield
141-
// different results for the same hash
142-
bust: 1,
143-
},
140+
options,
144141
context,
145-
[...parentConfigs, join(childProjectRoot, '.eslintignore')]
142+
[
143+
...parentConfigs,
144+
join(childProjectRoot, '.eslintignore'),
145+
getLockFileName(detectPackageManager(context.workspaceRoot)),
146+
]
146147
);
147148

148149
if (projectsCache[hash]) {
@@ -280,20 +281,18 @@ export const createNodesV2: CreateNodesV2<EslintPluginOptions> = [
280281
options,
281282
context
282283
);
284+
const lockFilePattern = getLockFileName(
285+
detectPackageManager(context.workspaceRoot)
286+
);
283287
const hashes = await calculateHashesForCreateNodes(
284288
projectRoots,
285-
{
286-
...options,
287-
// change this to bust the cache when making changes that would yield
288-
// different results for the same hash
289-
bust: 1,
290-
},
289+
options,
291290
context,
292291
projectRoots.map((root) => {
293292
const parentConfigs = eslintConfigFiles.filter((eslintConfig) =>
294293
isSubDir(root, dirname(eslintConfig))
295294
);
296-
return [...parentConfigs, join(root, '.eslintignore')];
295+
return [...parentConfigs, join(root, '.eslintignore'), lockFilePattern];
297296
})
298297
);
299298
const hashByRoot = new Map<string, string>(

packages/js/src/plugins/typescript/plugin.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,6 @@ async function getConfigFileHash(
363363
lockFileHash,
364364
optionsHash,
365365
...(packageJson ? [hashObject(packageJson)] : []),
366-
// change this to bust the cache when making changes that would yield
367-
// different results for the same hash
368-
hashObject({ bust: 3 }),
369366
]);
370367
}
371368

packages/nx/src/plugins/package-json/create-nodes.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
readTargetsFromPackageJson,
1717
} from '../../utils/package-json';
1818
import { joinPathFragments } from '../../utils/path';
19+
import { nxVersion } from '../../utils/versions';
1920
import {
2021
createNodesFromFiles,
2122
CreateNodesV2,
@@ -144,9 +145,7 @@ export function createNodeFromPackageJson(
144145
...json,
145146
root: projectRoot,
146147
isInPackageManagerWorkspaces,
147-
// change this to bust the cache when making changes that result in different
148-
// results for the same hash
149-
bust: 1,
148+
nxVersion,
150149
});
151150

152151
const cached = cache[hash];

0 commit comments

Comments
 (0)