mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
Treat compiler warnings as errors and run on travis (#3378)
* Enable compiler warnings as errors and run on travis
This commit is contained in:
@@ -63,7 +63,8 @@ Blockly.FieldVariable = function(varName, opt_validator, opt_variableTypes,
|
||||
/**
|
||||
* An array of options for a dropdown list,
|
||||
* or a function which generates these options.
|
||||
* @type {!function(this:Blockly.FieldVariable): !Array.<!Array>}
|
||||
* @type {(!Array.<!Array>|
|
||||
* !function(this:Blockly.FieldDropdown): !Array.<!Array>)}
|
||||
* @protected
|
||||
*/
|
||||
this.menuGenerator_ = Blockly.FieldVariable.dropdownCreate;
|
||||
|
||||
@@ -570,8 +570,8 @@ Blockly.InsertionMarkerManager.prototype.highlightBlock_ = function() {
|
||||
closest.targetBlock().highlightForReplacement(true);
|
||||
} else if (local.type == Blockly.OUTPUT_VALUE) {
|
||||
this.highlightedBlock_ = closest.getSourceBlock();
|
||||
// TODO: remove?
|
||||
closest.getSourceBlock().highlightShapeForInput(closest, true);
|
||||
// TODO: Bring this back for zelos rendering.
|
||||
// closest.getSourceBlock().highlightShapeForInput(closest, true);
|
||||
}
|
||||
this.highlightingBlock_ = true;
|
||||
};
|
||||
@@ -585,7 +585,8 @@ Blockly.InsertionMarkerManager.prototype.unhighlightBlock_ = function() {
|
||||
// If there's no block in place, but we're still connecting to a value input,
|
||||
// then we must have been highlighting an input shape.
|
||||
if (closest.type == Blockly.INPUT_VALUE && !closest.isConnected()) {
|
||||
this.highlightedBlock_.highlightShapeForInput(closest, false);
|
||||
// TODO: Bring this back for zelos rendering.
|
||||
// this.highlightedBlock_.highlightShapeForInput(closest, false);
|
||||
} else {
|
||||
this.highlightedBlock_.highlightForReplacement(false);
|
||||
}
|
||||
|
||||
@@ -137,5 +137,6 @@ Blockly.geras.PathObject.prototype.applyColour = function(isShadow) {
|
||||
Blockly.geras.PathObject.prototype.setStyle = function(blockStyle) {
|
||||
this.style = blockStyle;
|
||||
this.colourDark =
|
||||
Blockly.utils.colour.blend('#000', this.style.colourPrimary, 0.2);
|
||||
Blockly.utils.colour.blend('#000', this.style.colourPrimary, 0.2) ||
|
||||
this.colourDark;
|
||||
};
|
||||
|
||||
@@ -163,7 +163,7 @@ Blockly.Theme.createBlockStyle = function(colour) {
|
||||
*/
|
||||
Blockly.Theme.validatedBlockStyle = function(blockStyle) {
|
||||
// Make a new object with all of the same properties.
|
||||
var valid = {};
|
||||
var valid = /** @type {!Blockly.Theme.BlockStyle} */ ({});
|
||||
if (blockStyle) {
|
||||
Blockly.utils.object.mixin(valid, blockStyle);
|
||||
}
|
||||
@@ -174,10 +174,12 @@ Blockly.Theme.validatedBlockStyle = function(blockStyle) {
|
||||
valid.colourPrimary = parsedColour.hex;
|
||||
valid.colourSecondary = valid.colourSecondary ?
|
||||
Blockly.utils.colour.parseBlockColour(valid.colourSecondary).hex :
|
||||
Blockly.utils.colour.blend('#fff', valid.colourPrimary, 0.6);
|
||||
Blockly.utils.colour.blend('#fff', valid.colourPrimary, 0.6) ||
|
||||
valid.colourPrimary;
|
||||
valid.colourTertiary = valid.colourTertiary ?
|
||||
Blockly.utils.colour.parseBlockColour(valid.colourTertiary).hex :
|
||||
Blockly.utils.colour.blend('#fff', valid.colourPrimary, 0.3);
|
||||
Blockly.utils.colour.blend('#fff', valid.colourPrimary, 0.3) ||
|
||||
valid.colourPrimary;
|
||||
|
||||
valid.hat = valid.hat || '';
|
||||
return valid;
|
||||
|
||||
68
gulpfile.js
68
gulpfile.js
@@ -79,12 +79,71 @@ function prependHeader() {
|
||||
return gulp.insert.prepend(`// Do not edit this file; automatically generated by gulp.\n`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closure compiler warning groups used to treat warnings as errors.
|
||||
*/
|
||||
var JSCOMP_ERROR = [
|
||||
'accessControls',
|
||||
'ambiguousFunctionDecl',
|
||||
'checkPrototypalTypes',
|
||||
'checkRegExp',
|
||||
'checkTypes',
|
||||
'checkVars',
|
||||
'conformanceViolations',
|
||||
'const',
|
||||
'constantProperty',
|
||||
'deprecated',
|
||||
'deprecatedAnnotations',
|
||||
'duplicateMessage',
|
||||
// 'es3',
|
||||
'es5Strict',
|
||||
'externsValidation',
|
||||
'fileoverviewTags',
|
||||
'functionParams',
|
||||
'globalThis',
|
||||
'internetExplorerChecks',
|
||||
'invalidCasts',
|
||||
'misplacedTypeAnnotation',
|
||||
'missingGetCssName',
|
||||
// 'missingOverride',
|
||||
'missingPolyfill',
|
||||
'missingProperties',
|
||||
'missingProvide',
|
||||
'missingRequire',
|
||||
'missingReturn',
|
||||
// 'missingSourcesWarnings',
|
||||
'moduleLoad',
|
||||
'msgDescriptions',
|
||||
'newCheckTypes',
|
||||
'nonStandardJsDocs',
|
||||
// 'polymer',
|
||||
// 'reportUnknownTypes',
|
||||
// 'strictCheckTypes',
|
||||
// 'strictMissingProperties',
|
||||
'strictModuleDepCheck',
|
||||
// 'strictPrimitiveOperators',
|
||||
'suspiciousCode',
|
||||
'typeInvalidation',
|
||||
'undefinedNames',
|
||||
'undefinedVars',
|
||||
'underscore',
|
||||
'unknownDefines',
|
||||
'unusedLocalVariables',
|
||||
// 'unusedPrivateMembers',
|
||||
'useOfGoogBase',
|
||||
'uselessCode',
|
||||
'untranspilableFeatures',
|
||||
'visibility'
|
||||
];
|
||||
|
||||
/**
|
||||
* Helper method for calling the Closure compiler.
|
||||
* @param {*} compilerOptions
|
||||
* @param {boolean=} opt_verbose Optional option for verbose logging
|
||||
* @param {boolean=} opt_warnings_as_error Optional option for treating warnings
|
||||
* as errors.
|
||||
*/
|
||||
function compile(compilerOptions, opt_verbose) {
|
||||
function compile(compilerOptions, opt_verbose, opt_warnings_as_error) {
|
||||
if (!compilerOptions) compilerOptions = {};
|
||||
compilerOptions.compilation_level = 'SIMPLE_OPTIMIZATIONS';
|
||||
compilerOptions.warning_level = opt_verbose ? 'VERBOSE' : 'DEFAULT';
|
||||
@@ -92,6 +151,7 @@ function compile(compilerOptions, opt_verbose) {
|
||||
compilerOptions.language_out = 'ECMASCRIPT5_STRICT';
|
||||
compilerOptions.rewrite_polyfills = false;
|
||||
compilerOptions.hide_warnings_for = 'node_modules';
|
||||
if (opt_warnings_as_error) compilerOptions.jscomp_error = JSCOMP_ERROR;
|
||||
|
||||
const platform = ['native', 'java', 'javascript'];
|
||||
|
||||
@@ -125,7 +185,7 @@ gulp.task('build-core', function () {
|
||||
js_output_file: 'blockly_compressed.js',
|
||||
externs: './externs/svg-externs.js',
|
||||
define: defines
|
||||
}, argv.verbose))
|
||||
}, argv.verbose, argv.strict))
|
||||
.pipe(prependHeader())
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
@@ -157,7 +217,7 @@ goog.provide('Blockly.Mutator');`;
|
||||
.pipe(compile({
|
||||
dependency_mode: 'NONE',
|
||||
js_output_file: 'blocks_compressed.js'
|
||||
}, argv.verbose))
|
||||
}, argv.verbose, argv.strict))
|
||||
.pipe(gulp.replace('\'use strict\';', '\'use strict\';\n\n\n'))
|
||||
// Remove Blockly.Blocks to be compatible with Blockly.
|
||||
.pipe(gulp.replace(/var Blockly=\{[^;]*\};\n?/, ''))
|
||||
@@ -185,7 +245,7 @@ goog.provide('Blockly.utils.string');`;
|
||||
.pipe(compile({
|
||||
dependency_mode: 'NONE',
|
||||
js_output_file: `${language}_compressed.js`
|
||||
}, argv.verbose))
|
||||
}, argv.verbose, argv.strict))
|
||||
.pipe(gulp.replace('\'use strict\';', '\'use strict\';\n\n\n'))
|
||||
// Remove Blockly.Generator and Blockly.utils.string to be compatible with Blockly.
|
||||
.pipe(gulp.replace(/var Blockly=\{[^;]*\};\s*Blockly.utils.global={};\s*Blockly.utils.string={};\n?/, ''))
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
"build": "gulp build",
|
||||
"build:blocks": "gulp build-blocks",
|
||||
"build:core": "gulp build-core",
|
||||
"build:debug": "gulp build-core --verbose > build-debug.log 2>&1 && tail -3 -r build-debug.log",
|
||||
"build:debug": "gulp build-core --verbose --strict",
|
||||
"build:debug:log": "npm run build:debug > build-debug.log 2>&1 && tail -3 build-debug.log",
|
||||
"build:langfiles": "gulp build-langfiles",
|
||||
"build:uncompressed": "gulp build-uncompressed",
|
||||
"bump": "npm version 3.$(date +'%Y%m%d').0",
|
||||
|
||||
@@ -64,6 +64,9 @@ run_test_command "node" "./node_modules/.bin/mocha tests/node --opts tests/node/
|
||||
# Run generator tests inside a browser and check the results.
|
||||
run_test_command "generators" "tests/scripts/run_generators.sh"
|
||||
|
||||
# Run the closure compiler ensuring there are no errors.
|
||||
run_test_command "compile" "npm run build:debug"
|
||||
|
||||
# Generate TypeScript typings and ensure there are no errors.
|
||||
run_test_command "typings" "tests/scripts/compile_typings.sh"
|
||||
|
||||
@@ -71,7 +74,7 @@ run_test_command "typings" "tests/scripts/compile_typings.sh"
|
||||
run_test_command "metadata" "tests/scripts/check_metadata.sh"
|
||||
|
||||
# # Attempt advanced compilation of a Blockly app.
|
||||
# run_test_command "compile" "tests/compile/compile.sh"
|
||||
# run_test_command "advanced_compile" "tests/compile/compile.sh"
|
||||
|
||||
|
||||
# End of tests.
|
||||
|
||||
Reference in New Issue
Block a user