-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improved errors when config can not be found (#85)
Co-authored-by: Anthony Fu <[email protected]>
- Loading branch information
Showing
5 changed files
with
136 additions
and
17 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
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import c from 'picocolors' | ||
import { MARK_ERROR } from './constants' | ||
|
||
export class ConfigInspectorError extends Error { | ||
prettyPrint() { | ||
console.error(MARK_ERROR, this.message) | ||
} | ||
} | ||
|
||
export class ConfigPathError extends ConfigInspectorError { | ||
override name = 'ConfigPathError' as const | ||
|
||
constructor( | ||
public basePath: string, | ||
public configFilenames: string[], | ||
) { | ||
super('Cannot find ESLint config file') | ||
} | ||
|
||
override prettyPrint() { | ||
console.error(MARK_ERROR, this.message, c.dim(` | ||
Looked in ${c.underline(this.basePath)} and parent folders for: | ||
* ${this.configFilenames.join('\n * ')}`, | ||
)) | ||
} | ||
} | ||
|
||
export class ConfigPathLegacyError extends ConfigInspectorError { | ||
override name = 'ConfigPathLegacyError' as const | ||
|
||
constructor( | ||
public basePath: string, | ||
public configFilename: string, | ||
) { | ||
super('Found ESLint legacy config file') | ||
} | ||
|
||
override prettyPrint() { | ||
console.error(MARK_ERROR, this.message, c.dim(` | ||
Encountered unsupported legacy config ${c.underline(this.configFilename)} in ${c.underline(this.basePath)} | ||
\`@eslint/config-inspector\` only works with the new flat config format: | ||
https://eslint.org/docs/latest/use/configure/configuration-files-new`, | ||
)) | ||
} | ||
} |
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