@virmator/lint 14.12.0 → 14.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lint.js CHANGED
@@ -3,7 +3,7 @@ import { RuntimeEnv } from '@augment-vir/common';
3
3
  import { interpolationSafeWindowsPath } from '@augment-vir/node';
4
4
  import { defineVirmatorPlugin, NpmDepType, PackageType } from '@virmator/core';
5
5
  import mri from 'mri';
6
- import { join } from 'node:path';
6
+ import { join, relative } from 'node:path';
7
7
  /** A virmator plugin for running ESLint. */
8
8
  export const virmatorLintPlugin = defineVirmatorPlugin(import.meta.dirname, {
9
9
  name: 'Lint',
@@ -233,20 +233,27 @@ export const virmatorLintPlugin = defineVirmatorPlugin(import.meta.dirname, {
233
233
  : `--config '${interpolationSafeWindowsPath(configs.lint.configs.eslint.fullCopyToPath)}'`;
234
234
  const fixArg = usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '';
235
235
  if (packageType === PackageType.MonoRoot && !args._.length) {
236
- await runPerPackage(({ packageName }) => {
236
+ await runPerPackage(({ packageCwd, packageName }) => {
237
237
  const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', `.eslintcache-${packageName}`);
238
- return [
238
+ const relativePackagePath = relative(monoRepoRootPath, packageCwd);
239
+ /**
240
+ * ESLint resolves ignore patterns relative to the config file's directory (the
241
+ * monorepo root). We must `cd` back to the root so that file paths match those
242
+ * patterns correctly; `runPerPackage` sets CWD to the package directory.
243
+ */
244
+ const eslintCommand = [
239
245
  'npx',
240
246
  'eslint',
241
247
  '--cache',
242
248
  `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
243
249
  configArg,
244
250
  fixArg,
245
- '.',
251
+ `'${interpolationSafeWindowsPath(relativePackagePath)}'`,
246
252
  ...filteredArgs,
247
253
  ]
248
254
  .filter(check.isTruthy)
249
255
  .join(' ');
256
+ return `cd '${interpolationSafeWindowsPath(monoRepoRootPath)}' && ${eslintCommand}`;
250
257
  });
251
258
  }
252
259
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/lint",
3
- "version": "14.12.0",
3
+ "version": "14.12.1",
4
4
  "description": "Default ESLint linting plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -35,7 +35,7 @@
35
35
  "@augment-vir/assert": "^31.68.3",
36
36
  "@augment-vir/common": "^31.68.3",
37
37
  "@augment-vir/node": "^31.68.3",
38
- "@virmator/core": "^14.12.0",
38
+ "@virmator/core": "^14.12.1",
39
39
  "jiti": "^2.6.1",
40
40
  "mri": "^1.2.0"
41
41
  },
package/src/lint.ts CHANGED
@@ -3,7 +3,7 @@ import {RuntimeEnv} from '@augment-vir/common';
3
3
  import {interpolationSafeWindowsPath} from '@augment-vir/node';
4
4
  import {defineVirmatorPlugin, NpmDepType, PackageType} from '@virmator/core';
5
5
  import mri from 'mri';
6
- import {join} from 'node:path';
6
+ import {join, relative} from 'node:path';
7
7
 
8
8
  /** A virmator plugin for running ESLint. */
9
9
  export const virmatorLintPlugin = defineVirmatorPlugin(
@@ -245,26 +245,34 @@ export const virmatorLintPlugin = defineVirmatorPlugin(
245
245
  const fixArg = usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '';
246
246
 
247
247
  if (packageType === PackageType.MonoRoot && !args._.length) {
248
- await runPerPackage(({packageName}) => {
248
+ await runPerPackage(({packageCwd, packageName}) => {
249
249
  const cacheLocation = join(
250
250
  monoRepoRootPath,
251
251
  'node_modules',
252
252
  '.cache',
253
253
  `.eslintcache-${packageName}`,
254
254
  );
255
+ const relativePackagePath = relative(monoRepoRootPath, packageCwd);
255
256
 
256
- return [
257
+ /**
258
+ * ESLint resolves ignore patterns relative to the config file's directory (the
259
+ * monorepo root). We must `cd` back to the root so that file paths match those
260
+ * patterns correctly; `runPerPackage` sets CWD to the package directory.
261
+ */
262
+ const eslintCommand = [
257
263
  'npx',
258
264
  'eslint',
259
265
  '--cache',
260
266
  `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
261
267
  configArg,
262
268
  fixArg,
263
- '.',
269
+ `'${interpolationSafeWindowsPath(relativePackagePath)}'`,
264
270
  ...filteredArgs,
265
271
  ]
266
272
  .filter(check.isTruthy)
267
273
  .join(' ');
274
+
275
+ return `cd '${interpolationSafeWindowsPath(monoRepoRootPath)}' && ${eslintCommand}`;
268
276
  });
269
277
  } else {
270
278
  const dirPath = args._.length ? '' : '.';