Last active
January 19, 2024 06:03
-
-
Save NoamGaash/663ead53f7cbc3c0fbc541b9368df536 to your computer and use it in GitHub Desktop.
it's my solution for my particular case, I can't gureentee it will ever help you. Use with cation - it will delete a lot of your code (hopefully).
This file contains hidden or 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
/* | |
example to fix: | |
*/ | |
const fs = require("fs"); | |
const path = require("path"); | |
const filename = "lint"; | |
const filePath = path.join(__dirname, filename); | |
fs.readFileSync(filePath, "utf8").split("\n\n") | |
.forEach((error) => { | |
error = error.trim(); | |
try { | |
if (error[0] === ">") { | |
return; | |
} | |
const lines = error.split("\n"); | |
const file = lines[0].split(":")[0]; | |
lines.slice(1).forEach((error) => { | |
const line = error.split(":")[0].trim(); | |
const fileContent = fs.readFileSync(file, "utf8").split("\n"); | |
const lineContent = fileContent[line - 1]; | |
const errorMessage = error.split("warning")[1].trim(); | |
if (errorMessage.includes("exported declaration 'default' not used")) { | |
if (["function", "const", "class"].some((word) => lineContent.includes(word))) { | |
const newLine = lineContent.replace("export default", "export"); | |
fileContent[line - 1] = newLine; | |
fs.writeFileSync(file, fileContent.join("\n")); | |
} else if (lineContent.includes("export default")) { | |
fileContent[line - 1] = ""; | |
fs.writeFileSync(file, fileContent.join("\n")); | |
} | |
} else if (errorMessage.includes("No exports found")) { | |
fs.rmSync(file); | |
} else if (errorMessage.includes("exported declaration")) { | |
const newLine = lineContent.replace(/export\s/g, ""); | |
fileContent[line - 1] = newLine; | |
fs.writeFileSync(file, fileContent.join("\n")); | |
} | |
}); | |
} catch (e) { | |
// eslint-disable-next-line no-console | |
console.log(e); | |
} | |
}); |
This file contains hidden or 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
# iterate 11 times | |
$i = 0 | |
while [ $i -lt 11 ] | |
do | |
i=$(( $i + 1 )) | |
echo "Iteration $i" | |
npm run lint > lint | |
sleep 1 | |
node fixlint.js | |
rm .eslintcache | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment