npm install --save-dev grunt-lint-pattern
Then add grunt-lint-pattern to the list of modules to be loaded in Gruntfile.js, and add the following configuration: lint_pattern: { view_statics: { options: { rules: [ { pattern: /<link [^>]*href=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <link>.' }, { pattern: /<script [^>]*src=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <script>.' }, { pattern: /<img [^>]*src=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <img>.' }, ] }, files: { src: [ 'views/**/*.handlebars' ] } }, css_statics: { options: { rules: [ { pattern: /url\(/, message: 'Un-mapped static found in LESS property.' }, ] }, files: { src: [ 'less/**/*.less' ] } } }
And add lint_pattern to your default rule: grunt.registerTask('default', ['cafemocha', 'jshint', 'exec', 'lint_pattern']);
Now when we run grunt (which we should be doing regularly), we will catch any inâ&#x20AC;? stances of unmapped statics.
196
| Chapter 16: Static Content
www.it-ebooks.info