diff --git a/Gruntfile.js b/Gruntfile.js index b707034f6c..d699e4c8e4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,26 +7,25 @@ */ module.exports = function (grunt) { - 'use strict'; + 'use strict' // Force use of Unix newlines - grunt.util.linefeed = '\n'; + grunt.util.linefeed = '\n' RegExp.quote = function (string) { - return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'); - }; + return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') + } - var fs = require('fs'); - var path = require('path'); - var isTravis = require('is-travis'); + var path = require('path') + var isTravis = require('is-travis') - var configBridge = grunt.file.readJSON('./grunt/configBridge.json', { encoding: 'utf8' }); + var configBridge = grunt.file.readJSON('./grunt/configBridge.json', { encoding: 'utf8' }) Object.keys(configBridge.paths).forEach(function (key) { configBridge.paths[key].forEach(function (val, i, arr) { - arr[i] = path.join('./docs', val); - }); - }); + arr[i] = path.join('./docs', val) + }) + }) // Project configuration. grunt.initConfig({ @@ -100,7 +99,7 @@ module.exports = function (grunt) { options: { // Custom function to remove all export and import statements process: function (src) { - return src.replace(/^(export|import).*/gm, ''); + return src.replace(/^(export|import).*/gm, '') } }, bootstrap: { @@ -275,83 +274,83 @@ module.exports = function (grunt) { } } - }); + }) // These plugins provide necessary tasks. require('load-grunt-tasks')(grunt, { scope: 'devDependencies', // Exclude Sass compilers. We choose the one to load later on. - pattern: ['grunt-*', '!grunt-sass', '!grunt-contrib-sass'] }); - require('time-grunt')(grunt); + pattern: ['grunt-*', '!grunt-sass', '!grunt-contrib-sass'] }) + require('time-grunt')(grunt) // Docs HTML validation task - grunt.registerTask('validate-html', ['jekyll:docs', 'htmllint', 'exec:htmlhint']); + grunt.registerTask('validate-html', ['jekyll:docs', 'htmllint', 'exec:htmlhint']) var runSubset = function (subset) { - return !process.env.TWBS_TEST || process.env.TWBS_TEST === subset; - }; + return !process.env.TWBS_TEST || process.env.TWBS_TEST === subset + } var isUndefOrNonZero = function (val) { - return val === undefined || val !== '0'; - }; + return val === undefined || val !== '0' + } // Test task. - var testSubtasks = []; + var testSubtasks = [] // Skip core tests if running a different subset of the test suite if (runSubset('core') && // Skip core tests if this is a Savage build process.env.TRAVIS_REPO_SLUG !== 'twbs-savage/bootstrap') { - testSubtasks = testSubtasks.concat(['dist-css', 'dist-js', 'test-scss', 'qunit', 'docs']); + testSubtasks = testSubtasks.concat(['dist-css', 'dist-js', 'test-scss', 'qunit', 'docs']) } // Skip HTML validation if running a different subset of the test suite if (runSubset('validate-html') && isTravis && // Skip HTML5 validator when [skip validator] is in the commit message isUndefOrNonZero(process.env.TWBS_DO_VALIDATOR)) { - testSubtasks.push('validate-html'); + testSubtasks.push('validate-html') } // Only run Sauce Labs tests if there's a Sauce access key if (typeof process.env.SAUCE_ACCESS_KEY !== 'undefined' && // Skip Sauce if running a different subset of the test suite runSubset('sauce-js-unit')) { - testSubtasks = testSubtasks.concat(['dist', 'docs-css', 'docs-js', 'clean:docs', 'copy:docs']); + testSubtasks = testSubtasks.concat(['dist', 'docs-css', 'docs-js', 'clean:docs', 'copy:docs']) // Skip Sauce on Travis when [skip sauce] is in the commit message if (isUndefOrNonZero(process.env.TWBS_DO_SAUCE)) { - testSubtasks.push('connect'); - testSubtasks.push('saucelabs-qunit'); + testSubtasks.push('connect') + testSubtasks.push('saucelabs-qunit') } } - grunt.registerTask('test', testSubtasks); + grunt.registerTask('test', testSubtasks) // JS distribution task. - grunt.registerTask('dist-js', ['babel:dev', 'concat', 'babel:dist', 'stamp', 'exec:uglify']); + grunt.registerTask('dist-js', ['babel:dev', 'concat', 'babel:dist', 'stamp', 'exec:uglify']) grunt.registerTask('test-scss', ['exec:scss-lint']); // CSS distribution task. // Supported Compilers: sass (Ruby) and libsass. (function (sassCompilerName) { - require('./grunt/bs-sass-compile/' + sassCompilerName + '.js')(grunt); - })(process.env.TWBS_SASS || 'libsass'); + require('./grunt/bs-sass-compile/' + sassCompilerName + '.js')(grunt) + }(process.env.TWBS_SASS || 'libsass')) // grunt.registerTask('sass-compile', ['sass:core', 'sass:extras', 'sass:docs']); - grunt.registerTask('sass-compile', ['sass:core', 'sass:extras', 'sass:docs']); + grunt.registerTask('sass-compile', ['sass:core', 'sass:extras', 'sass:docs']) - grunt.registerTask('dist-css', ['sass-compile', 'exec:postcss', 'exec:clean-css', 'exec:clean-css-docs']); + grunt.registerTask('dist-css', ['sass-compile', 'exec:postcss', 'exec:clean-css', 'exec:clean-css-docs']) // Full distribution task. - grunt.registerTask('dist', ['clean:dist', 'dist-css', 'dist-js']); + grunt.registerTask('dist', ['clean:dist', 'dist-css', 'dist-js']) // Default task. - grunt.registerTask('default', ['clean:dist', 'test']); + grunt.registerTask('default', ['clean:dist', 'test']) // Docs task. - grunt.registerTask('docs-css', ['exec:clean-css-docs', 'exec:postcss-docs']); - grunt.registerTask('lint-docs-css', ['exec:scss-lint-docs']); - grunt.registerTask('docs-js', ['exec:uglify-docs']); - grunt.registerTask('docs', ['lint-docs-css', 'docs-css', 'docs-js', 'clean:docs', 'copy:docs']); - grunt.registerTask('docs-github', ['jekyll:github']); + grunt.registerTask('docs-css', ['exec:clean-css-docs', 'exec:postcss-docs']) + grunt.registerTask('lint-docs-css', ['exec:scss-lint-docs']) + grunt.registerTask('docs-js', ['exec:uglify-docs']) + grunt.registerTask('docs', ['lint-docs-css', 'docs-css', 'docs-js', 'clean:docs', 'copy:docs']) + grunt.registerTask('docs-github', ['jekyll:github']) - grunt.registerTask('prep-release', ['dist', 'docs', 'docs-github', 'compress']); + grunt.registerTask('prep-release', ['dist', 'docs', 'docs-github', 'compress']) // Publish to GitHub - grunt.registerTask('publish', ['buildcontrol:pages']); -}; + grunt.registerTask('publish', ['buildcontrol:pages']) +} diff --git a/docs/assets/js/ie-emulation-modes-warning.js b/docs/assets/js/ie-emulation-modes-warning.js index 452c1268f6..7996b9e340 100644 --- a/docs/assets/js/ie-emulation-modes-warning.js +++ b/docs/assets/js/ie-emulation-modes-warning.js @@ -10,7 +10,7 @@ */ // Intended to prevent false-positive bug reports about Bootstrap not working properly in old versions of IE due to folks testing using IE's unreliable emulation modes. (function () { - 'use strict'; + 'use strict' function emulatedIEMajorVersion() { var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent) @@ -49,4 +49,4 @@ if (emulated !== nonEmulated) { window.alert('WARNING: You appear to be using IE' + nonEmulated + ' in IE' + emulated + ' emulation mode.\nIE emulation modes can behave significantly differently from ACTUAL older versions of IE.\nPLEASE DON\'T FILE BOOTSTRAP BUGS based on testing in IE emulation modes!') } -})(); +}()) diff --git a/docs/assets/js/ie10-viewport-bug-workaround.js b/docs/assets/js/ie10-viewport-bug-workaround.js index 0aecf6b305..36afc46b85 100644 --- a/docs/assets/js/ie10-viewport-bug-workaround.js +++ b/docs/assets/js/ie10-viewport-bug-workaround.js @@ -9,7 +9,7 @@ // https://getbootstrap.com/getting-started/#support-ie10-width (function () { - 'use strict'; + 'use strict' if (navigator.userAgent.match(/IEMobile\/10\.0/)) { var msViewportStyle = document.createElement('style') @@ -21,4 +21,4 @@ document.head.appendChild(msViewportStyle) } -})(); +}()) diff --git a/docs/assets/js/src/application.js b/docs/assets/js/src/application.js index 529b0c1b89..fee96113d7 100644 --- a/docs/assets/js/src/application.js +++ b/docs/assets/js/src/application.js @@ -12,8 +12,8 @@ /* global Clipboard, anchors */ -!function ($) { - 'use strict'; +(function ($) { + 'use strict' $(function () { @@ -86,11 +86,11 @@ }) -}(jQuery) +}(jQuery)) ;(function () { - 'use strict'; + 'use strict' - anchors.options.placement = 'left'; + anchors.options.placement = 'left' anchors.add('.bd-content > h1, .bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5') -})(); +}()) diff --git a/grunt/bs-sass-compile/libsass.js b/grunt/bs-sass-compile/libsass.js index 3abfbd6d0d..06b9dcc0cd 100644 --- a/grunt/bs-sass-compile/libsass.js +++ b/grunt/bs-sass-compile/libsass.js @@ -28,6 +28,6 @@ module.exports = function configureLibsass(grunt) { } } } - }); - grunt.loadNpmTasks('grunt-sass'); -}; + }) + grunt.loadNpmTasks('grunt-sass') +} diff --git a/grunt/bs-sass-compile/sass.js b/grunt/bs-sass-compile/sass.js index 665212e0cb..dadd93d405 100644 --- a/grunt/bs-sass-compile/sass.js +++ b/grunt/bs-sass-compile/sass.js @@ -9,7 +9,7 @@ module.exports = function configureRubySass(grunt) { style: 'expanded', trace: true, bundleExec: true - }; + } grunt.config.merge({ sass: { core: { @@ -32,6 +32,6 @@ module.exports = function configureRubySass(grunt) { } } } - }); - grunt.loadNpmTasks('grunt-contrib-sass'); -}; + }) + grunt.loadNpmTasks('grunt-contrib-sass') +} diff --git a/grunt/change-version.js b/grunt/change-version.js index 4ad5825f28..12794f6087 100755 --- a/grunt/change-version.js +++ b/grunt/change-version.js @@ -1,5 +1,6 @@ #!/usr/bin/env node -'use strict'; + +'use strict' /*! * Script to update version number references in the project. @@ -7,87 +8,90 @@ * Copyright 2015 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ -var fs = require('fs'); -var path = require('path'); -var sh = require('shelljs'); -sh.config.fatal = true; -var sed = sh.sed; + +/* global Set */ + +var fs = require('fs') +var path = require('path') +var sh = require('shelljs') +sh.config.fatal = true +var sed = sh.sed // Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 RegExp.quote = function (string) { - return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'); -}; + return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') +} RegExp.quoteReplacement = function (string) { - return string.replace(/[$]/g, '$$'); -}; + return string.replace(/[$]/g, '$$') +} -var DRY_RUN = false; +var DRY_RUN = false function walkAsync(directory, excludedDirectories, fileCallback, errback) { if (excludedDirectories.has(path.parse(directory).base)) { - return; + return } fs.readdir(directory, function (err, names) { if (err) { - errback(err); - return; + errback(err) + return } names.forEach(function (name) { - var filepath = path.join(directory, name); + var filepath = path.join(directory, name) fs.lstat(filepath, function (err, stats) { if (err) { - process.nextTick(errback, err); - return; + process.nextTick(errback, err) + return } if (stats.isSymbolicLink()) { - return; + return } else if (stats.isDirectory()) { - process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback); + process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback) } else if (stats.isFile()) { - process.nextTick(fileCallback, filepath); + process.nextTick(fileCallback, filepath) } - }); - }); - }); + }) + }) + }) } function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { - original = new RegExp(RegExp.quote(original), 'g'); - replacement = RegExp.quoteReplacement(replacement); + original = new RegExp(RegExp.quote(original), 'g') + replacement = RegExp.quoteReplacement(replacement) var updateFile = !DRY_RUN ? function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { - sed('-i', original, replacement, filepath); + sed('-i', original, replacement, filepath) } } : function (filepath) { if (allowedExtensions.has(path.parse(filepath).ext)) { - console.log('FILE: ' + filepath); + console.log('FILE: ' + filepath) } else { - console.log('EXCLUDED:' + filepath); + console.log('EXCLUDED:' + filepath) } - }; + } walkAsync(directory, excludedDirectories, updateFile, function (err) { - console.error('ERROR while traversing directory!:'); - console.error(err); - process.exit(1); - }); + console.error('ERROR while traversing directory!:') + console.error(err) + process.exit(1) + }) } function main(args) { if (args.length !== 2) { - console.error('USAGE: change-version old_version new_version'); - console.error('Got arguments:', args); - process.exit(1); + console.error('USAGE: change-version old_version new_version') + console.error('Got arguments:', args) + process.exit(1) } - var oldVersion = args[0]; - var newVersion = args[1]; + var oldVersion = args[0] + var newVersion = args[1] var EXCLUDED_DIRS = new Set([ '.git', 'node_modules', 'vendor' - ]); + ]) var INCLUDED_EXTENSIONS = new Set([ // This extension whitelist is how we avoid modifying binary files '', @@ -99,8 +103,8 @@ function main(args) { '.scss', '.txt', '.yml' - ]); - replaceRecursively('.', EXCLUDED_DIRS, INCLUDED_EXTENSIONS, oldVersion, newVersion); + ]) + replaceRecursively('.', EXCLUDED_DIRS, INCLUDED_EXTENSIONS, oldVersion, newVersion) } -main(process.argv.slice(2)); +main(process.argv.slice(2))