Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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}`);

This comment has been minimized.

Copy link

@ronapelbaum ronapelbaum commented Jun 13, 2017

Great script!
I use it a lot!

I've added my own script to enforce the removing of /* eslint-disable */ comment at file header:

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