@jterrazz/codestyle 1.2.6 → 2.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/README.md +25 -32
- package/bin/codestyle.sh +147 -0
- package/{src → config}/oxlint/architectures/hexagonal.json +1 -0
- package/{src → config}/oxlint/base.json +2 -1
- package/{src → config}/oxlint/expo.json +1 -0
- package/{src/oxlint/nextjs.json → config/oxlint/next.json} +1 -0
- package/{src → config}/oxlint/node.json +1 -0
- package/package.json +24 -17
- package/src/index.js +5 -5
- package/src/codestyle.sh +0 -188
- /package/{src → config}/oxfmt/index.json +0 -0
- /package/{src → config}/oxlint/plugins/codestyle.js +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @jterrazz/codestyle
|
|
2
2
|
|
|
3
|
-
Fast, opinionated linting and formatting for TypeScript. Powered by Oxlint
|
|
3
|
+
Fast, opinionated linting and formatting for TypeScript. Powered by Oxlint, Oxfmt, and tsgo.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -12,55 +12,42 @@ Create `.oxlintrc.json`:
|
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
15
|
-
"extends": ["
|
|
15
|
+
"extends": ["@jterrazz/codestyle/oxlint/node"]
|
|
16
16
|
}
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
> **Note:** The `node_modules/` path is required because oxlint doesn't support npm module resolution in `extends`.
|
|
20
|
-
|
|
21
19
|
Run:
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
|
-
npx codestyle
|
|
25
|
-
npx codestyle
|
|
22
|
+
npx codestyle check # Check everything (types + lint + format)
|
|
23
|
+
npx codestyle fix # Fix everything
|
|
26
24
|
```
|
|
27
25
|
|
|
28
26
|
## Configurations
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| Config | Use Case |
|
|
33
|
-
| --------------------------------------------------------- | --------------------------------- |
|
|
34
|
-
| `node_modules/@jterrazz/codestyle/src/oxlint/node.json` | Node.js (requires .js extensions) |
|
|
35
|
-
| `node_modules/@jterrazz/codestyle/src/oxlint/expo.json` | Expo / React Native |
|
|
36
|
-
| `node_modules/@jterrazz/codestyle/src/oxlint/nextjs.json` | Next.js |
|
|
28
|
+
Pick a base config:
|
|
37
29
|
|
|
38
|
-
|
|
30
|
+
| Config | Use Case |
|
|
31
|
+
| --------------------------------- | --------------------------------- |
|
|
32
|
+
| `@jterrazz/codestyle/oxlint/node` | Node.js (requires .js extensions) |
|
|
33
|
+
| `@jterrazz/codestyle/oxlint/expo` | Expo / React Native |
|
|
34
|
+
| `@jterrazz/codestyle/oxlint/next` | Next.js |
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
| -------------------------------------------------------------------------- | ---------------------------------- |
|
|
42
|
-
| `node_modules/@jterrazz/codestyle/src/oxlint/architectures/hexagonal.json` | Hexagonal architecture enforcement |
|
|
36
|
+
Architecture plugin (additive):
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+
| Plugin | Use Case |
|
|
39
|
+
| ---------------------------------------------------- | ---------------------------------- |
|
|
40
|
+
| `@jterrazz/codestyle/oxlint/architectures/hexagonal` | Hexagonal architecture enforcement |
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
npx codestyle # Run all checks (type + lint + format)
|
|
48
|
-
npx codestyle --fix # Auto-fix all issues
|
|
49
|
-
|
|
50
|
-
npx codestyle --type # TypeScript only
|
|
51
|
-
npx codestyle --lint # Lint only
|
|
52
|
-
npx codestyle --format # Format only
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Architecture Enforcement (Optional)
|
|
42
|
+
## Architecture Enforcement
|
|
56
43
|
|
|
57
44
|
Enforce hexagonal architecture boundaries:
|
|
58
45
|
|
|
59
46
|
```json
|
|
60
47
|
{
|
|
61
48
|
"extends": [
|
|
62
|
-
"
|
|
63
|
-
"
|
|
49
|
+
"@jterrazz/codestyle/oxlint/node",
|
|
50
|
+
"@jterrazz/codestyle/oxlint/architectures/hexagonal"
|
|
64
51
|
]
|
|
65
52
|
}
|
|
66
53
|
```
|
|
@@ -72,6 +59,12 @@ Rules enforced:
|
|
|
72
59
|
- `presentation/ui/` cannot import navigation
|
|
73
60
|
- `features/` cannot import other features
|
|
74
61
|
|
|
75
|
-
|
|
62
|
+
## What runs
|
|
63
|
+
|
|
64
|
+
`codestyle` runs three tools in parallel:
|
|
76
65
|
|
|
77
|
-
|
|
66
|
+
| Tool | Purpose |
|
|
67
|
+
| ------ | ------------- |
|
|
68
|
+
| tsgo | Type checking |
|
|
69
|
+
| oxlint | Linting |
|
|
70
|
+
| oxfmt | Formatting |
|
package/bin/codestyle.sh
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Colors for output
|
|
4
|
+
RED='\033[0;31m'
|
|
5
|
+
GREEN='\033[0;32m'
|
|
6
|
+
CYAN_BG='\033[46m'
|
|
7
|
+
BRIGHT_WHITE='\033[1;30m'
|
|
8
|
+
NC='\033[0m'
|
|
9
|
+
|
|
10
|
+
# Resolve symlinks to get the real script location
|
|
11
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
12
|
+
while [ -L "$SOURCE" ]; do
|
|
13
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
14
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
15
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
16
|
+
done
|
|
17
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
18
|
+
PACKAGE_ROOT="$SCRIPT_DIR/.."
|
|
19
|
+
|
|
20
|
+
# Find bin directory
|
|
21
|
+
if [ -x "$PACKAGE_ROOT/../../.bin/oxlint" ]; then
|
|
22
|
+
BIN_DIR="$PACKAGE_ROOT/../../.bin"
|
|
23
|
+
elif [ -x "$PACKAGE_ROOT/node_modules/.bin/oxlint" ]; then
|
|
24
|
+
BIN_DIR="$PACKAGE_ROOT/node_modules/.bin"
|
|
25
|
+
else
|
|
26
|
+
BIN_DIR="$(npm bin 2>/dev/null)"
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Parse command and args
|
|
30
|
+
COMMAND=""
|
|
31
|
+
LINT_ARGS=()
|
|
32
|
+
|
|
33
|
+
if [[ "${1:-}" == -* ]] || [ -z "${1:-}" ]; then
|
|
34
|
+
# No command, everything is args
|
|
35
|
+
true
|
|
36
|
+
else
|
|
37
|
+
COMMAND="$1"
|
|
38
|
+
shift
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Parse remaining args
|
|
42
|
+
while [[ $# -gt 0 ]]; do
|
|
43
|
+
case $1 in
|
|
44
|
+
--ignore-pattern)
|
|
45
|
+
LINT_ARGS+=("$1" "$2")
|
|
46
|
+
shift 2
|
|
47
|
+
;;
|
|
48
|
+
*)
|
|
49
|
+
shift
|
|
50
|
+
;;
|
|
51
|
+
esac
|
|
52
|
+
done
|
|
53
|
+
|
|
54
|
+
# Create a temporary directory for log files
|
|
55
|
+
tmp_dir=$(mktemp -d)
|
|
56
|
+
cleanup() { rm -rf "$tmp_dir"; }
|
|
57
|
+
trap cleanup EXIT
|
|
58
|
+
|
|
59
|
+
run_checks() {
|
|
60
|
+
local FIX_MODE="$1"
|
|
61
|
+
local LABEL
|
|
62
|
+
|
|
63
|
+
if [ "$FIX_MODE" = true ]; then
|
|
64
|
+
LABEL="Running quality fixes"
|
|
65
|
+
else
|
|
66
|
+
LABEL="Running quality checks"
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
printf "${CYAN_BG}${BRIGHT_WHITE} START ${NC} ${LABEL}\n"
|
|
70
|
+
|
|
71
|
+
# Run all three in parallel
|
|
72
|
+
"$BIN_DIR/tsgo" --noEmit > "$tmp_dir/type.log" 2>&1 &
|
|
73
|
+
local type_pid=$!
|
|
74
|
+
|
|
75
|
+
if [ "$FIX_MODE" = true ]; then
|
|
76
|
+
"$BIN_DIR/oxlint" --fix "${LINT_ARGS[@]}" > "$tmp_dir/lint.log" 2>&1 &
|
|
77
|
+
else
|
|
78
|
+
"$BIN_DIR/oxlint" "${LINT_ARGS[@]}" > "$tmp_dir/lint.log" 2>&1 &
|
|
79
|
+
fi
|
|
80
|
+
local lint_pid=$!
|
|
81
|
+
|
|
82
|
+
if [ "$FIX_MODE" = true ]; then
|
|
83
|
+
"$BIN_DIR/oxfmt" > "$tmp_dir/format.log" 2>&1 &
|
|
84
|
+
else
|
|
85
|
+
"$BIN_DIR/oxfmt" --check > "$tmp_dir/format.log" 2>&1 &
|
|
86
|
+
fi
|
|
87
|
+
local format_pid=$!
|
|
88
|
+
|
|
89
|
+
# Wait and collect statuses
|
|
90
|
+
wait $type_pid; local type_status=$?
|
|
91
|
+
wait $lint_pid; local lint_status=$?
|
|
92
|
+
wait $format_pid; local format_status=$?
|
|
93
|
+
|
|
94
|
+
# Print results
|
|
95
|
+
printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} TypeScript Check\n\n"
|
|
96
|
+
[ -s "$tmp_dir/type.log" ] && cat "$tmp_dir/type.log"
|
|
97
|
+
[ $type_status -ne 0 ] && printf "${RED}✗ Failed with exit code %d${NC}\n" $type_status || printf "${GREEN}✓ Passed${NC}\n"
|
|
98
|
+
|
|
99
|
+
local lint_label="Oxlint Check"
|
|
100
|
+
[ "$FIX_MODE" = true ] && lint_label="Oxlint Fix"
|
|
101
|
+
printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} ${lint_label}\n\n"
|
|
102
|
+
[ -s "$tmp_dir/lint.log" ] && cat "$tmp_dir/lint.log"
|
|
103
|
+
[ $lint_status -ne 0 ] && printf "${RED}✗ Failed with exit code %d${NC}\n" $lint_status || printf "${GREEN}✓ Passed${NC}\n"
|
|
104
|
+
|
|
105
|
+
local format_label="Oxfmt Check"
|
|
106
|
+
[ "$FIX_MODE" = true ] && format_label="Oxfmt Format"
|
|
107
|
+
printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} ${format_label}\n\n"
|
|
108
|
+
[ -s "$tmp_dir/format.log" ] && cat "$tmp_dir/format.log"
|
|
109
|
+
[ $format_status -ne 0 ] && printf "${RED}✗ Failed with exit code %d${NC}\n" $format_status || printf "${GREEN}✓ Passed${NC}\n"
|
|
110
|
+
|
|
111
|
+
# Summary
|
|
112
|
+
if [ "$FIX_MODE" = true ]; then
|
|
113
|
+
printf "\n${CYAN_BG}${BRIGHT_WHITE} END ${NC} Finalizing quality fixes\n\n"
|
|
114
|
+
else
|
|
115
|
+
printf "\n${CYAN_BG}${BRIGHT_WHITE} END ${NC} Finalizing quality checks\n\n"
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
if [ $type_status -eq 0 ] && [ $lint_status -eq 0 ] && [ $format_status -eq 0 ]; then
|
|
119
|
+
printf "${GREEN}✓ All checks passed${NC}\n"
|
|
120
|
+
exit 0
|
|
121
|
+
else
|
|
122
|
+
printf "${RED}✗ Some checks failed${NC}\n"
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case "$COMMAND" in
|
|
128
|
+
check)
|
|
129
|
+
run_checks false
|
|
130
|
+
;;
|
|
131
|
+
|
|
132
|
+
fix)
|
|
133
|
+
run_checks true
|
|
134
|
+
;;
|
|
135
|
+
|
|
136
|
+
*)
|
|
137
|
+
printf "${CYAN_BG}${BRIGHT_WHITE} CODESTYLE ${NC} Code quality toolkit\n\n"
|
|
138
|
+
printf "Usage: codestyle <command>\n\n"
|
|
139
|
+
printf "Commands:\n"
|
|
140
|
+
printf " check Check types, lint, and formatting\n"
|
|
141
|
+
printf " fix Auto-fix lint and formatting issues\n\n"
|
|
142
|
+
printf "Examples:\n"
|
|
143
|
+
printf " codestyle check\n"
|
|
144
|
+
printf " codestyle fix\n"
|
|
145
|
+
exit 1
|
|
146
|
+
;;
|
|
147
|
+
esac
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
|
|
3
3
|
"plugins": ["typescript", "import", "oxc", "unicorn"],
|
|
4
|
-
"jsPlugins": ["eslint-plugin-perfectionist"
|
|
4
|
+
"jsPlugins": ["eslint-plugin-perfectionist"],
|
|
5
5
|
"categories": {
|
|
6
6
|
"correctness": "error",
|
|
7
7
|
"suspicious": "error",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"unicorn/no-array-sort": "off",
|
|
90
90
|
"import/no-unassigned-import": "off",
|
|
91
91
|
"import/no-named-default": "off",
|
|
92
|
+
"import/no-nodejs-modules": "off",
|
|
92
93
|
|
|
93
94
|
// ============================================
|
|
94
95
|
// ENABLED - Code style enforcement
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
|
|
3
3
|
"extends": ["./base.json"],
|
|
4
4
|
"plugins": ["typescript", "import", "react"],
|
|
5
|
+
"jsPlugins": ["./plugins/codestyle.js"],
|
|
5
6
|
"rules": {
|
|
6
7
|
"typescript/no-require-imports": [
|
|
7
8
|
"error",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
|
|
3
3
|
"extends": ["./base.json"],
|
|
4
4
|
"plugins": ["typescript", "import", "react", "nextjs"],
|
|
5
|
+
"jsPlugins": ["./plugins/codestyle.js"],
|
|
5
6
|
"ignorePatterns": ["dist/**", "node_modules/**", ".next/**", "next-env.d.ts"],
|
|
6
7
|
"rules": {
|
|
7
8
|
"codestyle/imports-without-ext": "error"
|
package/package.json
CHANGED
|
@@ -1,42 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jterrazz/codestyle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/jterrazz/package-codestyle"
|
|
8
|
+
},
|
|
5
9
|
"bin": {
|
|
6
|
-
"codestyle": "
|
|
10
|
+
"codestyle": "bin/codestyle.sh"
|
|
7
11
|
},
|
|
8
12
|
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"config",
|
|
9
15
|
"src"
|
|
10
16
|
],
|
|
11
17
|
"type": "module",
|
|
12
18
|
"main": "src/index.js",
|
|
13
19
|
"exports": {
|
|
14
20
|
".": "./src/index.js",
|
|
15
|
-
"./oxfmt": "./
|
|
16
|
-
"./oxlint/node": "./
|
|
17
|
-
"./oxlint/expo": "./
|
|
18
|
-
"./oxlint/
|
|
19
|
-
"./oxlint/architectures/hexagonal": "./
|
|
20
|
-
"./oxlint/plugins/codestyle": "./
|
|
21
|
-
"./
|
|
21
|
+
"./oxfmt": "./config/oxfmt/index.json",
|
|
22
|
+
"./oxlint/node": "./config/oxlint/node.json",
|
|
23
|
+
"./oxlint/expo": "./config/oxlint/expo.json",
|
|
24
|
+
"./oxlint/next": "./config/oxlint/next.json",
|
|
25
|
+
"./oxlint/architectures/hexagonal": "./config/oxlint/architectures/hexagonal.json",
|
|
26
|
+
"./oxlint/plugins/codestyle": "./config/oxlint/plugins/codestyle.js",
|
|
27
|
+
"./config/oxlint/plugins/codestyle.js": "./config/oxlint/plugins/codestyle.js"
|
|
22
28
|
},
|
|
23
29
|
"publishConfig": {
|
|
24
30
|
"registry": "https://registry.npmjs.org/"
|
|
25
31
|
},
|
|
26
32
|
"scripts": {
|
|
27
33
|
"build": "# no build script",
|
|
28
|
-
"lint": "./
|
|
29
|
-
"lint:fix": "./
|
|
34
|
+
"lint": "./bin/codestyle.sh check --ignore-pattern '**/fixtures/**'",
|
|
35
|
+
"lint:fix": "./bin/codestyle.sh fix --ignore-pattern '**/fixtures/**'",
|
|
30
36
|
"test": "vitest --run"
|
|
31
37
|
},
|
|
32
38
|
"dependencies": {
|
|
33
|
-
"@jterrazz/typescript": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"@jterrazz/typescript": "^5.0.0",
|
|
40
|
+
"@typescript/native-preview": "^7.0.0-dev.20260327.2",
|
|
41
|
+
"eslint-plugin-perfectionist": "^5.7.0",
|
|
42
|
+
"oxfmt": "^0.42.0",
|
|
43
|
+
"oxlint": "^1.57.0"
|
|
37
44
|
},
|
|
38
45
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^25.0
|
|
40
|
-
"vitest": "^4.
|
|
46
|
+
"@types/node": "^25.5.0",
|
|
47
|
+
"vitest": "^4.1.2"
|
|
41
48
|
}
|
|
42
49
|
}
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import oxfmtConfig from "
|
|
2
|
-
import expoConfig from "
|
|
3
|
-
import
|
|
4
|
-
import nodeConfig from "
|
|
1
|
+
import oxfmtConfig from "../config/oxfmt/index.json" with { type: "json" };
|
|
2
|
+
import expoConfig from "../config/oxlint/expo.json" with { type: "json" };
|
|
3
|
+
import nextConfig from "../config/oxlint/next.json" with { type: "json" };
|
|
4
|
+
import nodeConfig from "../config/oxlint/node.json" with { type: "json" };
|
|
5
5
|
|
|
6
6
|
export const oxfmt = oxfmtConfig;
|
|
7
7
|
|
|
8
8
|
export const oxlint = {
|
|
9
9
|
expo: expoConfig,
|
|
10
|
-
|
|
10
|
+
next: nextConfig,
|
|
11
11
|
node: nodeConfig,
|
|
12
12
|
};
|
|
13
13
|
|
package/src/codestyle.sh
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Colors for output (using Vitest-like colors)
|
|
4
|
-
RED='\033[0;31m'
|
|
5
|
-
GREEN='\033[0;32m'
|
|
6
|
-
CYAN_BG='\033[46m' # Cyan background
|
|
7
|
-
BRIGHT_WHITE='\033[1;30m' # Bold black text
|
|
8
|
-
NC='\033[0m' # No Color
|
|
9
|
-
|
|
10
|
-
# Parse arguments
|
|
11
|
-
FIX_MODE=false
|
|
12
|
-
RUN_TYPE=false
|
|
13
|
-
RUN_LINT=false
|
|
14
|
-
RUN_FORMAT=false
|
|
15
|
-
RUN_ALL=true
|
|
16
|
-
EXTRA_ARGS=()
|
|
17
|
-
LINT_ARGS=()
|
|
18
|
-
|
|
19
|
-
while [[ $# -gt 0 ]]; do
|
|
20
|
-
case $1 in
|
|
21
|
-
--fix)
|
|
22
|
-
FIX_MODE=true
|
|
23
|
-
shift
|
|
24
|
-
;;
|
|
25
|
-
--type)
|
|
26
|
-
RUN_TYPE=true
|
|
27
|
-
RUN_ALL=false
|
|
28
|
-
shift
|
|
29
|
-
;;
|
|
30
|
-
--lint)
|
|
31
|
-
RUN_LINT=true
|
|
32
|
-
RUN_ALL=false
|
|
33
|
-
shift
|
|
34
|
-
;;
|
|
35
|
-
--format)
|
|
36
|
-
RUN_FORMAT=true
|
|
37
|
-
RUN_ALL=false
|
|
38
|
-
shift
|
|
39
|
-
;;
|
|
40
|
-
--ignore-pattern)
|
|
41
|
-
LINT_ARGS+=("$1" "$2")
|
|
42
|
-
shift 2
|
|
43
|
-
;;
|
|
44
|
-
*)
|
|
45
|
-
EXTRA_ARGS+=("$1")
|
|
46
|
-
shift
|
|
47
|
-
;;
|
|
48
|
-
esac
|
|
49
|
-
done
|
|
50
|
-
|
|
51
|
-
# If running all, enable all checks
|
|
52
|
-
if [ "$RUN_ALL" = true ]; then
|
|
53
|
-
RUN_TYPE=true
|
|
54
|
-
RUN_LINT=true
|
|
55
|
-
RUN_FORMAT=true
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
# Create a temporary directory for log files
|
|
59
|
-
tmp_dir=$(mktemp -d)
|
|
60
|
-
cleanup() {
|
|
61
|
-
rm -rf "$tmp_dir"
|
|
62
|
-
}
|
|
63
|
-
trap cleanup EXIT
|
|
64
|
-
|
|
65
|
-
if [ "$FIX_MODE" = true ]; then
|
|
66
|
-
printf "${CYAN_BG}${BRIGHT_WHITE} START ${NC} Running quality fixes\n"
|
|
67
|
-
else
|
|
68
|
-
printf "${CYAN_BG}${BRIGHT_WHITE} START ${NC} Running quality checks\n"
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
# Run selected commands in parallel and save their outputs
|
|
72
|
-
type_pid=""
|
|
73
|
-
code_pid=""
|
|
74
|
-
style_pid=""
|
|
75
|
-
|
|
76
|
-
# Find the node_modules/.bin directory relative to this script
|
|
77
|
-
# Resolve symlinks to get the real script location
|
|
78
|
-
SOURCE="${BASH_SOURCE[0]}"
|
|
79
|
-
while [ -L "$SOURCE" ]; do
|
|
80
|
-
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
81
|
-
SOURCE="$(readlink "$SOURCE")"
|
|
82
|
-
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
83
|
-
done
|
|
84
|
-
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
85
|
-
# Find bin directory: installed package or development
|
|
86
|
-
if [ -x "$SCRIPT_DIR/../../../.bin/oxlint" ]; then
|
|
87
|
-
BIN_DIR="$SCRIPT_DIR/../../../.bin"
|
|
88
|
-
elif [ -x "$SCRIPT_DIR/../node_modules/.bin/oxlint" ]; then
|
|
89
|
-
BIN_DIR="$SCRIPT_DIR/../node_modules/.bin"
|
|
90
|
-
else
|
|
91
|
-
BIN_DIR="$(npm bin 2>/dev/null)"
|
|
92
|
-
fi
|
|
93
|
-
|
|
94
|
-
if [ "$RUN_TYPE" = true ]; then
|
|
95
|
-
"$BIN_DIR/tsgo" --noEmit "${EXTRA_ARGS[@]}" > "$tmp_dir/type.log" 2>&1 &
|
|
96
|
-
type_pid=$!
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
if [ "$RUN_LINT" = true ]; then
|
|
100
|
-
if [ "$FIX_MODE" = true ]; then
|
|
101
|
-
"$BIN_DIR/oxlint" --fix "${LINT_ARGS[@]}" "${EXTRA_ARGS[@]:-.}" > "$tmp_dir/code.log" 2>&1 &
|
|
102
|
-
else
|
|
103
|
-
"$BIN_DIR/oxlint" "${LINT_ARGS[@]}" "${EXTRA_ARGS[@]:-.}" > "$tmp_dir/code.log" 2>&1 &
|
|
104
|
-
fi
|
|
105
|
-
code_pid=$!
|
|
106
|
-
fi
|
|
107
|
-
|
|
108
|
-
if [ "$RUN_FORMAT" = true ]; then
|
|
109
|
-
if [ "$FIX_MODE" = true ]; then
|
|
110
|
-
"$BIN_DIR/oxfmt" "${EXTRA_ARGS[@]:-.}" > "$tmp_dir/style.log" 2>&1 &
|
|
111
|
-
else
|
|
112
|
-
"$BIN_DIR/oxfmt" --check "${EXTRA_ARGS[@]:-.}" > "$tmp_dir/style.log" 2>&1 &
|
|
113
|
-
fi
|
|
114
|
-
style_pid=$!
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
# Function to print output with a header
|
|
118
|
-
print_output() {
|
|
119
|
-
local file=$1
|
|
120
|
-
local header=$2
|
|
121
|
-
local status=$3
|
|
122
|
-
|
|
123
|
-
printf "\n${CYAN_BG}${BRIGHT_WHITE} RUN ${NC} %s\n\n" "$header"
|
|
124
|
-
if [ -s "$file" ]; then
|
|
125
|
-
cat "$file"
|
|
126
|
-
fi
|
|
127
|
-
if [ $status -ne 0 ]; then
|
|
128
|
-
printf "${RED}✗ Failed with exit code %d${NC}\n" $status
|
|
129
|
-
else
|
|
130
|
-
printf "${GREEN}✓ Passed${NC}\n"
|
|
131
|
-
fi
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
# Wait for processes and collect statuses
|
|
135
|
-
type_status=0
|
|
136
|
-
code_status=0
|
|
137
|
-
style_status=0
|
|
138
|
-
|
|
139
|
-
if [ -n "$type_pid" ]; then
|
|
140
|
-
wait $type_pid
|
|
141
|
-
type_status=$?
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
if [ -n "$code_pid" ]; then
|
|
145
|
-
wait $code_pid
|
|
146
|
-
code_status=$?
|
|
147
|
-
fi
|
|
148
|
-
|
|
149
|
-
if [ -n "$style_pid" ]; then
|
|
150
|
-
wait $style_pid
|
|
151
|
-
style_status=$?
|
|
152
|
-
fi
|
|
153
|
-
|
|
154
|
-
# Print outputs with headers
|
|
155
|
-
if [ "$RUN_TYPE" = true ]; then
|
|
156
|
-
print_output "$tmp_dir/type.log" "TypeScript Check" $type_status
|
|
157
|
-
fi
|
|
158
|
-
|
|
159
|
-
if [ "$RUN_LINT" = true ]; then
|
|
160
|
-
if [ "$FIX_MODE" = true ]; then
|
|
161
|
-
print_output "$tmp_dir/code.log" "Oxlint Fix" $code_status
|
|
162
|
-
else
|
|
163
|
-
print_output "$tmp_dir/code.log" "Oxlint Check" $code_status
|
|
164
|
-
fi
|
|
165
|
-
fi
|
|
166
|
-
|
|
167
|
-
if [ "$RUN_FORMAT" = true ]; then
|
|
168
|
-
if [ "$FIX_MODE" = true ]; then
|
|
169
|
-
print_output "$tmp_dir/style.log" "Oxfmt Format" $style_status
|
|
170
|
-
else
|
|
171
|
-
print_output "$tmp_dir/style.log" "Oxfmt Check" $style_status
|
|
172
|
-
fi
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
# Print final summary
|
|
176
|
-
if [ "$FIX_MODE" = true ]; then
|
|
177
|
-
printf "\n${CYAN_BG}${BRIGHT_WHITE} END ${NC} Finalizing quality fixes\n\n"
|
|
178
|
-
else
|
|
179
|
-
printf "\n${CYAN_BG}${BRIGHT_WHITE} END ${NC} Finalizing quality checks\n\n"
|
|
180
|
-
fi
|
|
181
|
-
|
|
182
|
-
if [ $type_status -eq 0 ] && [ $code_status -eq 0 ] && [ $style_status -eq 0 ]; then
|
|
183
|
-
printf "${GREEN}✓ All checks passed${NC}\n"
|
|
184
|
-
exit 0
|
|
185
|
-
else
|
|
186
|
-
printf "${RED}✗ Some checks failed${NC}\n"
|
|
187
|
-
exit 1
|
|
188
|
-
fi
|
|
File without changes
|
|
File without changes
|