@jpp-toolkit/plugin-lint 0.0.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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Julien Papini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import * as _oclif_core_interfaces0 from "@oclif/core/interfaces";
3
+
4
+ //#region src/lint-command.d.ts
5
+ declare class LintCommand extends Command {
6
+ static summary: string;
7
+ static flags: {
8
+ format: _oclif_core_interfaces0.BooleanFlag<boolean>;
9
+ root: _oclif_core_interfaces0.BooleanFlag<boolean>;
10
+ };
11
+ static examples: {
12
+ description: string;
13
+ command: string;
14
+ }[];
15
+ run(): Promise<void>;
16
+ }
17
+ //#endregion
18
+ //#region src/index.d.ts
19
+ declare const commands: {
20
+ lint: typeof LintCommand;
21
+ };
22
+ //#endregion
23
+ export { commands };
24
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,73 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import { buildEslintArgs, buildPrettierArgs, findProjectRoot } from "@jpp-toolkit/utils";
3
+ import { Flags } from "@oclif/core";
4
+ import { execa } from "execa";
5
+
6
+ //#region src/lint-command.ts
7
+ var LintCommand = class LintCommand extends Command {
8
+ static summary = "Run code linting on the project source code.";
9
+ static flags = {
10
+ format: Flags.boolean({
11
+ char: "f",
12
+ description: "Automatically fix linting issues.",
13
+ default: false
14
+ }),
15
+ root: Flags.boolean({
16
+ char: "R",
17
+ description: "Lint from the project root directory.",
18
+ default: false
19
+ })
20
+ };
21
+ static examples = [
22
+ {
23
+ description: "Run the lint command.",
24
+ command: "<%= config.bin %> <%= command.id %>"
25
+ },
26
+ {
27
+ description: "Run the lint command and automatically fix issues.",
28
+ command: "<%= config.bin %> <%= command.id %> --format"
29
+ },
30
+ {
31
+ description: "Run the lint command from the project root directory.",
32
+ command: "<%= config.bin %> <%= command.id %> --root"
33
+ }
34
+ ];
35
+ async run() {
36
+ const { flags } = await this.parse(LintCommand);
37
+ const cwd = flags.root ? findProjectRoot() : process.cwd();
38
+ const mode = flags.format ? "formatting" : "linting";
39
+ this.logger.info(`Running Prettier ${mode}...`);
40
+ const prettierResult = await execa("prettier", buildPrettierArgs({ format: flags.format }), {
41
+ cwd,
42
+ stdio: "inherit",
43
+ preferLocal: true,
44
+ reject: false
45
+ });
46
+ if (prettierResult.failed) this.logger.error(`Prettier ${mode} failed.`);
47
+ else this.logger.success(`Prettier ${mode} completed successfully.`);
48
+ this.logger.log();
49
+ this.logger.info(`Running ESLint ${mode}...`);
50
+ const eslintResult = await execa("eslint", buildEslintArgs({ format: flags.format }), {
51
+ cwd,
52
+ stdio: "inherit",
53
+ preferLocal: true,
54
+ reject: false
55
+ });
56
+ if (eslintResult.failed) this.logger.error(`ESLint ${mode} failed.`);
57
+ else this.logger.success(`ESLint ${mode} completed successfully.`);
58
+ this.logger.log();
59
+ if (!prettierResult.failed && !eslintResult.failed) this.logger.success(`Linting process completed successfully.`);
60
+ else {
61
+ this.logger.error(`Linting process encountered issues.`);
62
+ process.exit(1);
63
+ }
64
+ }
65
+ };
66
+
67
+ //#endregion
68
+ //#region src/index.ts
69
+ const commands = { lint: LintCommand };
70
+
71
+ //#endregion
72
+ export { commands };
73
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/lint-command.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@jpp-toolkit/core';\nimport { buildEslintArgs, buildPrettierArgs, findProjectRoot } from '@jpp-toolkit/utils';\nimport { Flags } from '@oclif/core';\nimport { execa } from 'execa';\n\nexport class LintCommand extends Command {\n static override summary = 'Run code linting on the project source code.';\n\n static override flags = {\n format: Flags.boolean({\n char: 'f',\n description: 'Automatically fix linting issues.',\n default: false,\n }),\n root: Flags.boolean({\n char: 'R',\n description: 'Lint from the project root directory.',\n default: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Run the lint command.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Run the lint command and automatically fix issues.',\n command: '<%= config.bin %> <%= command.id %> --format',\n },\n {\n description: 'Run the lint command from the project root directory.',\n command: '<%= config.bin %> <%= command.id %> --root',\n },\n ];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(LintCommand);\n\n const cwd = flags.root ? findProjectRoot() : process.cwd();\n const mode = flags.format ? 'formatting' : 'linting';\n\n this.logger.info(`Running Prettier ${mode}...`);\n const prettierResult = await execa(\n 'prettier',\n buildPrettierArgs({ format: flags.format }),\n {\n cwd,\n stdio: 'inherit',\n preferLocal: true,\n reject: false,\n },\n );\n if (prettierResult.failed) this.logger.error(`Prettier ${mode} failed.`);\n else this.logger.success(`Prettier ${mode} completed successfully.`);\n this.logger.log();\n\n this.logger.info(`Running ESLint ${mode}...`);\n const eslintResult = await execa('eslint', buildEslintArgs({ format: flags.format }), {\n cwd,\n stdio: 'inherit',\n preferLocal: true,\n reject: false,\n });\n if (eslintResult.failed) this.logger.error(`ESLint ${mode} failed.`);\n else this.logger.success(`ESLint ${mode} completed successfully.`);\n this.logger.log();\n\n if (!prettierResult.failed && !eslintResult.failed) {\n this.logger.success(`Linting process completed successfully.`);\n } else {\n this.logger.error(`Linting process encountered issues.`);\n process.exit(1);\n }\n }\n}\n","import { LintCommand } from './lint-command';\n\nexport const commands = {\n lint: LintCommand,\n};\n"],"mappings":";;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoB,QAAQ;CACrC,OAAgB,UAAU;CAE1B,OAAgB,QAAQ;EACpB,QAAQ,MAAM,QAAQ;GAClB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACF,MAAM,MAAM,QAAQ;GAChB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,YAAY;EAE/C,MAAM,MAAM,MAAM,OAAO,iBAAiB,GAAG,QAAQ,KAAK;EAC1D,MAAM,OAAO,MAAM,SAAS,eAAe;AAE3C,OAAK,OAAO,KAAK,oBAAoB,KAAK,KAAK;EAC/C,MAAM,iBAAiB,MAAM,MACzB,YACA,kBAAkB,EAAE,QAAQ,MAAM,QAAQ,CAAC,EAC3C;GACI;GACA,OAAO;GACP,aAAa;GACb,QAAQ;GACX,CACJ;AACD,MAAI,eAAe,OAAQ,MAAK,OAAO,MAAM,YAAY,KAAK,UAAU;MACnE,MAAK,OAAO,QAAQ,YAAY,KAAK,0BAA0B;AACpE,OAAK,OAAO,KAAK;AAEjB,OAAK,OAAO,KAAK,kBAAkB,KAAK,KAAK;EAC7C,MAAM,eAAe,MAAM,MAAM,UAAU,gBAAgB,EAAE,QAAQ,MAAM,QAAQ,CAAC,EAAE;GAClF;GACA,OAAO;GACP,aAAa;GACb,QAAQ;GACX,CAAC;AACF,MAAI,aAAa,OAAQ,MAAK,OAAO,MAAM,UAAU,KAAK,UAAU;MAC/D,MAAK,OAAO,QAAQ,UAAU,KAAK,0BAA0B;AAClE,OAAK,OAAO,KAAK;AAEjB,MAAI,CAAC,eAAe,UAAU,CAAC,aAAa,OACxC,MAAK,OAAO,QAAQ,0CAA0C;OAC3D;AACH,QAAK,OAAO,MAAM,sCAAsC;AACxD,WAAQ,KAAK,EAAE;;;;;;;ACtE3B,MAAa,WAAW,EACpB,MAAM,aACT"}
@@ -0,0 +1,8 @@
1
+ export default {
2
+ description: 'Plugin that add the lint command to the jpp cli.',
3
+ commands: {
4
+ strategy: 'explicit',
5
+ target: './dist/index.mjs',
6
+ identifier: 'commands',
7
+ },
8
+ };
@@ -0,0 +1,47 @@
1
+ {
2
+ "commands": {
3
+ "lint": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "examples": [
7
+ {
8
+ "description": "Run the lint command.",
9
+ "command": "<%= config.bin %> <%= command.id %>"
10
+ },
11
+ {
12
+ "description": "Run the lint command and automatically fix issues.",
13
+ "command": "<%= config.bin %> <%= command.id %> --format"
14
+ },
15
+ {
16
+ "description": "Run the lint command from the project root directory.",
17
+ "command": "<%= config.bin %> <%= command.id %> --root"
18
+ }
19
+ ],
20
+ "flags": {
21
+ "format": {
22
+ "char": "f",
23
+ "description": "Automatically fix linting issues.",
24
+ "name": "format",
25
+ "allowNo": false,
26
+ "type": "boolean"
27
+ },
28
+ "root": {
29
+ "char": "R",
30
+ "description": "Lint from the project root directory.",
31
+ "name": "root",
32
+ "allowNo": false,
33
+ "type": "boolean"
34
+ }
35
+ },
36
+ "hasDynamicHelp": false,
37
+ "hiddenAliases": [],
38
+ "id": "lint",
39
+ "pluginAlias": "@jpp-toolkit/plugin-lint",
40
+ "pluginName": "@jpp-toolkit/plugin-lint",
41
+ "pluginType": "core",
42
+ "strict": true,
43
+ "summary": "Run code linting on the project source code."
44
+ }
45
+ },
46
+ "version": "0.0.11"
47
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@jpp-toolkit/plugin-lint",
3
+ "version": "0.0.11",
4
+ "description": "Plugin that add the lint command to the jpp cli.",
5
+ "keywords": [
6
+ "jpp",
7
+ "plugin",
8
+ "lint"
9
+ ],
10
+ "homepage": "https://github.com/jpapini/jpp-toolkit/tree/main/packages/plugin-lint#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/jpapini/jpp-toolkit/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/jpapini/jpp-toolkit.git",
17
+ "directory": "packages/plugin-lint"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Julien Papini <julien.papini@gmail.com> (https://github.com/jpapini)",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.mts",
25
+ "default": "./dist/index.mjs"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "src",
32
+ "oclif.config.js",
33
+ "oclif.manifest.json"
34
+ ],
35
+ "dependencies": {
36
+ "@oclif/core": "4.8.0",
37
+ "execa": "9.6.1",
38
+ "@jpp-toolkit/core": "0.0.11",
39
+ "@jpp-toolkit/utils": "0.0.11"
40
+ },
41
+ "devDependencies": {
42
+ "oclif": "4.22.52"
43
+ },
44
+ "engines": {
45
+ "node": "24",
46
+ "pnpm": "10"
47
+ },
48
+ "volta": {
49
+ "extends": "../../package.json"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "typecheck": "tsc --noEmit --pretty",
56
+ "dev": "build-lib --watch",
57
+ "build": "build-lib"
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { LintCommand } from './lint-command';
2
+
3
+ export const commands = {
4
+ lint: LintCommand,
5
+ };
@@ -0,0 +1,76 @@
1
+ import { Command } from '@jpp-toolkit/core';
2
+ import { buildEslintArgs, buildPrettierArgs, findProjectRoot } from '@jpp-toolkit/utils';
3
+ import { Flags } from '@oclif/core';
4
+ import { execa } from 'execa';
5
+
6
+ export class LintCommand extends Command {
7
+ static override summary = 'Run code linting on the project source code.';
8
+
9
+ static override flags = {
10
+ format: Flags.boolean({
11
+ char: 'f',
12
+ description: 'Automatically fix linting issues.',
13
+ default: false,
14
+ }),
15
+ root: Flags.boolean({
16
+ char: 'R',
17
+ description: 'Lint from the project root directory.',
18
+ default: false,
19
+ }),
20
+ };
21
+
22
+ static override examples = [
23
+ {
24
+ description: 'Run the lint command.',
25
+ command: '<%= config.bin %> <%= command.id %>',
26
+ },
27
+ {
28
+ description: 'Run the lint command and automatically fix issues.',
29
+ command: '<%= config.bin %> <%= command.id %> --format',
30
+ },
31
+ {
32
+ description: 'Run the lint command from the project root directory.',
33
+ command: '<%= config.bin %> <%= command.id %> --root',
34
+ },
35
+ ];
36
+
37
+ public async run(): Promise<void> {
38
+ const { flags } = await this.parse(LintCommand);
39
+
40
+ const cwd = flags.root ? findProjectRoot() : process.cwd();
41
+ const mode = flags.format ? 'formatting' : 'linting';
42
+
43
+ this.logger.info(`Running Prettier ${mode}...`);
44
+ const prettierResult = await execa(
45
+ 'prettier',
46
+ buildPrettierArgs({ format: flags.format }),
47
+ {
48
+ cwd,
49
+ stdio: 'inherit',
50
+ preferLocal: true,
51
+ reject: false,
52
+ },
53
+ );
54
+ if (prettierResult.failed) this.logger.error(`Prettier ${mode} failed.`);
55
+ else this.logger.success(`Prettier ${mode} completed successfully.`);
56
+ this.logger.log();
57
+
58
+ this.logger.info(`Running ESLint ${mode}...`);
59
+ const eslintResult = await execa('eslint', buildEslintArgs({ format: flags.format }), {
60
+ cwd,
61
+ stdio: 'inherit',
62
+ preferLocal: true,
63
+ reject: false,
64
+ });
65
+ if (eslintResult.failed) this.logger.error(`ESLint ${mode} failed.`);
66
+ else this.logger.success(`ESLint ${mode} completed successfully.`);
67
+ this.logger.log();
68
+
69
+ if (!prettierResult.failed && !eslintResult.failed) {
70
+ this.logger.success(`Linting process completed successfully.`);
71
+ } else {
72
+ this.logger.error(`Linting process encountered issues.`);
73
+ process.exit(1);
74
+ }
75
+ }
76
+ }