-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7289acd
commit 13383af
Showing
5 changed files
with
170 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,20 @@ | ||
import type {ESLint, Linter} from 'eslint'; | ||
|
||
export = formatterPretty; | ||
|
||
/** | ||
Pretty formatter for [ESLint](https://eslint.org). | ||
@param results - Lint result for the individual files. | ||
@param data - Extended information related to the analysis results. | ||
@returns The formatted output. | ||
*/ | ||
declare function formatterPretty( | ||
results: readonly formatterPretty.LintResult[], | ||
data?: ESLint.LintResultData | ||
export default function eslintFormatterPretty( | ||
results: LintResult[], | ||
data?: LintResultData | ||
): string; | ||
|
||
declare namespace formatterPretty { | ||
interface LintResult { | ||
readonly filePath: string; | ||
readonly errorCount: number; | ||
readonly warningCount: number; | ||
readonly messages: readonly LintMessage[]; | ||
} | ||
|
||
type Severity = Linter.Severity | 'warning' | 'error'; | ||
export type LintResult = ESLint.LintResult; | ||
export type LintResultData = ESLint.LintResultData; | ||
export type Severity = Linter.Severity; | ||
export type LintMessage = Linter.LintMessage; | ||
|
||
interface LintMessage { | ||
readonly severity: Severity; | ||
readonly fatal?: boolean; | ||
readonly line?: number; | ||
readonly column?: number; | ||
readonly message: string; | ||
readonly ruleId?: string | null; | ||
} | ||
} | ||
export {Linter} from 'eslint'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
import type {ESLint} from 'eslint'; | ||
import {expectType} from 'tsd'; | ||
import formatterPretty = require('.'); | ||
|
||
// Test type exports | ||
type LintResult = formatterPretty.LintResult; | ||
type LintMessage = formatterPretty.LintMessage; | ||
type Severity = formatterPretty.Severity; | ||
import eslintFormatterPretty, { | ||
type LintResult, | ||
type LintMessage, | ||
type Severity, | ||
} from './index.js'; | ||
|
||
// Test LintResult interface members | ||
declare const lintResult: LintResult; | ||
expectType<string>(lintResult.filePath); | ||
expectType<number>(lintResult.errorCount); | ||
expectType<number>(lintResult.warningCount); | ||
expectType<readonly LintMessage[]>(lintResult.messages); | ||
expectType<LintMessage[]>(lintResult.messages); | ||
|
||
// Test LintMessage interface members | ||
const lintMessage = lintResult.messages[0]; | ||
expectType<Severity>(lintMessage.severity); | ||
expectType<string>(lintMessage.message); | ||
expectType<boolean | undefined>(lintMessage.fatal); | ||
expectType<number | undefined>(lintMessage.line); | ||
expectType<number | undefined>(lintMessage.column); | ||
expectType<string | null | undefined>(lintMessage.ruleId); | ||
expectType<true | undefined>(lintMessage.fatal); | ||
expectType<number>(lintMessage.line); | ||
expectType<number>(lintMessage.column); | ||
expectType<string | null >(lintMessage.ruleId); // eslint-disable-line @typescript-eslint/ban-types | ||
|
||
// Test formatterPretty() | ||
declare const lintResults: LintResult[]; | ||
declare const eslintLintResults: ESLint.LintResult[]; | ||
declare const lintResultData: ESLint.LintResultData; | ||
|
||
expectType<string>(formatterPretty(lintResults)); | ||
expectType<string>(formatterPretty(eslintLintResults)); | ||
expectType<string>(formatterPretty(eslintLintResults, lintResultData)); | ||
|
||
interface PartialLintResult { | ||
filePath: string; | ||
errorCount: number; | ||
warningCount: number; | ||
messages: Array<{ | ||
fileName: string; | ||
message: string; | ||
severity: 'error' | 'warning'; | ||
line?: number; | ||
column?: number; | ||
}>; | ||
} | ||
|
||
declare const partialLintResults: PartialLintResult[]; | ||
|
||
expectType<string>(formatterPretty(partialLintResults)); | ||
expectType<string>(eslintFormatterPretty(lintResults)); | ||
expectType<string>(eslintFormatterPretty(eslintLintResults)); | ||
expectType<string>(eslintFormatterPretty(eslintLintResults, lintResultData)); | ||
|
||
// FIXME | ||
// type PartialLintResult = { | ||
// filePath: string; | ||
// errorCount: number; | ||
// warningCount: number; | ||
// messages: Array<{ | ||
// fileName: string; | ||
// message: string; | ||
// severity: 0 | 1 | 2; | ||
// line?: number; | ||
// column?: number; | ||
// }>; | ||
// }; | ||
|
||
// declare const partialLintResults: PartialLintResult[]; | ||
|
||
// expectType<string>(eslintFormatterPretty(partialLintResults)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,13 @@ | |
"email": "[email protected]", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -29,23 +34,28 @@ | |
"validate" | ||
], | ||
"dependencies": { | ||
"@types/eslint": "^8.0.0", | ||
"ansi-escapes": "^4.2.1", | ||
"chalk": "^4.1.0", | ||
"@types/eslint": "^8.44.6", | ||
"ansi-escapes": "^6.2.0", | ||
"chalk": "^5.3.0", | ||
"eslint-rule-docs": "^1.1.235", | ||
"log-symbols": "^4.0.0", | ||
"plur": "^4.0.0", | ||
"string-width": "^4.2.0", | ||
"supports-hyperlinks": "^2.0.0" | ||
"log-symbols": "^6.0.0", | ||
"plur": "^5.1.0", | ||
"string-width": "^7.0.0", | ||
"supports-hyperlinks": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"strip-ansi": "^6.0.0", | ||
"tsd": "^0.17.0", | ||
"typescript": "^4.3.2", | ||
"xo": "^0.32.0" | ||
"ava": "^5.3.1", | ||
"strip-ansi": "^7.1.0", | ||
"tsd": "^0.29.0", | ||
"typescript": "^5.2.2", | ||
"xo": "^0.56.0" | ||
}, | ||
"ava": { | ||
"serial": true | ||
}, | ||
"xo": { | ||
"rules": { | ||
"import/no-extraneous-dependencies": "off" | ||
} | ||
} | ||
} |
Oops, something went wrong.