eslint-plugin-file-progress
Advanced tools
Comparing version 1.2.1 to 1.3.0
{ | ||
"name": "eslint-plugin-file-progress", | ||
"description": "Eslint plugin to print file progress", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -35,8 +35,8 @@ "author": "sibiraj-s", | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.0.2", | ||
"@commitlint/config-conventional": "^17.0.2", | ||
"@types/node": "^16.11.38", | ||
"eslint": "^8.16.0", | ||
"@commitlint/cli": "^17.0.3", | ||
"@commitlint/config-conventional": "^17.0.3", | ||
"@types/node": "^16.11.41", | ||
"eslint": "^8.18.0", | ||
"eslint-config-pegasus": "^3.3.0", | ||
"eslint-plugin-eslint-plugin": "^4.2.0", | ||
"eslint-plugin-eslint-plugin": "^4.3.0", | ||
"eslint-plugin-file-progress": "file:.", | ||
@@ -43,0 +43,0 @@ "husky": "^8.0.1", |
@@ -29,2 +29,7 @@ # eslint-plugin-file-progress | ||
file-progress/activate: 1 | ||
settings: | ||
progress: | ||
hide: false # hides the progress with spinner. Print's a static `Linting...` text | ||
successMessage: "Lint done..." | ||
``` | ||
@@ -37,1 +42,22 @@ | ||
![Progress](assets/progress.gif) | ||
### Only on CLI | ||
Some eslint plugins for code editors may conflict with this plugin rule (or, in that context, a file progress is not relevant) | ||
```bash | ||
npx eslint . --plugin file-progress --rule 'file-progress/activate: 1' | ||
``` | ||
Or, in your package.json's command: | ||
```diff | ||
{ | ||
"scripts: [ | ||
- "lint": "eslint ./packages/" | ||
+ "lint": "eslint . --plugin file-progress --rule \"file-progress/activate: 1\"" | ||
] | ||
} | ||
``` | ||
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 |
@@ -10,23 +10,35 @@ const path = require('path'); | ||
let bindExit = false; | ||
let initialReportDone = false; | ||
const exitCallback = (exitCode) => { | ||
const defaultSettings = { | ||
hide: false, | ||
successMessage: 'Lint done.', | ||
}; | ||
const exitCallback = (exitCode, settings) => { | ||
if (exitCode === 0) { | ||
spinner.succeed('Lint done...'); | ||
spinner.succeed(settings.successMessage); | ||
} | ||
}; | ||
const rootPath = process.cwd(); | ||
const create = (context) => { | ||
const settings = { ...defaultSettings, ...context.settings.progress }; | ||
const create = (context) => { | ||
if (!bindExit) { | ||
process.on('exit', exitCallback); | ||
process.on('exit', (code) => { | ||
exitCallback(code, settings); | ||
}); | ||
bindExit = true; | ||
} | ||
const filename = context.getFilename(); | ||
const relativeFilePath = path.relative(rootPath, filename); | ||
if (!settings.hide) { | ||
const filename = context.getFilename(); | ||
const relativeFilePath = path.relative(context.getCwd(), filename); | ||
spinner.text = `Processing: ${chalk.green(relativeFilePath)} \n`; | ||
} else if (!initialReportDone) { | ||
spinner.text = 'Linting...\n'; | ||
initialReportDone = true; | ||
} | ||
spinner.text = `Processing: ${chalk.green(relativeFilePath)} \n`; | ||
spinner.render(); | ||
return {}; | ||
@@ -33,0 +45,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5047
47
62