@rtorcato/js-tooling 1.0.6 ā 1.1.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
|
@@ -58,6 +58,13 @@ The package provides several CLI commands:
|
|
|
58
58
|
# Interactive project setup wizard
|
|
59
59
|
npx @rtorcato/js-tooling setup
|
|
60
60
|
|
|
61
|
+
# Copy configuration files to current directory
|
|
62
|
+
npx @rtorcato/js-tooling copy biome
|
|
63
|
+
npx @rtorcato/js-tooling copy tsconfig
|
|
64
|
+
|
|
65
|
+
# List all available configurations
|
|
66
|
+
npx @rtorcato/js-tooling list
|
|
67
|
+
|
|
61
68
|
# Run commit message helper
|
|
62
69
|
npx @rtorcato/js-tooling commitmessage
|
|
63
70
|
|
|
@@ -65,6 +72,97 @@ npx @rtorcato/js-tooling commitmessage
|
|
|
65
72
|
npx @rtorcato/js-tooling helloworld
|
|
66
73
|
```
|
|
67
74
|
|
|
75
|
+
## Configuration Usage
|
|
76
|
+
|
|
77
|
+
### Biome (Formatter & Linter)
|
|
78
|
+
|
|
79
|
+
Since Biome doesn't support configuration extension, use the copy command to get the base configuration:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Copy base Biome configuration
|
|
83
|
+
npx @rtorcato/js-tooling copy biome
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This creates a `biome.json` file with:
|
|
87
|
+
- Tab indentation, 100 character line width
|
|
88
|
+
- Single quotes, ES5 trailing commas
|
|
89
|
+
- Recommended linting rules with sensible overrides
|
|
90
|
+
- Smart file patterns excluding build directories
|
|
91
|
+
|
|
92
|
+
After copying, customize for your project:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"linter": {
|
|
97
|
+
"rules": {
|
|
98
|
+
"recommended": true,
|
|
99
|
+
"suspicious": {
|
|
100
|
+
"noExplicitAny": "error"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### TypeScript
|
|
108
|
+
|
|
109
|
+
Import TypeScript configurations directly in your `tsconfig.json`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"extends": "@rtorcato/js-tooling/typescript/base"
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Available configurations:
|
|
118
|
+
- `typescript/base` - Base configuration for all projects
|
|
119
|
+
- `typescript/react` - React-specific settings
|
|
120
|
+
- `typescript/next` - Next.js optimized configuration
|
|
121
|
+
- `typescript/node` - Node.js server configuration
|
|
122
|
+
- `typescript/express` - Express.js API configuration
|
|
123
|
+
|
|
124
|
+
### ESLint
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
// eslint.config.js
|
|
128
|
+
import baseConfig from '@rtorcato/js-tooling/eslint/base'
|
|
129
|
+
import nextjsConfig from '@rtorcato/js-tooling/eslint/nextjs'
|
|
130
|
+
|
|
131
|
+
export default [
|
|
132
|
+
...baseConfig,
|
|
133
|
+
// Add project-specific rules
|
|
134
|
+
]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Commitlint
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
// commitlint.config.js
|
|
141
|
+
import config from '@rtorcato/js-tooling/commitlint/config'
|
|
142
|
+
export default config
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Vitest
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// vitest.config.js
|
|
149
|
+
import { defineConfig } from 'vitest/config'
|
|
150
|
+
import baseConfig from '@rtorcato/js-tooling/vitest/config'
|
|
151
|
+
|
|
152
|
+
export default defineConfig({
|
|
153
|
+
...baseConfig,
|
|
154
|
+
// Add project-specific settings
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Semantic Release
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
// release.config.js
|
|
162
|
+
import config from '@rtorcato/js-tooling/semantic-release/github'
|
|
163
|
+
export default config
|
|
164
|
+
```
|
|
165
|
+
|
|
68
166
|
## Using with Package Managers
|
|
69
167
|
|
|
70
168
|
### With pnpm
|
package/dist/cli/index.js
CHANGED
|
@@ -15,6 +15,49 @@ program
|
|
|
15
15
|
.option('-d, --directory <path>', 'Target directory for setup', process.cwd())
|
|
16
16
|
.option('--skip-install', 'Skip installing dependencies')
|
|
17
17
|
.action(setupProject);
|
|
18
|
+
program
|
|
19
|
+
.command('copy <config>')
|
|
20
|
+
.description('š Copy a specific configuration file to current directory')
|
|
21
|
+
.action(async (config) => {
|
|
22
|
+
const availableConfigs = {
|
|
23
|
+
biome: {
|
|
24
|
+
source: 'tooling/biome/biome.json',
|
|
25
|
+
target: 'biome.json',
|
|
26
|
+
desc: 'Biome formatter and linter configuration',
|
|
27
|
+
},
|
|
28
|
+
tsconfig: {
|
|
29
|
+
source: 'tooling/typescript/tsconfig.base.json',
|
|
30
|
+
target: 'tsconfig.json',
|
|
31
|
+
desc: 'TypeScript base configuration',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
if (!availableConfigs[config]) {
|
|
35
|
+
console.error(chalk.red(`\nā Unknown configuration: ${config}`));
|
|
36
|
+
console.log(chalk.gray('Available configurations:'));
|
|
37
|
+
Object.entries(availableConfigs).forEach(([key, { desc }]) => {
|
|
38
|
+
console.log(` ${chalk.green('ā')} ${chalk.bold(key)}: ${chalk.gray(desc)}`);
|
|
39
|
+
});
|
|
40
|
+
console.log();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { source, target, desc } = availableConfigs[config];
|
|
44
|
+
try {
|
|
45
|
+
const fs = (await import('fs-extra')).default;
|
|
46
|
+
const path = (await import('node:path')).default;
|
|
47
|
+
// Get the package installation path - CLI is in dist/cli/index.js, need to go up 3 levels
|
|
48
|
+
const cliFile = new URL(import.meta.url).pathname;
|
|
49
|
+
const packagePath = path.dirname(path.dirname(path.dirname(cliFile)));
|
|
50
|
+
const sourcePath = path.join(packagePath, source);
|
|
51
|
+
const targetPath = path.join(process.cwd(), target);
|
|
52
|
+
await fs.copy(sourcePath, targetPath);
|
|
53
|
+
console.log(chalk.green(`\nā
Copied ${desc}`));
|
|
54
|
+
console.log(chalk.gray(` From: ${source}`));
|
|
55
|
+
console.log(chalk.gray(` To: ${target}\n`));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(chalk.red(`\nā Error copying configuration: ${error}\n`));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
18
61
|
program
|
|
19
62
|
.command('list')
|
|
20
63
|
.alias('ls')
|
|
@@ -22,12 +65,18 @@ program
|
|
|
22
65
|
.action(() => {
|
|
23
66
|
console.log(chalk.cyan('\nš ļø Available tooling configurations:\n'));
|
|
24
67
|
const configs = [
|
|
25
|
-
{
|
|
68
|
+
{
|
|
69
|
+
name: 'TypeScript',
|
|
70
|
+
desc: 'Base, React, Next.js, Node.js, Express configurations',
|
|
71
|
+
},
|
|
26
72
|
{ name: 'ESLint', desc: 'Base and Next.js ESLint configurations' },
|
|
27
73
|
{ name: 'Biome', desc: 'Fast formatter and linter configuration' },
|
|
28
74
|
{ name: 'Prettier', desc: 'Code formatter configuration' },
|
|
29
75
|
{ name: 'Vitest', desc: 'Testing framework configuration' },
|
|
30
|
-
{
|
|
76
|
+
{
|
|
77
|
+
name: 'Jest',
|
|
78
|
+
desc: 'Testing framework presets for browser and Node.js',
|
|
79
|
+
},
|
|
31
80
|
{ name: 'Playwright', desc: 'End-to-end testing configuration' },
|
|
32
81
|
{ name: 'Commitlint', desc: 'Conventional commit linting' },
|
|
33
82
|
{ name: 'Husky', desc: 'Git hooks for pre-commit validation' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtorcato/js-tooling",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "JavaScript and TypeScript tooling for Node.js, React, Next.js, and Vitest.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"build-cli": "rimraf ./dist/cli && tsc --project src/cli/tsconfig.json",
|
|
26
26
|
"prepublishOnly": "./scripts/fix-bins.sh",
|
|
27
27
|
"==================== Common ====================": "",
|
|
28
|
-
"lint": "pnpm exec biome lint .",
|
|
29
|
-
"format": "pnpm exec biome format .",
|
|
30
|
-
"check:fix": "pnpm exec biome check --fix",
|
|
31
|
-
"check": "pnpm exec biome check .",
|
|
28
|
+
"lint": "pnpm exec biome lint --config-path=tooling/biome/biome.json src scripts",
|
|
29
|
+
"format": "pnpm exec biome format --config-path=tooling/biome/biome.json src scripts",
|
|
30
|
+
"check:fix": "pnpm exec biome check --config-path=tooling/biome/biome.json --fix src scripts",
|
|
31
|
+
"check": "pnpm exec biome check --config-path=tooling/biome/biome.json src scripts",
|
|
32
32
|
"prepare": "is-ci || husky",
|
|
33
33
|
"typecheck1": "tsc --noEmit",
|
|
34
34
|
"test": "vitest",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"dist/cli/**/*.js",
|
|
42
42
|
"tooling/*",
|
|
43
|
-
"tooling/commitlint/commitlint.
|
|
43
|
+
"tooling/commitlint/commitlint.mjs",
|
|
44
44
|
"tooling/esbuild/index.mjs",
|
|
45
45
|
"tooling/eslint/*.mjs",
|
|
46
46
|
"tooling/jest-presets/**",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"tooling/vitest/vitest.config.mjs",
|
|
51
51
|
"tooling/tsup/index.ts",
|
|
52
52
|
"tooling/biome/biome.json",
|
|
53
|
+
"tooling/biome/biome.jsonc",
|
|
53
54
|
"tooling/semantic-release/*.mjs",
|
|
54
55
|
"README.md"
|
|
55
56
|
],
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"semantic-release": "^25.0.1",
|
|
107
108
|
"typescript": "^5.9.3",
|
|
108
109
|
"typescript-eslint": "latest",
|
|
109
|
-
"vitest": "4.0.
|
|
110
|
+
"vitest": "4.0.3"
|
|
110
111
|
},
|
|
111
112
|
"devDependencies": {
|
|
112
113
|
"@next/eslint-plugin-next": "^16.0.0",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Biome Configuration
|
|
2
|
+
|
|
3
|
+
This package provides a standardized Biome configuration for consistent code formatting and linting across projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @rtorcato/js-tooling @biomejs/biome
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Option 1: CLI Copy Command (Recommended)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @rtorcato/js-tooling copy biome
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will copy the base `biome.json` configuration to your project root.
|
|
20
|
+
|
|
21
|
+
### Option 2: Manual Copy
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cp node_modules/@rtorcato/js-tooling/tooling/biome/biome.json ./biome.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Option 3: Reference in package.json
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"scripts": {
|
|
32
|
+
"lint": "biome lint .",
|
|
33
|
+
"format": "biome format .",
|
|
34
|
+
"check": "biome check .",
|
|
35
|
+
"check:fix": "biome check --fix ."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configuration Features
|
|
41
|
+
|
|
42
|
+
- **Formatter**: Tab indentation, 100 character line width, single quotes
|
|
43
|
+
- **Linter**: Recommended rules with sensible overrides
|
|
44
|
+
- **JavaScript**: ES5 trailing commas, semicolons as needed
|
|
45
|
+
- **Import organization**: Disabled to prevent conflicts
|
|
46
|
+
- **File patterns**: Excludes common build/config directories
|
|
47
|
+
|
|
48
|
+
## Customization
|
|
49
|
+
|
|
50
|
+
After copying the configuration, you can customize it for your project:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
// Add project-specific rules
|
|
55
|
+
"linter": {
|
|
56
|
+
"rules": {
|
|
57
|
+
"recommended": true,
|
|
58
|
+
"suspicious": {
|
|
59
|
+
"noExplicitAny": "error"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// Add project-specific file patterns
|
|
64
|
+
"files": {
|
|
65
|
+
"includes": [
|
|
66
|
+
"src/**/*",
|
|
67
|
+
"!src/generated/**"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## VS Code Integration
|
|
74
|
+
|
|
75
|
+
Add to your `.vscode/settings.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
80
|
+
"editor.formatOnSave": true,
|
|
81
|
+
"editor.codeActionsOnSave": {
|
|
82
|
+
"quickfix.biome": "explicit",
|
|
83
|
+
"source.organizeImports.biome": "explicit"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Why Biome Can't Extend Configurations
|
|
89
|
+
|
|
90
|
+
Unlike ESLint or TypeScript, Biome doesn't support configuration inheritance/extending. Each project needs its own complete `biome.json` file. This package provides a well-tested base configuration that you can copy and customize.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"root": false,
|
|
3
2
|
"$schema": "https://biomejs.dev/schemas/2.3.0/schema.json",
|
|
4
3
|
"vcs": {
|
|
5
4
|
"enabled": false,
|
|
@@ -25,16 +24,27 @@
|
|
|
25
24
|
"indentStyle": "tab",
|
|
26
25
|
"lineWidth": 100
|
|
27
26
|
},
|
|
28
|
-
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
29
27
|
"linter": {
|
|
30
28
|
"enabled": true,
|
|
31
29
|
"rules": {
|
|
32
30
|
"recommended": true,
|
|
33
31
|
"style": {
|
|
34
32
|
"noInferrableTypes": "off"
|
|
33
|
+
},
|
|
34
|
+
"complexity": {
|
|
35
|
+
"useLiteralKeys": "off"
|
|
36
|
+
},
|
|
37
|
+
"suspicious": {
|
|
38
|
+
"noExplicitAny": "off",
|
|
39
|
+
"noTemplateCurlyInString": "off"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"assist": {
|
|
44
|
+
"actions": {
|
|
45
|
+
"source": {
|
|
46
|
+
"organizeImports": "off"
|
|
35
47
|
}
|
|
36
|
-
// "noUnusedVariables": "error", ā Not supported yet
|
|
37
|
-
// "noExplicitAny": "warn" ā Not supported yet
|
|
38
48
|
}
|
|
39
49
|
},
|
|
40
50
|
"javascript": {
|
|
@@ -43,5 +53,11 @@
|
|
|
43
53
|
"trailingCommas": "es5",
|
|
44
54
|
"semicolons": "asNeeded"
|
|
45
55
|
}
|
|
56
|
+
},
|
|
57
|
+
"json": {
|
|
58
|
+
"formatter": {
|
|
59
|
+
"indentStyle": "space",
|
|
60
|
+
"indentWidth": 2
|
|
61
|
+
}
|
|
46
62
|
}
|
|
47
63
|
}
|
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
extends: [
|
|
3
|
-
ignores: [(commit) => commit.includes(
|
|
4
|
-
|
|
2
|
+
extends: ["@commitlint/config-conventional"],
|
|
3
|
+
ignores: [(commit) => commit.includes("[skip ci]")],
|
|
4
|
+
rules: {
|
|
5
|
+
// Enforce strict type validation
|
|
6
|
+
"type-enum": [
|
|
7
|
+
2,
|
|
8
|
+
"always",
|
|
9
|
+
[
|
|
10
|
+
"build",
|
|
11
|
+
"chore",
|
|
12
|
+
"ci",
|
|
13
|
+
"docs",
|
|
14
|
+
"feat",
|
|
15
|
+
"fix",
|
|
16
|
+
"perf",
|
|
17
|
+
"refactor",
|
|
18
|
+
"revert",
|
|
19
|
+
"style",
|
|
20
|
+
"test",
|
|
21
|
+
],
|
|
22
|
+
],
|
|
23
|
+
// Enforce length limits (strict)
|
|
24
|
+
"header-max-length": [2, "always", 50],
|
|
25
|
+
"body-max-line-length": [2, "always", 72],
|
|
26
|
+
"footer-max-line-length": [2, "always", 72],
|
|
27
|
+
// Enforce case rules (allow common patterns)
|
|
28
|
+
"subject-case": [0], // Disable case enforcement to allow flexibility
|
|
29
|
+
"type-case": [2, "always", "lower-case"],
|
|
30
|
+
// Enforce required elements
|
|
31
|
+
"type-empty": [2, "never"],
|
|
32
|
+
"subject-empty": [2, "never"],
|
|
33
|
+
// Enforce punctuation rules
|
|
34
|
+
"subject-full-stop": [2, "never", "."],
|
|
35
|
+
// Enforce scope rules (optional but recommended)
|
|
36
|
+
"scope-case": [2, "always", "lower-case"],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
// "moduleResolution": "node", // Prefer "bundler" if you're using Vite, esbuild, etc.
|
|
10
10
|
// "target": "esnext", //
|
|
11
11
|
"lib": ["ES2022"], // Specify library files to be included in the compilation
|
|
12
|
-
"baseUrl": ".", // Base directory to resolve non-relative module names
|
|
13
12
|
"rootDir": "src",
|
|
14
13
|
"outDir": "dist",
|
|
15
14
|
|