@naturalcycles/dev-lib 15.16.0 → 15.18.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/cfg/_cnst.js CHANGED
@@ -6,6 +6,7 @@ module.exports = {
6
6
  prettierExtensionsExclusive: 'js,jsx,json,md,graphql,yml,yaml,html',
7
7
  // everything that prettier supports:
8
8
  prettierExtensionsAll: 'ts,tsx,cts,mts,css,scss,js,jsx,cjs,mjs,json,md,graphql,yml,yaml,html,vue',
9
+ eslintExtensions: 'ts,tsx,cts,mts,vue,html',
9
10
  stylelintExtensions: 'css,scss',
10
11
  lintExclude: ['./**/__exclude/**', './**/dist/**', './**/cache/**', './CHANGELOG.md'],
11
12
  }
package/cfg/biome.jsonc CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
3
3
  "files": {
4
- "ignore": ["**/tsconfig.json", "**/tsconfig.*.json", "**/__exclude", "**/try.ts", "*.compact.json"]
4
+ "ignore": ["**/*.html", "**/tsconfig.json", "**/tsconfig.*.json", "**/__exclude", "**/try.ts", "*.compact.json"]
5
5
  },
6
6
  "formatter": {
7
7
  "enabled": true,
@@ -12,7 +12,7 @@ const tseslint = require('typescript-eslint')
12
12
  const hasJest = require('node:fs').existsSync('./node_modules/jest')
13
13
  // console.log({ hasJest })
14
14
 
15
- const defaultFiles = ['**/*.ts', '**/*.tsx']
15
+ const defaultFiles = ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts']
16
16
 
17
17
  module.exports = [
18
18
  {
@@ -59,8 +59,8 @@ if (!stylelintCmd) {
59
59
  }
60
60
 
61
61
  const linters = {
62
- // *.{ts,tsx,vue} files: biome, eslint, prettier
63
- './src/**/*.{ts,tsx,cts,mts,vue}': match => {
62
+ // biome, eslint, prettier
63
+ './src/**/*.{ts,tsx,cts,mts,vue,html}': match => {
64
64
  const filesList = getFilesList(match)
65
65
  if (!filesList) return []
66
66
  return [
@@ -141,7 +141,7 @@ if (fs.existsSync(`./scripts`)) {
141
141
  )
142
142
  Object.assign(linters, {
143
143
  // biome, eslint, Prettier
144
- './scripts/**/*.{ts,tsx,cts,mts}': match => {
144
+ './scripts/**/*.{ts,tsx,cts,mts,vue,html}': match => {
145
145
  const filesList = getFilesList(match)
146
146
  if (!filesList) return []
147
147
  return [
@@ -12,31 +12,28 @@ const test_util_1 = require("../test.util");
12
12
  const yarn_util_1 = require("../yarn.util");
13
13
  const commands = [
14
14
  new prompts_1.Separator(), // build
15
+ {
16
+ name: 'tsc',
17
+ fn: tscAll,
18
+ desc: 'Run tsc in folders (src, scripts, e2e, playwright) if there is tsconfig.json present',
19
+ },
20
+ { name: 'bt', fn: bt, desc: 'Build & Test: run "tsc" and then "test".' },
21
+ { name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".' },
15
22
  {
16
23
  name: 'build',
17
24
  fn: build_util_1.buildProd,
18
- desc: 'Clean ./dist, run "build-copy" then tsc with emit, using tsconfig.prod.json',
19
- cliOnly: true,
25
+ desc: 'Clean ./dist, run "build-copy" then tsc with --emit and --noCheck, using tsconfig.prod.json',
20
26
  },
21
27
  {
22
28
  name: 'build-copy',
23
29
  fn: build_util_1.buildCopy,
24
30
  desc: 'Copy the non-ts files from ./src to ./dist',
25
- cliOnly: true,
26
31
  },
27
32
  {
28
33
  name: 'build-esm-cjs',
29
34
  fn: build_util_1.buildEsmCjs,
30
- desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes.',
31
- cliOnly: true,
32
- },
33
- {
34
- name: 'tsc',
35
- fn: tscAll,
36
- desc: 'Run tsc in folders (src, scripts, e2e, playwright) if there is tsconfig.json present',
35
+ desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes, with --emit and --noCheck',
37
36
  },
38
- { name: 'bt', fn: bt, desc: 'Build & Test: run "build" and then "test".' },
39
- { name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "build", then "test".' },
40
37
  new prompts_1.Separator(), // test
41
38
  { name: 'test', fn: test_util_1.runJest, desc: 'Run jest for *.test.ts files.' },
42
39
  {
@@ -8,5 +8,5 @@ export declare function runTSCInFolders(tsconfigPaths: string[], args?: string[]
8
8
  * Pass '.' to run in root.
9
9
  */
10
10
  export declare function runTSCInFolder(tsconfigPath: string, args?: string[]): Promise<void>;
11
- export declare function runTSCProd(): Promise<void>;
11
+ export declare function runTSCProd(args?: string[]): Promise<void>;
12
12
  export declare function buildCopy(): void;
@@ -33,6 +33,9 @@ async function buildEsmCjs() {
33
33
  'nodenext',
34
34
  '--moduleResolution',
35
35
  'nodenext',
36
+ '--noEmit',
37
+ 'false',
38
+ '--noCheck',
36
39
  ],
37
40
  shell: false,
38
41
  }),
@@ -48,6 +51,9 @@ async function buildEsmCjs() {
48
51
  'bundler',
49
52
  '--declaration',
50
53
  'false',
54
+ '--noEmit',
55
+ 'false',
56
+ '--noCheck',
51
57
  ],
52
58
  shell: false,
53
59
  }),
@@ -84,10 +90,10 @@ async function runTSCInFolder(tsconfigPath, args = []) {
84
90
  shell: false,
85
91
  });
86
92
  }
87
- async function runTSCProd() {
93
+ async function runTSCProd(args = []) {
88
94
  const tsconfigPath = [`./tsconfig.prod.json`].find(p => node_fs_1.default.existsSync(p)) || 'tsconfig.json';
89
95
  await nodejs_lib_1.exec2.spawnAsync(`tsc`, {
90
- args: ['-P', tsconfigPath],
96
+ args: ['-P', tsconfigPath, '--noEmit', 'false', '--noCheck', ...args],
91
97
  shell: false,
92
98
  });
93
99
  }
package/dist/lint.util.js CHANGED
@@ -14,7 +14,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
14
14
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
15
15
  const yargs_1 = tslib_1.__importDefault(require("yargs"));
16
16
  const paths_1 = require("./paths");
17
- const { prettierDirs, prettierExtensionsAll, stylelintExtensions, lintExclude, } = require('../cfg/_cnst');
17
+ const { prettierDirs, prettierExtensionsAll, stylelintExtensions, eslintExtensions, lintExclude, } = require('../cfg/_cnst');
18
18
  /**
19
19
  * Run all linters.
20
20
  */
@@ -75,7 +75,7 @@ async function eslintAll(opt) {
75
75
  const { argv } = yargs_1.default.options({
76
76
  ext: {
77
77
  type: 'string',
78
- default: 'ts,tsx,vue',
78
+ default: eslintExtensions,
79
79
  },
80
80
  fix: {
81
81
  type: 'boolean',
@@ -110,11 +110,11 @@ async function eslintAll(opt) {
110
110
  // /src
111
111
  runESLint(`./src`, eslintConfigPathRoot, undefined, extensions, fix),
112
112
  // /scripts
113
- runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, undefined, fix),
113
+ runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, extensions, fix),
114
114
  // /e2e
115
- runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, undefined, fix),
115
+ runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, extensions, fix),
116
116
  // /playwright // todo: remove after migration to e2e folder is completed
117
- runESLint(`./playwright`, eslintConfigPathPlaywright, tsconfigPathPlaywright, undefined, fix),
117
+ runESLint(`./playwright`, eslintConfigPathPlaywright, tsconfigPathPlaywright, extensions, fix),
118
118
  ]);
119
119
  }
120
120
  else {
@@ -122,15 +122,15 @@ async function eslintAll(opt) {
122
122
  // /src
123
123
  await runESLint(`./src`, eslintConfigPathRoot, undefined, extensions, fix);
124
124
  // /scripts
125
- await runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, undefined, fix);
125
+ await runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, extensions, fix);
126
126
  // /e2e
127
- await runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, undefined, fix);
127
+ await runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, extensions, fix);
128
128
  // /e2e
129
- await runESLint(`./playwright`, eslintConfigPathPlaywright, tsconfigPathPlaywright, undefined, fix);
129
+ await runESLint(`./playwright`, eslintConfigPathPlaywright, tsconfigPathPlaywright, extensions, fix);
130
130
  }
131
131
  console.log(`${(0, nodejs_lib_1.boldGrey)('eslint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
132
132
  }
133
- async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
133
+ async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = eslintExtensions, fix = true) {
134
134
  if (!eslintConfigPath || !node_fs_1.default.existsSync(dir))
135
135
  return; // faster to bail-out like this
136
136
  await nodejs_lib_1.exec2.spawnAsync('eslint', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "15.16.0",
3
+ "version": "15.18.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "tsn-debug": "tsn testScript.ts",