@naturalcycles/dev-lib 20.45.2 → 20.46.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.
@@ -70,6 +70,13 @@ export const sharedConfig = {
70
70
  ],
71
71
  '@stylistic/lines-between-class-members': [2, 'always', { exceptAfterSingleLine: true }],
72
72
  complexity: [2, { max: 40 }],
73
+ 'logical-assignment-operators': [
74
+ 2,
75
+ 'always',
76
+ {
77
+ enforceForIfStatements: true,
78
+ },
79
+ ],
73
80
  'no-this-alias': 0,
74
81
  'no-shadow': 0, // too many shadows in the codebase already
75
82
  'no-async-promise-executor': 0,
@@ -409,6 +416,8 @@ export const sharedConfig = {
409
416
  'vitest/prefer-hooks-in-order': 2,
410
417
  'vitest/prefer-hooks-on-top': 2,
411
418
  'vitest/prefer-mock-promise-shorthand': 2,
419
+ 'vitest/prefer-mock-return-shorthand': 2,
420
+ 'vitest/prefer-snapshot-hint': 0, // annoying
412
421
  'vitest/prefer-to-have-length': 2,
413
422
  'vitest/require-to-throw-message': 2,
414
423
  'vitest/valid-describe-callback': 0,
@@ -421,17 +430,15 @@ export const sharedConfig = {
421
430
  'vitest/prefer-called-exactly-once-with': 2,
422
431
  'vitest/consistent-test-filename': 2,
423
432
  'vitest/warn-todo': 0,
424
- 'jest/consistent-test-it': [
433
+ 'vitest/consistent-test-it': [
425
434
  2,
426
435
  {
427
436
  fn: 'test',
428
437
  withinDescribe: 'test',
429
438
  },
430
439
  ],
431
- 'jest/max-nested-describe': [0, { max: 4 }], // not good
432
- 'jest/no-alias-methods': 2,
433
- 'jest/prefer-mock-return-shorthand': 2,
434
- 'jest/prefer-snapshot-hint': 0, // annoying
440
+ 'vitest/max-nested-describe': [0, { max: 4 }], // not good
441
+ 'vitest/no-alias-methods': 2,
435
442
  'vue/no-multiple-slot-args': 2,
436
443
  'vue/no-deprecated-destroyed-lifecycle': 2,
437
444
  'vue/define-emits-declaration': [2, 'type-based'],
@@ -22,7 +22,7 @@ const pool = 'threads'
22
22
  process.env.TZ ||= 'UTC'
23
23
 
24
24
  if (testType === 'unit') {
25
- process.env.APP_ENV = process.env.APP_ENV || 'test'
25
+ process.env.APP_ENV ||= 'test'
26
26
  }
27
27
 
28
28
  if (silent) {
@@ -3,7 +3,7 @@ import { _assert } from '@naturalcycles/js-lib/error/assert.js';
3
3
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
4
4
  import { runScript } from '@naturalcycles/nodejs-lib/runScript';
5
5
  import { buildCopy, buildProd, eslintAll, lintStagedCommand, runCheck, runOxfmt, runOxlint, runTest, stylelintAll, typecheckWithTS, typecheckWithTSC, typecheckWithTSGO, } from '../check.util.js';
6
- import { runCommitlint } from '../commitlint.js';
6
+ import { runCommitlint } from '../commitlint.command.js';
7
7
  const commands = [
8
8
  { name: 'check', fn: runCheck, desc: '"Run all possible checks": lint, typecheck, then test.' },
9
9
  {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validates the commit message,
3
+ * which is read from a file, passed as process.argv.at(-1)
4
+ */
5
+ export declare function runCommitlint(): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { _assert } from '@naturalcycles/js-lib/error';
2
+ import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
3
+ import { validateCommitMessage } from './commitlint.util.js';
4
+ import { readDevLibConfigIfPresent } from './config.js';
5
+ /**
6
+ * Validates the commit message,
7
+ * which is read from a file, passed as process.argv.at(-1)
8
+ */
9
+ export async function runCommitlint() {
10
+ // || '.git/COMMIT_EDITMSG' // fallback is unnecessary, first argument should be always present
11
+ const arg1 = process.argv.at(-1);
12
+ _assert(arg1, 'dev-lib commitlint2 is called with $1 (first argument) missing');
13
+ console.log({ arg1 });
14
+ fs2.requireFileToExist(arg1);
15
+ const msg = fs2.readText(arg1);
16
+ console.log({ msg });
17
+ // Skip validation for merge commits (MERGE_HEAD exists during merge)
18
+ if (fs2.pathExists('.git/MERGE_HEAD')) {
19
+ console.log('✓ Merge commit - skipping validation');
20
+ return;
21
+ }
22
+ const devLibCfg = await readDevLibConfigIfPresent();
23
+ console.log({ devLibCfg });
24
+ const { valid, errors } = validateCommitMessage(msg, devLibCfg.commitlint);
25
+ if (valid) {
26
+ console.log('✓ Valid commit message');
27
+ return;
28
+ }
29
+ console.error('✗ Invalid commit message:');
30
+ for (const err of errors) {
31
+ console.error(` - ${err}`);
32
+ }
33
+ process.exit(1);
34
+ }
@@ -1,9 +1,4 @@
1
1
  import type { DevLibCommitlintConfig } from './config.js';
2
- /**
3
- * Validates the commit message,
4
- * which is read from a file, passed as process.argv.at(-1)
5
- */
6
- export declare function runCommitlint(): Promise<void>;
7
2
  /**
8
3
  * Commit message validator following Conventional Commits specification.
9
4
  * https://www.conventionalcommits.org/
@@ -1,6 +1,3 @@
1
- import { _assert } from '@naturalcycles/js-lib/error';
2
- import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
3
- import { readDevLibConfigIfPresent } from './config.js';
4
1
  const ALLOWED_TYPES = new Set([
5
2
  'feat',
6
3
  'fix',
@@ -15,36 +12,6 @@ const ALLOWED_TYPES = new Set([
15
12
  'revert',
16
13
  ]);
17
14
  const SUBJECT_MAX_LENGTH = 120; // Only applies to subject line (first line)
18
- /**
19
- * Validates the commit message,
20
- * which is read from a file, passed as process.argv.at(-1)
21
- */
22
- export async function runCommitlint() {
23
- // || '.git/COMMIT_EDITMSG' // fallback is unnecessary, first argument should be always present
24
- const arg1 = process.argv.at(-1);
25
- _assert(arg1, 'dev-lib commitlint2 is called with $1 (first argument) missing');
26
- console.log({ arg1 });
27
- fs2.requireFileToExist(arg1);
28
- const msg = fs2.readText(arg1);
29
- console.log({ msg });
30
- // Skip validation for merge commits (MERGE_HEAD exists during merge)
31
- if (fs2.pathExists('.git/MERGE_HEAD')) {
32
- console.log('✓ Merge commit - skipping validation');
33
- return;
34
- }
35
- const devLibCfg = await readDevLibConfigIfPresent();
36
- console.log({ devLibCfg });
37
- const { valid, errors } = validateCommitMessage(msg, devLibCfg.commitlint);
38
- if (valid) {
39
- console.log('✓ Valid commit message');
40
- return;
41
- }
42
- console.error('✗ Invalid commit message:');
43
- for (const err of errors) {
44
- console.error(` - ${err}`);
45
- }
46
- process.exit(1);
47
- }
48
15
  /**
49
16
  * Commit message validator following Conventional Commits specification.
50
17
  * https://www.conventionalcommits.org/
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './config.js';
2
+ export * from './commitlint.util.js';
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export * from './config.js';
2
+ export * from './commitlint.util.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.45.2",
4
+ "version": "20.46.1",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@naturalcycles/nodejs-lib": "^15",