aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2013-06-14 09:01:02 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2013-07-03 16:01:51 +0200
commit7da828375afb20d58736bb1eb530f915c445d5b9 (patch)
treef9a1223e6c4de203447e6974d0e88b98e66aef28 /build
parent4ed52cba6555660268210ef76c38101d9dfef8df (diff)
downloadjquery-ui-7da828375afb20d58736bb1eb530f915c445d5b9.tar.gz
jquery-ui-7da828375afb20d58736bb1eb530f915c445d5b9.zip
Build: Implement an asciilint task to verify content of ui files (ignore i18n). Fixes #9037 - Build: Verify characters in output
Diffstat (limited to 'build')
-rw-r--r--build/tasks/build.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/build/tasks/build.js b/build/tasks/build.js
index 4d803df77..c50745899 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -135,4 +135,37 @@ grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});
+grunt.registerTask( "asciilint", function() {
+ var valid = true,
+ files = grunt.file.expand({ filter: "isFile" }, "ui/*.js" );
+ files.forEach(function( filename ) {
+ var i, c,
+ text = grunt.file.read( filename );
+
+ // Ensure files use only \n for line endings, not \r\n
+ if ( /\x0d\x0a/.test( text ) ) {
+ grunt.log.error( filename + ": Incorrect line endings (\\r\\n)" );
+ valid = false;
+ }
+
+ // Ensure only ASCII chars so script tags don't need a charset attribute
+ if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
+ grunt.log.error( filename + ": Non-ASCII characters detected:" );
+ for ( i = 0; i < text.length; i++ ) {
+ c = text.charCodeAt( i );
+ if ( c > 127 ) {
+ grunt.log.error( "- position " + i + ": " + c );
+ grunt.log.error( "-- " + text.substring( i - 20, i + 20 ) );
+ break;
+ }
+ }
+ valid = false;
+ }
+ });
+ if ( valid ) {
+ grunt.log.ok( files.length + " files lint free." );
+ }
+ return valid;
+});
+
};