This is a gulp plugin that allows testing the content of different files to ensure guidelines.
npm install https://github.com/xavicolomer/gulp-content-watchdog.git --save-dev
This example will apply the listed plugins to all the js files on a given directory, and will display the affected line too. (This is useful because 'CMD + Click' on the console will open the default editor on the selected line)
Gulpfile.js
gulp.task('content-watchdog', function() {
gulp.src(paths.source + 'js/**/*').pipe(contentWatchdog({
showLineNumbers: true,
plugins: [
'hardcoded-classes',
'global-jquery-selector'
]
}))
});
On the console:
$ gulp content-watchdog
- showLineNumbers (true | false) Regular Expressions will be applied to the line or to the file
- plugins (String Array) A collection of plugins to apply to the content
hardcoded-classes
Searches for Hardcoded Jquery classes. Since I prefer to have them all in variables.
Incorrect:
$myVariable.find('.className');
Correct:
var className = '.className';
$myVariable.find(className);
global-jquery-selector
Searches for Global Jquery Queries. Global queries are really dangerous because multiple instances can be affected.
Incorrect:
$('.className');
Correct:
$myVariable.find('.className');
0.1.0