eslint-plugin-file-progress-2 3.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/LICENSE +22 -0
- package/README.md +110 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +39 -0
- package/dist/rules/progress.d.ts +17 -0
- package/dist/rules/progress.js +109 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nick2bad4u
|
|
4
|
+
Copyright (c) 2020 Sibiraj
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# eslint-plugin-file-progress-2
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/eslint-plugin-file-progress-2)
|
|
4
|
+
[](https://github.com/Nick2bad4u/eslint-plugin-file-progress-2/blob/master/LICENSE)
|
|
5
|
+
[](https://github.com/Nick2bad4u/eslint-plugin-file-progress-2/actions)
|
|
6
|
+
|
|
7
|
+
> ESLint plugin to print file progress
|
|
8
|
+
|
|
9
|
+
> Fork note: Originally created by [@sibiraj-s](https://github.com/sibiraj-s) in [`eslint-plugin-file-progress`](https://github.com/sibiraj-s/eslint-plugin-file-progress). Huge thanks for the original plugin.
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i -D eslint-plugin-file-progress-2
|
|
17
|
+
# or
|
|
18
|
+
yarn add --dev eslint-plugin-file-progress-2
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
// eslint.config.js
|
|
25
|
+
import progress from "eslint-plugin-file-progress-2";
|
|
26
|
+
|
|
27
|
+
export default [
|
|
28
|
+
{
|
|
29
|
+
name: "progress",
|
|
30
|
+
plugins: {
|
|
31
|
+
"file-progress": progress,
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
"file-progress/activate": "warn",
|
|
35
|
+
},
|
|
36
|
+
settings: {
|
|
37
|
+
progress: {
|
|
38
|
+
hide: false, // hide progress output (useful in CI)
|
|
39
|
+
hideFileName: false, // show generic "Linting..." instead of file names
|
|
40
|
+
successMessage: "Lint done...",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or use the recommended config
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// eslint.config.js
|
|
51
|
+
import progress from "eslint-plugin-file-progress-2";
|
|
52
|
+
|
|
53
|
+
export default [progress.configs.recommended];
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
or if you want to hide the progress message in CI
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
// eslint.config.js
|
|
60
|
+
import progress from "eslint-plugin-file-progress-2";
|
|
61
|
+
|
|
62
|
+
export default [progress.configs["recommended-ci"]];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This configuration is similar to the recommended one, but it automatically detects CI environments by checking if the `CI` environment variable is set to `true`, and hides the progress message accordingly.
|
|
66
|
+
|
|
67
|
+
For CI's where CI is not set to `true`, you can use the `settings.progress.hide` option to hide the progress message.
|
|
68
|
+
|
|
69
|
+
### Demo
|
|
70
|
+
|
|
71
|
+
Who likes a silent console ¯\\\_(ツ)\_/¯
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
### Only on CLI
|
|
76
|
+
|
|
77
|
+
Some eslint plugins for code editors may conflict with this plugin rule (or, in that context, a file progress is not relevant)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx eslint . --plugin file-progress --rule 'file-progress/activate: warn'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or, in your package.json's command:
|
|
84
|
+
|
|
85
|
+
```diff
|
|
86
|
+
{
|
|
87
|
+
"scripts": {
|
|
88
|
+
- "lint": "eslint .",
|
|
89
|
+
+ "lint": "eslint . --plugin file-progress --rule \"file-progress/activate: warn\""
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use `file-progress/activate: 0` to disable the plugin. See https://eslint.org/docs/latest/user-guide/command-line-interface#specifying-rules-and-plugins for more details on how to use CLI
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
This project is authored in TypeScript (`src/**`) and publishes compiled artifacts from `dist/**`.
|
|
99
|
+
Linting uses `@typescript-eslint/eslint-plugin` with the flat `recommended-type-checked` config.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm run lint
|
|
103
|
+
npm run typecheck
|
|
104
|
+
npm run test
|
|
105
|
+
npm run build
|
|
106
|
+
npm run format
|
|
107
|
+
npm run check
|
|
108
|
+
npm run publint
|
|
109
|
+
npm run release:verify
|
|
110
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import progressRule from "./rules/progress.js";
|
|
2
|
+
const env = process.env;
|
|
3
|
+
const plugin = {
|
|
4
|
+
meta: {
|
|
5
|
+
name: "eslint-plugin-file-progress-2",
|
|
6
|
+
version: "3.0.2",
|
|
7
|
+
},
|
|
8
|
+
configs: {},
|
|
9
|
+
rules: {
|
|
10
|
+
activate: progressRule,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
const configs = {
|
|
14
|
+
recommended: {
|
|
15
|
+
name: "file-progress/recommended",
|
|
16
|
+
plugins: {
|
|
17
|
+
"file-progress": plugin,
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
"file-progress/activate": "warn",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"recommended-ci": {
|
|
24
|
+
name: "file-progress/recommended-ci",
|
|
25
|
+
plugins: {
|
|
26
|
+
"file-progress": plugin,
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
"file-progress/activate": "warn",
|
|
30
|
+
},
|
|
31
|
+
settings: {
|
|
32
|
+
progress: {
|
|
33
|
+
hide: env.CI === "true",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
Object.assign(plugin.configs, configs);
|
|
39
|
+
export default plugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
export interface NormalizedProgressSettings {
|
|
3
|
+
hide: boolean;
|
|
4
|
+
hideFileName: boolean;
|
|
5
|
+
successMessage: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ProgressInternals {
|
|
8
|
+
defaultSettings: Readonly<NormalizedProgressSettings>;
|
|
9
|
+
normalizeSettings: (raw: unknown) => NormalizedProgressSettings;
|
|
10
|
+
toRelativeFilePath: (filename: string, cwd: string) => string;
|
|
11
|
+
formatFileProgress: (relativeFilePath: string) => string;
|
|
12
|
+
formatGenericProgress: () => string;
|
|
13
|
+
formatSuccessMessage: (settings: NormalizedProgressSettings) => string;
|
|
14
|
+
}
|
|
15
|
+
declare const progressRule: Rule.RuleModule;
|
|
16
|
+
export declare const internals: ProgressInternals;
|
|
17
|
+
export default progressRule;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createSpinner } from "nanospinner";
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
const spinner = createSpinner("", {
|
|
5
|
+
frames: ["|", "/", "-", "\\"],
|
|
6
|
+
color: "cyan",
|
|
7
|
+
});
|
|
8
|
+
const defaultSettings = Object.freeze({
|
|
9
|
+
hide: false,
|
|
10
|
+
hideFileName: false,
|
|
11
|
+
successMessage: "Lint complete.",
|
|
12
|
+
});
|
|
13
|
+
const pluginPrefix = `${pc.bold(pc.cyan("eslint-file-progress"))} ${pc.dim("•")}`;
|
|
14
|
+
let isExitHandlerBound = false;
|
|
15
|
+
let initialReportDone = false;
|
|
16
|
+
let lastVisibleSettings = { ...defaultSettings };
|
|
17
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
18
|
+
const normalizeSettings = (raw) => {
|
|
19
|
+
if (!isRecord(raw)) {
|
|
20
|
+
return { ...defaultSettings };
|
|
21
|
+
}
|
|
22
|
+
const typedRaw = raw;
|
|
23
|
+
const hide = typedRaw.hide === true;
|
|
24
|
+
const hideFileName = typedRaw.hideFileName === true;
|
|
25
|
+
const successMessage = typeof typedRaw.successMessage === "string" && typedRaw.successMessage.trim().length > 0
|
|
26
|
+
? typedRaw.successMessage.trim()
|
|
27
|
+
: defaultSettings.successMessage;
|
|
28
|
+
return {
|
|
29
|
+
hide,
|
|
30
|
+
hideFileName,
|
|
31
|
+
successMessage,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const toRelativeFilePath = (filename, cwd) => {
|
|
35
|
+
if (!filename || filename === "<input>") {
|
|
36
|
+
return filename || "<input>";
|
|
37
|
+
}
|
|
38
|
+
const isWindowsAbsolutePath = path.win32.isAbsolute(filename);
|
|
39
|
+
const isNativeAbsolutePath = path.isAbsolute(filename);
|
|
40
|
+
if (!isNativeAbsolutePath && !isWindowsAbsolutePath) {
|
|
41
|
+
return filename;
|
|
42
|
+
}
|
|
43
|
+
const effectiveCwd = cwd || process.cwd();
|
|
44
|
+
const relativePath = isWindowsAbsolutePath
|
|
45
|
+
? path.win32.relative(effectiveCwd, filename)
|
|
46
|
+
: path.relative(effectiveCwd, filename);
|
|
47
|
+
if (relativePath.length === 0) {
|
|
48
|
+
return isWindowsAbsolutePath ? path.win32.basename(filename) : path.basename(filename);
|
|
49
|
+
}
|
|
50
|
+
return relativePath;
|
|
51
|
+
};
|
|
52
|
+
const formatFileProgress = (relativeFilePath) => `${pluginPrefix} ${pc.dim("linting")} ${pc.green(relativeFilePath)}`;
|
|
53
|
+
const formatGenericProgress = () => `${pluginPrefix} ${pc.dim("linting project files...")}`;
|
|
54
|
+
const formatSuccessMessage = (settings) => `${pluginPrefix} ${pc.bold(pc.green("✔"))} ${pc.green(settings.successMessage)}`;
|
|
55
|
+
const bindExitHandler = () => {
|
|
56
|
+
if (isExitHandlerBound) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
process.once("exit", (exitCode) => {
|
|
60
|
+
if (exitCode === 0 && lastVisibleSettings.hide !== true) {
|
|
61
|
+
spinner.success({ text: formatSuccessMessage(lastVisibleSettings) });
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
isExitHandlerBound = true;
|
|
65
|
+
};
|
|
66
|
+
const create = (context) => {
|
|
67
|
+
const settings = normalizeSettings(context.settings?.progress);
|
|
68
|
+
bindExitHandler();
|
|
69
|
+
if (settings.hide) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
lastVisibleSettings = settings;
|
|
73
|
+
if (settings.hideFileName) {
|
|
74
|
+
if (!initialReportDone) {
|
|
75
|
+
spinner.update({ text: formatGenericProgress() });
|
|
76
|
+
initialReportDone = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const relativeFilePath = toRelativeFilePath(context.filename, context.cwd);
|
|
81
|
+
spinner.update({ text: formatFileProgress(relativeFilePath) });
|
|
82
|
+
}
|
|
83
|
+
spinner.spin();
|
|
84
|
+
return {};
|
|
85
|
+
};
|
|
86
|
+
const progressRule = {
|
|
87
|
+
meta: {
|
|
88
|
+
type: "suggestion",
|
|
89
|
+
docs: {
|
|
90
|
+
description: "enforce displaying lint progress in CLI output.",
|
|
91
|
+
recommended: true,
|
|
92
|
+
url: "https://github.com/Nick2bad4u/eslint-plugin-file-progress-2#readme",
|
|
93
|
+
},
|
|
94
|
+
schema: [],
|
|
95
|
+
messages: {
|
|
96
|
+
status: "Display lint progress in CLI output.",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
create,
|
|
100
|
+
};
|
|
101
|
+
export const internals = {
|
|
102
|
+
defaultSettings,
|
|
103
|
+
normalizeSettings,
|
|
104
|
+
toRelativeFilePath,
|
|
105
|
+
formatFileProgress,
|
|
106
|
+
formatGenericProgress,
|
|
107
|
+
formatSuccessMessage,
|
|
108
|
+
};
|
|
109
|
+
export default progressRule;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Linter, Rule } from "eslint";
|
|
2
|
+
export interface ProgressSettings {
|
|
3
|
+
hide?: boolean;
|
|
4
|
+
hideFileName?: boolean;
|
|
5
|
+
successMessage?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FileProgressPlugin {
|
|
8
|
+
meta: {
|
|
9
|
+
name: "eslint-plugin-file-progress-2";
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
configs: {
|
|
13
|
+
recommended: Linter.Config;
|
|
14
|
+
"recommended-ci": Linter.Config;
|
|
15
|
+
};
|
|
16
|
+
rules: {
|
|
17
|
+
activate: Rule.RuleModule;
|
|
18
|
+
};
|
|
19
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-file-progress-2",
|
|
3
|
+
"description": "ESLint plugin to print file progress",
|
|
4
|
+
"version": "3.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Nick2bad4u",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Nick2bad4u/eslint-plugin-file-progress-2.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/Nick2bad4u/eslint-plugin-file-progress-2/issues",
|
|
12
|
+
"homepage": "https://github.com/Nick2bad4u/eslint-plugin-file-progress-2#readme",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"eslint",
|
|
25
|
+
"eslintplugin",
|
|
26
|
+
"eslint-plugin",
|
|
27
|
+
"eslint-plugin-file-progress",
|
|
28
|
+
"eslint-plugin-file-progress-2",
|
|
29
|
+
"eslint-progress",
|
|
30
|
+
"progress"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"provenance": true,
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/"
|
|
38
|
+
],
|
|
39
|
+
"contributors": [
|
|
40
|
+
{
|
|
41
|
+
"name": "sibiraj-s",
|
|
42
|
+
"url": "https://github.com/sibiraj-s"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "Nick2bad4u",
|
|
46
|
+
"url": "https://github.com/Nick2bad4u"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"readme": "README.md",
|
|
50
|
+
"prettier": "./.prettierrc.json",
|
|
51
|
+
"displayName": "eslint-plugin-file-progress-2",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"clean": "rimraf dist .cache/tsbuildinfo/tsconfig.build.tsbuildinfo",
|
|
54
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
55
|
+
"prelint": "npm run build",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
57
|
+
"lint": "eslint .",
|
|
58
|
+
"test": "tsx --test test/progress.test.ts",
|
|
59
|
+
"publint": "publint",
|
|
60
|
+
"format": "prettier --write .",
|
|
61
|
+
"format:check": "prettier --check .",
|
|
62
|
+
"check": "npm run lint && npm run typecheck && npm run test && npm run format:check",
|
|
63
|
+
"release:verify": "npm run check && npm run publint",
|
|
64
|
+
"release:publish": "npm run build && changeset publish",
|
|
65
|
+
"prepack": "npm run build"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=22.0.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"eslint": "^9.0.0 || ^10.0.2"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"nanospinner": "^1.2.2",
|
|
75
|
+
"picocolors": "^1.1.1"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@changesets/cli": "^2.29.8",
|
|
79
|
+
"@commitlint/cli": "^20.4.2",
|
|
80
|
+
"@commitlint/config-conventional": "^20.4.2",
|
|
81
|
+
"@types/node": "^25.3.0",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
83
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
84
|
+
"eslint": "^10.0.2",
|
|
85
|
+
"eslint-config-pegasus": "^6.0.2",
|
|
86
|
+
"eslint-plugin-eslint-plugin": "^7.3.1",
|
|
87
|
+
"husky": "^9.1.7",
|
|
88
|
+
"is-ci": "^4.1.0",
|
|
89
|
+
"prettier": "^3.8.1",
|
|
90
|
+
"publint": "^0.3.17",
|
|
91
|
+
"rimraf": "^6.1.3",
|
|
92
|
+
"tsx": "^4.21.0",
|
|
93
|
+
"typescript": "^5.9.3"
|
|
94
|
+
}
|
|
95
|
+
}
|