@ttoss/config 1.37.10 → 1.37.11

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
@@ -79,6 +79,8 @@ const { lintstagedConfig } = require('@ttoss/config');
79
79
  module.exports = lintstagedConfig();
80
80
  ```
81
81
 
82
+ The default config runs ESLint on JS/TS files, Prettier on Markdown/JSON/YAML, and automatically sorts `package.json` keys using [sort-package-json](https://github.com/nicolo-ribaudo/sort-package-json). No additional packages needed.
83
+
82
84
  Finally, configure Husky:
83
85
 
84
86
  ```shell
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+
6
+ const { sortPackageJson } = require('sort-package-json');
7
+
8
+ const files = process.argv
9
+ .slice(2)
10
+ .filter((filePath) => path.basename(filePath) === 'package.json');
11
+
12
+ if (files.length === 0) {
13
+ process.exit(0);
14
+ }
15
+
16
+ const failedFiles = [];
17
+
18
+ for (const filePath of files) {
19
+ try {
20
+ const fileContent = fs.readFileSync(filePath, 'utf8');
21
+ const packageJson = JSON.parse(fileContent);
22
+ const sortedPackageJson = sortPackageJson(packageJson);
23
+ const nextContent = `${JSON.stringify(sortedPackageJson, null, 2)}\n`;
24
+
25
+ if (fileContent !== nextContent) {
26
+ fs.writeFileSync(filePath, nextContent);
27
+ }
28
+ } catch (error) {
29
+ failedFiles.push({
30
+ error,
31
+ filePath,
32
+ });
33
+ }
34
+ }
35
+
36
+ if (failedFiles.length > 0) {
37
+ for (const failedFile of failedFiles) {
38
+ const message =
39
+ failedFile.error instanceof Error
40
+ ? failedFile.error.message
41
+ : String(failedFile.error);
42
+
43
+ console.error(`Failed to sort ${failedFile.filePath}: ${message}`);
44
+ }
45
+
46
+ process.exit(1);
47
+ }
package/dist/esm/index.js CHANGED
@@ -133,7 +133,7 @@ var jestUnitConfig = configCreator({
133
133
  var defaultConfig4 = {
134
134
  "*.{js,jsx,ts,tsx}": "eslint --quiet --fix",
135
135
  "*.{md,mdx,html,json,yml,yaml}": "prettier --write",
136
- "package.json": "prettier-package-json --write"
136
+ "package.json": "node ./node_modules/@ttoss/config/bin/sort-package-json"
137
137
  };
138
138
  var lintstagedConfig = configCreator(defaultConfig4);
139
139
 
package/dist/index.js CHANGED
@@ -177,7 +177,7 @@ var jestUnitConfig = configCreator({
177
177
  var defaultConfig4 = {
178
178
  "*.{js,jsx,ts,tsx}": "eslint --quiet --fix",
179
179
  "*.{md,mdx,html,json,yml,yaml}": "prettier --write",
180
- "package.json": "prettier-package-json --write"
180
+ "package.json": "node ./node_modules/@ttoss/config/bin/sort-package-json"
181
181
  };
182
182
  var lintstagedConfig = configCreator(defaultConfig4);
183
183
 
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
2
  "name": "@ttoss/config",
3
- "version": "1.37.10",
3
+ "version": "1.37.11",
4
4
  "description": "Default configuration for packages.",
5
- "license": "MIT",
6
- "author": "ttoss",
7
- "contributors": [
8
- "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"
9
- ],
5
+ "keywords": [],
10
6
  "repository": {
11
7
  "type": "git",
12
8
  "url": "https://github.com/ttoss/ttoss.git",
13
9
  "directory": "packages/config"
14
10
  },
11
+ "license": "MIT",
12
+ "author": "ttoss",
13
+ "contributors": [
14
+ "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"
15
+ ],
16
+ "sideEffects": false,
15
17
  "main": "dist/index.js",
16
18
  "module": "dist/esm/index.js",
19
+ "typings": "dist/index.d.ts",
20
+ "bin": {
21
+ "ttoss-sort-package-json": "./bin/sort-package-json"
22
+ },
17
23
  "files": [
24
+ "bin",
18
25
  "dist",
19
26
  "tsconfig.json",
20
27
  "tsconfig.test.json"
21
28
  ],
22
- "sideEffects": false,
23
- "typings": "dist/index.d.ts",
24
29
  "dependencies": {
25
30
  "@babel/core": "^7.29.0",
26
31
  "@babel/plugin-proposal-decorators": "^7.29.0",
@@ -28,12 +33,12 @@
28
33
  "@babel/preset-react": "^7.28.5",
29
34
  "@babel/preset-typescript": "^7.28.5",
30
35
  "@commitlint/config-conventional": "^20.5.0",
31
- "@formatjs/ts-transformer": "^4.4.3",
36
+ "@formatjs/ts-transformer": "^4.4.8",
32
37
  "babel-plugin-formatjs": "^11.3.2",
33
38
  "babel-plugin-transform-import-meta": "^2.3.3",
34
39
  "deepmerge": "^4.3.1",
35
40
  "identity-obj-proxy": "^3.0.0",
36
- "prettier-package-json": "^2.8.0"
41
+ "sort-package-json": "^3.6.1"
37
42
  },
38
43
  "devDependencies": {
39
44
  "@jest/types": "^30.3.0",
@@ -43,7 +48,6 @@
43
48
  "jest": "^30.3.0",
44
49
  "tsup": "^8.5.1"
45
50
  },
46
- "keywords": [],
47
51
  "publishConfig": {
48
52
  "access": "public",
49
53
  "provenance": true
package/tsconfig.json CHANGED
@@ -22,8 +22,8 @@
22
22
  */
23
23
  "types": ["node"],
24
24
  /**
25
- * `target` to `es2024` because Node.js 24 supports ES2024 features.
26
- * https://node.green/#ES2024
25
+ * `target` to `es2024` because Node.js 24 supports ES2024 features and
26
+ * esbuild does not yet support `es2025` as a target.
27
27
  */
28
28
  "target": "es2024",
29
29
  "declaration": true,