aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZlatan Vasović <[email protected]>2014-02-08 21:59:17 +0100
committerChris Rebert <[email protected]>2014-02-10 11:15:08 -0800
commitba4206b6443ab3f5744f3a7f88bcdfcefa7c5756 (patch)
tree241fb3dc99fd340f11f5788487ce964b5a8d4cdd
parent9afead3fb0b919dd7f7185dcdac7b3f2ab3b9c50 (diff)
downloadbootstrap-ba4206b6443ab3f5744f3a7f88bcdfcefa7c5756.tar.xz
bootstrap-ba4206b6443ab3f5744f3a7f88bcdfcefa7c5756.zip
Use different coding style for Gruntfile
Fixes #12657
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--Gruntfile.js2
-rw-r--r--grunt/.jshintrc16
-rw-r--r--grunt/bs-glyphicons-data-generator.js24
-rw-r--r--grunt/bs-lessdoc-parser.js1
-rw-r--r--grunt/bs-raw-files-generator.js27
-rw-r--r--grunt/shrinkwrap.js2
7 files changed, 46 insertions, 28 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e0021c8e5..dbccc8761 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -178,7 +178,7 @@ license your work under the terms of the [MIT License](LICENSE.md).
### JS
-- No semicolons
+- No semicolons (in client-side JS)
- 2 spaces (no tabs)
- strict mode
- "Attractive"
diff --git a/Gruntfile.js b/Gruntfile.js
index 41fe0785b..5a9abedb8 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -45,7 +45,7 @@ module.exports = function (grunt) {
},
grunt: {
options: {
- node: true
+ jshintrc: 'grunt/.jshintrc'
},
src: ['Gruntfile.js', 'grunt/*.js']
},
diff --git a/grunt/.jshintrc b/grunt/.jshintrc
new file mode 100644
index 000000000..ddc04c9a5
--- /dev/null
+++ b/grunt/.jshintrc
@@ -0,0 +1,16 @@
+{
+ "asi": false,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 2,
+ "newcap": true,
+ "noarg": true,
+ "nonbsp": true,
+ "quotmark": "single",
+ "undef": true,
+ "strict": true,
+ "trailing": true,
+ "node" : true
+}
diff --git a/grunt/bs-glyphicons-data-generator.js b/grunt/bs-glyphicons-data-generator.js
index 9e4317f6f..941684cc9 100644
--- a/grunt/bs-glyphicons-data-generator.js
+++ b/grunt/bs-glyphicons-data-generator.js
@@ -4,29 +4,31 @@
* Copyright 2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
-
-var fs = require('fs')
+'use strict';
+var fs = require('fs');
module.exports = function generateGlyphiconsData() {
// Pass encoding, utf8, so `readFileSync` will return a string instead of a
// buffer
- var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8')
- var glpyhiconsLines = glyphiconsFile.split('\n')
+ var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8');
+ var glpyhiconsLines = glyphiconsFile.split('\n');
// Use any line that starts with ".glyphicon-" and capture the class name
- var iconClassName = /^\.(glyphicon-[^\s]+)/
+ var iconClassName = /^\.(glyphicon-[^\s]+)/;
var glyphiconsData = '# This file is generated via Grunt task. **Do not edit directly.** \n' +
'# See the \'build-glyphicons-data\' task in Gruntfile.js.\n\n';
for (var i = 0, len = glpyhiconsLines.length; i < len; i++) {
- var match = glpyhiconsLines[i].match(iconClassName)
+ var match = glpyhiconsLines[i].match(iconClassName);
- if (match != null) {
- glyphiconsData += '- ' + match[1] + '\n'
+ if (match !== null) {
+ glyphiconsData += '- ' + match[1] + '\n';
}
}
// Create the `_data` directory if it doesn't already exist
- if (!fs.existsSync('docs/_data')) fs.mkdirSync('docs/_data')
+ if (!fs.existsSync('docs/_data')) {
+ fs.mkdirSync('docs/_data');
+ }
- fs.writeFileSync('docs/_data/glyphicons.yml', glyphiconsData)
-}
+ fs.writeFileSync('docs/_data/glyphicons.yml', glyphiconsData);
+};
diff --git a/grunt/bs-lessdoc-parser.js b/grunt/bs-lessdoc-parser.js
index 0433e6175..5a86f13a0 100644
--- a/grunt/bs-lessdoc-parser.js
+++ b/grunt/bs-lessdoc-parser.js
@@ -4,6 +4,7 @@
* Copyright 2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
+'use strict';
var markdown = require('markdown').markdown;
diff --git a/grunt/bs-raw-files-generator.js b/grunt/bs-raw-files-generator.js
index bc005a422..b5b33093d 100644
--- a/grunt/bs-raw-files-generator.js
+++ b/grunt/bs-raw-files-generator.js
@@ -1,32 +1,31 @@
/* global btoa: true */
-
/*!
* Bootstrap Grunt task for generating raw-files.min.js for the Customizer
* http://getbootstrap.com
* Copyright 2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
-
-var btoa = require('btoa')
-var fs = require('fs')
+'use strict';
+var btoa = require('btoa');
+var fs = require('fs');
function getFiles(type) {
- var files = {}
+ var files = {};
fs.readdirSync(type)
.filter(function (path) {
- return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
+ return type === 'fonts' ? true : new RegExp('\\.' + type + '$').test(path);
})
.forEach(function (path) {
- var fullPath = type + '/' + path
- return files[path] = (type == 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'))
- })
- return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
+ var fullPath = type + '/' + path;
+ files[path] = (type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'));
+ });
+ return 'var __' + type + ' = ' + JSON.stringify(files) + '\n';
}
module.exports = function generateRawFilesJs(banner) {
if (!banner) {
- banner = ''
+ banner = '';
}
- var files = banner + getFiles('js') + getFiles('less') + getFiles('fonts')
- fs.writeFileSync('docs/assets/js/raw-files.min.js', files)
-}
+ var files = banner + getFiles('js') + getFiles('less') + getFiles('fonts');
+ fs.writeFileSync('docs/assets/js/raw-files.min.js', files);
+};
diff --git a/grunt/shrinkwrap.js b/grunt/shrinkwrap.js
index 53daec7dd..d3292b498 100644
--- a/grunt/shrinkwrap.js
+++ b/grunt/shrinkwrap.js
@@ -8,7 +8,7 @@
This Grunt task updates the npm-shrinkwrap.canonical.json file that's used as the key for Bootstrap's npm packages cache.
This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
*/
-
+'use strict';
var canonicallyJsonStringify = require('canonical-json');
var NON_CANONICAL_FILE = 'npm-shrinkwrap.json';
var DEST_FILE = 'test-infra/npm-shrinkwrap.canonical.json';