From 7d7c86b956d47d6b2704d1e625f38dd1051719b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Gomes?= Date: Thu, 15 Dec 2016 16:10:19 +0000 Subject: [PATCH] Updating JSCS and fixing linting errors. Also removing custom JSCS rule for Closure. --- .jscsrc | 5 +- gulpfile.babel.js | 6 +-- package.json | 2 +- src/third_party/rAF.js | 68 +++++++++++++------------- utils/jscs-rules/closure-camel-case.js | 68 -------------------------- 5 files changed, 39 insertions(+), 110 deletions(-) delete mode 100644 utils/jscs-rules/closure-camel-case.js diff --git a/.jscsrc b/.jscsrc index ca195c19..211744d0 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,6 +1,5 @@ { "preset": "google", - "esnext": true, "disallowSpacesInAnonymousFunctionExpression": null, "validateLineBreaks": "LF", "validateIndentation": 2, @@ -8,9 +7,7 @@ "maximumLineLength": 130, "validateQuoteMarks": "'", "requireDotNotation": false, - "requireCamelCaseOrUpperCaseIdentifiers": null, - "additionalRules": ["./utils/jscs-rules/*.js", "../utils/jscs-rules/*.js"], - "closureCamelCase": true, + "requireCamelCaseOrUpperCaseIdentifiers": {"allowedPrefixes": ["opt_"]}, "jsDoc": { "checkAnnotations": { "preset": "closurecompiler", diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 76e12bb8..d5b70d8d 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -17,7 +17,7 @@ * */ - // jscs:disable jsDoc +// jscs:disable jsDoc 'use strict'; @@ -219,12 +219,12 @@ gulp.task('closure', () => { compilerPath: 'node_modules/google-closure-compiler/compiler.jar', fileName: 'material.closure.min.js', compilerFlags: { - // jscs:disable closureCamelCase + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers compilation_level: 'ADVANCED_OPTIMIZATIONS', language_in: 'ECMASCRIPT6_STRICT', language_out: 'ECMASCRIPT5_STRICT', warning_level: 'VERBOSE' - // jscs:enable closureCamelCase + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers } })) .pipe(gulp.dest('./dist')); diff --git a/package.json b/package.json index f660e44b..a2161e75 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "gulp-if": "^2.0.0", "gulp-iife": "^0.3.0", "gulp-imagemin": "^3.1.0", - "gulp-jscs": "^3.0.1", + "gulp-jscs": "^4.0.0", "gulp-jshint": "^2.0.4", "gulp-load-plugins": "^1.3.0", "gulp-marked": "^1.0.0", diff --git a/src/third_party/rAF.js b/src/third_party/rAF.js index d2e8d777..863f561f 100644 --- a/src/third_party/rAF.js +++ b/src/third_party/rAF.js @@ -9,42 +9,42 @@ // MIT license (function() { -'use strict'; + 'use strict'; -if (!Date.now) { - /** - * Date.now polyfill. - * @return {number} the current Date - */ - Date.now = function() { return new Date().getTime(); }; - Date['now'] = Date.now; -} + if (!Date.now) { + /** + * Date.now polyfill. + * @return {number} the current Date + */ + Date.now = function() { return new Date().getTime(); }; + Date['now'] = Date.now; + } -var vendors = ['webkit', 'moz']; -for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { - var vp = vendors[i]; - window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; - window.cancelAnimationFrame = (window[vp + 'CancelAnimationFrame'] || - window[vp + 'CancelRequestAnimationFrame']); - window['requestAnimationFrame'] = window.requestAnimationFrame; - window['cancelAnimationFrame'] = window.cancelAnimationFrame; -} + var vendors = ['webkit', 'moz']; + for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { + var vp = vendors[i]; + window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; + window.cancelAnimationFrame = (window[vp + 'CancelAnimationFrame'] || + window[vp + 'CancelRequestAnimationFrame']); + window['requestAnimationFrame'] = window.requestAnimationFrame; + window['cancelAnimationFrame'] = window.cancelAnimationFrame; + } -if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { - var lastTime = 0; - /** - * requestAnimationFrame polyfill. - * @param {!Function} callback the callback function. - */ - window.requestAnimationFrame = function(callback) { - var now = Date.now(); - var nextTime = Math.max(lastTime + 16, now); - return setTimeout(function() { callback(lastTime = nextTime); }, - nextTime - now); - }; - window.cancelAnimationFrame = clearTimeout; - window['requestAnimationFrame'] = window.requestAnimationFrame; - window['cancelAnimationFrame'] = window.cancelAnimationFrame; -} + if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { + var lastTime = 0; + /** + * requestAnimationFrame polyfill. + * @param {!Function} callback the callback function. + */ + window.requestAnimationFrame = function(callback) { + var now = Date.now(); + var nextTime = Math.max(lastTime + 16, now); + return setTimeout(function() { callback(lastTime = nextTime); }, + nextTime - now); + }; + window.cancelAnimationFrame = clearTimeout; + window['requestAnimationFrame'] = window.requestAnimationFrame; + window['cancelAnimationFrame'] = window.cancelAnimationFrame; + } })(); diff --git a/utils/jscs-rules/closure-camel-case.js b/utils/jscs-rules/closure-camel-case.js deleted file mode 100644 index 4c1b5e35..00000000 --- a/utils/jscs-rules/closure-camel-case.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Checks that identifiers are written in camelCase (or UPPER_CASE), with the - * exception of optional parameters (opt_foo), which follow Closure convention. - */ - -'use strict'; - -module.exports = function() {}; - -/** - * Returns the option name to JSCS. - * @return {string} the option name. - */ -module.exports.prototype.getOptionName = function() { - return 'closureCamelCase'; -}; - -/** - * Configure the rule parameters. - * @param {boolean} value the value for this rule. - */ -module.exports.prototype.configure = function(value) { - // rule preparation and configuration - this._options = value; -}; - -/** - * Checks whether or not the rule is being broken. - * @param {Object} file the file being checked - * @param {Object} errors the current list of errors on the file - */ -module.exports.prototype.check = function(file, errors) { - if (!this._options) { - return; - } - file.iterateTokensByType('Identifier', function(token) { - var name = token.value; - if (name.replace(/^_+/g, '') - .replace(/^opt_+/g, '') - .replace(/_+$/g, '') - .indexOf('_') === -1 || - name.toUpperCase() === name) { - return; - } - errors.add( - 'All identifiers must be camelCase or UPPER_CASE', - token.loc.start.line, - token.loc.start.column - ); - }); -};