@virmator/lint 14.11.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 +49 -21
- package/package.json +2 -2
- package/src/lint.ts +56 -22
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',
|
|
@@ -225,26 +225,54 @@ export const virmatorLintPlugin = defineVirmatorPlugin(import.meta.dirname, {
|
|
|
225
225
|
},
|
|
226
226
|
},
|
|
227
227
|
},
|
|
228
|
-
}, async ({ package: { monoRepoRootPath }, runShellCommand, cliInputs: { usedCommands, filteredArgs }, configs, }) => {
|
|
228
|
+
}, async ({ package: { monoRepoRootPath, packageType }, runShellCommand, runPerPackage, cliInputs: { usedCommands, filteredArgs }, configs, }) => {
|
|
229
229
|
const args = mri(filteredArgs);
|
|
230
|
-
const dirPath = args._.length ? '' : '.';
|
|
231
|
-
const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
|
|
232
230
|
const userSpecifiedConfig = filteredArgs.some((arg) => arg === '-c' || arg === '--config');
|
|
233
|
-
const
|
|
234
|
-
'
|
|
235
|
-
'eslint'
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
231
|
+
const configArg = userSpecifiedConfig
|
|
232
|
+
? ''
|
|
233
|
+
: `--config '${interpolationSafeWindowsPath(configs.lint.configs.eslint.fullCopyToPath)}'`;
|
|
234
|
+
const fixArg = usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '';
|
|
235
|
+
if (packageType === PackageType.MonoRoot && !args._.length) {
|
|
236
|
+
await runPerPackage(({ packageCwd, packageName }) => {
|
|
237
|
+
const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', `.eslintcache-${packageName}`);
|
|
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 = [
|
|
245
|
+
'npx',
|
|
246
|
+
'eslint',
|
|
247
|
+
'--cache',
|
|
248
|
+
`--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
|
|
249
|
+
configArg,
|
|
250
|
+
fixArg,
|
|
251
|
+
`'${interpolationSafeWindowsPath(relativePackagePath)}'`,
|
|
252
|
+
...filteredArgs,
|
|
253
|
+
]
|
|
254
|
+
.filter(check.isTruthy)
|
|
255
|
+
.join(' ');
|
|
256
|
+
return `cd '${interpolationSafeWindowsPath(monoRepoRootPath)}' && ${eslintCommand}`;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const dirPath = args._.length ? '' : '.';
|
|
261
|
+
const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
|
|
262
|
+
const eslintCommand = [
|
|
263
|
+
'npx',
|
|
264
|
+
'eslint',
|
|
265
|
+
'--cache',
|
|
266
|
+
`--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
|
|
267
|
+
configArg,
|
|
268
|
+
fixArg,
|
|
269
|
+
dirPath,
|
|
270
|
+
...filteredArgs,
|
|
271
|
+
]
|
|
272
|
+
.filter(check.isTruthy)
|
|
273
|
+
.join(' ');
|
|
274
|
+
await runShellCommand(eslintCommand, {
|
|
275
|
+
cwd: monoRepoRootPath,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
250
278
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/lint",
|
|
3
|
-
"version": "14.
|
|
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.
|
|
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(
|
|
@@ -230,36 +230,70 @@ export const virmatorLintPlugin = defineVirmatorPlugin(
|
|
|
230
230
|
},
|
|
231
231
|
},
|
|
232
232
|
async ({
|
|
233
|
-
package: {monoRepoRootPath},
|
|
233
|
+
package: {monoRepoRootPath, packageType},
|
|
234
234
|
runShellCommand,
|
|
235
|
+
runPerPackage,
|
|
235
236
|
cliInputs: {usedCommands, filteredArgs},
|
|
236
237
|
configs,
|
|
237
238
|
}) => {
|
|
238
239
|
const args = mri(filteredArgs);
|
|
239
240
|
|
|
240
|
-
const
|
|
241
|
+
const userSpecifiedConfig = filteredArgs.some((arg) => arg === '-c' || arg === '--config');
|
|
242
|
+
const configArg = userSpecifiedConfig
|
|
243
|
+
? ''
|
|
244
|
+
: `--config '${interpolationSafeWindowsPath(configs.lint.configs.eslint.fullCopyToPath)}'`;
|
|
245
|
+
const fixArg = usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '';
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
if (packageType === PackageType.MonoRoot && !args._.length) {
|
|
248
|
+
await runPerPackage(({packageCwd, packageName}) => {
|
|
249
|
+
const cacheLocation = join(
|
|
250
|
+
monoRepoRootPath,
|
|
251
|
+
'node_modules',
|
|
252
|
+
'.cache',
|
|
253
|
+
`.eslintcache-${packageName}`,
|
|
254
|
+
);
|
|
255
|
+
const relativePackagePath = relative(monoRepoRootPath, packageCwd);
|
|
243
256
|
|
|
244
|
-
|
|
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 = [
|
|
263
|
+
'npx',
|
|
264
|
+
'eslint',
|
|
265
|
+
'--cache',
|
|
266
|
+
`--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
|
|
267
|
+
configArg,
|
|
268
|
+
fixArg,
|
|
269
|
+
`'${interpolationSafeWindowsPath(relativePackagePath)}'`,
|
|
270
|
+
...filteredArgs,
|
|
271
|
+
]
|
|
272
|
+
.filter(check.isTruthy)
|
|
273
|
+
.join(' ');
|
|
274
|
+
|
|
275
|
+
return `cd '${interpolationSafeWindowsPath(monoRepoRootPath)}' && ${eslintCommand}`;
|
|
276
|
+
});
|
|
277
|
+
} else {
|
|
278
|
+
const dirPath = args._.length ? '' : '.';
|
|
279
|
+
const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
|
|
245
280
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
.filter(check.isTruthy)
|
|
259
|
-
.join(' ');
|
|
281
|
+
const eslintCommand = [
|
|
282
|
+
'npx',
|
|
283
|
+
'eslint',
|
|
284
|
+
'--cache',
|
|
285
|
+
`--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
|
|
286
|
+
configArg,
|
|
287
|
+
fixArg,
|
|
288
|
+
dirPath,
|
|
289
|
+
...filteredArgs,
|
|
290
|
+
]
|
|
291
|
+
.filter(check.isTruthy)
|
|
292
|
+
.join(' ');
|
|
260
293
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
294
|
+
await runShellCommand(eslintCommand, {
|
|
295
|
+
cwd: monoRepoRootPath,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
264
298
|
},
|
|
265
299
|
);
|