Created
November 6, 2016 15:38
-
-
Save barzik/d6f43a1ee650643ced19a5094d4cec3d to your computer and use it in GitHub Desktop.
Adding ignore remark for to CSS\JS files
This file contains 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
/* 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}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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