@virmator/lint 14.10.3 → 14.12.0

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/README.md CHANGED
@@ -11,7 +11,6 @@ A default plugin for [virmator](https://www.npmjs.com/package/virmator).
11
11
  - Examples
12
12
  - `virmator lint`
13
13
  - Configs
14
- - configs/tsconfig.eslint.json
15
14
  - eslint.config.ts
16
15
  - Deps
17
16
  - [eslint](https://npmjs.com/package/eslint)
@@ -6,8 +6,6 @@ import prettierEslintRecommended from 'eslint-plugin-prettier/recommended';
6
6
  import sonarJsEslint from 'eslint-plugin-sonarjs';
7
7
  import eslintPluginUnicorn from 'eslint-plugin-unicorn';
8
8
  import globals from 'globals';
9
- import {existsSync} from 'node:fs';
10
- import {join} from 'node:path';
11
9
  import tsEslint from 'typescript-eslint';
12
10
  import preferIfElseChainRule from '../src/rules/prefer-if-else-chain.lint.js';
13
11
  import preferParseUrlRule from '../src/rules/prefer-parse-url.lint.js';
@@ -17,24 +15,11 @@ export const globalVars = {
17
15
  ...globals.browser,
18
16
  };
19
17
 
20
- export function determineTsconfigPath(repoDir: string) {
21
- const eslintTsconfig = join(repoDir, 'configs', 'tsconfig.eslint.json');
22
- const rootTsconfig = join(repoDir, 'tsconfig.json');
23
-
24
- if (existsSync(eslintTsconfig)) {
25
- return eslintTsconfig;
26
- } else {
27
- return rootTsconfig;
28
- }
29
- }
30
-
31
18
  export function defineEslintConfig(repoDir: string) {
32
19
  const compat = new FlatCompat({
33
20
  baseDirectory: repoDir,
34
21
  });
35
22
 
36
- const tsConfigPath = determineTsconfigPath(repoDir);
37
-
38
23
  return [
39
24
  ...compat.plugins('require-extensions'),
40
25
  ...compat.extends('plugin:require-extensions/recommended'),
@@ -74,9 +59,8 @@ export function defineEslintConfig(repoDir: string) {
74
59
  {
75
60
  languageOptions: {
76
61
  parserOptions: {
77
- project: [
78
- tsConfigPath,
79
- ],
62
+ projectService: true,
63
+ tsconfigRootDir: repoDir,
80
64
  },
81
65
  globals: globalVars,
82
66
  },
package/dist/lint.d.ts CHANGED
@@ -21,30 +21,6 @@ export declare const virmatorLintPlugin: Readonly<Readonly<{
21
21
  };
22
22
  };
23
23
  readonly configFiles: {
24
- readonly eslintTsconfig: {
25
- readonly copyFromPath: string;
26
- readonly copyToPath: string;
27
- readonly env: {
28
- readonly node: true;
29
- readonly web: true;
30
- };
31
- readonly packageType: {
32
- readonly "mono-root": true;
33
- };
34
- readonly required: true;
35
- };
36
- readonly eslintTsconfigTopPackage: {
37
- readonly copyFromPath: string;
38
- readonly copyToPath: string;
39
- readonly env: {
40
- readonly node: true;
41
- readonly web: true;
42
- };
43
- readonly packageType: {
44
- readonly package: true;
45
- };
46
- readonly required: true;
47
- };
48
24
  readonly eslint: {
49
25
  readonly copyFromPath: string;
50
26
  readonly copyToPath: string;
@@ -250,30 +226,6 @@ export declare const virmatorLintPlugin: Readonly<Readonly<{
250
226
  };
251
227
  };
252
228
  readonly configFiles: {
253
- readonly eslintTsconfig: {
254
- readonly copyFromPath: string;
255
- readonly copyToPath: string;
256
- readonly env: {
257
- readonly node: true;
258
- readonly web: true;
259
- };
260
- readonly packageType: {
261
- readonly "mono-root": true;
262
- };
263
- readonly required: true;
264
- };
265
- readonly eslintTsconfigTopPackage: {
266
- readonly copyFromPath: string;
267
- readonly copyToPath: string;
268
- readonly env: {
269
- readonly node: true;
270
- readonly web: true;
271
- };
272
- readonly packageType: {
273
- readonly package: true;
274
- };
275
- readonly required: true;
276
- };
277
229
  readonly eslint: {
278
230
  readonly copyFromPath: string;
279
231
  readonly copyToPath: string;
package/dist/lint.js CHANGED
@@ -38,30 +38,6 @@ export const virmatorLintPlugin = defineVirmatorPlugin(import.meta.dirname, {
38
38
  },
39
39
  },
40
40
  configFiles: {
41
- eslintTsconfig: {
42
- copyFromPath: join('configs', 'tsconfig.eslint.json'),
43
- copyToPath: join('configs', 'tsconfig.eslint.json'),
44
- env: {
45
- [RuntimeEnv.Node]: true,
46
- [RuntimeEnv.Web]: true,
47
- },
48
- packageType: {
49
- [PackageType.MonoRoot]: true,
50
- },
51
- required: true,
52
- },
53
- eslintTsconfigTopPackage: {
54
- copyFromPath: join('configs', 'tsconfig.eslint.top-package.json'),
55
- copyToPath: join('configs', 'tsconfig.eslint.json'),
56
- env: {
57
- [RuntimeEnv.Node]: true,
58
- [RuntimeEnv.Web]: true,
59
- },
60
- packageType: {
61
- [PackageType.TopPackage]: true,
62
- },
63
- required: true,
64
- },
65
41
  eslint: {
66
42
  copyFromPath: join('configs', 'eslint.config.share.ts'),
67
43
  copyToPath: join('eslint.config.ts'),
@@ -249,26 +225,47 @@ export const virmatorLintPlugin = defineVirmatorPlugin(import.meta.dirname, {
249
225
  },
250
226
  },
251
227
  },
252
- }, async ({ package: { monoRepoRootPath }, runShellCommand, cliInputs: { usedCommands, filteredArgs }, configs, }) => {
228
+ }, async ({ package: { monoRepoRootPath, packageType }, runShellCommand, runPerPackage, cliInputs: { usedCommands, filteredArgs }, configs, }) => {
253
229
  const args = mri(filteredArgs);
254
- const dirPath = args._.length ? '' : '.';
255
- const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
256
230
  const userSpecifiedConfig = filteredArgs.some((arg) => arg === '-c' || arg === '--config');
257
- const eslintCommand = [
258
- 'npx',
259
- 'eslint',
260
- '--cache',
261
- `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
262
- userSpecifiedConfig
263
- ? ''
264
- : `--config '${interpolationSafeWindowsPath(configs.lint.configs.eslint.fullCopyToPath)}'`,
265
- usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '',
266
- dirPath,
267
- ...filteredArgs,
268
- ]
269
- .filter(check.isTruthy)
270
- .join(' ');
271
- await runShellCommand(eslintCommand, {
272
- cwd: monoRepoRootPath,
273
- });
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(({ packageName }) => {
237
+ const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', `.eslintcache-${packageName}`);
238
+ return [
239
+ 'npx',
240
+ 'eslint',
241
+ '--cache',
242
+ `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
243
+ configArg,
244
+ fixArg,
245
+ '.',
246
+ ...filteredArgs,
247
+ ]
248
+ .filter(check.isTruthy)
249
+ .join(' ');
250
+ });
251
+ }
252
+ else {
253
+ const dirPath = args._.length ? '' : '.';
254
+ const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
255
+ const eslintCommand = [
256
+ 'npx',
257
+ 'eslint',
258
+ '--cache',
259
+ `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
260
+ configArg,
261
+ fixArg,
262
+ dirPath,
263
+ ...filteredArgs,
264
+ ]
265
+ .filter(check.isTruthy)
266
+ .join(' ');
267
+ await runShellCommand(eslintCommand, {
268
+ cwd: monoRepoRootPath,
269
+ });
270
+ }
274
271
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/lint",
3
- "version": "14.10.3",
3
+ "version": "14.12.0",
4
4
  "description": "Default ESLint linting plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -32,32 +32,32 @@
32
32
  "test:update": "npm test update"
33
33
  },
34
34
  "dependencies": {
35
- "@augment-vir/assert": "^31.68.1",
36
- "@augment-vir/common": "^31.68.1",
37
- "@augment-vir/node": "^31.68.1",
38
- "@virmator/core": "^14.10.3",
35
+ "@augment-vir/assert": "^31.68.3",
36
+ "@augment-vir/common": "^31.68.3",
37
+ "@augment-vir/node": "^31.68.3",
38
+ "@virmator/core": "^14.12.0",
39
39
  "jiti": "^2.6.1",
40
40
  "mri": "^1.2.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@augment-vir/test": "^31.68.1",
43
+ "@augment-vir/test": "^31.68.3",
44
44
  "@eslint/eslintrc": "^3.3.5",
45
45
  "@eslint/js": "9.39.2",
46
46
  "@stylistic/eslint-plugin": "^5.10.0",
47
47
  "@stylistic/eslint-plugin-ts": "^4.4.1",
48
48
  "@types/estree": "^1.0.8",
49
- "@types/node": "^25.3.0",
50
- "@typescript-eslint/eslint-plugin": "^8.57.0",
49
+ "@types/node": "^25.5.2",
50
+ "@typescript-eslint/eslint-plugin": "^8.58.0",
51
51
  "c8": "^11.0.0",
52
52
  "eslint": "^9.39.2",
53
53
  "eslint-config-prettier": "^10.1.8",
54
- "eslint-plugin-jsdoc": "^62.7.1",
54
+ "eslint-plugin-jsdoc": "^62.9.0",
55
55
  "eslint-plugin-monorepo-cop": "^1.0.2",
56
- "eslint-plugin-playwright": "^2.9.0",
56
+ "eslint-plugin-playwright": "^2.10.1",
57
57
  "eslint-plugin-prettier": "^5.5.5",
58
58
  "eslint-plugin-require-extensions": "^0.1.3",
59
59
  "eslint-plugin-sonarjs": "^4.0.2",
60
- "eslint-plugin-unicorn": "^63.0.0",
60
+ "eslint-plugin-unicorn": "^64.0.0",
61
61
  "istanbul-smart-text-reporter": "^1.1.5",
62
62
  "typescript-eslint": "8.57.1"
63
63
  },
package/src/lint.ts CHANGED
@@ -41,30 +41,6 @@ export const virmatorLintPlugin = defineVirmatorPlugin(
41
41
  },
42
42
  },
43
43
  configFiles: {
44
- eslintTsconfig: {
45
- copyFromPath: join('configs', 'tsconfig.eslint.json'),
46
- copyToPath: join('configs', 'tsconfig.eslint.json'),
47
- env: {
48
- [RuntimeEnv.Node]: true,
49
- [RuntimeEnv.Web]: true,
50
- },
51
- packageType: {
52
- [PackageType.MonoRoot]: true,
53
- },
54
- required: true,
55
- },
56
- eslintTsconfigTopPackage: {
57
- copyFromPath: join('configs', 'tsconfig.eslint.top-package.json'),
58
- copyToPath: join('configs', 'tsconfig.eslint.json'),
59
- env: {
60
- [RuntimeEnv.Node]: true,
61
- [RuntimeEnv.Web]: true,
62
- },
63
- packageType: {
64
- [PackageType.TopPackage]: true,
65
- },
66
- required: true,
67
- },
68
44
  eslint: {
69
45
  copyFromPath: join('configs', 'eslint.config.share.ts'),
70
46
  copyToPath: join('eslint.config.ts'),
@@ -254,36 +230,62 @@ export const virmatorLintPlugin = defineVirmatorPlugin(
254
230
  },
255
231
  },
256
232
  async ({
257
- package: {monoRepoRootPath},
233
+ package: {monoRepoRootPath, packageType},
258
234
  runShellCommand,
235
+ runPerPackage,
259
236
  cliInputs: {usedCommands, filteredArgs},
260
237
  configs,
261
238
  }) => {
262
239
  const args = mri(filteredArgs);
263
240
 
264
- const dirPath = args._.length ? '' : '.';
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' : '';
265
246
 
266
- const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
247
+ if (packageType === PackageType.MonoRoot && !args._.length) {
248
+ await runPerPackage(({packageName}) => {
249
+ const cacheLocation = join(
250
+ monoRepoRootPath,
251
+ 'node_modules',
252
+ '.cache',
253
+ `.eslintcache-${packageName}`,
254
+ );
267
255
 
268
- const userSpecifiedConfig = filteredArgs.some((arg) => arg === '-c' || arg === '--config');
256
+ return [
257
+ 'npx',
258
+ 'eslint',
259
+ '--cache',
260
+ `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
261
+ configArg,
262
+ fixArg,
263
+ '.',
264
+ ...filteredArgs,
265
+ ]
266
+ .filter(check.isTruthy)
267
+ .join(' ');
268
+ });
269
+ } else {
270
+ const dirPath = args._.length ? '' : '.';
271
+ const cacheLocation = join(monoRepoRootPath, 'node_modules', '.cache', '.eslintcache');
269
272
 
270
- const eslintCommand = [
271
- 'npx',
272
- 'eslint',
273
- '--cache',
274
- `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
275
- userSpecifiedConfig
276
- ? ''
277
- : `--config '${interpolationSafeWindowsPath(configs.lint.configs.eslint.fullCopyToPath)}'`,
278
- usedCommands.lint?.subCommands.fix && !args.fix ? '--fix' : '',
279
- dirPath,
280
- ...filteredArgs,
281
- ]
282
- .filter(check.isTruthy)
283
- .join(' ');
273
+ const eslintCommand = [
274
+ 'npx',
275
+ 'eslint',
276
+ '--cache',
277
+ `--cache-location='${interpolationSafeWindowsPath(cacheLocation)}'`,
278
+ configArg,
279
+ fixArg,
280
+ dirPath,
281
+ ...filteredArgs,
282
+ ]
283
+ .filter(check.isTruthy)
284
+ .join(' ');
284
285
 
285
- await runShellCommand(eslintCommand, {
286
- cwd: monoRepoRootPath,
287
- });
286
+ await runShellCommand(eslintCommand, {
287
+ cwd: monoRepoRootPath,
288
+ });
289
+ }
288
290
  },
289
291
  );
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": ".."
4
- },
5
- "extends": "./tsconfig.base.json",
6
- "include": [
7
- "../eslint.config.ts",
8
- "../packages/**/*.ts"
9
- ]
10
- }
@@ -1,7 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": ".."
4
- },
5
- "extends": "../tsconfig.json",
6
- "include": ["../eslint.config.ts", "../src/**/*.ts"]
7
- }