Skip to content

Commit

Permalink
chore: keep formatting on eslint parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Dec 30, 2024
1 parent 83c9a44 commit 319beaa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/lint/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export class LintFile {
#path;
#fullPath;
#useDefaults;
#originalData;
#data;
#type;
#hash;
Expand Down Expand Up @@ -301,7 +302,7 @@ export class LintFile {
this.#fullPath = this.path;

// read file content
this.#data = await this.#file.text( "utf8" );
this.#originalData = this.#data = await this.#file.text( "utf8" );

// detect type
{
Expand Down Expand Up @@ -563,7 +564,7 @@ export class LintFile {
}
}

async #runEslint ( { configs, editorConfig } ) {
async #runEslint ( { configs, editorConfig, fatalError } ) {
if ( !this.#type?.eslint ) return result( 200 );

const fullPath = this.#fullPath;
Expand Down Expand Up @@ -627,7 +628,17 @@ export class LintFile {
"warnIgnored": true,
} );

if ( report[ 0 ].output != null ) this.#data = report[ 0 ].output;
// fatal error
if ( !fatalError && report[ 0 ].output == null ) {

// repeat with the original data
this.#data = this.#originalData;

return this.#runEslint( { configs, editorConfig, "fatalError": true } );
}
else if ( report[ 0 ].output ) {
this.#data = report[ 0 ].output;
}

// append log
var log = "",
Expand Down

0 comments on commit 319beaa

Please sign in to comment.