Skip to content

Commit

Permalink
Publish as standalone module
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Aug 3, 2021
1 parent 7bfecb2 commit 2ee183f
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock=false
2 changes: 2 additions & 0 deletions index.d.ts
@@ -0,0 +1,2 @@
declare function formatter(): string;
export = formatter;
21 changes: 21 additions & 0 deletions license
@@ -0,0 +1,21 @@
eslint
MIT
Copyright JS Foundation and other contributors, https://js.foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
31 changes: 31 additions & 0 deletions package.json
@@ -0,0 +1,31 @@
{
"name": "eslint-formatter-table",
"version": "7.32.0",
"description": "ESLint’s official `table` formatter, extracted from ESLint 7",
"keywords": [
"lint",
"javascript",
"ecmascript"
],
"repository": "fregante/eslint-formatter-table",
"license": "MIT",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
"dependencies": {
"chalk": "^4.0.0",
"table": "^6.0.9"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"files": [
"index.js",
"index.d.ts"
],
"scripts": {
"test": "mocha"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3"
}
}
50 changes: 50 additions & 0 deletions readme.md
@@ -0,0 +1,50 @@
# eslint-formatter-table

> ESLint’s official `table` formatter, extracted from ESLint 7
This formatter has been removed from ESLint 8 so it lives as a standalone module here.

**Warning:** This module is not maintained. If you're an ESLint contributor or dependable open-sourcerer, open an issue here and I'll pass you this repo and npm name. You can also ping me on Twitter [@fregante](https://twitter.com/fregante)

## Install

```sh
npm install --save-dev eslint-formatter-table
```

## Usage

More information about formatters can be found on https://eslint.org/docs/user-guide/formatters/

```
eslint --format table
```

## Example output

```
/var/lib/jenkins/workspace/Releases/eslint Release/eslint/fullOfProblems.js
║ Line │ Column │ Type │ Message │ Rule ID ║
╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
║ 1 │ 10 │ error │ 'addOne' is defined but never used. │ no-unused-vars ║
║ 2 │ 9 │ error │ Use the isNaN function to compare with NaN. │ use-isnan ║
║ 3 │ 16 │ error │ Unexpected space before unary operator '++'. │ space-unary-ops ║
║ 3 │ 20 │ warning │ Missing semicolon. │ semi ║
║ 4 │ 12 │ warning │ Unnecessary 'else' after 'return'. │ no-else-return ║
║ 5 │ 1 │ warning │ Expected indentation of 8 spaces but found 6. │ indent ║
║ 5 │ 7 │ error │ Function 'addOne' expected a return value. │ consistent-return ║
║ 5 │ 13 │ warning │ Missing semicolon. │ semi ║
║ 7 │ 2 │ error │ Unnecessary semicolon. │ no-extra-semi ║
╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ 5 Errors ║
╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║ 4 Warnings ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
```

## Links

- [Other official ESLint formatters as standalone modules](https://github.com/fregante/eslint-formatters)

2 changes: 1 addition & 1 deletion test.js
Expand Up @@ -10,7 +10,7 @@

const assert = require("chai").assert;
const chalk = require("chalk");
const formatter = require("../../../../lib/cli-engine/formatters/table");
const formatter = require(".");

//------------------------------------------------------------------------------
// Tests
Expand Down

1 comment on commit 2ee183f

@fregante
Copy link
Contributor Author

@fregante fregante commented on 2ee183f Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git history preservation courtesy of https://github.com/newren/git-filter-repo

I ran something like this (⚠️ this destroys the local repo)

# Disconnect the remote because it didn't work otherwise
git remote remove origin

# Follow file rename
git filter-repo --force \
      --path-rename lib/cli-engine/formatters:lib/formatters \
      --path-rename tests/lib/cli-engine/formatters:tests/lib/formatters

# Rename to just index.js and test.js
git filter-repo --force \
      --path-rename tests/lib/formatters/table.js:test.js \
      --path-rename lib/formatters/table.js:index.js

# Delete all files except index.js and test.js
git filter-repo --force \
      --path index.js \
      --path test.js

Please sign in to comment.