mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 12:59:05 +02:00
Change remaining JS files to comply with ESLint config.
This commit is contained in:
83
Gruntfile.js
83
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'])
|
||||
}
|
||||
|
Reference in New Issue
Block a user