Skip to content

Instantly share code, notes, and snippets.

@barzik
Created November 6, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barzik/d6f43a1ee650643ced19a5094d4cec3d to your computer and use it in GitHub Desktop.
Save barzik/d6f43a1ee650643ced19a5094d4cec3d to your computer and use it in GitHub Desktop.
Adding ignore remark for to CSS\JS files
/* eslint-disable angular/log,no-console,angular/json-functions,no-loop-func */
const fs = require('fs');
const glob = require('glob');
const pathToFiles = './src/**/*.less';
const disableString = '/* stylelint-disable */';
const files = glob.sync(pathToFiles, { cwd: './', realpath: true });
for (const file of files) {
const content = fs.readFileSync(file, 'utf8');
if (content.startsWith(disableString) === false) {
fs.writeFile(file, `${disableString} \n ${content}`, 'utf-8', (err) => {
if (err) {
throw err;
} else {
console.log(`Add disable string to ${file}`);
}
});
} else {
console.log(`disable string already existing ${file}`);
}
}
@ronapelbaum
Copy link

Great script!
I use it a lot!

I've added my own script to enforce the removing of /* eslint-disable */ comment at file header:
https://gist.github.com/ronapelbaum/2855a4c6d1f6cd2bb23d69db7bdf583d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment