Skip to content

Commit 86ac9ca

Browse files
committed
Publish as standalone module
1 parent 65c2267 commit 86ac9ca

File tree

7 files changed

+175
-1
lines changed

7 files changed

+175
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare function formatter(): string;
2+
export = formatter;

license

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
eslint
2+
MIT
3+
Copyright JS Foundation and other contributors, https://js.foundation
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
13+
all 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
21+
THE SOFTWARE.

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "eslint-formatter-codeframe",
3+
"version": "7.32.0",
4+
"description": "ESLint’s official `codeframe` formatter, extracted from ESLint 7",
5+
"keywords": [
6+
"lint",
7+
"javascript",
8+
"ecmascript"
9+
],
10+
"repository": "fregante/eslint-formatter-codeframe",
11+
"license": "MIT",
12+
"author": "Nicholas C. Zakas <[email protected]>",
13+
"dependencies": {
14+
"@babel/code-frame": "7.12.11",
15+
"chalk": "^4.0.0"
16+
},
17+
"engines": {
18+
"node": "^10.12.0 || >=12.0.0"
19+
},
20+
"files": [
21+
"index.js",
22+
"index.d.ts"
23+
],
24+
"scripts": {
25+
"test": "mocha"
26+
},
27+
"devDependencies": {
28+
"chai": "^4.3.4",
29+
"mocha": "^9.0.3",
30+
"path": "^0.12.7",
31+
"proxyquire": "^2.1.3",
32+
"sinon": "^11.1.2",
33+
"strip-ansi": "^6.0.0"
34+
}
35+
}

readme.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# eslint-formatter-codeframe
2+
3+
> ESLint’s official `codeframe` formatter, extracted from ESLint 7
4+
5+
This formatter has been removed from ESLint 8 so it lives as a standalone module here.
6+
7+
**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)
8+
9+
## Install
10+
11+
```sh
12+
npm install --save-dev eslint-formatter-codeframe
13+
```
14+
15+
## Usage
16+
17+
More information about formatters can be found on https://eslint.org/docs/user-guide/formatters/
18+
19+
```
20+
eslint --format codeframe
21+
```
22+
23+
## Example output
24+
25+
```
26+
error: 'addOne' is defined but never used (no-unused-vars) at fullOfProblems.js:1:10:
27+
> 1 | function addOne(i) {
28+
| ^
29+
2 | if (i != NaN) {
30+
3 | return i ++
31+
4 | } else {
32+
33+
34+
error: Use the isNaN function to compare with NaN (use-isnan) at fullOfProblems.js:2:9:
35+
1 | function addOne(i) {
36+
> 2 | if (i != NaN) {
37+
| ^
38+
3 | return i ++
39+
4 | } else {
40+
5 | return
41+
42+
43+
error: Unexpected space before unary operator '++' (space-unary-ops) at fullOfProblems.js:3:16:
44+
1 | function addOne(i) {
45+
2 | if (i != NaN) {
46+
> 3 | return i ++
47+
| ^
48+
4 | } else {
49+
5 | return
50+
6 | }
51+
52+
53+
warning: Missing semicolon (semi) at fullOfProblems.js:3:20:
54+
1 | function addOne(i) {
55+
2 | if (i != NaN) {
56+
> 3 | return i ++
57+
| ^
58+
4 | } else {
59+
5 | return
60+
6 | }
61+
62+
63+
warning: Unnecessary 'else' after 'return' (no-else-return) at fullOfProblems.js:4:12:
64+
2 | if (i != NaN) {
65+
3 | return i ++
66+
> 4 | } else {
67+
| ^
68+
5 | return
69+
6 | }
70+
7 | };
71+
72+
73+
warning: Expected indentation of 8 spaces but found 6 (indent) at fullOfProblems.js:5:1:
74+
3 | return i ++
75+
4 | } else {
76+
> 5 | return
77+
| ^
78+
6 | }
79+
7 | };
80+
81+
82+
error: Function 'addOne' expected a return value (consistent-return) at fullOfProblems.js:5:7:
83+
3 | return i ++
84+
4 | } else {
85+
> 5 | return
86+
| ^
87+
6 | }
88+
7 | };
89+
90+
91+
warning: Missing semicolon (semi) at fullOfProblems.js:5:13:
92+
3 | return i ++
93+
4 | } else {
94+
> 5 | return
95+
| ^
96+
6 | }
97+
7 | };
98+
99+
100+
error: Unnecessary semicolon (no-extra-semi) at fullOfProblems.js:7:2:
101+
5 | return
102+
6 | }
103+
> 7 | };
104+
| ^
105+
106+
107+
5 errors and 4 warnings found.
108+
2 errors and 4 warnings potentially fixable with the `--fix` option.
109+
```
110+
111+
## Links
112+
113+
- [Other official ESLint formatters as standalone modules](https://github.com/fregante/eslint-formatters)
114+

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const chalkStub = Object.create(chalk, {
3535
chalkStub.yellow.bold = chalk.yellow.bold;
3636
chalkStub.red.bold = chalk.red.bold;
3737

38-
const formatter = proxyquire("../../../../lib/cli-engine/formatters/codeframe", { chalk: chalkStub });
38+
const formatter = proxyquire(".", { chalk: chalkStub });
3939

4040
//------------------------------------------------------------------------------
4141
// Tests

0 commit comments

Comments
 (0)