qcobjects-cli 2.6.1 → 2.6.2
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/CHANGELOG.md +7 -0
- package/VERSION +1 -1
- package/package.json +6 -3
- package/public/cjs/cli-commands-lint.js +207 -0
- package/public/cjs/cli-commands-lint.js.map +1 -0
- package/public/cjs/cli-commands.js +2 -1
- package/public/cjs/cli-commands.js.map +1 -1
- package/public/esm/cli-commands-lint.mjs +139 -0
- package/public/esm/cli-commands-lint.mjs.map +7 -0
- package/public/esm/cli-commands.mjs +2 -0
- package/public/esm/cli-commands.mjs.map +2 -2
- package/public/types/index.d.ts +15 -0
- package/src/cli-commands-lint.ts +181 -0
- package/src/cli-commands.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This is an automatic Changelog history of versions generated using the command: **qcobjects v-changelog > CHANGELOG.md**
|
|
4
4
|
|
|
5
|
+
## v2.6.2
|
|
6
|
+
|
|
7
|
+
- New built-in lint command: qcobjects lint [targets...]
|
|
8
|
+
- Ships QCObjects default ESLint 9 flat settings; app overrides via eslint.config.*
|
|
9
|
+
- Bundled @typescript-eslint parser + plugin; legacy .eslintrc detection with migration warning
|
|
10
|
+
- Runtime deps: eslint@9, globals@15, @typescript-eslint/eslint-plugin@8, @typescript-eslint/parser@8
|
|
11
|
+
|
|
5
12
|
## v2.6.1
|
|
6
13
|
|
|
7
14
|
- Build fixes: unbalanced exec callback in create flow (unblocks esbuild + npm publish)
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.6.
|
|
1
|
+
2.6.2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcobjects-cli",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "qcobjects cli command line tool",
|
|
5
5
|
"main": "public/cjs/index.js",
|
|
6
6
|
"module": "public/esm/index.mjs",
|
|
@@ -139,10 +139,14 @@
|
|
|
139
139
|
"qcobjects-collab": "public/cjs/qcobjects-collab.js"
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
|
+
"@typescript-eslint/eslint-plugin": "^8.70.0",
|
|
143
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
142
144
|
"commander": "^10.0.1",
|
|
143
145
|
"esbuild": "^0.28.0",
|
|
144
146
|
"esbuild-plugin-alias": "^0.2.1",
|
|
147
|
+
"eslint": "^9.0.0",
|
|
145
148
|
"glob": "^8.0.3",
|
|
149
|
+
"globals": "^15.11.0",
|
|
146
150
|
"mime": "^2.6.0",
|
|
147
151
|
"typescript": "^5.7.2",
|
|
148
152
|
"yaml": "^2.6.0"
|
|
@@ -158,8 +162,7 @@
|
|
|
158
162
|
"@types/jasmine": "^5.1.4",
|
|
159
163
|
"@types/mime": "^3.0.4",
|
|
160
164
|
"@types/node": "^22.10.2",
|
|
161
|
-
"@typescript-eslint/
|
|
162
|
-
"@typescript-eslint/parser": "^5.58.0",
|
|
165
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
163
166
|
"eslint": "^8.56.0",
|
|
164
167
|
"eslint-config-prettier": "^8.10.0",
|
|
165
168
|
"eslint-config-semistandard": "^17.0.0",
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects Framework CLI
|
|
3
|
+
* ________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QCObjects is licensed under the MIT License
|
|
9
|
+
* [LICENSE] (https://github.com/QCObjects/qcobjects-cli/blob/main/LICENSE.txt)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
12
|
+
*
|
|
13
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
14
|
+
* license document, but changing it is not allowed.
|
|
15
|
+
*/
|
|
16
|
+
/*eslint no-unused-vars: "off"*/
|
|
17
|
+
/*eslint no-redeclare: "off"*/
|
|
18
|
+
/*eslint no-empty: "off"*/
|
|
19
|
+
/*eslint strict: "off"*/
|
|
20
|
+
/*eslint no-mixed-operators: "off"*/
|
|
21
|
+
/*eslint no-undef: "off"*/
|
|
22
|
+
"use strict";
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.CommandHandler = void 0;
|
|
61
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
62
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
63
|
+
const node_url_1 = require("node:url");
|
|
64
|
+
const glob_1 = __importDefault(require("glob"));
|
|
65
|
+
const eslint_1 = require("eslint");
|
|
66
|
+
const globals_1 = __importDefault(require("globals"));
|
|
67
|
+
const tsParserModule = __importStar(require("@typescript-eslint/parser"));
|
|
68
|
+
const tsPluginModule = __importStar(require("@typescript-eslint/eslint-plugin"));
|
|
69
|
+
const qcobjects_1 = require("qcobjects");
|
|
70
|
+
const tsParser = tsParserModule.default ?? tsParserModule;
|
|
71
|
+
const tsPlugin = tsPluginModule.default ?? tsPluginModule;
|
|
72
|
+
const DEFAULT_TARGETS = ["src/**/*.ts"];
|
|
73
|
+
const DEFAULT_IGNORES = [
|
|
74
|
+
"node_modules/**",
|
|
75
|
+
"build/**",
|
|
76
|
+
"public/**",
|
|
77
|
+
"dist/**",
|
|
78
|
+
"coverage/**",
|
|
79
|
+
".git/**",
|
|
80
|
+
];
|
|
81
|
+
const DEFAULT_FLAT_CONFIG = [
|
|
82
|
+
{
|
|
83
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
84
|
+
plugins: {
|
|
85
|
+
"@typescript-eslint": tsPlugin,
|
|
86
|
+
},
|
|
87
|
+
languageOptions: {
|
|
88
|
+
parser: tsParser,
|
|
89
|
+
ecmaVersion: "latest",
|
|
90
|
+
sourceType: "module",
|
|
91
|
+
globals: {
|
|
92
|
+
...globals_1.default.browser,
|
|
93
|
+
...globals_1.default.node,
|
|
94
|
+
...globals_1.default.commonjs,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
rules: {
|
|
98
|
+
"no-undef": "error",
|
|
99
|
+
"no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
100
|
+
"no-empty": "off",
|
|
101
|
+
"no-constant-condition": "off",
|
|
102
|
+
"no-redeclare": "off",
|
|
103
|
+
"no-var": "off",
|
|
104
|
+
"no-mixed-operators": "off",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
class CommandHandler extends qcobjects_1.InheritClass {
|
|
109
|
+
choiceOption;
|
|
110
|
+
constructor({ switchCommander }) {
|
|
111
|
+
super({ switchCommander });
|
|
112
|
+
this.choiceOption = {
|
|
113
|
+
async lint(targets, options) {
|
|
114
|
+
try {
|
|
115
|
+
const cwd = process.cwd();
|
|
116
|
+
const requestedTargets = targets.length > 0 ? targets : DEFAULT_TARGETS;
|
|
117
|
+
const ignoreFlags = DEFAULT_IGNORES.map(ignored => new RegExp(ignored.replace(/\*\*/g, ".*")));
|
|
118
|
+
const files = requestedTargets
|
|
119
|
+
.flatMap(target => glob_1.default.sync(target, { cwd, nodir: true }))
|
|
120
|
+
.filter((file) => !ignoreFlags.some(flag => flag.test(file)));
|
|
121
|
+
if (files.length === 0) {
|
|
122
|
+
console.warn(`No files matched: ${requestedTargets.join(", ")}`);
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
let flatConfig = DEFAULT_FLAT_CONFIG;
|
|
126
|
+
const appConfigPath = ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"]
|
|
127
|
+
.map(name => node_path_1.default.resolve(cwd, name))
|
|
128
|
+
.find(appConfigPath => node_fs_1.default.existsSync(appConfigPath));
|
|
129
|
+
if (options.config) {
|
|
130
|
+
const explicitConfigPath = node_path_1.default.resolve(cwd, options.config);
|
|
131
|
+
if (!node_fs_1.default.existsSync(explicitConfigPath)) {
|
|
132
|
+
console.warn(`Config file not found: ${explicitConfigPath}`);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
flatConfig = (await import((0, node_url_1.pathToFileURL)(explicitConfigPath).href)).default;
|
|
136
|
+
console.log(`Using config file: ${explicitConfigPath}`);
|
|
137
|
+
}
|
|
138
|
+
else if (appConfigPath) {
|
|
139
|
+
flatConfig = (await import((0, node_url_1.pathToFileURL)(appConfigPath).href)).default;
|
|
140
|
+
console.log(`Using app config file: ${appConfigPath}`);
|
|
141
|
+
}
|
|
142
|
+
else if (node_fs_1.default.existsSync(node_path_1.default.resolve(cwd, ".eslintrc")) || node_fs_1.default.existsSync(node_path_1.default.resolve(cwd, ".eslintrc.js")) || node_fs_1.default.existsSync(node_path_1.default.resolve(cwd, ".eslintrc.cjs")) || node_fs_1.default.existsSync(node_path_1.default.resolve(cwd, ".eslintrc.json"))) {
|
|
143
|
+
console.warn("Legacy .eslintrc config detected but not supported; using built-in QCObjects settings. Migrate to eslint.config.mjs to override defaults.");
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
console.log("No app eslint config found. Using built-in QCObjects settings (overridable with an eslint.config.mjs in your app).");
|
|
147
|
+
}
|
|
148
|
+
const linter = new eslint_1.Linter({ cwd, configType: "flat" });
|
|
149
|
+
let errorCount = 0;
|
|
150
|
+
let warningCount = 0;
|
|
151
|
+
let fixedCount = 0;
|
|
152
|
+
for (const file of files) {
|
|
153
|
+
const absolutePath = node_path_1.default.resolve(cwd, file);
|
|
154
|
+
const source = node_fs_1.default.readFileSync(absolutePath, "utf8");
|
|
155
|
+
const result = options.fix
|
|
156
|
+
? linter.verifyAndFix(source, flatConfig, absolutePath)
|
|
157
|
+
: { fixed: false, output: source, messages: linter.verify(source, flatConfig, absolutePath) };
|
|
158
|
+
if (result.fixed) {
|
|
159
|
+
fixedCount++;
|
|
160
|
+
node_fs_1.default.writeFileSync(absolutePath, result.output);
|
|
161
|
+
}
|
|
162
|
+
for (const message of result.messages) {
|
|
163
|
+
const severity = message.severity === 2 ? "error" : message.severity === 1 ? "warning" : "info";
|
|
164
|
+
const output = `${file}:${message.line}:${message.column} ${severity} ${message.message} (${message.ruleId ?? "parse"})`;
|
|
165
|
+
if (message.severity === 2) {
|
|
166
|
+
errorCount++;
|
|
167
|
+
console.error(output);
|
|
168
|
+
}
|
|
169
|
+
else if (message.severity === 1) {
|
|
170
|
+
warningCount++;
|
|
171
|
+
console.warn(output);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log(output);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const summary = `${files.length} file(s) linted, ${errorCount} error(s), ${warningCount} warning(s), ${fixedCount} file(s) fixed.`;
|
|
179
|
+
if (errorCount > 0) {
|
|
180
|
+
console.error(summary);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
console.log(summary);
|
|
184
|
+
process.exit(0);
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
console.warn(`Something went wrong trying to lint: ${e.message}`);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const commandHandler = this;
|
|
193
|
+
const lintCommand = switchCommander.program.command("lint [targets...]")
|
|
194
|
+
.allowExcessArguments(false)
|
|
195
|
+
.option("-f, --fix", "Automatically fix problems")
|
|
196
|
+
.option("-c, --config <path>", "Use a specific eslint config file")
|
|
197
|
+
.description("Lints JS/TS files using built-in QCObjects settings. Default target: src/**/*.ts")
|
|
198
|
+
.action(function (targets, options) {
|
|
199
|
+
commandHandler.choiceOption.lint.call(commandHandler, targets ?? [], options);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.CommandHandler = CommandHandler;
|
|
204
|
+
(0, qcobjects_1.Package)("com.qcobjects.cli.commands.lint", [
|
|
205
|
+
CommandHandler
|
|
206
|
+
]);
|
|
207
|
+
//# sourceMappingURL=cli-commands-lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-commands-lint.js","sourceRoot":"","sources":["../../src/cli-commands-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,gCAAgC;AAChC,8BAA8B;AAC9B,0BAA0B;AAC1B,wBAAwB;AACxB,oCAAoC;AACpC,0BAA0B;AAC1B,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,sDAAyB;AACzB,0DAA6B;AAC7B,uCAAyC;AACzC,gDAAwB;AACxB,mCAAgC;AAChC,sDAA8B;AAC9B,0EAA4D;AAC5D,iFAAmE;AACnE,yCAAkD;AAElD,MAAM,QAAQ,GAAI,cAAsB,CAAC,OAAO,IAAI,cAAc,CAAC;AACnE,MAAM,QAAQ,GAAI,cAAsB,CAAC,OAAO,IAAI,cAAc,CAAC;AAEnE,MAAM,eAAe,GAAG,CAAC,aAAa,CAAC,CAAC;AAExC,MAAM,eAAe,GAAG;IACtB,iBAAiB;IACjB,UAAU;IACV,WAAW;IACX,SAAS;IACT,aAAa;IACb,SAAS;CACV,CAAC;AAEF,MAAM,mBAAmB,GAAU;IACjC;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;QACjE,OAAO,EAAE;YACP,oBAAoB,EAAE,QAAQ;SAC/B;QACD,eAAe,EAAE;YACf,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE;gBACP,GAAG,iBAAO,CAAC,OAAO;gBAClB,GAAG,iBAAO,CAAC,IAAI;gBACf,GAAG,iBAAO,CAAC,QAAQ;aACpB;SACF;QACD,KAAK,EAAE;YACL,UAAU,EAAE,OAAO;YACnB,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,iBAAiB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,EAAE,CAAC;oBAChB,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;oBAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC;QAEF,MAAM,cAAc,GAAG,IAAI,CAAC;QAE5B,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;aACrE,oBAAoB,CAAC,KAAK,CAAC;aAC3B,MAAM,CAAC,WAAW,EAAE,4BAA4B,CAAC;aACjD,MAAM,CAAC,qBAAqB,EAAE,mCAAmC,CAAC;aAClE,WAAW,CAAC,kFAAkF,CAAC;aAC/F,MAAM,CAAC,UAAU,OAAiB,EAAE,OAA2C;YAC9E,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IAEL,CAAC;CACJ;AAtGD,wCAsGC;AAED,IAAA,mBAAO,EAAC,iCAAiC,EAAE;IACzC,cAAc;CACf,CAAC,CAAC"}
|
|
@@ -54,11 +54,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
54
54
|
};
|
|
55
55
|
})();
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.buildEsbuild = exports.buildTypescript = exports.publishStatic = exports.jiraCommand = exports.versionCommand = void 0;
|
|
57
|
+
exports.lintCommand = exports.buildEsbuild = exports.buildTypescript = exports.publishStatic = exports.jiraCommand = exports.versionCommand = void 0;
|
|
58
58
|
// plugin commands here
|
|
59
59
|
exports.versionCommand = __importStar(require("./cli-commands-version"));
|
|
60
60
|
exports.jiraCommand = __importStar(require("./cli-commands-jira"));
|
|
61
61
|
exports.publishStatic = __importStar(require("./cli-commands-publish-static"));
|
|
62
62
|
exports.buildTypescript = __importStar(require("./cli-commands-build-typescript"));
|
|
63
63
|
exports.buildEsbuild = __importStar(require("./cli-commands-build-esbuild"));
|
|
64
|
+
exports.lintCommand = __importStar(require("./cli-commands-lint"));
|
|
64
65
|
//# sourceMappingURL=cli-commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-commands.js","sourceRoot":"","sources":["../../src/cli-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AACF,gCAAgC;AAChC,8BAA8B;AAC9B,0BAA0B;AAC1B,wBAAwB;AACxB,oCAAoC;AACpC,0BAA0B;AAC1B,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uBAAuB;AAEvB,yEAAyD;AACzD,mEAAmD;AACnD,+EAA+D;AAC/D,mFAAmE;AACnE,6EAA6D"}
|
|
1
|
+
{"version":3,"file":"cli-commands.js","sourceRoot":"","sources":["../../src/cli-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AACF,gCAAgC;AAChC,8BAA8B;AAC9B,0BAA0B;AAC1B,wBAAwB;AACxB,oCAAoC;AACpC,0BAA0B;AAC1B,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uBAAuB;AAEvB,yEAAyD;AACzD,mEAAmD;AACnD,+EAA+D;AAC/D,mFAAmE;AACnE,6EAA6D;AAC7D,mEAAmD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import glob from "glob";
|
|
7
|
+
import { Linter } from "eslint";
|
|
8
|
+
import globals from "globals";
|
|
9
|
+
import * as tsParserModule from "@typescript-eslint/parser";
|
|
10
|
+
import * as tsPluginModule from "@typescript-eslint/eslint-plugin";
|
|
11
|
+
import { Package, InheritClass } from "qcobjects";
|
|
12
|
+
const tsParser = tsParserModule.default ?? tsParserModule;
|
|
13
|
+
const tsPlugin = tsPluginModule.default ?? tsPluginModule;
|
|
14
|
+
const DEFAULT_TARGETS = ["src/**/*.ts"];
|
|
15
|
+
const DEFAULT_IGNORES = [
|
|
16
|
+
"node_modules/**",
|
|
17
|
+
"build/**",
|
|
18
|
+
"public/**",
|
|
19
|
+
"dist/**",
|
|
20
|
+
"coverage/**",
|
|
21
|
+
".git/**"
|
|
22
|
+
];
|
|
23
|
+
const DEFAULT_FLAT_CONFIG = [
|
|
24
|
+
{
|
|
25
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
26
|
+
plugins: {
|
|
27
|
+
"@typescript-eslint": tsPlugin
|
|
28
|
+
},
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parser: tsParser,
|
|
31
|
+
ecmaVersion: "latest",
|
|
32
|
+
sourceType: "module",
|
|
33
|
+
globals: {
|
|
34
|
+
...globals.browser,
|
|
35
|
+
...globals.node,
|
|
36
|
+
...globals.commonjs
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
"no-undef": "error",
|
|
41
|
+
"no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
42
|
+
"no-empty": "off",
|
|
43
|
+
"no-constant-condition": "off",
|
|
44
|
+
"no-redeclare": "off",
|
|
45
|
+
"no-var": "off",
|
|
46
|
+
"no-mixed-operators": "off"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
class CommandHandler extends InheritClass {
|
|
51
|
+
static {
|
|
52
|
+
__name(this, "CommandHandler");
|
|
53
|
+
}
|
|
54
|
+
choiceOption;
|
|
55
|
+
constructor({
|
|
56
|
+
switchCommander
|
|
57
|
+
}) {
|
|
58
|
+
super({ switchCommander });
|
|
59
|
+
this.choiceOption = {
|
|
60
|
+
async lint(targets, options) {
|
|
61
|
+
try {
|
|
62
|
+
const cwd = process.cwd();
|
|
63
|
+
const requestedTargets = targets.length > 0 ? targets : DEFAULT_TARGETS;
|
|
64
|
+
const ignoreFlags = DEFAULT_IGNORES.map((ignored) => new RegExp(ignored.replace(/\*\*/g, ".*")));
|
|
65
|
+
const files = requestedTargets.flatMap((target) => glob.sync(target, { cwd, nodir: true })).filter((file) => !ignoreFlags.some((flag) => flag.test(file)));
|
|
66
|
+
if (files.length === 0) {
|
|
67
|
+
console.warn(`No files matched: ${requestedTargets.join(", ")}`);
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
let flatConfig = DEFAULT_FLAT_CONFIG;
|
|
71
|
+
const appConfigPath = ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"].map((name) => path.resolve(cwd, name)).find((appConfigPath2) => fs.existsSync(appConfigPath2));
|
|
72
|
+
if (options.config) {
|
|
73
|
+
const explicitConfigPath = path.resolve(cwd, options.config);
|
|
74
|
+
if (!fs.existsSync(explicitConfigPath)) {
|
|
75
|
+
console.warn(`Config file not found: ${explicitConfigPath}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
flatConfig = (await import(pathToFileURL(explicitConfigPath).href)).default;
|
|
79
|
+
console.log(`Using config file: ${explicitConfigPath}`);
|
|
80
|
+
} else if (appConfigPath) {
|
|
81
|
+
flatConfig = (await import(pathToFileURL(appConfigPath).href)).default;
|
|
82
|
+
console.log(`Using app config file: ${appConfigPath}`);
|
|
83
|
+
} else if (fs.existsSync(path.resolve(cwd, ".eslintrc")) || fs.existsSync(path.resolve(cwd, ".eslintrc.js")) || fs.existsSync(path.resolve(cwd, ".eslintrc.cjs")) || fs.existsSync(path.resolve(cwd, ".eslintrc.json"))) {
|
|
84
|
+
console.warn("Legacy .eslintrc config detected but not supported; using built-in QCObjects settings. Migrate to eslint.config.mjs to override defaults.");
|
|
85
|
+
} else {
|
|
86
|
+
console.log("No app eslint config found. Using built-in QCObjects settings (overridable with an eslint.config.mjs in your app).");
|
|
87
|
+
}
|
|
88
|
+
const linter = new Linter({ cwd, configType: "flat" });
|
|
89
|
+
let errorCount = 0;
|
|
90
|
+
let warningCount = 0;
|
|
91
|
+
let fixedCount = 0;
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
const absolutePath = path.resolve(cwd, file);
|
|
94
|
+
const source = fs.readFileSync(absolutePath, "utf8");
|
|
95
|
+
const result = options.fix ? linter.verifyAndFix(source, flatConfig, absolutePath) : { fixed: false, output: source, messages: linter.verify(source, flatConfig, absolutePath) };
|
|
96
|
+
if (result.fixed) {
|
|
97
|
+
fixedCount++;
|
|
98
|
+
fs.writeFileSync(absolutePath, result.output);
|
|
99
|
+
}
|
|
100
|
+
for (const message of result.messages) {
|
|
101
|
+
const severity = message.severity === 2 ? "error" : message.severity === 1 ? "warning" : "info";
|
|
102
|
+
const output = `${file}:${message.line}:${message.column} ${severity} ${message.message} (${message.ruleId ?? "parse"})`;
|
|
103
|
+
if (message.severity === 2) {
|
|
104
|
+
errorCount++;
|
|
105
|
+
console.error(output);
|
|
106
|
+
} else if (message.severity === 1) {
|
|
107
|
+
warningCount++;
|
|
108
|
+
console.warn(output);
|
|
109
|
+
} else {
|
|
110
|
+
console.log(output);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const summary = `${files.length} file(s) linted, ${errorCount} error(s), ${warningCount} warning(s), ${fixedCount} file(s) fixed.`;
|
|
115
|
+
if (errorCount > 0) {
|
|
116
|
+
console.error(summary);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
console.log(summary);
|
|
120
|
+
process.exit(0);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.warn(`Something went wrong trying to lint: ${e.message}`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const commandHandler = this;
|
|
128
|
+
const lintCommand = switchCommander.program.command("lint [targets...]").allowExcessArguments(false).option("-f, --fix", "Automatically fix problems").option("-c, --config <path>", "Use a specific eslint config file").description("Lints JS/TS files using built-in QCObjects settings. Default target: src/**/*.ts").action(function(targets, options) {
|
|
129
|
+
commandHandler.choiceOption.lint.call(commandHandler, targets ?? [], options);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
Package("com.qcobjects.cli.commands.lint", [
|
|
134
|
+
CommandHandler
|
|
135
|
+
]);
|
|
136
|
+
export {
|
|
137
|
+
CommandHandler
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=cli-commands-lint.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli-commands-lint.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * QCObjects Framework CLI\n * ________________\n *\n * Author: Jean Machuca <correojean@gmail.com>\n *\n * Cross Browser Javascript Framework for MVC Patterns\n * QCObjects is licensed under the MIT License\n * [LICENSE] (https://github.com/QCObjects/qcobjects-cli/blob/main/LICENSE.txt)\n *\n * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>\n *\n * Everyone is permitted to copy and distribute verbatim copies of this\n * license document, but changing it is not allowed.\n */\n/*eslint no-unused-vars: \"off\"*/\n/*eslint no-redeclare: \"off\"*/\n/*eslint no-empty: \"off\"*/\n/*eslint strict: \"off\"*/\n/*eslint no-mixed-operators: \"off\"*/\n/*eslint no-undef: \"off\"*/\n\"use strict\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport glob from \"glob\";\nimport { Linter } from \"eslint\";\nimport globals from \"globals\";\nimport * as tsParserModule from \"@typescript-eslint/parser\";\nimport * as tsPluginModule from \"@typescript-eslint/eslint-plugin\";\nimport { Package, InheritClass } from \"qcobjects\";\n\nconst tsParser = (tsParserModule as any).default ?? tsParserModule;\nconst tsPlugin = (tsPluginModule as any).default ?? tsPluginModule;\n\nconst DEFAULT_TARGETS = [\"src/**/*.ts\"];\n\nconst DEFAULT_IGNORES = [\n \"node_modules/**\",\n \"build/**\",\n \"public/**\",\n \"dist/**\",\n \"coverage/**\",\n \".git/**\",\n];\n\nconst DEFAULT_FLAT_CONFIG: any[] = [\n {\n files: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.mjs\", \"**/*.cjs\"],\n plugins: {\n \"@typescript-eslint\": tsPlugin,\n },\n languageOptions: {\n parser: tsParser,\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n globals: {\n ...globals.browser,\n ...globals.node,\n ...globals.commonjs,\n },\n },\n rules: {\n \"no-undef\": \"error\",\n \"no-unused-vars\": [\"warn\", { argsIgnorePattern: \"^_\", varsIgnorePattern: \"^_\" }],\n \"no-empty\": \"off\",\n \"no-constant-condition\": \"off\",\n \"no-redeclare\": \"off\",\n \"no-var\": \"off\",\n \"no-mixed-operators\": \"off\",\n },\n },\n];\n\nexport class CommandHandler extends InheritClass {\n choiceOption: {\n lint: (targets: string[], options: { fix?: boolean; config?: string }) => Promise<void>;\n };\n\n constructor({\n switchCommander\n }: { switchCommander: any }) {\n super({ switchCommander });\n this.choiceOption = {\n async lint(targets, options) {\n try {\n const cwd = process.cwd();\n const requestedTargets = targets.length > 0 ? targets : DEFAULT_TARGETS;\n const ignoreFlags = DEFAULT_IGNORES.map(ignored => new RegExp(ignored.replace(/\\*\\*/g, \".*\")));\n const files = requestedTargets\n .flatMap(target => glob.sync(target, { cwd, nodir: true }))\n .filter((file: string) => !ignoreFlags.some(flag => flag.test(file)));\n\n if (files.length === 0) {\n console.warn(`No files matched: ${requestedTargets.join(\", \")}`);\n process.exit(0);\n }\n\n let flatConfig = DEFAULT_FLAT_CONFIG;\n const appConfigPath = [\"eslint.config.js\", \"eslint.config.mjs\", \"eslint.config.cjs\"]\n .map(name => path.resolve(cwd, name))\n .find(appConfigPath => fs.existsSync(appConfigPath));\n\n if (options.config) {\n const explicitConfigPath = path.resolve(cwd, options.config);\n if (!fs.existsSync(explicitConfigPath)) {\n console.warn(`Config file not found: ${explicitConfigPath}`);\n process.exit(1);\n }\n flatConfig = (await import(pathToFileURL(explicitConfigPath).href)).default;\n console.log(`Using config file: ${explicitConfigPath}`);\n } else if (appConfigPath) {\n flatConfig = (await import(pathToFileURL(appConfigPath).href)).default;\n console.log(`Using app config file: ${appConfigPath}`);\n } else if (fs.existsSync(path.resolve(cwd, \".eslintrc\")) || fs.existsSync(path.resolve(cwd, \".eslintrc.js\")) || fs.existsSync(path.resolve(cwd, \".eslintrc.cjs\")) || fs.existsSync(path.resolve(cwd, \".eslintrc.json\"))) {\n console.warn(\"Legacy .eslintrc config detected but not supported; using built-in QCObjects settings. Migrate to eslint.config.mjs to override defaults.\");\n } else {\n console.log(\"No app eslint config found. Using built-in QCObjects settings (overridable with an eslint.config.mjs in your app).\");\n }\n\n const linter = new Linter({ cwd, configType: \"flat\" });\n let errorCount = 0;\n let warningCount = 0;\n let fixedCount = 0;\n\n for (const file of files) {\n const absolutePath = path.resolve(cwd, file);\n const source = fs.readFileSync(absolutePath, \"utf8\");\n const result: { fixed: boolean; output: string; messages: any[] } = options.fix\n ? linter.verifyAndFix(source, flatConfig, absolutePath)\n : { fixed: false, output: source, messages: linter.verify(source, flatConfig, absolutePath) };\n if (result.fixed) {\n fixedCount++;\n fs.writeFileSync(absolutePath, result.output);\n }\n for (const message of result.messages) {\n const severity = message.severity === 2 ? \"error\" : message.severity === 1 ? \"warning\" : \"info\";\n const output = `${file}:${message.line}:${message.column} ${severity} ${message.message} (${message.ruleId ?? \"parse\"})`;\n if (message.severity === 2) {\n errorCount++;\n console.error(output);\n } else if (message.severity === 1) {\n warningCount++;\n console.warn(output);\n } else {\n console.log(output);\n }\n }\n }\n\n const summary = `${files.length} file(s) linted, ${errorCount} error(s), ${warningCount} warning(s), ${fixedCount} file(s) fixed.`;\n if (errorCount > 0) {\n console.error(summary);\n process.exit(1);\n }\n console.log(summary);\n process.exit(0);\n } catch (e: any) {\n console.warn(`Something went wrong trying to lint: ${e.message}`);\n process.exit(1);\n }\n }\n };\n\n const commandHandler = this;\n\n const lintCommand = switchCommander.program.command(\"lint [targets...]\")\n .allowExcessArguments(false)\n .option(\"-f, --fix\", \"Automatically fix problems\")\n .option(\"-c, --config <path>\", \"Use a specific eslint config file\")\n .description(\"Lints JS/TS files using built-in QCObjects settings. Default target: src/**/*.ts\")\n .action(function (targets: string[], options: { fix?: boolean; config?: string }) {\n commandHandler.choiceOption.lint.call(commandHandler, targets ?? [], options);\n });\n\n }\n}\n\nPackage(\"com.qcobjects.cli.commands.lint\", [\n CommandHandler\n]);"],
|
|
5
|
+
"mappings": ";;AAsBA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,YAAY,oBAAoB;AAChC,YAAY,oBAAoB;AAChC,SAAS,SAAS,oBAAoB;AAEtC,MAAM,WAAY,eAAuB,WAAW;AACpD,MAAM,WAAY,eAAuB,WAAW;AAEpD,MAAM,kBAAkB,CAAC,aAAa;AAEtC,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,sBAA6B;AAAA,EACjC;AAAA,IACE,OAAO,CAAC,WAAW,YAAY,WAAW,YAAY,UAAU;AAAA,IAChE,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,IACA,iBAAiB;AAAA,MACf,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,GAAG,QAAQ;AAAA,QACX,GAAG,QAAQ;AAAA,QACX,GAAG,QAAQ;AAAA,MACb;AAAA,IACF;AAAA,IACA,OAAO;AAAA,MACL,YAAY;AAAA,MACZ,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,MAAM,mBAAmB,KAAK,CAAC;AAAA,MAC/E,YAAY;A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cACtB,WAAW,QAAQ,aAAa,GAAG;AACjC;AACA,wBAAQ,KAAK,MAAM;AAAA,cACrB,OAAO;AACL,wBAAQ,IAAI,MAAM;AAAA,cACpB;AAAA,YACF;AAAA,UACF;AAEA,gBAAM,UAAU,GAAG,MAAM,MAAM,oBAAoB,UAAU,cAAc,YAAY,gBAAgB,UAAU;AACjH,cAAI,aAAa,GAAG;AAClB,oBAAQ,MAAM,OAAO;AACrB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA,kBAAQ,IAAI,OAAO;AACnB,kBAAQ,KAAK,CAAC;AAAA,QAChB,SAAS,GAAQ;AACf,kBAAQ,KAAK,wCAAwC,EAAE,OAAO,EAAE;AAChE,kBAAQ,KAAK,CAAC;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAEA,UAAM,iBAAiB;AAEvB,UAAM,cAAc,gBAAgB,QAAQ,QAAQ,mBAAmB,EACpE,qBAAqB,KAAK,EAC1B,OAAO,aAAa,4BAA4B,EAChD,OAAO,uBAAuB,mCAAmC,EACjE,YAAY,kFAAkF,EAC9F,OAAO,SAAU,SAAmB,SAA6C;AAChF,qBAAe,aAAa,KAAK,KAAK,gBAAgB,WAAW,CAAC,GAAG,OAAO;AAAA,IAC9E,CAAC;AAAA,EAEH;AACJ;AAEA,QAAQ,mCAAmC;AAAA,EACzC;AACF,CAAC;",
|
|
6
|
+
"names": ["appConfigPath"]
|
|
7
|
+
}
|
|
@@ -3,10 +3,12 @@ import * as jiraCommand from "./cli-commands-jira";
|
|
|
3
3
|
import * as publishStatic from "./cli-commands-publish-static";
|
|
4
4
|
import * as buildTypescript from "./cli-commands-build-typescript";
|
|
5
5
|
import * as buildEsbuild from "./cli-commands-build-esbuild";
|
|
6
|
+
import * as lintCommand from "./cli-commands-lint";
|
|
6
7
|
export {
|
|
7
8
|
buildEsbuild,
|
|
8
9
|
buildTypescript,
|
|
9
10
|
jiraCommand,
|
|
11
|
+
lintCommand,
|
|
10
12
|
publishStatic,
|
|
11
13
|
versionCommand
|
|
12
14
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli-commands.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * QCObjects Framework CLI\n * ________________\n *\n * Author: Jean Machuca <correojean@gmail.com>\n *\n * Cross Browser Javascript Framework for MVC Patterns\n * QCObjects is licensed under the MIT License\n * [LICENSE] (https://github.com/QCObjects/qcobjects-cli/blob/main/LICENSE.txt)\n *\n * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>\n *\n * Everyone is permitted to copy and distribute verbatim copies of this\n * license document, but changing it is not allowed.\n*/\n/*eslint no-unused-vars: \"off\"*/\n/*eslint no-redeclare: \"off\"*/\n/*eslint no-empty: \"off\"*/\n/*eslint strict: \"off\"*/\n/*eslint no-mixed-operators: \"off\"*/\n/*eslint no-undef: \"off\"*/\n\"use strict\";\n\n// plugin commands here\n\nexport * as versionCommand from \"./cli-commands-version\";\nexport * as jiraCommand from \"./cli-commands-jira\";\nexport * as publishStatic from \"./cli-commands-publish-static\";\nexport * as buildTypescript from \"./cli-commands-build-typescript\";\nexport * as buildEsbuild from \"./cli-commands-build-esbuild\";"],
|
|
5
|
-
"mappings": "AAyBA,YAAY,oBAAoB;AAChC,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,YAAY,qBAAqB;AACjC,YAAY,kBAAkB;",
|
|
4
|
+
"sourcesContent": ["/**\n * QCObjects Framework CLI\n * ________________\n *\n * Author: Jean Machuca <correojean@gmail.com>\n *\n * Cross Browser Javascript Framework for MVC Patterns\n * QCObjects is licensed under the MIT License\n * [LICENSE] (https://github.com/QCObjects/qcobjects-cli/blob/main/LICENSE.txt)\n *\n * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>\n *\n * Everyone is permitted to copy and distribute verbatim copies of this\n * license document, but changing it is not allowed.\n*/\n/*eslint no-unused-vars: \"off\"*/\n/*eslint no-redeclare: \"off\"*/\n/*eslint no-empty: \"off\"*/\n/*eslint strict: \"off\"*/\n/*eslint no-mixed-operators: \"off\"*/\n/*eslint no-undef: \"off\"*/\n\"use strict\";\n\n// plugin commands here\n\nexport * as versionCommand from \"./cli-commands-version\";\nexport * as jiraCommand from \"./cli-commands-jira\";\nexport * as publishStatic from \"./cli-commands-publish-static\";\nexport * as buildTypescript from \"./cli-commands-build-typescript\";\nexport * as buildEsbuild from \"./cli-commands-build-esbuild\";\nexport * as lintCommand from \"./cli-commands-lint\";"],
|
|
5
|
+
"mappings": "AAyBA,YAAY,oBAAoB;AAChC,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,YAAY,qBAAqB;AACjC,YAAY,kBAAkB;AAC9B,YAAY,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/public/types/index.d.ts
CHANGED
|
@@ -92,6 +92,20 @@ declare module "cli-commands-jira" {
|
|
|
92
92
|
getIssueList(): Promise<void>;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
declare module "cli-commands-lint" {
|
|
96
|
+
import { InheritClass } from "qcobjects";
|
|
97
|
+
export class CommandHandler extends InheritClass {
|
|
98
|
+
choiceOption: {
|
|
99
|
+
lint: (targets: string[], options: {
|
|
100
|
+
fix?: boolean;
|
|
101
|
+
config?: string;
|
|
102
|
+
}) => Promise<void>;
|
|
103
|
+
};
|
|
104
|
+
constructor({ switchCommander }: {
|
|
105
|
+
switchCommander: any;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
95
109
|
declare module "cli-commands-publish-static" {
|
|
96
110
|
import { InheritClass } from "qcobjects";
|
|
97
111
|
export class CommandHandler extends InheritClass {
|
|
@@ -118,6 +132,7 @@ declare module "cli-commands" {
|
|
|
118
132
|
export * as publishStatic from "cli-commands-publish-static";
|
|
119
133
|
export * as buildTypescript from "cli-commands-build-typescript";
|
|
120
134
|
export * as buildEsbuild from "cli-commands-build-esbuild";
|
|
135
|
+
export * as lintCommand from "cli-commands-lint";
|
|
121
136
|
}
|
|
122
137
|
declare module "defaultsettings" {
|
|
123
138
|
import "qcobjects";
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects Framework CLI
|
|
3
|
+
* ________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QCObjects is licensed under the MIT License
|
|
9
|
+
* [LICENSE] (https://github.com/QCObjects/qcobjects-cli/blob/main/LICENSE.txt)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
12
|
+
*
|
|
13
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
14
|
+
* license document, but changing it is not allowed.
|
|
15
|
+
*/
|
|
16
|
+
/*eslint no-unused-vars: "off"*/
|
|
17
|
+
/*eslint no-redeclare: "off"*/
|
|
18
|
+
/*eslint no-empty: "off"*/
|
|
19
|
+
/*eslint strict: "off"*/
|
|
20
|
+
/*eslint no-mixed-operators: "off"*/
|
|
21
|
+
/*eslint no-undef: "off"*/
|
|
22
|
+
"use strict";
|
|
23
|
+
import fs from "node:fs";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { pathToFileURL } from "node:url";
|
|
26
|
+
import glob from "glob";
|
|
27
|
+
import { Linter } from "eslint";
|
|
28
|
+
import globals from "globals";
|
|
29
|
+
import * as tsParserModule from "@typescript-eslint/parser";
|
|
30
|
+
import * as tsPluginModule from "@typescript-eslint/eslint-plugin";
|
|
31
|
+
import { Package, InheritClass } from "qcobjects";
|
|
32
|
+
|
|
33
|
+
const tsParser = (tsParserModule as any).default ?? tsParserModule;
|
|
34
|
+
const tsPlugin = (tsPluginModule as any).default ?? tsPluginModule;
|
|
35
|
+
|
|
36
|
+
const DEFAULT_TARGETS = ["src/**/*.ts"];
|
|
37
|
+
|
|
38
|
+
const DEFAULT_IGNORES = [
|
|
39
|
+
"node_modules/**",
|
|
40
|
+
"build/**",
|
|
41
|
+
"public/**",
|
|
42
|
+
"dist/**",
|
|
43
|
+
"coverage/**",
|
|
44
|
+
".git/**",
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const DEFAULT_FLAT_CONFIG: any[] = [
|
|
48
|
+
{
|
|
49
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
50
|
+
plugins: {
|
|
51
|
+
"@typescript-eslint": tsPlugin,
|
|
52
|
+
},
|
|
53
|
+
languageOptions: {
|
|
54
|
+
parser: tsParser,
|
|
55
|
+
ecmaVersion: "latest",
|
|
56
|
+
sourceType: "module",
|
|
57
|
+
globals: {
|
|
58
|
+
...globals.browser,
|
|
59
|
+
...globals.node,
|
|
60
|
+
...globals.commonjs,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
rules: {
|
|
64
|
+
"no-undef": "error",
|
|
65
|
+
"no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
66
|
+
"no-empty": "off",
|
|
67
|
+
"no-constant-condition": "off",
|
|
68
|
+
"no-redeclare": "off",
|
|
69
|
+
"no-var": "off",
|
|
70
|
+
"no-mixed-operators": "off",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
export class CommandHandler extends InheritClass {
|
|
76
|
+
choiceOption: {
|
|
77
|
+
lint: (targets: string[], options: { fix?: boolean; config?: string }) => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
constructor({
|
|
81
|
+
switchCommander
|
|
82
|
+
}: { switchCommander: any }) {
|
|
83
|
+
super({ switchCommander });
|
|
84
|
+
this.choiceOption = {
|
|
85
|
+
async lint(targets, options) {
|
|
86
|
+
try {
|
|
87
|
+
const cwd = process.cwd();
|
|
88
|
+
const requestedTargets = targets.length > 0 ? targets : DEFAULT_TARGETS;
|
|
89
|
+
const ignoreFlags = DEFAULT_IGNORES.map(ignored => new RegExp(ignored.replace(/\*\*/g, ".*")));
|
|
90
|
+
const files = requestedTargets
|
|
91
|
+
.flatMap(target => glob.sync(target, { cwd, nodir: true }))
|
|
92
|
+
.filter((file: string) => !ignoreFlags.some(flag => flag.test(file)));
|
|
93
|
+
|
|
94
|
+
if (files.length === 0) {
|
|
95
|
+
console.warn(`No files matched: ${requestedTargets.join(", ")}`);
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let flatConfig = DEFAULT_FLAT_CONFIG;
|
|
100
|
+
const appConfigPath = ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"]
|
|
101
|
+
.map(name => path.resolve(cwd, name))
|
|
102
|
+
.find(appConfigPath => fs.existsSync(appConfigPath));
|
|
103
|
+
|
|
104
|
+
if (options.config) {
|
|
105
|
+
const explicitConfigPath = path.resolve(cwd, options.config);
|
|
106
|
+
if (!fs.existsSync(explicitConfigPath)) {
|
|
107
|
+
console.warn(`Config file not found: ${explicitConfigPath}`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
flatConfig = (await import(pathToFileURL(explicitConfigPath).href)).default;
|
|
111
|
+
console.log(`Using config file: ${explicitConfigPath}`);
|
|
112
|
+
} else if (appConfigPath) {
|
|
113
|
+
flatConfig = (await import(pathToFileURL(appConfigPath).href)).default;
|
|
114
|
+
console.log(`Using app config file: ${appConfigPath}`);
|
|
115
|
+
} else if (fs.existsSync(path.resolve(cwd, ".eslintrc")) || fs.existsSync(path.resolve(cwd, ".eslintrc.js")) || fs.existsSync(path.resolve(cwd, ".eslintrc.cjs")) || fs.existsSync(path.resolve(cwd, ".eslintrc.json"))) {
|
|
116
|
+
console.warn("Legacy .eslintrc config detected but not supported; using built-in QCObjects settings. Migrate to eslint.config.mjs to override defaults.");
|
|
117
|
+
} else {
|
|
118
|
+
console.log("No app eslint config found. Using built-in QCObjects settings (overridable with an eslint.config.mjs in your app).");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const linter = new Linter({ cwd, configType: "flat" });
|
|
122
|
+
let errorCount = 0;
|
|
123
|
+
let warningCount = 0;
|
|
124
|
+
let fixedCount = 0;
|
|
125
|
+
|
|
126
|
+
for (const file of files) {
|
|
127
|
+
const absolutePath = path.resolve(cwd, file);
|
|
128
|
+
const source = fs.readFileSync(absolutePath, "utf8");
|
|
129
|
+
const result: { fixed: boolean; output: string; messages: any[] } = options.fix
|
|
130
|
+
? linter.verifyAndFix(source, flatConfig, absolutePath)
|
|
131
|
+
: { fixed: false, output: source, messages: linter.verify(source, flatConfig, absolutePath) };
|
|
132
|
+
if (result.fixed) {
|
|
133
|
+
fixedCount++;
|
|
134
|
+
fs.writeFileSync(absolutePath, result.output);
|
|
135
|
+
}
|
|
136
|
+
for (const message of result.messages) {
|
|
137
|
+
const severity = message.severity === 2 ? "error" : message.severity === 1 ? "warning" : "info";
|
|
138
|
+
const output = `${file}:${message.line}:${message.column} ${severity} ${message.message} (${message.ruleId ?? "parse"})`;
|
|
139
|
+
if (message.severity === 2) {
|
|
140
|
+
errorCount++;
|
|
141
|
+
console.error(output);
|
|
142
|
+
} else if (message.severity === 1) {
|
|
143
|
+
warningCount++;
|
|
144
|
+
console.warn(output);
|
|
145
|
+
} else {
|
|
146
|
+
console.log(output);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const summary = `${files.length} file(s) linted, ${errorCount} error(s), ${warningCount} warning(s), ${fixedCount} file(s) fixed.`;
|
|
152
|
+
if (errorCount > 0) {
|
|
153
|
+
console.error(summary);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
console.log(summary);
|
|
157
|
+
process.exit(0);
|
|
158
|
+
} catch (e: any) {
|
|
159
|
+
console.warn(`Something went wrong trying to lint: ${e.message}`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const commandHandler = this;
|
|
166
|
+
|
|
167
|
+
const lintCommand = switchCommander.program.command("lint [targets...]")
|
|
168
|
+
.allowExcessArguments(false)
|
|
169
|
+
.option("-f, --fix", "Automatically fix problems")
|
|
170
|
+
.option("-c, --config <path>", "Use a specific eslint config file")
|
|
171
|
+
.description("Lints JS/TS files using built-in QCObjects settings. Default target: src/**/*.ts")
|
|
172
|
+
.action(function (targets: string[], options: { fix?: boolean; config?: string }) {
|
|
173
|
+
commandHandler.choiceOption.lint.call(commandHandler, targets ?? [], options);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
Package("com.qcobjects.cli.commands.lint", [
|
|
180
|
+
CommandHandler
|
|
181
|
+
]);
|
package/src/cli-commands.ts
CHANGED
|
@@ -27,4 +27,5 @@ export * as versionCommand from "./cli-commands-version";
|
|
|
27
27
|
export * as jiraCommand from "./cli-commands-jira";
|
|
28
28
|
export * as publishStatic from "./cli-commands-publish-static";
|
|
29
29
|
export * as buildTypescript from "./cli-commands-build-typescript";
|
|
30
|
-
export * as buildEsbuild from "./cli-commands-build-esbuild";
|
|
30
|
+
export * as buildEsbuild from "./cli-commands-build-esbuild";
|
|
31
|
+
export * as lintCommand from "./cli-commands-lint";
|