Updating JSCS and fixing linting errors.

Also removing custom JSCS rule for Closure.
master
Sérgio Gomes 2016-12-15 16:10:19 +00:00
parent 76b1fc99cb
commit 7d7c86b956
No known key found for this signature in database
GPG Key ID: B273014C8B9F3B03
5 changed files with 39 additions and 110 deletions

View File

@ -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",

View File

@ -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'));

View File

@ -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",

View File

@ -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;
}
})();

View File

@ -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
);
});
};