Add a lint plugin to ensure we only use ES5 syntax. (#3160)

* Add a lint plugin to ensure we only use ES5 only syntax.
This commit is contained in:
Sam El-Husseini
2019-10-21 21:26:26 -04:00
committed by GitHub
parent ff067497fc
commit 6d8f22f39a
7 changed files with 35 additions and 19 deletions

View File

@@ -22,28 +22,28 @@
var assert = require('chai').assert;
var Blockly = require('../../dist/');
var xmlText = `<xml xmlns="https://developers.google.com/blockly/xml">
<block type="text_print" x="37" y="63">
<value name="TEXT">
<shadow type="text">
<field name="TEXT">Hello from Blockly!</field>
</shadow>
</value>
</block>
</xml>`;
var xmlText = '<xml xmlns="https://developers.google.com/blockly/xml">\n' +
' <block type="text_print" x="37" y="63">\n' +
' <value name="TEXT">\n' +
' <shadow type="text">\n' +
' <field name="TEXT">Hello from Blockly!</field>\n' +
' </shadow>\n' +
' </value>\n' +
' </block>\n' +
'</xml>';
suite('Test Node.js', function() {
test('Import XML', function() {
const xml = Blockly.Xml.textToDom(xmlText);
var xml = Blockly.Xml.textToDom(xmlText);
// Create workspace and import the XML
const workspace = new Blockly.Workspace();
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
});
test('Roundtrip XML', function() {
const xml = Blockly.Xml.textToDom(xmlText);
var xml = Blockly.Xml.textToDom(xmlText);
const workspace = new Blockly.Workspace();
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
var headlessXml = Blockly.Xml.workspaceToDom(workspace, true);
@@ -52,17 +52,17 @@ suite('Test Node.js', function() {
assert.equal(headlessText, xmlText, 'equal');
});
test('Generate Code', function() {
const xml = Blockly.Xml.textToDom(xmlText);
var xml = Blockly.Xml.textToDom(xmlText);
// Create workspace and import the XML
const workspace = new Blockly.Workspace();
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
// Convert code
const code = Blockly.JavaScript.workspaceToCode(workspace);
var code = Blockly.JavaScript.workspaceToCode(workspace);
// Check output
assert.equal(`window.alert('Hello from Blockly!');`, code.trim(), 'equal');
assert.equal('window.alert(\'Hello from Blockly!\');', code.trim(), 'equal');
});
});