tz-clean 1.0.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/.prettierrc +9 -0
- package/README-DEV.md +56 -0
- package/README-USER.md +34 -0
- package/README.md +16 -0
- package/eslint.config.mjs +35 -0
- package/index.js +33 -0
- package/package.json +38 -0
package/.prettierrc
ADDED
package/README-DEV.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Developer Guide: tz-clean ๐ ๏ธ
|
|
2
|
+
|
|
3
|
+
This guide is for developers who want to contribute to the `tz-clean` project, test it locally, or publish it to the npm registry.
|
|
4
|
+
|
|
5
|
+
## Local Development (For Contributors)
|
|
6
|
+
|
|
7
|
+
If you are modifying this tool and want to test it locally, clone the repository and install dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Available Scripts
|
|
14
|
+
|
|
15
|
+
You can run the individual scripts locally within this repository:
|
|
16
|
+
|
|
17
|
+
- `npm run format`: Runs Prettier.
|
|
18
|
+
- `npm run lint`: Runs ESLint without auto-fixing.
|
|
19
|
+
- `npm run lint:fix`: Runs ESLint with auto-fixing.
|
|
20
|
+
- `npm run typecheck`: Runs TypeScript type validation.
|
|
21
|
+
- `npm run fix`: Runs format, lint:fix, and typecheck sequentially.
|
|
22
|
+
|
|
23
|
+
## Testing the CLI Locally
|
|
24
|
+
|
|
25
|
+
Before publishing, you should test the global CLI command locally on your computer.
|
|
26
|
+
|
|
27
|
+
1. Open a terminal inside this project folder (`tz-clean`).
|
|
28
|
+
2. Run this command to install your package globally from the local folder:
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g .
|
|
31
|
+
```
|
|
32
|
+
_(Alternatively, you can use `npm link`)_
|
|
33
|
+
3. Open another folder/repo in your terminal, and type the command:
|
|
34
|
+
```bash
|
|
35
|
+
tz-clean
|
|
36
|
+
```
|
|
37
|
+
If it runs successfully, your configuration is correct.
|
|
38
|
+
|
|
39
|
+
## Publishing to the NPM Registry
|
|
40
|
+
|
|
41
|
+
To make the package available via `npm install -g tz-clean` on any computer, you must publish it to the NPM Registry.
|
|
42
|
+
|
|
43
|
+
1. **Create an NPM account**: If you don't have one, register at [npmjs.com](https://www.npmjs.com/).
|
|
44
|
+
2. **Login via Terminal**: Run `npm login` and enter your account credentials.
|
|
45
|
+
3. **Publish**: Run the `npm publish` command inside your project folder.
|
|
46
|
+
|
|
47
|
+
### Important Note on Package Names
|
|
48
|
+
|
|
49
|
+
The package name `tz-clean` is very common and likely already taken in the NPM registry. If it is, `npm publish` will fail with a `403 Forbidden` or `Conflict` error.
|
|
50
|
+
|
|
51
|
+
If this happens, use a **Scoped Package**:
|
|
52
|
+
|
|
53
|
+
1. Change `"name"` in `package.json` to `@your-npm-username/tz-clean` (example: `@terzogenito/tz-clean`).
|
|
54
|
+
2. Run `npm publish --access public`.
|
|
55
|
+
3. The install command will become `npm install -g @your-username/tz-clean`.
|
|
56
|
+
4. The executable command in the terminal will remain `tz-clean`, as defined in the `"bin"` property of `package.json`.
|
package/README-USER.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# User Guide: tz-clean ๐
|
|
2
|
+
|
|
3
|
+
This guide provides instructions on how to install and use the `tz-clean` CLI tool in your projects.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Node.js** installed on your machine.
|
|
8
|
+
- A `tsconfig.json` file must exist in the root of the project where you run this tool (required for the typechecking step).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
You can install this package globally using npm to use it across all your projects:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g tz-clean
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
_(Note: If published under a scoped name, the command might be `npm install -g @your-username/tz-clean`)_
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Navigate to any project directory where you want to clean your code and simply run:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
tz-clean
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### What it does:
|
|
29
|
+
|
|
30
|
+
The tool will sequentially run the following tasks on your project:
|
|
31
|
+
|
|
32
|
+
1. **Prettier**: Formats your code to ensure consistent styling.
|
|
33
|
+
2. **ESLint**: Lints your code and automatically fixes fixable issues (with auto-fix).
|
|
34
|
+
3. **TypeScript Validation**: Runs `tsc --noEmit` to check for type errors without compiling files.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# tz-clean ๐งน
|
|
2
|
+
|
|
3
|
+
A global command-line utility to enforce consistent code quality across your projects. It automatically formats your code with **Prettier**, lints and fixes it with **ESLint**, and performs typechecking with **TypeScript**.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Prettier**: Formats all supported files in the target directory.
|
|
8
|
+
- **ESLint**: Lints and automatically fixes errors using the bundled configuration.
|
|
9
|
+
- **TypeScript**: Performs a type check (`tsc --noEmit`) to ensure type safety.
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
For more detailed information, please refer to the specific guides:
|
|
14
|
+
|
|
15
|
+
- ๐ **[User Guide](./README-USER.md)**: Installation, prerequisites, and usage instructions for end-users.
|
|
16
|
+
- ๐ ๏ธ **[Developer Guide](./README-DEV.md)**: Instructions for contributing, local testing, and publishing.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import noCommentsPlugin from 'eslint-plugin-no-comments';
|
|
2
|
+
import js from '@eslint/js';
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
js.configs.recommended,
|
|
8
|
+
...tseslint.configs.recommended,
|
|
9
|
+
{
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: 2022,
|
|
12
|
+
sourceType: 'script',
|
|
13
|
+
globals: {
|
|
14
|
+
...globals.browser,
|
|
15
|
+
...globals.node,
|
|
16
|
+
...globals.jquery,
|
|
17
|
+
document: 'readonly',
|
|
18
|
+
window: 'readonly',
|
|
19
|
+
console: 'readonly',
|
|
20
|
+
module: 'readonly',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
plugins: {
|
|
24
|
+
'no-comments': noCommentsPlugin,
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
'no-comments/disallowComments': 'error',
|
|
28
|
+
'no-undef': 'off',
|
|
29
|
+
'no-unused-vars': ['error', { vars: 'local', args: 'none' }],
|
|
30
|
+
'no-useless-escape': 'off',
|
|
31
|
+
'no-useless-assignment': 'off',
|
|
32
|
+
'no-redeclare': 'off',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
package/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const configDir = __dirname;
|
|
9
|
+
const targetDir = process.cwd();
|
|
10
|
+
|
|
11
|
+
console.log('๐งน Running tz-clean (Prettier, ESLint & Typecheck)...');
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
console.log('\nโจ Running Prettier...');
|
|
15
|
+
execSync(`npx prettier --write . --config "${path.join(configDir, '.prettierrc')}" --ignore-unknown`, {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log('\n๐ Running ESLint (with --fix)...');
|
|
20
|
+
execSync(`npx eslint . --fix -c "${path.join(configDir, 'eslint.config.mjs')}"`, { stdio: 'inherit' });
|
|
21
|
+
|
|
22
|
+
console.log('\nโ๏ธ Running Typecheck (tsc)...');
|
|
23
|
+
if (fs.existsSync(path.join(targetDir, 'tsconfig.json'))) {
|
|
24
|
+
execSync(`npx tsc --noEmit`, { stdio: 'inherit' });
|
|
25
|
+
} else {
|
|
26
|
+
console.log('โ ๏ธ No tsconfig.json found in the target directory. Skipping typecheck.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('\nโ
tz-clean completed successfully!');
|
|
30
|
+
} catch {
|
|
31
|
+
console.error('\nโ tz-clean failed to execute.');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tz-clean",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tz-clean": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"lint:fix": "eslint . --fix",
|
|
13
|
+
"format": "prettier --write . --ignore-unknown",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"fix": "npm run format && npm run lint:fix && npm run typecheck"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/terzogenito/text-editor.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/terzogenito/text-editor/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/terzogenito/text-editor#readme",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^10.0.1",
|
|
31
|
+
"eslint": "^10.6.0",
|
|
32
|
+
"eslint-plugin-no-comments": "^1.2.1",
|
|
33
|
+
"globals": "^17.7.0",
|
|
34
|
+
"prettier": "^3.9.4",
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"typescript-eslint": "^8.63.0"
|
|
37
|
+
}
|
|
38
|
+
}
|