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 319beaa commit d037237
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lib/lint/file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import PrettierPluginXml from "@prettier/plugin-xml";
Expand Down Expand Up @@ -255,8 +254,6 @@ export class LintFile {
#originalData;
#data;
#type;
#hash;
#size;

constructor ( file, { cwd, processUnsupportedTypes, write, fix = true, log = true, cache } = {} ) {
this.#file = File.new( file );
Expand Down Expand Up @@ -329,9 +326,6 @@ export class LintFile {
}
}

this.#hash = this.#getHash( this.#data );
this.#size = this.#data.length;

let res;

if ( action === "lint" ) res = await this.#lint();
Expand All @@ -341,11 +335,9 @@ export class LintFile {

if ( res.status >= 500 ) return res;

const hash = this.#getHash( this.#data );

if ( hash !== this.#hash ) {
if ( this.#data !== this.#originalData ) {
res.meta.isModified = true;
res.meta.bytesDelta = this.#data.length - this.#size;
res.meta.bytesDelta = this.#data.length - this.#originalData.length;

if ( this.#write ) {
await fs.promises.writeFile( this.path, this.#data );
Expand Down Expand Up @@ -791,10 +783,6 @@ export class LintFile {
}
}

#getHash ( data ) {
return crypto.createHash( "MD5" ).update( data ).digest( "hex" );
}

#replaceTabs ( tabWidth ) {
this.#data = this.#data.replaceAll( "\t", " ".repeat( tabWidth ) );
}
Expand Down

0 comments on commit d037237

Please sign in to comment.