@naturalcycles/dev-lib 12.14.2 → 12.16.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.
@@ -83,6 +83,11 @@ module.exports = {
83
83
  },
84
84
  testEnvironment: 'node',
85
85
  errorOnDeprecated: true,
86
+ // this config would have the snapshot formatter not print a prefix for "Object" and "Array"
87
+ // snapshotFormat: {
88
+ // printBasicPrototype: false,
89
+ // },
90
+ restoreMocks: true,
86
91
  unmockedModulePathPatterns: [],
87
92
  setupFilesAfterEnv,
88
93
  collectCoverageFrom: [
@@ -79,7 +79,14 @@ const linters = {
79
79
  '**/*.{kt,kts}': match => {
80
80
  const filesList = micromatch.not(match, lintExclude).join(' ')
81
81
  if (!filesList) return []
82
- return [`ktlint -F ${filesList}`]
82
+ const dir = './node_modules/@naturalcycles/ktlint'
83
+
84
+ if (!fs.existsSync(dir)) {
85
+ console.log(`!!\n!! Please install @naturalcycles/ktlint to lint *.kt files\n!!\n`, filesList)
86
+ return []
87
+ }
88
+
89
+ return [`${dir}/resources/ktlint -F ${filesList}`]
83
90
  },
84
91
  }
85
92
 
@@ -14,35 +14,39 @@ end_of_line = lf
14
14
  trim_trailing_whitespace = true
15
15
  insert_final_newline = true
16
16
 
17
- [**.md]
17
+ [*.md]
18
18
  trim_trailing_whitespace = false
19
19
  indent_size = 4
20
20
 
21
- [**.html]
21
+ [*.html]
22
22
  indent_size = 2
23
23
 
24
- [**.{css,scss}]
24
+ [*.{css,scss}]
25
25
  indent_size = 2
26
26
 
27
- [**.{js,ts}]
27
+ [*.{js,ts}]
28
28
  indent_size = 2
29
29
 
30
- [**.json]
30
+ [*.json]
31
31
  indent_size = 2
32
32
 
33
- [**.xml]
34
- indent_size = 2
35
-
36
- [**.java]
33
+ [*.java]
37
34
  indent_size = 4
38
35
 
39
- [**.sql]
36
+ [*.{kt,kts}]
37
+ disabled_rules=no-wildcard-imports
38
+ ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
39
+
40
+ [*.xml]
41
+ indent_size = 2
42
+
43
+ [*.sql]
40
44
  indent_size = 2
41
45
 
42
46
  [.eslintrc]
43
47
  indent_size = 2
44
48
 
45
- [**.min.*]
49
+ [*.min.*]
46
50
  indent_style = ignore
47
51
  trim_trailing_whitespace = false
48
52
  insert_final_newline = ignore
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lintAllCommand = void 0;
4
+ const fs = require("fs");
4
5
  const yargs = require("yargs");
5
6
  const git_util_1 = require("../util/git.util");
6
7
  const prettier_util_1 = require("../util/prettier.util");
@@ -21,10 +22,14 @@ async function lintAllCommand() {
21
22
  },
22
23
  }).argv;
23
24
  const hadChangesBefore = await (0, git_util_1.gitHasUncommittedChanges)();
24
- // Currently we position ESLint before TSLint, but let's monitor if it's ok
25
25
  await (0, eslint_all_command_1.eslintAllCommand)();
26
26
  await (0, stylelint_util_1.stylelintAll)();
27
27
  await (0, prettier_util_1.runPrettier)();
28
+ // Running ktlintAll (experimental!)
29
+ if (fs.existsSync(`node_modules/@naturalcycles/ktlint`)) {
30
+ const ktlintLib = require('@naturalcycles/ktlint');
31
+ await ktlintLib.ktlintAll();
32
+ }
28
33
  if (commitOnChanges || failOnChanges) {
29
34
  // detect changes
30
35
  const hasChanges = await (0, git_util_1.gitHasUncommittedChanges)();
@@ -33,9 +38,7 @@ async function lintAllCommand() {
33
38
  console.log(`lint-all: there are changes before running lint-all, will not commit`);
34
39
  }
35
40
  else {
36
- const msg = 'style(lint-all): ' +
37
- (0, git_util_1.commitMessageToTitleMessage)(await (0, git_util_1.getLastGitCommitMsg)()) +
38
- '\n\n[skip ci]';
41
+ const msg = 'style(ci): ' + (0, git_util_1.commitMessageToTitleMessage)(await (0, git_util_1.getLastGitCommitMsg)()) + '\n\n[skip ci]';
39
42
  // pull, commit, push changes
40
43
  await (0, git_util_1.gitPull)();
41
44
  await (0, git_util_1.gitCommitAll)(msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "12.14.2",
3
+ "version": "12.16.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",
@@ -30,15 +30,15 @@
30
30
  "update-from-dev-lib": "tsn ./src/bin/update-from-dev-lib.ts"
31
31
  },
32
32
  "dependencies": {
33
- "@commitlint/cli": "^15.0.0",
34
- "@commitlint/config-conventional": "^15.0.0",
33
+ "@commitlint/cli": "^16.0.1",
34
+ "@commitlint/config-conventional": "^16.0.0",
35
35
  "@naturalcycles/cli": "^1.0.0",
36
36
  "@naturalcycles/js-lib": "^14.0.0",
37
37
  "@naturalcycles/nodejs-lib": "^12.0.0",
38
38
  "@naturalcycles/time-lib": "^3.0.1",
39
39
  "@types/fs-extra": "^9.0.0",
40
40
  "@types/jest": "^27.0.0",
41
- "@types/node": "^16.0.0",
41
+ "@types/node": "^17.0.0",
42
42
  "@types/yargs": "^16.0.0",
43
43
  "@typescript-eslint/eslint-plugin": "^5.0.0",
44
44
  "@typescript-eslint/parser": "^5.0.0",
@@ -48,7 +48,7 @@
48
48
  "eslint-plugin-import": "^2.22.1",
49
49
  "eslint-plugin-jest": "^25.0.5",
50
50
  "eslint-plugin-jsdoc": "^37.0.0",
51
- "eslint-plugin-unicorn": "^39.0.0",
51
+ "eslint-plugin-unicorn": "^40.0.0",
52
52
  "eslint-plugin-unused-imports": "^2.0.0",
53
53
  "eslint-plugin-vue": "^8.0.1",
54
54
  "execa": "^5.0.0",
package/readme.md CHANGED
@@ -149,11 +149,10 @@ Pass `--ext` (e.g `--ext ts,html`) to override the list of ESLint extensions (de
149
149
 
150
150
  `ktlint` will be used by lint-staged for all `**/*.{kt,kts}` files.
151
151
 
152
- Please install it with `brew install ktlint`.
152
+ ~~Please install it with `brew install ktlint`.~~
153
153
 
154
- Currently `ktlint` has a bug of not supporting absolute paths, to work around it use
155
- [this instruction](https://github.com/pinterest/ktlint/issues/1131#issuecomment-947570851) to
156
- install a working version.
154
+ Install it **locally** in you project by adding
155
+ [`@naturalcycles/ktlint`](https://github.com/NaturalCycles/ktlint) to your **dev**Dependencies.
157
156
 
158
157
  #### Other commands
159
158