Last active
October 27, 2022 13:01
-
-
Save monovertex/7e156eb6fb6080736ed4e812b1158099 to your computer and use it in GitHub Desktop.
Codemod to ignore HBS template lint rule for files that fail it
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
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