Skip to content

Instantly share code, notes, and snippets.

@monovertex
Last active October 27, 2022 13:01
Show Gist options
  • Save monovertex/7e156eb6fb6080736ed4e812b1158099 to your computer and use it in GitHub Desktop.
Save monovertex/7e156eb6fb6080736ed4e812b1158099 to your computer and use it in GitHub Desktop.
Codemod to ignore HBS template lint rule for files that fail it
const { exec } = require('child_process');
const fs = require('fs');
exec('yarn run lint:hbs', { maxBuffer: 1024 * 10000 }, (_err, stdout) => {
const lines = stdout.toString().split(/\r?\n/);
const files = lines.filter((line) => line.startsWith('packages/'));
for (const file of files) {
fs.readFile(file, function (_, fileContent) {
const fileLines = fileContent.toString().split(/\r?\n/);
fileLines.unshift('{{! template-lint-disable no-with }}');
fs.writeFileSync(file, fileLines.join('\n'));
});
}
});
/*
Regex to merge lint-disable rules:
Search:
\{\{! template-lint-disable (.+?) ?\}\}
\{\{! template-lint-disable (.+?) ?\}\}
Replace with:
{{! template-lint-disable $1 $2 }}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment