├── .changeset ├── README.md └── config.json ├── .commitlintrc.yml ├── .gitattributes ├── .github └── workflows │ ├── publish.yml │ └── test.yml ├── .gitignore ├── .husky ├── commit-msg ├── pre-commit └── pre-push ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets └── progress.gif ├── eslint.config.js ├── index.d.ts ├── index.js ├── package-lock.json ├── package.json ├── rules └── progress.js └── test.js /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "master", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.commitlintrc.yml: -------------------------------------------------------------------------------- 1 | extends: 2 | - '@commitlint/config-conventional' 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /.yarn/** linguist-vendored 2 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | concurrency: ${{ github.workflow }}-${{ github.ref }} 9 | 10 | env: 11 | NODE_VERSION: 22 12 | HUSKY: 0 13 | 14 | jobs: 15 | release: 16 | name: Release 17 | runs-on: ubuntu-latest 18 | permissions: 19 | contents: write 20 | pull-requests: write 21 | id-token: write 22 | steps: 23 | - name: Checkout Repo 24 | uses: actions/checkout@v4 25 | 26 | - name: Setup Node.js ${{ env.NODE_VERSION }} 27 | uses: actions/setup-node@v4 28 | with: 29 | node-version: ${{ env.NODE_VERSION }} 30 | 31 | - name: Install Dependencies 32 | run: npm ci 33 | 34 | - name: Create Release Pull Request or Publish to npm 35 | id: changesets 36 | uses: changesets/action@v1 37 | with: 38 | publish: npx changeset publish 39 | commit: 'release: version package' 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 43 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: master 6 | pull_request: 7 | branches: master 8 | 9 | env: 10 | NODE_VERSION: 22 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | 20 | - name: Use Node.js ${{ env.NODE_VERSION }} 21 | uses: actions/setup-node@v4 22 | with: 23 | node-version: ${{ env.NODE_VERSION }} 24 | cache: npm 25 | 26 | - name: Install dependencies 27 | run: npm ci 28 | 29 | - name: Run Tests 30 | run: npm run test 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Bower ### 2 | bower_components 3 | .bower-cache 4 | .bower-registry 5 | .bower-tmp 6 | 7 | ### grunt ### 8 | # Grunt usually compiles files inside this directory 9 | dist/ 10 | 11 | # Grunt usually preprocesses files such as coffeescript, compass... inside the .tmp directory 12 | .tmp/ 13 | 14 | ### Linux ### 15 | *~ 16 | 17 | # temporary files which can be created if a process still has a handle open of a deleted file 18 | .fuse_hidden* 19 | 20 | # KDE directory preferences 21 | .directory 22 | 23 | # Linux trash folder which might appear on any partition or disk 24 | .Trash-* 25 | 26 | # .nfs files are created when an open file is removed but is still being accessed 27 | .nfs* 28 | 29 | ### macOS ### 30 | # General 31 | .DS_Store 32 | .AppleDouble 33 | .LSOverride 34 | 35 | # Icon must end with two \r 36 | Icon 37 | 38 | # Thumbnails 39 | ._* 40 | 41 | # Files that might appear in the root of a volume 42 | .DocumentRevisions-V100 43 | .fseventsd 44 | .Spotlight-V100 45 | .TemporaryItems 46 | .Trashes 47 | .VolumeIcon.icns 48 | .com.apple.timemachine.donotpresent 49 | 50 | # Directories potentially created on remote AFP share 51 | .AppleDB 52 | .AppleDesktop 53 | Network Trash Folder 54 | Temporary Items 55 | .apdisk 56 | 57 | ### Node ### 58 | # Logs 59 | logs 60 | *.log 61 | npm-debug.log* 62 | yarn-debug.log* 63 | yarn-error.log* 64 | lerna-debug.log* 65 | 66 | # Diagnostic reports (https://nodejs.org/api/report.html) 67 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 68 | 69 | # Runtime data 70 | pids 71 | *.pid 72 | *.seed 73 | *.pid.lock 74 | 75 | # Directory for instrumented libs generated by jscoverage/JSCover 76 | lib-cov 77 | 78 | # Coverage directory used by tools like istanbul 79 | coverage 80 | *.lcov 81 | 82 | # nyc test coverage 83 | .nyc_output 84 | 85 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 86 | .grunt 87 | 88 | # Bower dependency directory (https://bower.io/) 89 | 90 | # node-waf configuration 91 | .lock-wscript 92 | 93 | # Compiled binary addons (https://nodejs.org/api/addons.html) 94 | build/Release 95 | 96 | # Dependency directories 97 | node_modules/ 98 | jspm_packages/ 99 | 100 | # TypeScript v1 declaration files 101 | typings/ 102 | 103 | # TypeScript cache 104 | *.tsbuildinfo 105 | 106 | # Optional npm cache directory 107 | .npm 108 | 109 | # Optional eslint cache 110 | .eslintcache 111 | 112 | # Microbundle cache 113 | .rpt2_cache/ 114 | .rts2_cache_cjs/ 115 | .rts2_cache_es/ 116 | .rts2_cache_umd/ 117 | 118 | # Optional REPL history 119 | .node_repl_history 120 | 121 | # Output of 'npm pack' 122 | *.tgz 123 | 124 | # Yarn Integrity file 125 | .yarn-integrity 126 | 127 | # dotenv environment variables file 128 | .env 129 | .env.test 130 | 131 | # parcel-bundler cache (https://parceljs.org/) 132 | .cache 133 | 134 | # Next.js build output 135 | .next 136 | 137 | # Nuxt.js build / generate output 138 | .nuxt 139 | dist 140 | 141 | # Gatsby files 142 | .cache/ 143 | # Comment in the public line in if your project uses Gatsby and not Next.js 144 | # https://nextjs.org/blog/next-9-1#public-directory-support 145 | # public 146 | 147 | # vuepress build output 148 | .vuepress/dist 149 | 150 | # Serverless directories 151 | .serverless/ 152 | 153 | # FuseBox cache 154 | .fusebox/ 155 | 156 | # DynamoDB Local files 157 | .dynamodb/ 158 | 159 | # TernJS port file 160 | .tern-port 161 | 162 | # Stores VSCode versions used for testing VSCode extensions 163 | .vscode-test 164 | 165 | ### Sass ### 166 | .sass-cache/ 167 | *.css.map 168 | *.sass.map 169 | *.scss.map 170 | 171 | ### Windows ### 172 | # Windows thumbnail cache files 173 | Thumbs.db 174 | Thumbs.db:encryptable 175 | ehthumbs.db 176 | ehthumbs_vista.db 177 | 178 | # Dump file 179 | *.stackdump 180 | 181 | # Folder config file 182 | [Dd]esktop.ini 183 | 184 | # Recycle Bin used on file shares 185 | $RECYCLE.BIN/ 186 | 187 | # Windows Installer files 188 | *.cab 189 | *.msi 190 | *.msix 191 | *.msm 192 | *.msp 193 | 194 | # Windows shortcuts 195 | *.lnk 196 | 197 | ### yarn ### 198 | # https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored 199 | 200 | # .yarn/unplugged and .yarn/build-state.yml should likely always be ignored since 201 | # they typically hold machine-specific build artifacts. Ignoring them might however 202 | # prevent Zero-Installs from working (to prevent this, set enableScripts to false). 203 | .yarn/* 204 | !.yarn/releases 205 | !.yarn/plugins 206 | !.yarn/sdks 207 | !.yarn/versions 208 | 209 | # .yarn/cache and .pnp.* may be safely ignored, but you'll need to run yarn install 210 | # to regenerate them between each branch switch. 211 | # Uncomment the following lines if you're not using Zero-Installs: 212 | .yarn/cache 213 | .pnp.* 214 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no-install commitlint --edit $1 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npm run lint 2 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | npm run test 2 | 3 | echo "\npublint:" 4 | npx --no -- publint 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## 3.0.2 4 | 5 | ### Patch Changes 6 | 7 | - fd02a52: hide status on exit with hide config option 8 | 9 | ## v3.0.1 (2024-11-09) 10 | 11 | ### Patch Changes 12 | 13 | - fix `hide` option to hide the progress message ([4228208](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/4228208)) 14 | - add `hideFileName` option to hide the file name during linting ([4228208](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/4228208)) 15 | 16 | ## v3.0.0 (2024-11-04) 17 | 18 | ### Breaking Changes 19 | 20 | - rename `noCI` config to `recommended-ci` ([f67c68a](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/f67c68a)) 21 | 22 | ## v2.1.2 (2024-11-04) 23 | 24 | ### Patch Changes 25 | 26 | - fix namespace for configuration presets ([cdf1726](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/cdf1726)) 27 | - fix `noCI` type not exported ([50825d2](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/50825d2)) 28 | 29 | ## v2.1.0 (2024-11-04) 30 | 31 | ### Features 32 | 33 | - add `recommended` and `noCI` configs ([5a581b6](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/5a581b6)) 34 | 35 | ## v2.0.1 (2024-11-04) 36 | 37 | ### Patch Changes 38 | 39 | - fix supported nodejs version range for eslint ([66e6b0b](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/66e6b0b)) 40 | 41 | ## v2.0.0 (2024-11-04) 42 | 43 | ### Breaking Changes 44 | 45 | - require eslint v9 ([e593243](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/e593243)) 46 | 47 | ## v1.5.0 (2024-08-12) 48 | 49 | #### Dependency Updates 50 | 51 | - replace `ora` with `nanospinner` ([96c5ccc](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/96c5ccc)) 52 | - replace `chalk` with `picocolors` ([96c5ccc](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/96c5ccc)) 53 | 54 | ## v1.4.0 (2024-05-11) 55 | 56 | #### Features 57 | 58 | - support eslint v9 ([dd74d77](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/dd74d77)) 59 | 60 | ## v1.3.0 (2022-06-27) 61 | 62 | #### Features 63 | 64 | - add option to hide progress ([21ae39a](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/21ae39a)) 65 | - add option to configure success message ([21ae39a](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/21ae39a)) 66 | 67 | #### Bug Fixes 68 | 69 | - print path relative to eslint project ([9c4600d](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/9c4600d)) 70 | 71 | ## v1.2.1 (2022-06-01) 72 | 73 | #### Bug Fixes 74 | 75 | - fix relative file path in windows ([9ebefd6](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/9ebefd6)) 76 | 77 | ## v1.2.0 (2021-10-18) 78 | 79 | #### Features 80 | 81 | - support eslint v8 ([46e1e38](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/46e1e38)) 82 | 83 | #### Internal 84 | 85 | - migrate to npm from yarn ([09c2da9](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/09c2da9)) 86 | - remove jest ([7fd164e](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/7fd164e)) 87 | 88 | ## v1.1.1 (2020-12-13) 89 | 90 | #### Internal 91 | 92 | - update LICENSE ([d3a365e](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/d3a365e)) 93 | 94 | ## v1.1.0 (2020-08-10) 95 | 96 | #### Enhancements 97 | 98 | - remove `cli-spinners` dependency ([9845971](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/9845971)) 99 | - color enhancements ([ee170ea](https://github.com/sibiraj-s/eslint-plugin-file-progress/commit/ee170ea)) 100 | 101 | ## v1.0.0 (2020-08-09) 102 | 103 | - **Initial Release**: Eslint plugin to print file progress 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sibiraj 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-file-progress 2 | 3 | [![Version](https://badgen.net/npm/v/eslint-plugin-file-progress)](https://www.npmjs.com/package/eslint-plugin-file-progress) 4 | [![Version](https://badgen.net/npm/license/eslint-plugin-file-progress?color=red)](https://github.com/sibiraj-s/eslint-plugin-file-progress/blob/master/LICENSE) 5 | [![Tests](https://github.com/sibiraj-s/eslint-plugin-file-progress/workflows/Tests/badge.svg)](https://github.com/sibiraj-s/eslint-plugin-file-progress/actions) 6 | 7 | > Eslint plugin to print file progress 8 | 9 | ## Getting Started 10 | 11 | ### Installation 12 | 13 | ```bash 14 | npm i -D eslint-plugin-file-progress 15 | # or 16 | yarn add --dev eslint-plugin-file-progress 17 | ``` 18 | 19 | ### Usage 20 | 21 | ```js 22 | // eslint.config.js 23 | 24 | { 25 | name: 'progress', 26 | plugins: { 27 | progress 28 | }, 29 | rules: { 30 | "progress/activate": 1 31 | }, 32 | settings: { 33 | progress: { 34 | hide: false, // use this to hide the progress message, can be useful in CI 35 | hideFileName: false, // use this to hide the file name, would simply show "Linting..." 36 | successMessage: "Lint done..." 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | Or use the recommended config 43 | 44 | ```js 45 | // eslint.config.js 46 | import progress from 'eslint-plugin-file-progress' 47 | 48 | export default [ 49 | progress.configs.recommended 50 | ] 51 | ``` 52 | 53 | or if you want to hide the progress message in CI 54 | 55 | ```js 56 | // eslint.config.js 57 | import progress from 'eslint-plugin-file-progress' 58 | 59 | export default [ 60 | progress.configs['recommended-ci'] 61 | ] 62 | ``` 63 | 64 | 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. 65 | 66 | For CI's where CI is not set to `true`, you can use the `settings.progress.hide` option to hide the progress message. 67 | 68 | ### Demo 69 | 70 | Who likes a silent console ¯\\\_(ツ)\_/¯ 71 | 72 | ![Progress](assets/progress.gif) 73 | 74 | ### Only on CLI 75 | 76 | Some eslint plugins for code editors may conflict with this plugin rule (or, in that context, a file progress is not relevant) 77 | 78 | ```bash 79 | npx eslint . --plugin file-progress --rule 'file-progress/activate: 1' 80 | ``` 81 | 82 | Or, in your package.json's command: 83 | 84 | ```diff 85 | { 86 | "scripts: [ 87 | - "lint": "eslint ." 88 | + "lint": "eslint . --plugin file-progress --rule \"file-progress/activate: 1\"" 89 | ] 90 | } 91 | ``` 92 | 93 | 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 94 | -------------------------------------------------------------------------------- /assets/progress.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibiraj-s/eslint-plugin-file-progress/2487dc9381532e2d555d15532d128385def06fad/assets/progress.gif -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import pegasus from 'eslint-config-pegasus' 2 | import eslintPlugin from 'eslint-plugin-eslint-plugin' 3 | 4 | import progress from './index.js' 5 | 6 | export default [ 7 | eslintPlugin.configs['flat/recommended'], 8 | pegasus.configs.default, 9 | pegasus.configs.node, 10 | progress.configs.recommended 11 | ] 12 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import type { Linter, Rule } from 'eslint'; 2 | 3 | declare const plugin: { 4 | meta: { 5 | name: string; 6 | version: string; 7 | }; 8 | configs: { 9 | recommended: Linter.Config; 10 | 'recommended-ci': Linter.Config; 11 | }; 12 | rules: { 13 | activate: Rule.RuleModule; 14 | }; 15 | }; 16 | 17 | export default plugin; 18 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import progress from './rules/progress.js'; 2 | 3 | const plugin = { 4 | meta: { 5 | name: "eslint-plugin-file-progress", 6 | version: "3.0.0" 7 | }, 8 | configs: {}, 9 | rules: { 10 | activate: progress, 11 | }, 12 | }; 13 | 14 | const configs = { 15 | recommended: { 16 | name: 'progress/recommended', 17 | plugins: { 18 | progress: plugin 19 | }, 20 | rules: { 21 | "progress/activate": 2 22 | } 23 | }, 24 | 'recommended-ci': { 25 | name: 'progress/recommended-ci', 26 | plugins: { 27 | progress: plugin 28 | }, 29 | rules: { 30 | "progress/activate": 2 31 | }, 32 | settings: { 33 | progress: { 34 | hide: process.env.CI === 'true' 35 | } 36 | } 37 | } 38 | } 39 | 40 | Object.assign(plugin.configs, configs) 41 | 42 | export default plugin 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-plugin-file-progress", 3 | "description": "Eslint plugin to print file progress", 4 | "version": "3.0.2", 5 | "license": "MIT", 6 | "author": "sibiraj-s", 7 | "repository": "github:sibiraj-s/eslint-plugin-file-progress", 8 | "bugs": "https://github.com/sibiraj-s/eslint-plugin-file-progress/issues", 9 | "homepage": "https://github.com/sibiraj-s/eslint-plugin-file-progress#readme", 10 | "type": "module", 11 | "main": "./index.js", 12 | "exports": "./index.js", 13 | "types": "./index.d.ts", 14 | "keywords": [ 15 | "eslint", 16 | "eslintplugin", 17 | "eslint-plugin", 18 | "eslint-plugin-file-progress", 19 | "eslint-progress", 20 | "progress" 21 | ], 22 | "publishConfig": { 23 | "provenance": true, 24 | "access": "public" 25 | }, 26 | "files": [ 27 | "index.js", 28 | "index.d.ts", 29 | "rules/" 30 | ], 31 | "scripts": { 32 | "lint": "eslint .", 33 | "test": "node test.js", 34 | "prepare": "is-ci || husky" 35 | }, 36 | "engines": { 37 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0" 38 | }, 39 | "peerDependencies": { 40 | "eslint": "^9.0.0" 41 | }, 42 | "dependencies": { 43 | "nanospinner": "^1.2.0", 44 | "picocolors": "^1.1.1" 45 | }, 46 | "devDependencies": { 47 | "@changesets/cli": "^2.28.1", 48 | "@commitlint/cli": "^19.8.0", 49 | "@commitlint/config-conventional": "^19.8.0", 50 | "@types/node": "^22.13.10", 51 | "eslint": "^9.22.0", 52 | "eslint-config-pegasus": "^6.0.2", 53 | "eslint-plugin-eslint-plugin": "^6.4.0", 54 | "husky": "^9.1.7", 55 | "is-ci": "^4.1.0", 56 | "publint": "^0.3.9" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rules/progress.js: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import nanospinner from 'nanospinner'; 3 | import pc from 'picocolors'; 4 | 5 | const spinner = nanospinner.createSpinner('', { 6 | frames: ['|', '/', '-', '\\'], 7 | color: 'cyan', 8 | }); 9 | 10 | let bindExit = false; 11 | let initialReportDone = false; 12 | 13 | const defaultSettings = { 14 | hide: false, 15 | hideFileName: false, 16 | successMessage: 'Lint done.', 17 | }; 18 | 19 | const exitCallback = (exitCode, settings) => { 20 | if (exitCode === 0 && settings.hide !== true) { 21 | spinner.success({ text: settings.successMessage }); 22 | } 23 | }; 24 | 25 | const create = (context) => { 26 | const settings = { ...defaultSettings, ...context.settings.progress }; 27 | 28 | if (!bindExit) { 29 | process.on('exit', (code) => { 30 | exitCallback(code, settings); 31 | }); 32 | bindExit = true; 33 | } 34 | 35 | if (settings.hide) { 36 | return {}; 37 | } 38 | 39 | if (!settings.hideFileName) { 40 | const filename = context.getFilename(); 41 | const relativeFilePath = path.relative(context.getCwd(), filename); 42 | spinner.update({ text: `Processing: ${pc.green(relativeFilePath)} \n` }); 43 | } else if (!initialReportDone) { 44 | spinner.update({ text: 'Linting...\n' }); 45 | initialReportDone = true; 46 | } 47 | 48 | spinner.spin(); 49 | return {}; 50 | }; 51 | 52 | const progress = { 53 | name: import.meta.filename, 54 | meta: { 55 | type: 'suggestion', 56 | messages: [], 57 | schema: [] 58 | }, 59 | create, 60 | }; 61 | 62 | export default progress; 63 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import { RuleTester } from 'eslint'; 2 | 3 | import progress from './rules/progress.js'; 4 | 5 | const ruleTester = new RuleTester(); 6 | const ruleName = 'file-progress/activate'; 7 | 8 | ruleTester.run(ruleName, progress, { 9 | valid: [ 10 | 'var foo = \'bar\'', 11 | { 12 | code: 'var foo = \'bar\'', 13 | settings: { 14 | progress: { 15 | hide: false, 16 | successMessage: 'Lint done...', 17 | }, 18 | }, 19 | }, 20 | ], 21 | invalid: [], 22 | }); 23 | --------------------------------------------------------------------------------