@xtrek/ts-migrate-plugins
Version:
Set of codemods, which are doing transformation of js/jsx to ts/tsx
34 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const eslint_1 = require("eslint");
const cli = new eslint_1.ESLint({
fix: true,
useEslintrc: true,
// Set ignore to false so we can lint in `tmp` for testing
ignore: false,
});
const eslintFixPlugin = {
name: 'eslint-fix',
async run({ fileName, text }) {
try {
let newText = text;
while (true) {
// eslint-disable-next-line no-await-in-loop
const [report] = await cli.lintText(newText, {
filePath: fileName,
});
if (!report || !report.output || report.output === newText) {
break;
}
newText = report.output;
}
return newText;
}
catch (e) {
console.error('Error occurred in eslint-fix plugin :(');
return text;
}
},
};
exports.default = eslintFixPlugin;
//# sourceMappingURL=eslint-fix.js.map