diff --git a/ably/ably-tests.ts b/ably/ably-tests.ts index 0f84e533a7..d9f19137f0 100644 --- a/ably/ably-tests.ts +++ b/ably/ably-tests.ts @@ -9,13 +9,13 @@ const restClient = new Ably.Rest(ApiKey); // Connection // Successful connection: -client.connection.on('connected', function() { +client.connection.on('connected', () => { // successful connection }); // Failed connection: -client.connection.on('failed', function() { +client.connection.on('failed', () => { // failed connection }); @@ -23,14 +23,14 @@ client.connection.on('failed', function() { // Subscribing to a channel var channel = client.channels.get('test'); -channel.subscribe(function(message) { +channel.subscribe(message => { message.name; // 'greeting' message.data; // 'Hello World!' }); // Only certain events: -channel.subscribe('myEvent', function(message) { +channel.subscribe('myEvent', message => { message.name; // 'myEvent' message.data; // 'myData' }); @@ -41,7 +41,7 @@ channel.subscribe('myEvent', function(message) { channel.publish('greeting', 'Hello World!'); // Optionally, you can use a callback to be notified of success or failure -channel.publish('greeting', 'Hello World!', function(err) { +channel.publish('greeting', 'Hello World!', err => { if(err) { console.log('publish failed with error ' + err); } else { @@ -50,21 +50,21 @@ channel.publish('greeting', 'Hello World!', function(err) { }); // Publish several messages at once -channel.publish([{name: 'greeting', data: 'Hello World!'}], function() { }); +channel.publish([{name: 'greeting', data: 'Hello World!'}], () => { }); // Querying the History -channel.history(function(err, messagesPage) { +channel.history((err, messagesPage) => { messagesPage.items; // array of Message messagesPage.items[0].data; // payload for first message messagesPage.items.length; // number of messages in the current page of history messagesPage.hasNext(); // true if there are further pages messagesPage.isLast(); // true if this page is the last page - messagesPage.next(function(nextPage) { nextPage; }); // retrieves the next page as PaginatedResult + messagesPage.next(nextPage => { nextPage; }); // retrieves the next page as PaginatedResult }); // Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history -channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards'}, function(err, messagesPage) { +channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards'}, (err, messagesPage) => { console.log(messagesPage.items.length); }); @@ -72,7 +72,7 @@ channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direct // Presence on a channel // Getting presence: -channel.presence.get(function(presenceSet) { +channel.presence.get(presenceSet => { presenceSet; // array of PresenceMessages }); @@ -80,35 +80,35 @@ channel.presence.get(function(presenceSet) { // Entering (and leaving) the presence set: -channel.presence.enter('my status', function(err) { +channel.presence.enter('my status', err => { // now I am entered }); -channel.presence.update('new status', function(err) { +channel.presence.update('new status', err => { // my presence data is updated }); -channel.presence.leave(null, function(err) { +channel.presence.leave(null, err => { // I've left the presence set }); -channel.presence.enterClient('myClientId', 'status', function(err) { +channel.presence.enterClient('myClientId', 'status', err => { }); // and similiarly, updateClient and leaveClient // Querying the Presence History -channel.presence.history(function(err, messagesPage) { // PaginatedResult +channel.presence.history((err, messagesPage) => { // PaginatedResult messagesPage.items; // array of PresenceMessage messagesPage.items[0].data; // payload for first message messagesPage.items.length; // number of messages in the current page of history messagesPage.hasNext(); // true if there are further pages messagesPage.isLast(); // true if this page is the last page - messagesPage.next(function(nextPage) { }); // retrieves the next page as PaginatedResult + messagesPage.next(nextPage => { }); // retrieves the next page as PaginatedResult }); // Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history -channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {}); +channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, (err, messagesPage) => {}); // Symmetrical end-to-end encrypted payloads on a channel @@ -116,10 +116,10 @@ channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direct // Generate a random 256-bit key for demonstration purposes (in // practice you need to create one and distribute it to clients yourselves) -Ably.Realtime.Crypto.generateRandomKey(function(err, key) { +Ably.Realtime.Crypto.generateRandomKey((err, key) => { var channel = client.channels.get('channelName', { cipher: { key } }); - channel.subscribe(function(message) { + channel.subscribe(message => { message.name; // 'name is not encrypted' message.data; // 'sensitive data is encrypted' }); @@ -129,7 +129,7 @@ Ably.Realtime.Crypto.generateRandomKey(function(err, key) { // You can also change the key on an existing channel using setOptions (which takes a callback which is called after the new encryption settings have taken effect): -channel.setOptions({cipher: {key: ''}}, function() { +channel.setOptions({cipher: {key: ''}}, () => { // New encryption settings are in effect }); @@ -143,7 +143,7 @@ var restChannel = restClient.channels.get('test'); restChannel.publish('greeting', 'Hello World!'); // Optionally, you can use a callback to be notified of success or failure -restChannel.publish('greeting', 'Hello World!', function(err) { +restChannel.publish('greeting', 'Hello World!', err => { if(err) { console.log('publish failed with error ' + err); } else { @@ -152,47 +152,47 @@ restChannel.publish('greeting', 'Hello World!', function(err) { }); // Publish several messages at once -restChannel.publish([{name: 'greeting', data: 'Hello World!'}], function() {}); +restChannel.publish([{name: 'greeting', data: 'Hello World!'}], () => {}); // Querying the History -restChannel.history(function(err, messagesPage) { +restChannel.history((err, messagesPage) => { messagesPage; // PaginatedResult messagesPage.items; // array of Message messagesPage.items[0].data; // payload for first message messagesPage.items.length; // number of messages in the current page of history messagesPage.hasNext(); // true if there are further pages messagesPage.isLast(); // true if this page is the last page - messagesPage.next(function(nextPage) {}); // retrieves the next page as PaginatedResult + messagesPage.next(nextPage => {}); // retrieves the next page as PaginatedResult }); // Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history -restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {}); +restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, (err, messagesPage) => {}); // Presence on a channel -restChannel.presence.get(function(err, presencePage) { // PaginatedResult +restChannel.presence.get((err, presencePage) => { // PaginatedResult presencePage.items; // array of PresenceMessage presencePage.items[0].data; // payload for first message presencePage.items.length; // number of messages in the current page of members presencePage.hasNext(); // true if there are further pages presencePage.isLast(); // true if this page is the last page - presencePage.next(function(nextPage) {}); // retrieves the next page as PaginatedResult + presencePage.next(nextPage => {}); // retrieves the next page as PaginatedResult }); // Querying the Presence History -restChannel.presence.history(function(err, messagesPage) { // PaginatedResult +restChannel.presence.history((err, messagesPage) => { // PaginatedResult messagesPage.items; // array of PresenceMessage messagesPage.items[0].data; // payload for first message messagesPage.items.length; // number of messages in the current page of history messagesPage.hasNext(); // true if there are further pages messagesPage.isLast(); // true if this page is the last page - messagesPage.next(function(nextPage) { }); // retrieves the next page as PaginatedResult + messagesPage.next(nextPage => { }); // retrieves the next page as PaginatedResult }); // Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history -restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, function(err, messagesPage) {}); +restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, (err, messagesPage) => {}); // Generate Token and Token Request @@ -200,7 +200,7 @@ restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, di // Requesting a token: -client.auth.requestToken(function(err, tokenDetails) { +client.auth.requestToken((err, tokenDetails) => { // tokenDetails is instance of TokenDetails // see https://www.ably.io/documentation/rest/authentication/#token-details for its properties @@ -211,11 +211,11 @@ client.auth.requestToken(function(err, tokenDetails) { // requestToken can take two optional params // tokenParams: https://www.ably.io/documentation/rest/authentication/#token-params // authOptions: https://www.ably.io/documentation/rest/authentication/#auth-options -client.auth.requestToken({}, {}, function(err, tokenDetails) { }); +client.auth.requestToken({}, {}, (err, tokenDetails) => { }); // Creating a token request (for example, on a server in response to a request by a client using the authCallback or authUrl mechanisms): -client.auth.createTokenRequest(function(err, tokenRequest) { +client.auth.createTokenRequest((err, tokenRequest) => { // now send the tokenRequest back to the client, which will // use it to request a token and connect to Ably }); @@ -223,22 +223,22 @@ client.auth.createTokenRequest(function(err, tokenRequest) { // createTokenRequest can take two optional params // tokenParams: https://www.ably.io/documentation/rest/authentication/#token-params // authOptions: https://www.ably.io/documentation/rest/authentication/#auth-options -client.auth.createTokenRequest({}, {}, function(err, tokenRequest) { }); +client.auth.createTokenRequest({}, {}, (err, tokenRequest) => { }); // Fetching your application's stats -client.stats({ limit: 50 }, function(err, statsPage) { // statsPage as PaginatedResult +client.stats({ limit: 50 }, (err, statsPage) => { // statsPage as PaginatedResult statsPage.items; // array of Stats statsPage.items[0].inbound.rest.messages.count; // total messages published over REST statsPage.items.length; // number of stats in the current page of history - statsPage.hasNext(); // true if there are further pages + statsPage.hasNext(); // true if there are wrther pages statsPage.isLast(); // true if this page is the last page - statsPage.next(function(nextPage) {}); // retrieves the next page as PaginatedResult + statsPage.next((nextPage) => {}); // retrieves the next page as PaginatedResult }); // Fetching the Ably service time -client.time({}, function(err, time) {}); // time is in ms since epoch +client.time({}, (err, time) => {}); // time is in ms since epoch // Getting decoded Message objects from JSON var messages = Ably.Realtime.Message.fromEncodedArray([{ id: 'foo' }]); diff --git a/amplify-deferred/amplify-deferred-tests.ts b/amplify-deferred/amplify-deferred-tests.ts index a4c7c656c4..5a65dd9dde 100644 --- a/amplify-deferred/amplify-deferred-tests.ts +++ b/amplify-deferred/amplify-deferred-tests.ts @@ -1,5 +1,5 @@ amplify.request({ resourceId: "statusExample1" -}).done(function (data, status) { -}).fail(function (data, status) { -}).always(function (data, status) { }); +}).done((data, status) => { +}).fail((data, status) => { +}).always((data, status) => { }); diff --git a/amplify/amplify-tests.ts b/amplify/amplify-tests.ts index 64e1f4791b..62584ec98b 100644 --- a/amplify/amplify-tests.ts +++ b/amplify/amplify-tests.ts @@ -7,7 +7,7 @@ import amplify = require("amplify"); // Subscribe and publish with no data -amplify.subscribe("nodataexample", function () { +amplify.subscribe("nodataexample", () => { alert("nodataexample topic published!"); }); @@ -15,14 +15,14 @@ amplify.subscribe("nodataexample", function () { amplify.publish("nodataexample"); -amplify.subscribe("dataexample", function (data) { +amplify.subscribe("dataexample", data => { alert(data.foo); // bar }); amplify.publish("dataexample", { foo: "bar" }); -amplify.subscribe("dataexample2", function (param1, param2) { +amplify.subscribe("dataexample2", (param1, param2) => { alert(param1 + param2); // barbaz }); @@ -32,7 +32,7 @@ amplify.publish("dataexample2", "bar", "baz"); // Subscribe and publish with context and data -amplify.subscribe("datacontextexample", $("p:first"), function (data) { +amplify.subscribe("datacontextexample", $("p:first"), data => { this.text(data.exampleText); // first p element would have "foo bar baz" as text }); @@ -40,11 +40,11 @@ amplify.publish("datacontextexample", { exampleText: "foo bar baz" }); // Subscribe to a topic with high priority -amplify.subscribe("priorityexample", function (data) { +amplify.subscribe("priorityexample", data => { alert(data.foo); }); -amplify.subscribe("priorityexample", function (data) { +amplify.subscribe("priorityexample", data => { if (data.foo === "oops") { return false; } @@ -87,7 +87,7 @@ amplify.request.define("ajaxExample1", "ajax", { }); // later in code -amplify.request("ajaxExample1", function (data) { +amplify.request("ajaxExample1", data => { data.foo; // bar }); @@ -101,12 +101,12 @@ amplify.request.define("ajaxExample2", "ajax", { }); // later in code -amplify.request("ajaxExample2", function (data) { +amplify.request("ajaxExample2", data => { data.foo; // bar }); // a second call will result in pulling from the cache -amplify.request("ajaxExample2", function (data) { +amplify.request("ajaxExample2", data => { data.baz; // qux }); @@ -123,7 +123,7 @@ amplify.request("ajaxRESTFulExample", type: "foo", id: "bar" }, - function (data) { + data => { // /myRESTFulApi/foo/bar was the URL used data.foo; // bar } @@ -142,7 +142,7 @@ amplify.request("ajaxPostExample", type: "foo", id: "bar" }, - function (data) { + data => { data.foo; // bar } ); @@ -165,7 +165,7 @@ amplify.request("twitter-search", { term: "amplifyjs" } ); amplify.request.define("twitter-mentions", "ajax", { url: "http://search.twitter.com/search.json", dataType: "jsonp", - dataMap: function (data) { + dataMap: data => { return { q: "@" + data.user }; @@ -178,7 +178,7 @@ amplify.request("twitter-mentions", { user: "amplifyjs" }); //Example: -var appEnvelopeDecoder: amplify.Decoder = function (data, status, xhr, success, error) { +var appEnvelopeDecoder: amplify.Decoder = (data, status, xhr, success, error) => { if (data.status === "success") { success(data.data); } else if (data.status === "fail" || data.status === "error") { @@ -209,10 +209,10 @@ amplify.request.define("decoderExample", "ajax", { amplify.request({ resourceId: "decoderExample", - success: function (data) { + success(data) { data.foo; // bar }, - error: function (message, level) { + error(message, level) { alert("always handle errors with alerts."); } }); @@ -224,7 +224,7 @@ amplify.request({ amplify.request.define("decoderSingleExample", "ajax", { url: "/myAjaxUrl", type: "POST", - decoder: function (data, status, xhr, success, error) { + decoder(data, status, xhr, success, error) { if (data.status === "success") { success(data.data); } else if (data.status === "fail" || data.status === "error") { @@ -237,10 +237,10 @@ amplify.request.define("decoderSingleExample", "ajax", { amplify.request({ resourceId: "decoderSingleExample", - success: function (data) { + success: data => { data.foo; // bar }, - error: function (message, level) { + error: (message, level) => { alert("always handle errors with alerts."); } }); @@ -255,9 +255,9 @@ amplify.request({ amplify.request({ resourceId: "statusExample1", - success: function (data, status) { + success: (data, status) => { }, - error: function (data, status) { + error: (data, status) => { } }); diff --git a/bitcoinjs-lib/bitcoinjs-lib-tests.ts b/bitcoinjs-lib/bitcoinjs-lib-tests.ts index e9368edd27..b9efec2f9d 100644 --- a/bitcoinjs-lib/bitcoinjs-lib-tests.ts +++ b/bitcoinjs-lib/bitcoinjs-lib-tests.ts @@ -7,8 +7,8 @@ declare var it: any; declare var describe: any; declare var assert: any; -describe('bitcoinjs-lib (basic)', function () { - it('can generate a random bitcoin address', function () { +describe('bitcoinjs-lib (basic)', () => { + it('can generate a random bitcoin address', () => { // for testing only function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'); } @@ -19,7 +19,7 @@ describe('bitcoinjs-lib (basic)', function () { assert.strictEqual(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64'); }); - it('can generate an address from a SHA256 hash', function () { + it('can generate an address from a SHA256 hash', () => { var hash = bitcoin.crypto.sha256('correct horse battery staple'); var d = bigi.fromBuffer(hash); @@ -29,7 +29,7 @@ describe('bitcoinjs-lib (basic)', function () { assert.strictEqual(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8'); }); - it('can generate a random keypair for alternative networks', function () { + it('can generate a random keypair for alternative networks', () => { // for testing only function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'); } @@ -43,14 +43,14 @@ describe('bitcoinjs-lib (basic)', function () { assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS'); }); - it('can import an address via WIF', function () { + it('can import an address via WIF', () => { var keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct'); var address = keyPair.getAddress(); assert.strictEqual(address, '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31'); }); - it('can create a Transaction', function () { + it('can create a Transaction', () => { var keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'); var tx = new bitcoin.TransactionBuilder(); diff --git a/bittorrent-protocol/bittorrent-protocol-tests.ts b/bittorrent-protocol/bittorrent-protocol-tests.ts index 1d73154565..1d0d17793a 100644 --- a/bittorrent-protocol/bittorrent-protocol-tests.ts +++ b/bittorrent-protocol/bittorrent-protocol-tests.ts @@ -1,20 +1,20 @@ import * as Protocol from 'bittorrent-protocol'; import * as net from 'net'; -net.createServer(function(socket) { +net.createServer(socket => { var wire = new Protocol(); // pipe to and from the protocol socket.pipe(wire).pipe(socket); - wire.on('handshake', function(infoHash, peerId) { + wire.on('handshake', (infoHash, peerId) => { // receive a handshake (infoHash and peerId are hex strings) // lets emit a handshake of our own as well wire.handshake('my info hash (hex)', 'my peer id (hex)'); }); - wire.on('unchoke', function() { + wire.on('unchoke', () => { console.log('peer is no longer choking us: ' + wire.peerChoking); }); }).listen(6881); diff --git a/camelcase-keys/camelcase-keys-tests.ts b/camelcase-keys/camelcase-keys-tests.ts index 2e8d7ab2d7..7388950bb6 100644 --- a/camelcase-keys/camelcase-keys-tests.ts +++ b/camelcase-keys/camelcase-keys-tests.ts @@ -3,8 +3,8 @@ import camelcaseKeys = require('camelcase-keys'); camelcaseKeys({'foo-bar': true}); //=> {fooBar: true} -camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); +camelcaseKeys({'foo-bar': true, 'nested': {unicorn_rainbow: true}}, {deep: true}); //=> {fooBar: true, nested: {unicornRainbow: true}} -camelcaseKeys({_: [], 'foo-bar': true}); +camelcaseKeys({'_': [], 'foo-bar': true}); //=> {_: [], fooBar: true} \ No newline at end of file diff --git a/chai-json-schema/chai-json-schema-tests.ts b/chai-json-schema/chai-json-schema-tests.ts index d0c1234e17..aacd40bf15 100644 --- a/chai-json-schema/chai-json-schema-tests.ts +++ b/chai-json-schema/chai-json-schema-tests.ts @@ -1,5 +1,3 @@ -/// - import { expect } from 'chai'; import { assert } from 'chai'; diff --git a/charm/charm-tests.ts b/charm/charm-tests.ts index 0cdbdc8055..afc8cbc3b6 100644 --- a/charm/charm-tests.ts +++ b/charm/charm-tests.ts @@ -7,7 +7,7 @@ var colors: getCharm.CharmColor[] = [ 'red', 'cyan', 'yellow', 'green', 'blue' ] var text = 'Always after me lucky charms.'; var offset = 0; -var iv = setInterval(function () { +var iv = setInterval(() => { var y = 0, dy = 1; for (var i = 0; i < 40; i++) { var color = colors[(i + offset) % colors.length]; diff --git a/clipboard/clipboard-tests.ts b/clipboard/clipboard-tests.ts index 7521c651dd..5af2671671 100644 --- a/clipboard/clipboard-tests.ts +++ b/clipboard/clipboard-tests.ts @@ -17,12 +17,12 @@ var cb5 = new Clipboard('.btn', { cb1.destroy(); -cb2.on('success', function(e) { +cb2.on('success', e => { console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger); e.clearSelection(); }); -cb2.on('error', function(e) { }); +cb2.on('error', e => { }); diff --git a/clndr/clndr-tests.ts b/clndr/clndr-tests.ts index 2dd65dd195..ea6c624ee8 100644 --- a/clndr/clndr-tests.ts +++ b/clndr/clndr-tests.ts @@ -25,21 +25,21 @@ let options: Clndr.ClndrOptions = { adjacentMonth: "adjacent-month", }, clickEvents: { - click: function (target) { }, - today: function (month) { }, - nextMonth: function (month) { }, - previousMonth: function (month) { }, - onMonthChange: function (month) { }, - nextYear: function (month) { }, - previousYear: function (month) { }, - onYearChange: function (month) { }, - nextInterval: function (start, end) { }, - previousInterval: function (start, end) { }, - onIntervalChange: function (start, end) { } + click(target) { }, + today(month) { }, + nextMonth(month) { }, + previousMonth(month) { }, + onMonthChange(month) { }, + nextYear(month) { }, + previousYear(month) { }, + onYearChange(month) { }, + nextInterval(start, end) { }, + previousInterval(start, end) { }, + onIntervalChange(start, end) { } }, useTouchEvents: false, - ready: function () { }, - doneRendering: function () { }, + ready() { }, + doneRendering() { }, events: [], dateParameter: 'date', multiDayEvents: { @@ -59,7 +59,7 @@ let options: Clndr.ClndrOptions = { interval: 1 }, extras: { }, - render: function (data) { + render(data) { return '
'; }, constraints: { diff --git a/code/code-tests.ts b/code/code-tests.ts index f90d2c9eb7..fd49303d77 100644 --- a/code/code-tests.ts +++ b/code/code-tests.ts @@ -136,8 +136,7 @@ class CustomError extends Error { call: (message: string) => Error; } -const throws = function () { - +const throws = () => { throw new CustomError("Oh no!"); }; diff --git a/codependency/codependency-tests.ts b/codependency/codependency-tests.ts index 46f2db8d6d..e0f8a793a6 100644 --- a/codependency/codependency-tests.ts +++ b/codependency/codependency-tests.ts @@ -1,6 +1,3 @@ -/// -/// - let requirePeer = codependency.register(module), package: any; requirePeer = codependency.register(module, {index: ["dependencies", "devDependencies"]}); requirePeer = codependency.get("some-middleware"); diff --git a/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts b/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts index 31c334afca..e2e1fbbded 100644 --- a/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts +++ b/cordova-sqlite-storage/cordova-sqlite-storage-tests.ts @@ -1,5 +1,3 @@ -/// - // examples taken from https://github.com/litehelpers/Cordova-sqlite-storage function echoTestFunction() { function successCallback(value: string) { @@ -33,26 +31,26 @@ function openingDatabase() { } function openingDatabase2() { - window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}, function(db) { - db.transaction(function(tx) { + window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}, db => { + db.transaction(tx => { // ... - }, function(err) { + }, err => { console.log('Open database ERROR: ' + JSON.stringify(err)); }); }); } function singleStatementTransactions(db: SQLitePlugin.Database) { - db.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value'], function (resultSet) { + db.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value'], resultSet => { console.log('resultSet.insertId: ' + resultSet.insertId); console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected); - }, function(error) { + }, error => { console.log('SELECT error: ' + error.message); }); - db.executeSql("SELECT LENGTH('tenletters') AS stringlength", [], function (resultSet) { + db.executeSql("SELECT LENGTH('tenletters') AS stringlength", [], resultSet => { console.log('got stringlength: ' + resultSet.rows.item(0).stringlength); - }, function(error) { + }, error => { console.log('SELECT error: ' + error.message); }); } @@ -62,40 +60,40 @@ function sqlBatchTransactions(db: SQLitePlugin.Database) { 'DROP TABLE IF EXISTS MyTable', 'CREATE TABLE MyTable (SampleColumn)', [ 'INSERT INTO MyTable VALUES (?)', ['test-value'] ], - ], function() { - db.executeSql('SELECT * FROM MyTable', [], function (resultSet) { + ], () => { + db.executeSql('SELECT * FROM MyTable', [], resultSet => { console.log('Sample column value: ' + resultSet.rows.item(0).SampleColumn); }); - }, function(error) { + }, error => { console.log('Populate table error: ' + error.message); }); } function asynchronousTransaction(db: SQLitePlugin.Database) { - db.transaction(function(tx) { + db.transaction(tx => { tx.executeSql('DROP TABLE IF EXISTS MyTable'); tx.executeSql('CREATE TABLE MyTable (SampleColumn)'); - tx.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value'], function(tx, resultSet) { + tx.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value'], (tx, resultSet) => { console.log('resultSet.insertId: ' + resultSet.insertId); console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected); - }, function(tx, error) { + }, (tx, error) => { console.log('INSERT error: ' + error.message); }); - }, function(error) { + }, error => { console.log('transaction error: ' + error.message); - }, function() { + }, () => { console.log('transaction ok'); }); - db.readTransaction(function(tx) { - tx.executeSql("SELECT UPPER('Some US-ASCII text') AS uppertext", [], function(tx, resultSet) { + db.readTransaction(tx => { + tx.executeSql("SELECT UPPER('Some US-ASCII text') AS uppertext", [], (tx, resultSet) => { console.log("resultSet.rows.item(0).uppertext: " + resultSet.rows.item(0).uppertext); - }, function(tx, error) { + }, (tx, error) => { console.log('SELECT error: ' + error.message); }); - }, function(error) { + }, error => { console.log('transaction error: ' + error.message); - }, function() { + }, () => { console.log('transaction ok'); }); } @@ -108,28 +106,28 @@ function sampleWithPRAGMA() { function onDeviceReady() { var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}); - db.transaction(function(tx) { + db.transaction(tx => { tx.executeSql('DROP TABLE IF EXISTS test_table'); tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)'); // demonstrate PRAGMA: - db.executeSql("pragma table_info (test_table);", [], function(res) { + db.executeSql("pragma table_info (test_table);", [], res => { console.log("PRAGMA res: " + JSON.stringify(res)); }); - tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) { + tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => { console.log("insertId: " + res.insertId + " -- probably 1"); console.log("rowsAffected: " + res.rowsAffected + " -- should be 1"); - db.transaction(function(tx) { - tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) { + db.transaction(tx => { + tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => { console.log("res.rows.length: " + res.rows.length + " -- should be 1"); console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1"); }); }); // }, function(e) { // probably example in https://github.com/litehelpers/Cordova-sqlite-storage is broken - }, function(_tx, e) { + }, (_tx, e) => { console.log("ERROR: " + e.message); }); }); @@ -145,20 +143,20 @@ function sampleWithTransactionLevelNesting() { function onDeviceReady() { var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}); - db.transaction(function(tx) { + db.transaction(tx => { tx.executeSql('DROP TABLE IF EXISTS test_table'); tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)'); - tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) { + tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], (tx, res) => { console.log("insertId: " + res.insertId + " -- probably 1"); console.log("rowsAffected: " + res.rowsAffected + " -- should be 1"); - tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) { + tx.executeSql("select count(id) as cnt from test_table;", [], (tx, res) => { console.log("res.rows.length: " + res.rows.length + " -- should be 1"); console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1"); }); - }, function(tx, e) { + }, (tx, e) => { console.log("ERROR: " + e.message); }); }); @@ -177,18 +175,18 @@ function dbClose(db: SQLitePlugin.Database) { db.close(successcb, errorcb); - db.transaction(function (tx) { - tx.executeSql("SELECT LENGTH('tenletters') AS stringlength", [], function (tx, res) { + db.transaction(tx => { + tx.executeSql("SELECT LENGTH('tenletters') AS stringlength", [], (tx, res) => { console.log('got stringlength: ' + res.rows.item(0).stringlength); }); - }, function (error) { + }, error => { // OK to close here: console.log('transaction error: ' + error.message); db.close(); - }, function () { + }, () => { // OK to close here: console.log('transaction ok'); - db.close(function () { + db.close(() => { console.log('database is closed ok'); }); }); @@ -207,8 +205,8 @@ function deleteDatabase() { function quickInstallationTest() { - window.sqlitePlugin.openDatabase({ name: 'hello-world.db', location: 'default' }, function (db) { - db.executeSql("select length('tenletters') as stringlength", [], function (res) { + window.sqlitePlugin.openDatabase({ name: 'hello-world.db', location: 'default' }, db => { + db.executeSql("select length('tenletters') as stringlength", [], res => { var stringlength = res.rows.item(0).stringlength; console.log('got stringlength: ' + stringlength); //document.getElementById('deviceready').querySelector('.received').innerHTML = 'stringlength: ' + stringlength; diff --git a/cryptojs/test/sha1-tests.ts b/cryptojs/test/sha1-tests.ts index 50dfe1992b..fa05f3289d 100644 --- a/cryptojs/test/sha1-tests.ts +++ b/cryptojs/test/sha1-tests.ts @@ -31,7 +31,7 @@ YUI.add('algo-sha1-test', function (Y) { Y.Assert.areEqual('761c457bf73b14d27e9e9265c46f4b4dda11f940', C.SHA1('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString()); }, - testVector7: function () { + testVector7() { Y.Assert.areEqual('50abf5706a150990a08b2c5ea40fa0e585554732', C.SHA1('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString()); }, diff --git a/d3-axis/d3-axis-tests.ts b/d3-axis/d3-axis-tests.ts index 1aa50ba641..9e50c05c7c 100644 --- a/d3-axis/d3-axis-tests.ts +++ b/d3-axis/d3-axis-tests.ts @@ -121,8 +121,8 @@ topAxis = topAxis.tickFormat(null); let formatFn: ((domainValue: string, index: number) => string) | null = bottomAxis.tickFormat(); -bottomAxis.tickFormat(function (d, i) { return '#' + i; }); -bottomAxis.tickFormat(function (d) { return d + '!'; }); +bottomAxis.tickFormat((d, i) => '#' + i); +bottomAxis.tickFormat(d => d + '!'); // tickSize(...) ---------------------------------------------------------------- rightAxis = rightAxis.tickSize(5); diff --git a/d3-brush/d3-brush-tests.ts b/d3-brush/d3-brush-tests.ts index eca4a8ef91..a4b0526a9d 100644 --- a/d3-brush/d3-brush-tests.ts +++ b/d3-brush/d3-brush-tests.ts @@ -39,7 +39,7 @@ extent = brush.extent(); brush = brush.extent([[0, 0], [300, 200]]); // chainable with function -brush = brush.extent(function (d, i, group) { +brush = brush.extent(function(d, i, group) { console.log('Owner SVG Element of svg group: ', this.ownerSVGElement); // this is of type SVGGElement return d.extent; // datum of type BrushDatum }); @@ -47,7 +47,7 @@ brush = brush.extent(function (d, i, group) { // filter() ---------------------------------------------------------------- // chainable -brush = brush.filter(function (d, i, group) { +brush = brush.filter(function(d, i, group) { // Cast d3 event to D3ZoomEvent to be used in filter logic let e = > event; @@ -68,7 +68,7 @@ let handleSize: number = brush.handleSize(); // on() ------------------------------------------------------------------------ let brushed: ((this: SVGGElement, datum: BrushDatum, index: number, group: SVGGElement[] | ArrayLike) => void) | undefined; -brushed = function (d, i, group) { +brushed = function(d, i, group) { // do anything }; @@ -87,7 +87,7 @@ brushed = brush.on('end'); brush = brush.on('end', null); // re-apply -brush.on('end', function (d, i, g) { +brush.on('end', function(d, i, g) { let that: SVGGElement = this; let datum: BrushDatum = d; let index: number = i; diff --git a/d3-chord/d3-chord-tests.ts b/d3-chord/d3-chord-tests.ts index 10d47698f0..5bde46600c 100644 --- a/d3-chord/d3-chord-tests.ts +++ b/d3-chord/d3-chord-tests.ts @@ -126,7 +126,7 @@ svgRibbon = svgRibbon.context(null); // source() ----------------------------------------------------------- -svgRibbon = svgRibbon.source(function (d) { +svgRibbon = svgRibbon.source(d => { return d.source; // datum is of type Chord }); @@ -134,7 +134,7 @@ subgroupAccessor = svgRibbon.source(); // target() ----------------------------------------------------------- -svgRibbon = svgRibbon.target(function (d) { +svgRibbon = svgRibbon.target(d => { return d.target; // datum is of type Chord }); diff --git a/expect/expect-tests.ts b/expect/expect-tests.ts index 6c5dfff5e2..3e08e0d747 100644 --- a/expect/expect-tests.ts +++ b/expect/expect-tests.ts @@ -4,8 +4,8 @@ import {Expectation, Extension, Spy, createSpy, isSpy, assert, spyOn, extend, restoreSpies} from 'expect'; import * as expect from 'expect'; -describe('chaining assertions', function () { - it('should allow chaining for array-like applications', function () { +describe('chaining assertions', () => { + it('should allow chaining for array-like applications', () => { expect([ 1, 2, 'foo', 3 ]) .toExist() .toBeAn(Array) @@ -13,7 +13,7 @@ describe('chaining assertions', function () { .toExclude('bar'); }); - it('should allow chaining for number checking', function () { + it('should allow chaining for number checking', () => { expect(3.14) .toExist() .toBeLessThan(4.2) @@ -23,16 +23,16 @@ describe('chaining assertions', function () { }); }); -describe('createSpy', function () { - describe('when given a function', function () { - it('returns a spy function', function () { +describe('createSpy', () => { + describe('when given a function', () => { + it('returns a spy function', () => { const spy = createSpy(() => { return; }); expect(spy).toBeA(Function); }); }); }); -describe('A spy', function () { +describe('A spy', () => { let targetContext: any, targetArguments: any; const target = { method() { @@ -48,7 +48,7 @@ describe('A spy', function () { targetContext = targetArguments = null; }); - it('is a spy', function () { + it('is a spy', () => { expect(isSpy(spy)).toBe(true); }); @@ -58,15 +58,15 @@ describe('A spy', function () { expect(createSpy((a, b, c) => a * b * c).length).toBe(3); }); - it('has a destroy method', function () { + it('has a destroy method', () => { expect(spy.destroy).toBeA(Function); }); - it('has a restore method', function () { + it('has a restore method', () => { expect(spy.restore).toBeA(Function); }); - it('has a reset method', function () { + it('has a reset method', () => { expect(spy.reset).toBeA(Function); }); @@ -77,90 +77,90 @@ describe('A spy', function () { expect(spy.calls.length).toEqual(0); }); - it('knows how many times it has been called', function () { + it('knows how many times it has been called', () => { spy(); spy(); expect(spy.calls.length).toEqual(2); }); - it('knows the arguments it was called with', function () { + it('knows the arguments it was called with', () => { spy(1, 2, 3); expect(spy).toHaveBeenCalledWith(1, 2, 3); }); - describe('that calls some other function', function () { + describe('that calls some other function', () => { let otherContext: any, otherArguments: any; function otherFn() { otherContext = this; otherArguments = Array.prototype.slice.call(arguments, 0); - }; + } - beforeEach(function () { + beforeEach(() => { spy.andCall(otherFn); otherContext = otherArguments = null; }); - it('calls that function', function () { + it('calls that function', () => { spy(); expect(otherContext).toNotBe(null); }); - it('uses the correct context', function () { + it('uses the correct context', () => { const context = {}; spy.call(context); expect(otherContext).toBe(context); }); - it('passes the arguments through', function () { + it('passes the arguments through', () => { spy(1, 2, 3); expect(otherArguments).toEqual([ 1, 2, 3 ]); }); }); - describe('that calls through', function () { - beforeEach(function () { + describe('that calls through', () => { + beforeEach(() => { spy.andCallThrough(); }); - it('calls the original function', function () { + it('calls the original function', () => { spy(); expect(targetContext).toNotBe(null); }); - it('uses the correct context', function () { + it('uses the correct context', () => { const context = {}; spy.call(context); expect(targetContext).toBe(context); }); - it('passes the arguments through', function () { + it('passes the arguments through', () => { spy(1, 2, 3); expect(targetArguments).toEqual([ 1, 2, 3 ]); }); }); - describe('with a thrown value', function () { - beforeEach(function () { + describe('with a thrown value', () => { + beforeEach(() => { spy.andThrow('hello'); }); - it('throws the correct value', function () { + it('throws the correct value', () => { expect(spy).toThrow('hello'); }); }); - describe('with a return value', function () { - beforeEach(function () { + describe('with a return value', () => { + beforeEach(() => { spy.andReturn('hello'); }); - it('returns the correct value', function () { + it('returns the correct value', () => { expect(spy()).toEqual('hello'); }); }); }); -describe('expect.extend', function () { +describe('expect.extend', () => { const ColorAssertions: Extension = { toBeAColor() { assert( @@ -173,16 +173,16 @@ describe('expect.extend', function () { let assertSpy: Spy<{}>; - beforeEach(function () { + beforeEach(() => { extend(ColorAssertions); assertSpy = spyOn(expect, 'assert'); }); - afterEach(function () { + afterEach(() => { assertSpy.restore(); }); - it('works', function () { + it('works', () => { interface ColorExpectation extends Expectation { toBeAColor(): Expectation; } @@ -191,42 +191,42 @@ describe('expect.extend', function () { }); }); -describe('restoreSpies', function () { - describe('with one spy', function () { - const original = function () { return; }; +describe('restoreSpies', () => { + describe('with one spy', () => { + const original = () => { return; }; const target = { method: original }; - beforeEach(function () { + beforeEach(() => { spyOn(target, 'method'); }); - it('works with spyOn()', function () { + it('works with spyOn()', () => { expect(target.method).toNotEqual(original); restoreSpies(); expect(target.method).toEqual(original); }); - it('is idempotent', function () { + it('is idempotent', () => { expect(target.method).toNotEqual(original); restoreSpies(); restoreSpies(); expect(target.method).toEqual(original); }); - it('can work even on createSpy()', function () { + it('can work even on createSpy()', () => { createSpy(original); restoreSpies(); }); }); - describe('with multiple spies', function () { - const originals = [ function () { return; }, function () { return; } ]; + describe('with multiple spies', () => { + const originals = [ () => { return; }, () => { return; } ]; const targets = [ { method: originals[0] }, { method: originals[1] } ]; - it('still works', function () { + it('still works', () => { spyOn(targets[0], 'method'); spyOn(targets[1], 'method'); @@ -241,119 +241,119 @@ describe('restoreSpies', function () { }); }); -describe('A function that was spied on', function () { +describe('A function that was spied on', () => { const video = { play(...args: any[]) { return; } }; let spy: Spy<{}>; - beforeEach(function () { + beforeEach(() => { spy = spyOn(video, 'play'); video.play('some', 'args'); }); - it('tracks the number of calls', function () { + it('tracks the number of calls', () => { expect(spy.calls.length).toEqual(1); }); - it('tracks the context that was used', function () { + it('tracks the context that was used', () => { expect(spy.calls[0].context).toBe(video); }); - it('tracks the arguments that were used', function () { + it('tracks the arguments that were used', () => { expect(spy.calls[0].arguments).toEqual([ 'some', 'args' ]); }); - it('was called', function () { + it('was called', () => { expect(spy).toHaveBeenCalled(); }); - it('was called with the correct args', function () { + it('was called with the correct args', () => { expect(spy).toHaveBeenCalledWith('some', 'args'); }); - it('can be restored', function () { + it('can be restored', () => { expect(video.play).toEqual(spy); spy.restore(); expect(video.play).toNotEqual(spy); }); }); -describe('A function that was spied on but not called', function () { +describe('A function that was spied on but not called', () => { const video = { - play () { return; } + play() { return; } }; let spy: Spy<{}>; - beforeEach(function () { + beforeEach(() => { spy = spyOn(video, 'play'); }); - it('number of calls to be zero', function () { + it('number of calls to be zero', () => { expect(spy.calls.length).toEqual(0); }); - it('was not called', function () { + it('was not called', () => { expect(spy).toNotHaveBeenCalled(); }); }); -describe('toBeA', function () { - it('requires the value to be a function or string', function () { - expect(function () { +describe('toBeA', () => { + it('requires the value to be a function or string', () => { + expect(() => { expect('actual').toBeA(4); }).toThrow(/must be a function or a string/); }); - it('does not throw when the actual value is an instanceof the constructor', function () { - expect(function () { + it('does not throw when the actual value is an instanceof the constructor', () => { + expect(() => { expect(new Expectation('foo')).toBeA(Expectation); }).toNotThrow(); }); - it('throws when the actual value is not an instanceof the constructor', function () { - expect(function () { + it('throws when the actual value is not an instanceof the constructor', () => { + expect(() => { expect('actual').toBeA(Expectation); }).toThrow(/to be/); }); - it('does not throw when the expected value is the typeof the actual value', function () { - expect(function () { + it('does not throw when the expected value is the typeof the actual value', () => { + expect(() => { expect(4).toBeA('number'); expect(NaN).toBeA('number'); // hahaha }).toNotThrow(); }); - it('throws when the expected value is not the typeof the actual value', function () { - expect(function () { + it('throws when the expected value is not the typeof the actual value', () => { + expect(() => { expect('actual').toBeA('number'); }).toThrow(/to be/); }); - it('does not throw when the actual value is an array', function () { - expect(function () { + it('does not throw when the actual value is an array', () => { + expect(() => { expect([]).toBeAn('array'); }).toNotThrow(); }); - it('throws when the actual value is not an array', function () { - expect(function () { + it('throws when the actual value is not an array', () => { + expect(() => { expect('actual').toBeAn('array'); }).toThrow(/to be/); }); }); -describe('toBeGreaterThan', function () { - it('does not throw when the actual value is greater than the expected value', function () { - expect(function () { +describe('toBeGreaterThan', () => { + it('does not throw when the actual value is greater than the expected value', () => { + expect(() => { expect(3).toBeGreaterThan(2); }).toNotThrow(); }); - it('throws when the actual value is not greater than the expected value', function () { - expect(function () { + it('throws when the actual value is not greater than the expected value', () => { + expect(() => { expect(2).toBeGreaterThan(3); }).toThrow(/to be greater than/); }); @@ -379,15 +379,15 @@ describe('toBeGreaterThanOrEqualTo', () => { }); }); -describe('toBeLessThan', function () { - it('does not throw when the actual value is less than the expected value', function () { - expect(function () { +describe('toBeLessThan', () => { + it('does not throw when the actual value is less than the expected value', () => { + expect(() => { expect(2).toBeLessThan(3); }).toNotThrow(); }); - it('throws when the actual value is not less than the expected value', function () { - expect(function () { + it('throws when the actual value is not less than the expected value', () => { + expect(() => { expect(3).toBeLessThan(2); }).toThrow(/to be less than/); }); @@ -413,47 +413,47 @@ describe('toBeLessThanOrEqualTo', () => { }); }); -describe('toBeTruthy', function () { - it('does not throw on truthy actual values', function () { - expect(function () { +describe('toBeTruthy', () => { + it('does not throw on truthy actual values', () => { + expect(() => { expect(1).toBeTruthy(); expect({ hello: 'world' }).toBeTruthy(); expect([ 1, 2, 3 ]).toBeTruthy(); }).toNotThrow(); }); - it('throws on falsy actual values', function () { - expect(function () { + it('throws on falsy actual values', () => { + expect(() => { expect(0).toBeTruthy(); }).toThrow(); - expect(function () { + expect(() => { expect(null).toBeTruthy(); }).toThrow(); - expect(function () { + expect(() => { expect(undefined).toBeTruthy(); }).toThrow(); }); }); -describe('toBeFalsy', function () { - it('throws on truthy values', function () { - expect(function () { +describe('toBeFalsy', () => { + it('throws on truthy values', () => { + expect(() => { expect(42).toBeFalsy(); }).toThrow(); - expect(function () { + expect(() => { expect({ foo: 'bar' }).toBeFalsy(); }).toThrow(); - expect(function () { + expect(() => { expect([]).toBeFalsy(); }).toThrow(); }); - it('does not throw with falsy actual values', function () { - expect(function () { + it('does not throw with falsy actual values', () => { + expect(() => { expect(0).toBeFalsy(); expect(null).toBeFalsy(); expect(undefined).toBeFalsy(); @@ -461,20 +461,20 @@ describe('toBeFalsy', function () { }); }); -describe('toEqual', function () { - it('works', function () { - expect(function () { +describe('toEqual', () => { + it('works', () => { + expect(() => { expect('actual').toEqual('expected'); }).toThrow(/Expected 'actual' to equal 'expected'/); }); - it('works with objects that have the same keys in different order', function () { + it('works with objects that have the same keys in different order', () => { const a = { a: 'a', b: 'b', c: 'c' }; const b = { b: 'b', c: 'c', a: 'a' }; expect(a).toEqual(b); }); - it('shows diff', function () { + it('shows diff', () => { try { expect('actual').toEqual('expected'); } catch (err) { @@ -485,21 +485,21 @@ describe('toEqual', function () { }); }); -describe('toExclude', function () { - it('requires the actual value to be an array or string', function () { - expect(function () { +describe('toExclude', () => { + it('requires the actual value to be an array or string', () => { + expect(() => { expect(1).toExclude(2); }).toThrow(/must be an array or a string/); }); - it('does not throw when an array does not contain the expected value', function () { - expect(function () { + it('does not throw when an array does not contain the expected value', () => { + expect(() => { expect([ 1, 2, 3 ]).toExclude(4); }).toNotThrow(); }); - it('throws when an array contains the expected value', function () { - expect(function () { + it('throws when an array contains the expected value', () => { + expect(() => { expect([ 1, 2, 3 ]).toExclude(2); }).toThrow(/to exclude/); }); @@ -522,14 +522,14 @@ describe('toExclude', function () { }).toNotThrow(); }); - it('does not throw when an array does not contain the expected value', function () { - expect(function () { + it('does not throw when an array does not contain the expected value', () => { + expect(() => { expect('hello world').toExclude('goodbye'); }).toNotThrow(); }); - it('throws when a string contains the expected value', function () { - expect(function () { + it('throws when a string contains the expected value', () => { + expect(() => { expect('hello world').toExclude('hello'); }).toThrow(/to exclude/); }); @@ -591,47 +591,47 @@ describe('toExcludeKeys', () => { }); }); -describe('toExist', function () { - it('does not throw on truthy actual values', function () { - expect(function () { +describe('toExist', () => { + it('does not throw on truthy actual values', () => { + expect(() => { expect(1).toExist(); expect({ hello: 'world' }).toExist(); expect([ 1, 2, 3 ]).toExist(); }).toNotThrow(); }); - it('throws on falsy actual values', function () { - expect(function () { + it('throws on falsy actual values', () => { + expect(() => { expect(0).toExist(); }).toThrow(); - expect(function () { + expect(() => { expect(null).toExist(); }).toThrow(); - expect(function () { + expect(() => { expect(undefined).toExist(); }).toThrow(); }); }); -describe('toNotExist', function () { - it('throws on truthy values', function () { - expect(function () { +describe('toNotExist', () => { + it('throws on truthy values', () => { + expect(() => { expect(42).toNotExist(); }).toThrow(); - expect(function () { + expect(() => { expect({ foo: 'bar' }).toNotExist(); }).toThrow(); - expect(function () { + expect(() => { expect([]).toNotExist(); }).toThrow(); }); - it('does not throw with falsy actual values', function () { - expect(function () { + it('does not throw with falsy actual values', () => { + expect(() => { expect(0).toNotExist(); expect(null).toNotExist(); expect(undefined).toNotExist(); @@ -1036,11 +1036,11 @@ describe('toNotEqual', () => { expect(a).toNotEqual(b); }); - }; + } }); -describe('withArgs', function () { - const fn = function (arg1: any, arg2: any) { +describe('withArgs', () => { + const fn = (arg1: any, arg2: any) => { if (arg1 === 'first' && typeof arg2 === 'undefined') { throw new Error('first arg found'); } @@ -1049,20 +1049,20 @@ describe('withArgs', function () { } }; - it('invokes actual function with args', function () { - expect(function () { + it('invokes actual function with args', () => { + expect(() => { expect(fn).withArgs('first').toThrow(/first arg found/); }).toNotThrow(); }); - it('can be chained', function () { - expect(function () { + it('can be chained', () => { + expect(() => { expect(fn).withArgs('first').withArgs('second').toThrow(/both args found/); }).toNotThrow(); }); - it('throws when actual is not a function', function () { - expect(function () { + it('throws when actual is not a function', () => { + expect(() => { expect('not a function').withArgs('first'); }).toThrow(/must be a function/); }); diff --git a/geolib/geolib-tests.ts b/geolib/geolib-tests.ts index c71af7ebb7..2dac05162f 100644 --- a/geolib/geolib-tests.ts +++ b/geolib/geolib-tests.ts @@ -23,13 +23,13 @@ dist = geolib.getDistance( // Working with W3C Geolocation API navigator.geolocation.getCurrentPosition( - function(position) { + position => { alert('You are ' + geolib.getDistance(position.coords, { latitude: 51.525, longitude: 7.4575 }) + ' meters away from 51.525, 7.4575'); }, - function() { + () => { alert('Position could not be determined.'); }, { diff --git a/jump.js/jump.js-tests.ts b/jump.js/jump.js-tests.ts index d46d8bc9b5..bce5d68f21 100644 --- a/jump.js/jump.js-tests.ts +++ b/jump.js/jump.js-tests.ts @@ -12,5 +12,5 @@ jump('.target', { }); jump(100); jump(-100, { - callback: () => { console.log('Done!') } + callback: () => { console.log('Done!'); } }); diff --git a/later/later-tests.ts b/later/later-tests.ts index 1ba355f08c..1ecd1d6d0e 100644 --- a/later/later-tests.ts +++ b/later/later-tests.ts @@ -420,7 +420,7 @@ namespace LaterTest_TimePeriods { range: later.hour.range * 6, - val: function(d: Date): number { + val(d: Date): number { return later.hour.val(d) < 12 ? 0 : later.hour.val(d) < 18 @@ -428,15 +428,15 @@ namespace LaterTest_TimePeriods { : 2; }, - isValid: function(d: Date, val: any) { + isValid(d: Date, val: any) { return customLater.partOfDay.val(d) === val; }, - extent: function(date?: Date) { + extent(date?: Date) { return [0, 2]; }, - start: function(date: Date) { + start(date: Date) { var hour = customLater.partOfDay.val(date) === 0 ? 0 : customLater.partOfDay.val(date) === 1 @@ -451,7 +451,7 @@ namespace LaterTest_TimePeriods { ); }, - end: function(date: Date) { + end(date: Date) { var hour = customLater.partOfDay.val(date) === 0 ? 11 : customLater.partOfDay.val(date) === 1 @@ -466,7 +466,7 @@ namespace LaterTest_TimePeriods { ); }, - next: function(date: Date, val: any) { + next(date: Date, val: any) { var hour = val === 0 ? 0 : val === 1 @@ -482,7 +482,7 @@ namespace LaterTest_TimePeriods { ); }, - prev: function(date: Date, val: any) { + prev(date: Date, val: any) { var hour = val === 0 ? 11 : val === 1 diff --git a/leaflet-draw/leaflet-draw-tests.ts b/leaflet-draw/leaflet-draw-tests.ts index 98d3681789..4260eac263 100644 --- a/leaflet-draw/leaflet-draw-tests.ts +++ b/leaflet-draw/leaflet-draw-tests.ts @@ -37,7 +37,7 @@ var drawControl = new L.Control.Draw({ }); map.addControl(drawControl); -map.on('draw:created', function (e: any) { +map.on('draw:created', (e: any) => { var drawEvent = (e as L.DrawEvents.Created); var type = drawEvent.layerType, layer = drawEvent.layer; diff --git a/modesl/modesl-tests.ts b/modesl/modesl-tests.ts index 89bc5dcedb..c3788833d0 100644 --- a/modesl/modesl-tests.ts +++ b/modesl/modesl-tests.ts @@ -8,7 +8,7 @@ const freeswitchListener = new modesl.Server(() => { const freeswitchConnection = new modesl.Connection("freeswitch-host", 8021, 'password', () => { // console.log('connection initialized'); - freeswitchConnection.api('conference', ['confname', 'dial', 'user/1006']) + freeswitchConnection.api('conference', ['confname', 'dial', 'user/1006']); freeswitchConnection.bgapi('conference', ['confname', 'dial', 'user/1006'], 'job-id', () => { // console.log('action queued'); diff --git a/nblas/nblas-tests.ts b/nblas/nblas-tests.ts index 754c47560c..1567a4e226 100644 --- a/nblas/nblas-tests.ts +++ b/nblas/nblas-tests.ts @@ -4,7 +4,7 @@ const a = new Float32Array(0); const n = 1; let res: number; -function test () { +function test() { // BLAS Level 1 Routines and Functions res = nblas.asum(a); nblas.axpy(a, a, n); diff --git a/openfin/openfin-tests.ts b/openfin/openfin-tests.ts index f7b34b401a..7ff62c2112 100644 --- a/openfin/openfin-tests.ts +++ b/openfin/openfin-tests.ts @@ -28,7 +28,7 @@ // addEventListener application.addEventListener("closed", function (event) { console.log("The application has closed"); - }, function () { + }, () => { console.log("The registration was successful"); }, function (reason) { console.log("failure: " + reason); @@ -76,32 +76,32 @@ // registerCustomData application.registerCustomData({ someData: "this is custom" - }, function () { + }, () => { console.log("You will not read this."); }, function (err) { console.log("failure:", err); }); // removeEventListener let previousCallback = function (event: fin.WindowEvent) { }; - application.removeEventListener("closed", previousCallback, function () { + application.removeEventListener("closed", previousCallback, () => { console.log("The unregistration was successful"); }, function (err) { console.log("failure:", err); }); // removeTrayIcon - application.removeTrayIcon(function () { + application.removeTrayIcon(() => { console.log("Removed the tray icon."); }, function (err) { console.log("failure:", err); }); // restart - application.restart(function () { + application.restart(() => { console.log("You will not read this."); }, function (err) { console.log("failure:", err); }); // schedule restart - application.scheduleRestart(function () { + application.scheduleRestart(() => { console.log("You will not read this."); }, function (err) { console.log("failure:", err); @@ -111,7 +111,7 @@ desktop: true, startMenu: false, systemStartup: true - }, function () { + }, () => { console.log("Successfully set new shortcut states"); }, function (error) { console.log("Failed to set new shortcut states. Error: ", error); @@ -123,7 +123,7 @@ // terminate application.terminate(); // wait - application.addEventListener("not-responding", function () { + application.addEventListener("not-responding", () => { console.log("waiting for hung application"); application.wait(); }); @@ -142,7 +142,7 @@ function test_external_application() { console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`); }); // removeEventListener - let previousCallback = function () { }; + let previousCallback = () => { }; externalApp.removeEventListener('connected', previousCallback, () => { console.log('The unregistration was successful'); }, (reason, err) => { @@ -211,7 +211,7 @@ function test_system() { // addEventListener fin.desktop.System.addEventListener('monitor-info-changed', function (event) { console.log("The monitor information has changed to: ", event); - }, function () { + }, () => { console.log("The registration was successful"); }, function (err) { console.log("failure: " + err); @@ -225,7 +225,7 @@ function test_system() { userData: true }); // deleteCacheOnExit - fin.desktop.System.deleteCacheOnExit(function () { + fin.desktop.System.deleteCacheOnExit(() => { console.log("successful"); }, function (err) { console.log("failure: " + err); @@ -249,7 +249,7 @@ function test_system() { console.log(reason, err); }); // exit - fin.desktop.System.exit(function () { + fin.desktop.System.exit(() => { console.log("successful"); }, function (err) { console.log("failure: " + err); @@ -392,7 +392,7 @@ function test_system() { console.log('Error:', error); }); // log - fin.desktop.System.log("info", "An example log message", function () { + fin.desktop.System.log("info", "An example log message", () => { console.log("message successfully logged"); }, function (err) { console.log(err); @@ -409,13 +409,13 @@ function test_system() { console.log("Error:", error); }); // openUrlWithBrowser - fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", function () { + fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", () => { console.log("successful"); }, function (err) { console.log("failure: " + err); }); // registerExternalConnection - fin.desktop.System.registerExternalConnection("remote-connection-uuid", function () { + fin.desktop.System.registerExternalConnection("remote-connection-uuid", function() { console.log(arguments); }); // releaseExternalProcess @@ -429,7 +429,7 @@ function test_system() { console.log("Result UUID is " + result.uuid); //release it. - fin.desktop.System.releaseExternalProcess(result.uuid, function () { + fin.desktop.System.releaseExternalProcess(result.uuid, () => { console.log("Process has been unmapped!"); }, function (reason) { console.log("failure: " + reason); @@ -437,13 +437,13 @@ function test_system() { }); // removeEventListener let aRegisteredListener = (event: fin.SystemBaseEvent) => { }; - fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, function () { + fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, () => { console.log("successful"); }, function (err) { console.log("failure: " + err); }); // showDeveloperTools - fin.desktop.System.showDeveloperTools("uuid", "name", function () { + fin.desktop.System.showDeveloperTools("uuid", "name", () => { console.log("successful"); }, function (err) { console.log("failure: " + err); @@ -468,7 +468,7 @@ function test_system() { }); }); // updateProxySettings - fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, function () { + fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, () => { console.log('success'); }, function (err) { console.log(err); @@ -543,9 +543,9 @@ function test_window() { frame: false, resizable: false, state: "normal" - }, function () { + }, () => { var _win = finWindow.getNativeWindow(); - _win.addEventListener("DOMContentLoaded", function () { finWindow.show(); }); + _win.addEventListener("DOMContentLoaded", () => { finWindow.show(); }); }, function (error) { console.log("Error creating window:", error); }); @@ -565,7 +565,7 @@ function test_window() { // addEventListener finWindow.addEventListener("bounds-changed", function (event) { console.log("The window has been moved or resized"); - }, function () { + }, () => { console.log("The registration was successful"); }, function (reason) { console.log("failure:" + reason); @@ -607,34 +607,34 @@ function test_window() { // focus finWindow.focus(); // getBounds - finWindow.getBounds(function (bounds) { + finWindow.getBounds(bounds => { console.log("top: " + bounds.top + "left: " + bounds.left + "height: " + bounds.height + "width: " + bounds.width); }); // getOptions - finWindow.getOptions(function (options) { + finWindow.getOptions(options => { console.log(options); }); // getSnapshot - finWindow.getSnapshot(function (base64Snapshot) { + finWindow.getSnapshot(base64Snapshot => { console.log("data:image/png;base64," + base64Snapshot); }); // getState - finWindow.getState(function (state) { + finWindow.getState(state => { console.log("state: " + state); }); // getZoomLevel - finWindow.getZoomLevel(function (level) { + finWindow.getZoomLevel(level => { console.log("zoom level: " + level); - }, function (error) { + }, error => { console.log('error:', error); }); // hide finWindow.hide(); // isShowing - finWindow.isShowing(function (showing) { + finWindow.isShowing(showing => { console.log("the window is " + (showing ? "showing" : "hidden")); }); // joinGroup @@ -642,7 +642,7 @@ function test_window() { url: "http://www.openfin.co", name: "secondWindow", autoShow: true - }, function () { + }, () => { // When mainWindow moves or is moved, secondWindow moves by the same amount secondWindow.joinGroup(finWindow); }); @@ -651,9 +651,9 @@ function test_window() { url: "http://www.openfin.co", name: "secondWindow", autoShow: true - }, function () { + }, () => { // When finWindow moves or is moved, secondWindow moves by the same amount - secondWindow.joinGroup(finWindow, function () { + secondWindow.joinGroup(finWindow, () => { //once we are in the group, lets leave it. secondWindow.leaveGroup(); }); diff --git a/p-defer/tsconfig.json b/p-defer/tsconfig.json index c0e0daf1e6..ebf8e83a49 100644 --- a/p-defer/tsconfig.json +++ b/p-defer/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "module": "commonjs", + "target": "es6", "lib": [ "es6", "dom" diff --git a/parse-torrent/parse-torrent-tests.ts b/parse-torrent/parse-torrent-tests.ts index dc20ff79e6..46d8b9e923 100644 --- a/parse-torrent/parse-torrent-tests.ts +++ b/parse-torrent/parse-torrent-tests.ts @@ -85,7 +85,7 @@ var buf = parseTorrent.toTorrentFile({ infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36', }); -parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', function(err, parsedTorrent) { +parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', (err, parsedTorrent) => { // if (err) throw err // console.log(parsedTorrent) }); diff --git a/pbf/pbf-tests.ts b/pbf/pbf-tests.ts index 2fde33cbd8..39c67602d8 100644 --- a/pbf/pbf-tests.ts +++ b/pbf/pbf-tests.ts @@ -7,13 +7,13 @@ pbf.pos; pbf.type; pbf.length; pbf.destroy(); -pbf.readFields(function (tag) {}); -pbf.readFields(function (tag, result) {}); -pbf.readFields(function (tag, result, pbf) {}); -pbf.readFields(function (tag) {}, {}, 1); -pbf.readMessage(function (tag) {}); -pbf.readMessage(function (tag, result) {}); -pbf.readMessage(function (tag, result, pbf) {}); +pbf.readFields(tag => {}); +pbf.readFields((tag, result) => {}); +pbf.readFields((tag, result, pbf) => {}); +pbf.readFields(tag => {}, {}, 1); +pbf.readMessage(tag => {}); +pbf.readMessage((tag, result) => {}); +pbf.readMessage((tag, result, pbf) => {}); pbf.readFixed32(); pbf.readSFixed32(); pbf.readFixed64(); @@ -60,12 +60,12 @@ pbf.writeString(''); pbf.writeFloat(1); pbf.writeDouble(1); pbf.writeBytes(new Uint8Array(1)); -pbf.writeRawMessage(function (obj) {}); -pbf.writeRawMessage(function (obj, pbf) {}); -pbf.writeRawMessage(function (obj) {}, {}); -pbf.writeMessage(1, function (obj) {}); -pbf.writeMessage(1, function (obj, pbf) {}); -pbf.writeMessage(1, function (obj) {}, {}); +pbf.writeRawMessage(obj => {}); +pbf.writeRawMessage((obj, pbf) => {}); +pbf.writeRawMessage(obj => {}, {}); +pbf.writeMessage(1, obj => {}); +pbf.writeMessage(1, (obj, pbf) => {}); +pbf.writeMessage(1, obj => {}, {}); pbf.writePackedVarint(1, []); pbf.writePackedSVarint(1, []); pbf.writePackedBoolean(1, []); diff --git a/python-shell/python-shell-tests.ts b/python-shell/python-shell-tests.ts index af282b427b..33a7c0eba1 100644 --- a/python-shell/python-shell-tests.ts +++ b/python-shell/python-shell-tests.ts @@ -2,7 +2,7 @@ import * as ps from 'python-shell'; let PythonShell = ps.PythonShell; -ps.run('my_script.py', function (err) { +ps.run('my_script.py', err => { if (err) throw err; console.log('finished'); }); @@ -15,7 +15,7 @@ var options = { args: ['value1', 'value2', 'value3'] }; -ps.run('my_script.py', options, function (err, results) { +ps.run('my_script.py', options, (err, results) => { if (err) throw err; // results is an array consisting of messages collected during execution console.log('results: %j', results); @@ -26,13 +26,13 @@ var pyshell = new PythonShell('my_script.py'); // sends a message to the Python script via stdin pyshell.send('hello'); -pyshell.on('message', function (message) { +pyshell.on('message', message => { // received a message sent from the Python script (a simple "print" statement) console.log(message); }); // end the input stream and allow the process to exit -pyshell.end(function (err) { +pyshell.end(err => { if (err) throw err; console.log('finished'); }); \ No newline at end of file diff --git a/rc-tree/rc-tree-tests.tsx b/rc-tree/rc-tree-tests.tsx index ce528ba168..857054aa13 100644 --- a/rc-tree/rc-tree-tests.tsx +++ b/rc-tree/rc-tree-tests.tsx @@ -26,7 +26,7 @@ export class Demo extends React.Component { }; } - public static defaultProps: Props = { + static defaultProps: Props = { keys: ['0-0-0-0'], }; diff --git a/react-leaflet/react-leaflet-tests.tsx b/react-leaflet/react-leaflet-tests.tsx index 4a33aa0748..e4ccde79c3 100644 --- a/react-leaflet/react-leaflet-tests.tsx +++ b/react-leaflet/react-leaflet-tests.tsx @@ -32,18 +32,18 @@ export class AnimateExample extends Component { lat: 51.505, lng: -0.09, }, - } + }; handleClick = (e: Leaflet.MouseEvent) => { this.setState({ latlng: e.latlng, - }) + }); } toggleAnimate = () => { this.setState({ animate: !this.state.animate, - }) + }); } render() { @@ -53,7 +53,7 @@ export class AnimateExample extends Component { You are here - ) : null + ) : null; return (
@@ -75,7 +75,7 @@ export class AnimateExample extends Component { {marker}
- ) + ); } } @@ -83,23 +83,23 @@ export class AnimateExample extends Component { const outer: Array<[number, number]> = [ [50.505, -29.09], [52.505, 29.09], -] +]; const inner: Array<[number, number]> = [ [49.505, -2.09], [53.505, 2.09], -] +]; export class BoundsExample extends Component { state = { bounds: outer, - } + }; onClickInner = () => { - this.setState({ bounds: inner }) + this.setState({ bounds: inner }); } onClickOuter = () => { - this.setState({ bounds: outer }) + this.setState({ bounds: outer }); } render() { @@ -120,14 +120,14 @@ export class BoundsExample extends Component { onclick={this.onClickInner} /> - ) + ); } } //custom-component.js const SomeFn = (asd: string) => ( asd + asd -) +); const MyPopupMarker = ({ children, position }: any) => ( @@ -145,12 +145,12 @@ const MyPopupMarker = ({ children, position }: any) => ( const MyMarkersList = ({ markers }: any) => { const items = markers.map(({ key, ...props }: any) => ( - )) - return
{items}
-} + )); + return
{items}
; +}; (MyMarkersList as any).propTypes = { markers: PropTypes.array.isRequired, -} +}; export class CustomComponent extends Component { state = { @@ -160,13 +160,13 @@ export class CustomComponent extends Component { }; render() { - const center: [number, number] = [this.state.lat, this.state.lng] + const center: [number, number] = [this.state.lat, this.state.lng]; const markers = [ { key: 'marker1', position: [51.5, -0.1], children: 'My first popup' }, { key: 'marker2', position: [51.51, -0.1], children: 'My second popup' }, { key: 'marker3', position: [51.49, -0.05], children: 'My third popup' }, - ] + ]; return ( { /> - ) + ); } } @@ -192,22 +192,22 @@ export class DraggableExample extends Component { }, zoom: 13, draggable: true, - } + }; toggleDraggable = () => { - this.setState({ draggable: !this.state.draggable }) + this.setState({ draggable: !this.state.draggable }); } updatePosition = () => { - const { lat, lng } = (this.refs['marker'] as MarkerInstance).leafletElement.getLatLng() + const { lat, lng } = (this.refs['marker'] as MarkerInstance).leafletElement.getLatLng(); this.setState({ marker: { lat, lng }, - }) + }); } render() { - const position: [number, number] = [this.state.center.lat, this.state.center.lng] - const markerPosition: [number, number] = [this.state.marker.lat, this.state.marker.lng] + const position: [number, number] = [this.state.center.lat, this.state.center.lng]; + const markerPosition: [number, number] = [this.state.marker.lat, this.state.marker.lng]; return ( @@ -227,7 +227,7 @@ export class DraggableExample extends Component {
- ) + ); } } @@ -239,17 +239,17 @@ export class EventsExample extends Component { lat: 51.505, lng: -0.09, }, - } + }; handleClick = () => { - (this.refs['map'] as MapInstance).leafletElement.locate() + (this.refs['map'] as MapInstance).leafletElement.locate(); } handleLocationFound = (e: Leaflet.LocationEvent) => { this.setState({ hasLocation: true, latlng: e.latlng, - }) + }); } render() { @@ -259,7 +259,7 @@ export class EventsExample extends Component { You are here - ) : null + ) : null; return ( { /> {marker} - ) + ); } } //layers-control.js export class LayersControlExample extends Component { render() { - const center: [number, number] = [51.505, -0.09] + const center: [number, number] = [51.505, -0.09]; const rectangle: Array<[number, number]> = [ [51.49, -0.08], [51.5, -0.06], - ] + ]; return ( @@ -330,18 +330,18 @@ export class LayersControlExample extends Component { - ) + ); } } //other-layers.js export class OtherLayersExample extends Component { render() { - const center: [number, number] = [51.505, -0.09] + const center: [number, number] = [51.505, -0.09]; const rectangle: Array<[number, number]> = [ [51.49, -0.08], [51.5, -0.06], - ] + ]; return ( @@ -364,7 +364,7 @@ export class OtherLayersExample extends Component { - ) + ); } } @@ -372,14 +372,14 @@ export class OtherLayersExample extends Component { export class PaneExample extends Component { state = { render: true, - } + }; componentDidMount() { setInterval(() => { this.setState({ render: !this.state.render, - }) - }, 5000) + }); + }, 5000); } render() { @@ -401,7 +401,7 @@ export class PaneExample extends Component { - ) + ); } } @@ -411,10 +411,10 @@ export class SimpleExample extends Component { lat: 51.505, lng: -0.09, zoom: 13, - } + }; render() { - const position: [number, number] = [this.state.lat, this.state.lng] + const position: [number, number] = [this.state.lat, this.state.lng]; return ( { - ) + ); } } @@ -435,28 +435,28 @@ export class SimpleExample extends Component { export class TooltipExample extends Component { state = { clicked: 0, - } + }; onClickCircle = () => { - this.setState({ clicked: this.state.clicked + 1 }) + this.setState({ clicked: this.state.clicked + 1 }); } render() { - const center: [number, number] = [51.505, -0.09] + const center: [number, number] = [51.505, -0.09]; const multiPolygon: Array> = [ [[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]], [[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]], - ] + ]; const rectangle: Array<[number, number]> = [ [51.49, -0.08], [51.5, -0.06], - ] + ]; const clickedText = this.state.clicked === 0 ? 'Click this Circle to change the Tooltip text' - : `Circle click: ${this.state.clicked}` + : `Circle click: ${this.state.clicked}`; return ( @@ -485,41 +485,41 @@ export class TooltipExample extends Component { - ) + ); } } //vector-layers.js export class VectorLayersExample extends Component { render() { - const center: [number, number] = [51.505, -0.09] + const center: [number, number] = [51.505, -0.09]; const polyline: Array<[number, number]> = [ [51.505, -0.09], [51.51, -0.1], [51.51, -0.12], - ] + ]; const multiPolyline: Array> = [ [[51.5, -0.1], [51.5, -0.12], [51.52, -0.12]], [[51.5, -0.05], [51.5, -0.06], [51.52, -0.06]], - ] + ]; const polygon: Array<[number, number]> = [ [51.515, -0.09], [51.52, -0.1], [51.52, -0.12], - ] + ]; const multiPolygon: Array> = [ [[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]], [[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]], - ] + ]; const rectangle: Array<[number, number]> = [ [51.49, -0.08], [51.5, -0.06], - ] + ]; return ( @@ -539,7 +539,7 @@ export class VectorLayersExample extends Component { - ) + ); } } @@ -550,12 +550,12 @@ export class WMSTileLayerExample extends Component { lng: -0.09, zoom: 5, bluemarble: false, - } + }; onClick = () => { this.setState({ bluemarble: !this.state.bluemarble, - }) + }); } render() { @@ -573,7 +573,7 @@ export class WMSTileLayerExample extends Component { url='http://demo.opengeo.org/geoserver/ows?' /> - ) + ); } } @@ -586,4 +586,4 @@ const ZoomControlExample = () => ( /> -) \ No newline at end of file +); diff --git a/react-maskedinput/react-maskedinput-tests.tsx b/react-maskedinput/react-maskedinput-tests.tsx index 609b5c8241..cdc8070415 100644 --- a/react-maskedinput/react-maskedinput-tests.tsx +++ b/react-maskedinput/react-maskedinput-tests.tsx @@ -1,22 +1,19 @@ -import * as React from "react" - -import * as MaskedInput from "react-maskedinput" +import * as React from "react"; +import * as MaskedInput from "react-maskedinput"; class Test extends React.Component { - - public render () { + render() { return ( char, transform: (char: string) => char } } } /> - ) + ); } - } diff --git a/react-modal/react-modal-tests.tsx b/react-modal/react-modal-tests.tsx index b153fa0573..c8e50a3057 100644 --- a/react-modal/react-modal-tests.tsx +++ b/react-modal/react-modal-tests.tsx @@ -3,8 +3,8 @@ import * as ReactModal from 'react-modal'; class ExampleOfUsingReactModal extends React.Component<{}, {}> { render() { - var onAfterOpenFn = () => { } - var onRequestCloseFn = () => { } + var onAfterOpenFn = () => { }; + var onRequestCloseFn = () => { }; var customStyle = { overlay: { position: 'fixed', @@ -29,7 +29,7 @@ class ExampleOfUsingReactModal extends React.Component<{}, {}> { padding: '20px' } - } + }; return ( marginLeft: 36 } }} - onDateChange={(date: string) => {this.setState({date});}} + onDateChange={(date: string) => { this.setState({date}); }} /> ); } diff --git a/react-native-swiper/react-native-swiper-tests.tsx b/react-native-swiper/react-native-swiper-tests.tsx index 93cdfcfd18..fa214e18f0 100644 --- a/react-native-swiper/react-native-swiper-tests.tsx +++ b/react-native-swiper/react-native-swiper-tests.tsx @@ -7,18 +7,13 @@ import { } from 'react-native'; import Swiper from 'react-native-swiper'; -interface IProperties { -} -interface IState { -} - -class SwiperTest extends React.Component { - public constructor(props: IProperties) { +class SwiperTest extends React.Component<{}, {}> { + constructor(props: {}) { super(props); } - public render(): React.ReactElement { + render(): React.ReactElement { return ( diff --git a/react-notification-system-redux/react-notification-system-redux-tests.tsx b/react-notification-system-redux/react-notification-system-redux-tests.tsx index 030d7a06b7..59f1a8404f 100644 --- a/react-notification-system-redux/react-notification-system-redux-tests.tsx +++ b/react-notification-system-redux/react-notification-system-redux-tests.tsx @@ -6,7 +6,7 @@ import { reducer, show, hide, info, error, warning, success, NotificationLevel } class Test extends React.Component { - private test () { + private test() { const notification: Notification = { message : "Test" }; @@ -23,11 +23,11 @@ class Test extends React.Component { hide(123); } - public render () { + render() { const notifications: Notification[] = []; return (); } } -const store: Store = createStore(reducer) +const store: Store = createStore(reducer); diff --git a/react-notification-system/index.d.ts b/react-notification-system/index.d.ts index bf76875f3a..eb2c089286 100644 --- a/react-notification-system/index.d.ts +++ b/react-notification-system/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React Notification System v0.2.11 +// Type definitions for React Notification System 0.2 // Project: https://www.npmjs.com/package/react-notification-system // Definitions by: Giedrius Grabauskas , Deividas Bakanas , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,8 +10,7 @@ declare namespace NotificationSystem { export interface System extends React.Component { addNotification(notification: Notification): Notification; - removeNotification(notification: Notification): void; - removeNotification(uid: number | string): void; + removeNotification(uidOrNotification: number | string | Notification): void; clearNotifications(): void; } diff --git a/react-notification-system/react-notification-system-tests.ts b/react-notification-system/react-notification-system-tests.ts index 908758a7af..d8e26ba60b 100644 --- a/react-notification-system/react-notification-system-tests.ts +++ b/react-notification-system/react-notification-system-tests.ts @@ -1,6 +1,3 @@ - -/// - import React = require('react'); import NotificationSystem = require('react-notification-system'); @@ -31,18 +28,18 @@ class MyComponent extends React.Component { render() { var style = { - NotificationItem: { // Override the notification item - DefaultStyle: { // Applied to every notification, regardless of the notification level + NotificationItem: { // Override the notification item + DefaultStyle: { // Applied to every notification, regardless of the notification level margin: '10px 5px 2px 1px' }, - success: { // Applied only to the success notification item + success: { // Applied only to the success notification item color: 'red' } } }; - var attributes: NotificationSystem.Attributes = { + var attributes: NotificationSystem.Attributes = { style: { Containers: { DefaultStyle: { @@ -55,7 +52,7 @@ class MyComponent extends React.Component { } } } - }; + }; return React.createElement(NotificationSystem, { title: "NotificationTitile", style: style, } as NotificationSystem.Attributes); } diff --git a/react-router/react-router-tests.tsx b/react-router/react-router-tests.tsx index 0b31169e76..9e7bcb4efc 100644 --- a/react-router/react-router-tests.tsx +++ b/react-router/react-router-tests.tsx @@ -43,7 +43,7 @@ const customHistory = createCustomHistory(browserHistory) const NavLink = (props: LinkProps) => ( -) +); interface MasterContext { router: InjectedRouter; @@ -52,7 +52,7 @@ interface MasterContext { class Master extends Component { static contextTypes: ValidationMap = { - "router": routerShape + router: routerShape }; context: MasterContext; @@ -72,14 +72,14 @@ class Master extends Component {

Master

Dashboard Users

{this.props.children}

- + ; } } interface DashboardProps { - router: InjectedRouter -}; + router: InjectedRouter; +} class Dashboard extends React.Component { @@ -96,32 +96,32 @@ class Dashboard extends React.Component { render() { return
This is a dashboard -
+ ; } } -const DashboardWithRouter = withRouter(Dashboard) +const DashboardWithRouter = withRouter(Dashboard); class NotFound extends React.Component<{}, {}> { render() { return
This path does not exists -
+ ; } } -interface UsersProps extends RouteComponentProps<{}, {}> { } +type UsersProps = RouteComponentProps<{}, {}>; class Users extends React.Component { render() { - const { location, params, route, routes, router, routeParams } = this.props; + const { location, params, route, routes, router, routeParams } = this.props; return
This is a user list -
+ ; } } @@ -135,7 +135,7 @@ ReactDOM.render(( -), document.body) +), document.body); ReactDOM.render(( diff --git a/react-toggle/react-toggle-tests.tsx b/react-toggle/react-toggle-tests.tsx index 9bec568663..f138268174 100644 --- a/react-toggle/react-toggle-tests.tsx +++ b/react-toggle/react-toggle-tests.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import Toggle from "react-toggle" +import * as React from "react"; +import Toggle from "react-toggle"; class Test extends React.Component<{}, {}> { - public render() { + render() { return ( ); diff --git a/rx-lite/rx-lite-tests.ts b/rx-lite/rx-lite-tests.ts index 8422bfd9f2..8d5ac19738 100644 --- a/rx-lite/rx-lite-tests.ts +++ b/rx-lite/rx-lite-tests.ts @@ -77,17 +77,17 @@ function test_scan() { function test_concatAll() { /* concatAll Example */ var source = Rx.Observable.range(0, 3) - .map(function (x) { return Rx.Observable.range(x, 3); }) + .map(x => Rx.Observable.range(x, 3)) .concatAll(); var subscription = source.subscribe( - function (x) { + x => { console.log('Next: %s', x); }, - function (err) { + err => { console.log('Error: %s', err); }, - function () { + () => { console.log('Completed'); }); } @@ -95,17 +95,17 @@ function test_concatAll() { function test_mergeAll() { /* mergeAll example */ var source = Rx.Observable.range(0, 3) - .map(function (x) { return Rx.Observable.range(x, 3); }) + .map(x => Rx.Observable.range(x, 3)) .mergeAll(); var subscription = source.subscribe( - function (x) { + x => { console.log('Next: %s', x); }, - function (err) { + err => { console.log('Error: %s', err); }, - function () { + () => { console.log('Completed'); }); @@ -117,7 +117,7 @@ function test_publish() { var source = interval .take(2) - .doAction(function (x) { + .doAction(x => { console.log('Side effect'); }); @@ -130,13 +130,13 @@ function test_publish() { function createObserver(tag: string) { return Rx.Observer.create( - function (x) { + x => { console.log('Next: ' + tag + x); }, - function (err) { + err => { console.log('Error: ' + err); }, - function () { + () => { console.log('Completed'); }); } diff --git a/service_worker_api/service_worker_api-tests.ts b/service_worker_api/service_worker_api-tests.ts index b2e183aa05..b87342f0e9 100644 --- a/service_worker_api/service_worker_api-tests.ts +++ b/service_worker_api/service_worker_api-tests.ts @@ -1,14 +1,14 @@ var OFFLINE_CACHE = "cache_test"; var OFFLINE_URL = "localhost"; -self.addEventListener('fetch', function(event: FetchEvent) { +self.addEventListener('fetch', (event: FetchEvent) => { if (event.request.method === 'GET' && event.request.headers.get('accept').indexOf('text/html') !== -1) { console.log('Handling fetch event for', event.request.url); event.respondWith( - self.fetch(event.request).catch(function(e) { + self.fetch(event.request).catch(e => { console.error('Fetch failed; returning offline page instead.', e); - return self.caches.open(OFFLINE_CACHE).then(function(cache: Cache) { + return self.caches.open(OFFLINE_CACHE).then((cache: Cache) => { return cache.match(OFFLINE_URL); }); }) @@ -16,25 +16,25 @@ self.addEventListener('fetch', function(event: FetchEvent) { } }); -self.caches.open('v1').then(function(cache: Cache) { - cache.matchAll('/images/').then(function(response: Response[]) { - response.forEach(function(element, index, array) { +self.caches.open('v1').then((cache: Cache) => { + cache.matchAll('/images/').then((response: Response[]) => { + response.forEach((element, index, array) => { cache.delete(element.url); }); }); }); -self.addEventListener('install', function(event: InstallEvent) { +self.addEventListener('install', (event: InstallEvent) => { event.waitUntil( - self.caches.open('v1').then(function(cache: Cache) { + self.caches.open('v1').then((cache: Cache) => { return cache.add('/sw-test/index.html'); }) ); }); -self.addEventListener('install', function(event: InstallEvent) { +self.addEventListener('install', (event: InstallEvent) => { event.waitUntil( - self.caches.open('v1').then(function(cache) { + self.caches.open('v1').then(cache => { return cache.addAll([ '/sw-test/', '/sw-test/index.html', @@ -51,50 +51,50 @@ self.addEventListener('install', function(event: InstallEvent) { ); }); -self.addEventListener('fetch', function(event: FetchEvent) { - var cachedResponse = self.caches.match(event.request).then(function(response: Response) { +self.addEventListener('fetch', (event: FetchEvent) => { + var cachedResponse = self.caches.match(event.request).then(response => { if (response) { return response; } - }).catch(function() { - return self.fetch(event.request).then(function(response: Response) { - return self.caches.open('v1').then(function(cache) { + }).catch(() => { + return self.fetch(event.request).then(response => { + return self.caches.open('v1').then(cache => { cache.put(event.request, response.clone()); return response; }); }); - }).catch(function() { + }).catch(() => { return self.caches.match('/sw-test/gallery/myLittleVader.jpg'); }); event.respondWith(cachedResponse); }); -self.caches.open('v1').then(function(cache) { - cache.match('/images/image.png').then(function(response: Response) { +self.caches.open('v1').then(cache => { + cache.match('/images/image.png').then(response => { cache.delete(response.url); }); }); -self.caches.open('v1').then(function(cache: Cache) { - cache.keys().then(function(response) { - response.forEach(function(element, index, array) { +self.caches.open('v1').then(cache => { + cache.keys().then(response => { + response.forEach((element, index, array) => { cache.delete(element); }); }); }); -self.caches.has('v1').then(function() { - self.caches.delete('v1').then(function() { +self.caches.has('v1').then(() => { + self.caches.delete('v1').then(() => { console.log('done'); }); }); -self.addEventListener('activate', function(event: ExtendableEvent) { +self.addEventListener('activate', (event: ExtendableEvent) => { var cacheWhitelist = ['v2']; event.waitUntil( - self.caches.keys().then(function(keyList) { + self.caches.keys().then(keyList => { for (var item of keyList) { if (cacheWhitelist.indexOf(item) === -1) { return self.caches.delete(item); @@ -105,7 +105,7 @@ self.addEventListener('activate', function(event: ExtendableEvent) { }); function sendMessage(message: any) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { var messageChannel = new MessageChannel(); messageChannel.port1.onmessage = function(event) { if (event.data.error) { @@ -118,15 +118,15 @@ function sendMessage(message: any) { }); } -self.addEventListener('message', function(evt: ExtendableMessageEvent) { +self.addEventListener('message', (evt: ExtendableMessageEvent) => { evt.ports[0].postMessage(evt.source.id); }); -sendMessage('test').then(function(clientId: string) { +sendMessage('test').then((clientId: string) => { console.log(clientId); }); -self.clients.matchAll({type: "test"}).then(function(clients) { +self.clients.matchAll({type: "test"}).then(clients => { for (var cli of clients) { if(cli.url === 'index.html') { self.clients.openWindow(cli.url); @@ -135,11 +135,11 @@ self.clients.matchAll({type: "test"}).then(function(clients) { } }); -self.addEventListener('activate', function(e: ExtendableEvent) { +self.addEventListener('activate', (e: ExtendableEvent) => { e.waitUntil(self.clients.claim()); }); -navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(function(registration) { +navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(registration => { // At this point, registration has taken place. // The service worker will not handle requests until this page and any // other instances of this page (in other tabs, etc.) have been @@ -154,31 +154,31 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi } if (serviceWorker) { console.log(serviceWorker.state); - serviceWorker.addEventListener('statechange', function(e: any) { + serviceWorker.addEventListener('statechange', (e: any) => { console.log(e.target.state); }); } -}).catch(function(error) { +}).catch(error => { // Something went wrong during registration. The service-worker.js file // might be unavailable or contain a syntax error. }); -navigator.serviceWorker.getRegistration('/app').then(function(registration: ServiceWorkerRegistration) { +navigator.serviceWorker.getRegistration('/app').then((registration: ServiceWorkerRegistration) => { console.log(registration); }); -navigator.serviceWorker.getRegistrations().then(function(registrations: ServiceWorkerRegistration[]) { +navigator.serviceWorker.getRegistrations().then((registrations: ServiceWorkerRegistration[]) => { console.log(registrations); }); self.registration.unregister(); -self.addEventListener('install', function(event: ExtendableEvent) { +self.addEventListener('install', (event: ExtendableEvent) => { event.waitUntil(self.skipWaiting()); }); -self.addEventListener('notificationclick', function(event: NotificationEvent) { +self.addEventListener('notificationclick', (event: NotificationEvent) => { console.log('On notification click: ', event.notification.tag); event.notification.close(); @@ -186,7 +186,7 @@ self.addEventListener('notificationclick', function(event: NotificationEvent) { // focuses if it is event.waitUntil(self.clients.matchAll({ type: "window" - }).then(function(clientList) { + }).then(clientList => { if (self.clients.openWindow) return self.clients.openWindow('/'); })); diff --git a/sha1/sha1-tests.ts b/sha1/sha1-tests.ts index f2c6547f2b..22467632c8 100644 --- a/sha1/sha1-tests.ts +++ b/sha1/sha1-tests.ts @@ -1,5 +1,3 @@ -/// - import fs = require("fs"); import sha1 = require("sha1"); /** @@ -31,6 +29,6 @@ console.log(sha1('message')); // should print 6f9b9af3cd6e8b8a73c2cdced37fe9f592 const testTwo = sha1('message', {asString: true}); const testThree = sha1('message', {asBytes: true}); -fs.readFile('sha1.d.ts', function(err: Error, buf: Buffer) { +fs.readFile('sha1.d.ts', (err: Error, buf: Buffer) => { console.log(sha1(buf)); }); diff --git a/sharp/sharp-tests.ts b/sharp/sharp-tests.ts index 00c318feb9..2ca348620a 100644 --- a/sharp/sharp-tests.ts +++ b/sharp/sharp-tests.ts @@ -9,14 +9,14 @@ const writableStream: NodeJS.WritableStream = createWriteStream(input); sharp(input) .extractChannel('green') - .toFile('input_green.jpg', function(err, info) { + .toFile('input_green.jpg', (err, info) => { // info.channels === 1 // input_green.jpg contains the green channel of the input image }); sharp('3-channel-rgb-input.png') .bandbool(sharp.bool.and) - .toFile('1-channel-output.png', function(err, info) { + .toFile('1-channel-output.png', (err, info) => { // The output will be a single channel image where each pixel `P = R & G & B`. // If `I(1,1) = [247, 170, 14] = [0b11110111, 0b10101010, 0b00001111]` // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`. @@ -34,7 +34,7 @@ sharp('input.png') quality: 90 }) .toBuffer() - .then(function(outputBuffer: Buffer) { + .then((outputBuffer: Buffer) => { // outputBuffer contains upside down, 300px wide, alpha channel flattened // onto orange background, composited with overlay.png with SE gravity, // sharpened, with metadata, 90% quality WebP image data. Phew! @@ -42,14 +42,14 @@ sharp('input.png') sharp('input.jpg') .resize(300, 200) - .toFile('output.jpg', function(err: Error) { + .toFile('output.jpg', (err: Error) => { // output.jpg is a 300 pixels wide and 200 pixels high image // containing a scaled and cropped version of input.jpg }); var transformer = sharp() .resize(300) - .on('info', function(info: sharp.OutputInfo) { + .on('info', (info: sharp.OutputInfo) => { console.log('Image height is ' + info.height); }); readableStream.pipe(transformer).pipe(writableStream); @@ -57,7 +57,7 @@ readableStream.pipe(transformer).pipe(writableStream); console.log(sharp.format); console.log(sharp.versions); -sharp.queue.on('change', function(queueLength: number) { +sharp.queue.on('change', (queueLength: number) => { console.log('Queue contains ' + queueLength + ' task(s)'); }); @@ -71,7 +71,7 @@ readableStream.pipe(pipeline); const image: sharp.SharpInstance = sharp(input); image .metadata() - .then(function(metadata: sharp.Metadata) { + .then((metadata: sharp.Metadata) => { if (metadata.width) { return image .resize(Math.round(metadata.width / 2)) @@ -79,14 +79,14 @@ image .toBuffer(); } }) - .then(function(data: Buffer) { + .then((data: Buffer) => { // data contains a WebP image half the width and height of the original JPEG }); pipeline = sharp() .rotate() .resize(undefined, 200) - .toBuffer(function(err: Error, outputBuffer: Buffer, info: sharp.OutputInfo) { + .toBuffer((err: Error, outputBuffer: Buffer, info: sharp.OutputInfo) => { // outputBuffer contains 200px high JPEG image data, // auto-rotated using EXIF Orientation tag // info.width and info.height contain the dimensions of the resized image @@ -95,7 +95,7 @@ readableStream.pipe(pipeline); sharp(input) .extract({ left: 0, top: 0, width: 100, height: 100 }) - .toFile("output", function(err: Error) { + .toFile("output", (err: Error) => { // Extract a region of the input image, saving in the same format. }); @@ -103,7 +103,7 @@ sharp(input) .extract({ left: 0, top: 0, width: 100, height: 100 }) .resize(200, 200) .extract({ left: 0, top: 0, width: 100, height: 100 }) - .toFile("output", function(err: Error) { + .toFile("output", (err: Error) => { // Extract a region, resize, then extract from the resized image }); @@ -121,7 +121,7 @@ sharp(input) kernel: [-1, 0, 1, -2, 0, 2, -1, 0, 1] }) .raw() - .toBuffer(function(err: Error, data: Buffer, info: sharp.OutputInfo) { + .toBuffer((err: Error, data: Buffer, info: sharp.OutputInfo) => { // data contains the raw pixel data representing the convolution // of the input image with the horizontal Sobel operator }); @@ -131,7 +131,7 @@ sharp('input.tiff') .tile({ size: 512 }) - .toFile('output.dz', function(err: Error, info: sharp.OutputInfo) { + .toFile('output.dz', (err: Error, info: sharp.OutputInfo) => { // output.dzi is the Deep Zoom XML definition // output_files contains 512x512 tiles grouped by zoom level }); @@ -144,7 +144,7 @@ sharp(input) .background('white') .embed() .toFile('output.tiff') - .then(function() { + .then(() => { // output.tiff is a 200 pixels wide and 300 pixels high image // containing a lanczos2/nohalo scaled version, embedded on a white canvas, // of the image data in inputBuffer @@ -153,7 +153,7 @@ sharp(input) transformer = sharp() .resize(200, 200) .crop(sharp.strategy.entropy) - .on('error', function(err: Error) { + .on('error', (err: Error) => { console.log(err); }); // Read image data from readableStream @@ -165,7 +165,7 @@ sharp('input.gif') .background({ r: 0, g: 0, b: 0, alpha: 0 }) .embed() .toFormat(sharp.format.webp) - .toBuffer(function(err: Error, outputBuffer: Buffer) { + .toBuffer((err: Error, outputBuffer: Buffer) => { if (err) { throw err; } @@ -178,7 +178,7 @@ sharp(input) .max() .toFormat('jpeg') .toBuffer() - .then(function(outputBuffer: Buffer) { + .then((outputBuffer: Buffer) => { // outputBuffer contains JPEG image data no wider than 200 pixels and no higher // than 200 pixels regardless of the inputBuffer image dimensions }); diff --git a/sheetify/sheetify-tests.ts b/sheetify/sheetify-tests.ts index bdeb1aa817..931e05b579 100644 --- a/sheetify/sheetify-tests.ts +++ b/sheetify/sheetify-tests.ts @@ -1,8 +1,8 @@ import * as sheetify from 'sheetify'; -function done1 (err: Error, css: string, prefix: string) {}; -function done2 (err: Error, css: string) {}; -function done3 (err: Error) {}; +function done1(err: Error, css: string, prefix: string) {}; +function done2(err: Error, css: string) {}; +function done3(err: Error) {}; const test1 = sheetify('foobar'); const test2 = sheetify('foobar', {global: true}); diff --git a/simple-oauth2/simple-oauth2-tests.ts b/simple-oauth2/simple-oauth2-tests.ts index 2b5f45e673..5a733020cc 100644 --- a/simple-oauth2/simple-oauth2-tests.ts +++ b/simple-oauth2/simple-oauth2-tests.ts @@ -19,7 +19,7 @@ const oauth2 = oauth2lib.create(credentials); // #Authorization Code flow -(function () { +(() => { // Authorization oauth2 URI const authorizationUri = oauth2.authorizationCode.authorizeURL({ @@ -60,7 +60,7 @@ const oauth2 = oauth2lib.create(credentials); // #Client Credentials Flow -(function () { +(() => { const tokenConfig = {}; // Callbacks @@ -88,7 +88,7 @@ const oauth2 = oauth2lib.create(credentials); // #Access Token object -(function () { +(() => { // Sample of a JSON access token (you got it through previous steps) const tokenObject = { access_token: '', diff --git a/slug/slug-tests.ts b/slug/slug-tests.ts index 5fc72d1032..5ba9aa7f29 100644 --- a/slug/slug-tests.ts +++ b/slug/slug-tests.ts @@ -22,7 +22,7 @@ print(slug('i <3 unicode')); // options is either object or replacement (sets options.replacement) slug('string', { } || 'replacement'); -slug.defaults.mode ='pretty'; +slug.defaults.mode = 'pretty'; slug.defaults.modes['rfc3986'] = { replacement: '-', // replace spaces with replacement symbols: true, // replace unicode symbols or not diff --git a/spatialite/spatialite-tests.ts b/spatialite/spatialite-tests.ts index eef51b3c18..0edf111cc1 100644 --- a/spatialite/spatialite-tests.ts +++ b/spatialite/spatialite-tests.ts @@ -44,8 +44,8 @@ function insertRows() { function readAllRows() { console.log("readAllRows lorem"); - db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) { - rows.forEach(function (row) { + db.all("SELECT rowid AS id, info FROM lorem", (err, rows) => { + rows.forEach(row => { console.log(row.id + ": " + row.info); }); readSomeRows(); @@ -54,7 +54,7 @@ function readAllRows() { function readSomeRows() { console.log("readAllRows lorem"); - db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, function(err, row) { + db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, (err, row) => { console.log(row.id + ": " + row.info); }, closeDb); } @@ -70,7 +70,7 @@ function runChainExample() { runChainExample(); -db.serialize(function() { +db.serialize(() => { db.run("CREATE TABLE lorem (info TEXT)"); var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); @@ -79,15 +79,15 @@ db.serialize(function() { } stmt.finalize(); - db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { + db.each("SELECT rowid AS id, info FROM lorem", (err, row) => { console.log(row.id + ": " + row.info); }); }); -db.serialize(function() { +db.serialize(() => { // These two queries will run sequentially. db.run("CREATE TABLE foo (num)"); - db.run("INSERT INTO foo VALUES (?)", 1, function(err) { + db.run("INSERT INTO foo VALUES (?)", 1, err => { // These queries will run in parallel and the second query will probably // fail because the table might not exist yet. db.run("CREATE TABLE bar (num)"); @@ -107,7 +107,7 @@ db.run("UPDATE tbl SET name = $name WHERE id = $id", { $name: "bar" }); db.run("UPDATE tbl SET name = $name WHERE id = $id", { $id: 2, $name: "bar" }, - function(err) { } + err => { } ); db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { diff --git a/sqlite3/sqlite3-tests.ts b/sqlite3/sqlite3-tests.ts index 5e13fd7840..75a8c2e72c 100644 --- a/sqlite3/sqlite3-tests.ts +++ b/sqlite3/sqlite3-tests.ts @@ -27,8 +27,8 @@ function insertRows() { function readAllRows() { console.log("readAllRows lorem"); - db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) { - rows.forEach(function (row) { + db.all("SELECT rowid AS id, info FROM lorem", (err, rows) => { + rows.forEach(row => { console.log(row.id + ": " + row.info); }); readSomeRows(); @@ -37,7 +37,7 @@ function readAllRows() { function readSomeRows() { console.log("readAllRows lorem"); - db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, function(err, row) { + db.each("SELECT rowid AS id, info FROM lorem WHERE rowid < ? ", 5, (err, row) => { console.log(row.id + ": " + row.info); }, closeDb); } @@ -53,7 +53,7 @@ function runChainExample() { runChainExample(); -db.serialize(function() { +db.serialize(() => { db.run("CREATE TABLE lorem (info TEXT)"); var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); @@ -62,15 +62,15 @@ db.serialize(function() { } stmt.finalize(); - db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { + db.each("SELECT rowid AS id, info FROM lorem", (err, row) => { console.log(row.id + ": " + row.info); }); }); -db.serialize(function() { +db.serialize(() => { // These two queries will run sequentially. db.run("CREATE TABLE foo (num)"); - db.run("INSERT INTO foo VALUES (?)", 1, function(err) { + db.run("INSERT INTO foo VALUES (?)", 1, err => { // These queries will run in parallel and the second query will probably // fail because the table might not exist yet. db.run("CREATE TABLE bar (num)"); @@ -90,7 +90,7 @@ db.run("UPDATE tbl SET name = $name WHERE id = $id", { $name: "bar" }); db.run("UPDATE tbl SET name = $name WHERE id = $id", { $id: 2, $name: "bar" }, - function(err) { } + err => { } ); db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { diff --git a/sshpk/index.d.ts b/sshpk/index.d.ts index 05d26053b6..0bc2274120 100644 --- a/sshpk/index.d.ts +++ b/sshpk/index.d.ts @@ -365,7 +365,8 @@ declare namespace SshPK { export function parseCertificate(data: string|Buffer, format: string, options?: any): Certificate; export function createSelfSignedCertificate(subjectOrSubjects: string, key: Key, options?: any): Certificate; - export function createCertificate(subjectOrSubjects: string, key: Key, issuer: string, + export function createCertificate( + subjectOrSubjects: string, key: Key, issuer: string, issuerKey: PrivateKey, options?: any): Certificate; export function identityFromDN(dn: string): Identity; diff --git a/swagger-hapi/swagger-hapi-tests.ts b/swagger-hapi/swagger-hapi-tests.ts index 50d3954975..0d3e56c40b 100644 --- a/swagger-hapi/swagger-hapi-tests.ts +++ b/swagger-hapi/swagger-hapi-tests.ts @@ -9,7 +9,7 @@ var config = { appRoot: __dirname // required config } as SwaggerHapi.Config; -SwaggerHapi.create(config, function(err, swaggerHapi) { +SwaggerHapi.create(config, (err, swaggerHapi) => { if (err) { throw err; } var port = process.env.PORT || 10010; @@ -22,7 +22,7 @@ SwaggerHapi.create(config, function(err, swaggerHapi) { let appRootFromMw = swaggerHapi.config.swagger.appRoot; } - app.register(swaggerHapi.plugin, function(err) { + app.register(swaggerHapi.plugin, err => { if (err) { return console.error("Failed to load plugin:", err); } // stat app etc.. }); diff --git a/swagger-node-runner/swagger-node-runner-tests.ts b/swagger-node-runner/swagger-node-runner-tests.ts index 77b516e71c..78e9783a45 100644 --- a/swagger-node-runner/swagger-node-runner-tests.ts +++ b/swagger-node-runner/swagger-node-runner-tests.ts @@ -49,7 +49,7 @@ SwaggerNodeRunner.create(config, (err, runner) => { //Hapi Middleware var hapiapp = new Hapi.Server(); -SwaggerNodeRunner.create(config, function(err, runner) { +SwaggerNodeRunner.create(config, (err, runner) => { if (err) { throw err; } var port = process.env.PORT || 10010; @@ -65,7 +65,7 @@ SwaggerNodeRunner.create(config, function(err, runner) { let pluginAttributes = hapiMiddleware.plugin.register.attributes.name + hapiMiddleware.plugin.register.attributes.version; - hapiapp.register(hapiMiddleware.plugin, function(err) { + hapiapp.register(hapiMiddleware.plugin, err => { if (err) { return console.error("Failed to load plugin:", err); } // stat app etc.. }); @@ -74,7 +74,7 @@ SwaggerNodeRunner.create(config, function(err, runner) { // Restify Middelware let app = restify.createServer(); -SwaggerNodeRunner.create(config, function(err, runner) { +SwaggerNodeRunner.create(config, (err, runner) => { if (err) { throw err; } let restifyMiddelware = runner.restifyMiddleware(); diff --git a/swagger-restify-mw/swagger-restify-mw-tests.ts b/swagger-restify-mw/swagger-restify-mw-tests.ts index c8bd436c7c..f03793e0c9 100644 --- a/swagger-restify-mw/swagger-restify-mw-tests.ts +++ b/swagger-restify-mw/swagger-restify-mw-tests.ts @@ -7,7 +7,7 @@ let config = { appRoot: __dirname // required config } as SwaggerRestify.Config; -SwaggerRestify.create(config, function(err, swaggerRestify) { +SwaggerRestify.create(config, (err, swaggerRestify) => { if (err) { throw err; } swaggerRestify.register(app); diff --git a/swiper/swiper-tests.ts b/swiper/swiper-tests.ts index 99465226c1..babe40c5d1 100644 --- a/swiper/swiper-tests.ts +++ b/swiper/swiper-tests.ts @@ -239,22 +239,22 @@ function dynamicSlides() { paginationClickable: true, spaceBetween: 30, }); - document.querySelector('.prepend-2-slides').addEventListener('click', function (e) { + document.querySelector('.prepend-2-slides').addEventListener('click', e => { e.preventDefault(); swiper.prependSlide([ '
Slide ' + (--prependNumber) + '
', '
Slide ' + (--prependNumber) + '
' ]); }); - document.querySelector('.prepend-slide').addEventListener('click', function (e) { + document.querySelector('.prepend-slide').addEventListener('click', e => { e.preventDefault(); swiper.prependSlide('
Slide ' + (--prependNumber) + '
'); }); - document.querySelector('.append-slide').addEventListener('click', function (e) { + document.querySelector('.append-slide').addEventListener('click', e => { e.preventDefault(); swiper.appendSlide('
Slide ' + (++appendNumber) + '
'); }); - document.querySelector('.append-2-slides').addEventListener('click', function (e) { + document.querySelector('.append-2-slides').addEventListener('click', e => { e.preventDefault(); swiper.appendSlide([ '
Slide ' + (++appendNumber) + '
', @@ -365,7 +365,7 @@ function customPagination() { var swiper = new Swiper('.swiper-container', { pagination: '.swiper-pagination', paginationClickable: true, - paginationBulletRender: function (swiper, index, className) { + paginationBulletRender(swiper, index, className) { return '' + (index + 1) + ''; } }); @@ -388,41 +388,41 @@ function customPlugin() { /* ======== Debugger plugin, simple demo plugin to console.log some of callbacks ======== */ - Swiper.prototype.plugins.debugger = function (swiper: any, params: any) { + Swiper.prototype.plugins.debugger = (swiper: any, params: any) => { if (!params) return; // Need to return object with properties that names are the same as callbacks return { - onInit: function (swiper: any) { + onInit(swiper: any) { console.log('onInit'); }, - onClick: function (swiper: any, e: any) { + onClick(swiper: any, e: any) { console.log('onClick'); }, - onTap: function (swiper: any, e: any) { + onTap(swiper: any, e: any) { console.log('onTap'); }, - onDoubleTap: function (swiper: any, e: any) { + onDoubleTap(swiper: any, e: any) { console.log('onDoubleTap'); }, - onSliderMove: function (swiper: any, e: any) { + onSliderMove(swiper: any, e: any) { console.log('onSliderMove'); }, - onSlideChangeStart: function (swiper: any) { + onSlideChangeStart(swiper: any) { console.log('onSlideChangeStart'); }, - onSlideChangeEnd: function (swiper: any) { + onSlideChangeEnd(swiper: any) { console.log('onSlideChangeEnd'); }, - onTransitionStart: function (swiper: any) { + onTransitionStart(swiper: any) { console.log('onTransitionStart'); }, - onTransitionEnd: function (swiper: any) { + onTransitionEnd(swiper: any) { console.log('onTransitionEnd'); }, - onReachBeginning: function (swiper: any) { + onReachBeginning(swiper: any) { console.log('onReachBeginning'); }, - onReachEnd: function (swiper: any) { + onReachEnd(swiper: any) { console.log('onReachEnd'); } }; @@ -440,7 +440,7 @@ function scrollContainer() { } // 32-slideable-menu.html function slideableMenu() { - var toggleMenu = function () { + var toggleMenu = () => { if (swiper.previousIndex === 0) swiper.slidePrev(); } @@ -449,14 +449,14 @@ function slideableMenu() { slidesPerView: 'auto' , initialSlide: 1 , resistanceRatio: .00000000000001 - , onSlideChangeStart: function (slider) { + , onSlideChangeStart: (slider) => { if (slider.activeIndex === 0) { menuButton.classList.add('cross'); menuButton.removeEventListener('click', toggleMenu, false); } else menuButton.classList.remove('cross'); } - , onSlideChangeEnd: function (slider) { + , onSlideChangeEnd: (slider) => { if (slider.activeIndex === 0) menuButton.removeEventListener('click', toggleMenu, false); else diff --git a/uikit/uikit-tests.ts b/uikit/uikit-tests.ts index d9032fa8b0..566ef362d9 100644 --- a/uikit/uikit-tests.ts +++ b/uikit/uikit-tests.ts @@ -37,7 +37,7 @@ function testModal() { UIkit.modal.confirm("Are you sure?", () => {}, () => {}, {}); UIkit.modal.confirm("Are you sure?", () => {}, {}); - UIkit.modal.prompt("Name:", 'value', function (newvalue: string) { + UIkit.modal.prompt("Name:", 'value', (newvalue: string) => { // will be executed on submit. }); var modal = UIkit.modal.blockUI("Any content..."); @@ -142,7 +142,7 @@ function testTooltip() { } function testUpload() { - $(function(){ + $(() => { var progressbar = $("#progressbar"), bar = progressbar.find('.uk-progress-bar'), @@ -152,21 +152,21 @@ function testUpload() { allow : '*.(jpg|jpeg|gif|png)', // allow only images - loadstart: function() { + loadstart() { bar.css("width", "0%").text("0%"); progressbar.removeClass("uk-hidden"); }, - progress: function(percent: number) { + progress(percent: number) { percent = Math.ceil(percent); bar.css("width", percent + "%").text(percent + "%"); }, - allcomplete: function(response: any) { + allcomplete(response: any) { bar.css("width", "100%").text("100%"); - setTimeout(function(){ + setTimeout(() => { progressbar.addClass("uk-hidden"); }, 250); @@ -185,15 +185,15 @@ function testUpload() { allow: '*.(jpg|jpeg|gif|png)', // allow only images - loadstart: function () { + loadstart: () => { }, - progress: function (percent: number) { + progress: (percent: number) => { }, - allcomplete: function (response: any) { + allcomplete: (response: any) => { } }); @@ -203,15 +203,15 @@ function testUpload() { allow: '*.(jpg|jpeg|gif|png)', // allow only images - loadstart: function () { + loadstart: () => { }, - progress: function (percent: number) { + progress: (percent: number) => { }, - allcomplete: function (response: any) { + allcomplete: (response: any) => { } }); diff --git a/vis/vis-tests.ts b/vis/vis-tests.ts index a5c755da84..a42c53698e 100644 --- a/vis/vis-tests.ts +++ b/vis/vis-tests.ts @@ -34,7 +34,7 @@ data.add([ ]); // subscribe to any change in the DataSet -data.on('*', function (event, properties, senderId) { +data.on('*', (event, properties, senderId) => { console.log('event', event, properties); }); @@ -54,7 +54,7 @@ console.log('item1', item1); // retrieve a filtered subset of the data var items = data.get({ - filter: function (item) { + filter: (item) => { return item.group === 1; } }); @@ -77,7 +77,7 @@ console.log('formatted items', items); var data = new vis.DataSet(); // subscribe to any change in the DataSet -data.on('*', function (event, properties, senderId) { +data.on('*', (event, properties, senderId) => { console.log('event:', event, 'properties:', properties, 'senderId:', senderId); }); @@ -132,14 +132,14 @@ var dataset = new vis.DataSet(); // retrieve all items having a property group with value 2 var group2 = dataset.get({ - filter: function (item) { + filter: (item) => { return (item.group === 2); } }); // retrieve all items having a property balance with a value above zero var positiveBalance = dataset.get({ - filter: function (item) { + filter: (item) => { return (item.balance > 0); } }); diff --git a/webpack-dev-middleware/webpack-dev-middleware-tests.ts b/webpack-dev-middleware/webpack-dev-middleware-tests.ts index 63d32332b5..3764a6b9aa 100644 --- a/webpack-dev-middleware/webpack-dev-middleware-tests.ts +++ b/webpack-dev-middleware/webpack-dev-middleware-tests.ts @@ -31,6 +31,6 @@ app.use(webpackDevMiddlewareInstance); webpackDevMiddlewareInstance.close(); webpackDevMiddlewareInstance.invalidate(); -webpackDevMiddlewareInstance.waitUntilValid(function(){ +webpackDevMiddlewareInstance.waitUntilValid(() => { console.log('Package is in a valid state'); }); diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index ac72e9415c..cb1a264b1e 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -208,7 +208,7 @@ declare var path: any; configuration = { plugins: [ function(this: webpack.Compiler) { - this.plugin("done", function(stats: any) { + this.plugin("done", stats => { require("fs").writeFileSync( path.join(__dirname, "...", "stats.json"), JSON.stringify(stats.toJson())); @@ -284,9 +284,7 @@ plugin = new webpack.optimize.UglifyJsPlugin({ } }); plugin = new webpack.optimize.UglifyJsPlugin({ - comments: function(astNode: any, comment: any) { - return false; - } + comments: (astNode: any, comment: any) => false }); plugin = new webpack.optimize.CommonsChunkPlugin(options); plugin = new CommonsChunkPlugin({ @@ -374,7 +372,7 @@ plugin = new webpack.LoaderOptionsPlugin({ // returns a Compiler instance webpack({ // configuration -}, function(err, stats) { +}, (err, stats) => { // ... }); @@ -383,7 +381,7 @@ var compiler = webpack({ // configuration }); -compiler.run(function(err, stats) { +compiler.run((err, stats) => { // ... }); // or @@ -391,19 +389,19 @@ compiler.watch({ // watch options: aggregateTimeout: 300, // wait so long for more changes poll: true // use polling instead of native watchers // pass a number to set the polling interval -}, function(err, stats) { +}, (err, stats) => { // ... }); // or compiler.watch({ // watch options: ignored: 'foo/**/*' -}, function(err, stats) { +}, (err, stats) => { // ... }); // or compiler.watch({ // watch options: ignored: /node_modules/ -}, function(err, stats) { +}, (err, stats) => { // ... }); @@ -414,7 +412,7 @@ declare function successfullyCompiled(): void; webpack({ // configuration -}, function(err, stats) { +}, (err, stats) => { if(err) return handleFatalError(err); var jsonStats = stats.toJson(); @@ -451,7 +449,7 @@ declare var fs: any; compiler = webpack({ }); compiler.outputFileSystem = fs; -compiler.run(function(err, stats) { +compiler.run((err, stats) => { // ... var fileContent = fs.readFileSync("..."); }); @@ -469,7 +467,7 @@ rule = { }, loader: "./loader", options: "third" -} +}; configuration = { module: { @@ -499,7 +497,7 @@ configuration = { { loader: "./loader", options: { - get: function() { return "second-3"; } + get: () => "second-3" } } ] @@ -517,19 +515,17 @@ configuration = { ]} ] } -} +}; const resolve: webpack.Resolve = { cachePredicate: 'boo' // why does this test _not_ fail!? -} +}; const performance: webpack.Options.Performance = { hints: 'error', maxEntrypointSize: 400000, maxAssetSize: 100000, - assetFilter: function(assetFilename) { - return assetFilename.endsWith('.js'); - }, + assetFilter: assetFilename => assetFilename.endsWith('.js'), }; configuration = { diff --git a/webtorrent/webtorrent-tests.ts b/webtorrent/webtorrent-tests.ts index ba08944d58..c693c4ffa3 100644 --- a/webtorrent/webtorrent-tests.ts +++ b/webtorrent/webtorrent-tests.ts @@ -4,26 +4,26 @@ import * as fs from 'fs'; var client = new WebTorrent(); var magnetURI = '...'; -client.add(magnetURI, {}, function(torrent) { +client.add(magnetURI, {}, torrent => { // Got torrent metadata! console.log('Client is downloading:', torrent.infoHash); - torrent.files.forEach(function(file) { + torrent.files.forEach(file => { // Display the file by appending it to the DOM. Supports video, audio, images, and // more. Specify a container element (CSS selector or reference to DOM node). file.appendTo('body'); - file.getBuffer(function(err, buffer) { + file.getBuffer((err, buffer) => { if (err) throw err; console.log(buffer); // }); - file.appendTo('#containerElement', function(err, elem) { + file.appendTo('#containerElement', (err, elem) => { if (err) throw err; // file failed to download or display in the DOM console.log('New DOM node with the content', elem); }); - file.getBlobURL(function(err, url) { + file.getBlobURL((err, url) => { if (err) throw err; var a = document.createElement('a'); // a.download = file.name @@ -35,14 +35,14 @@ client.add(magnetURI, {}, function(torrent) { }); }); - torrent.on('done', function() { + torrent.on('done', () => { console.log('torrent finished downloading'); - torrent.files.forEach(function(file) { + torrent.files.forEach(file => { // do something with file }); }); - torrent.on('download', function(chunkSize) { + torrent.on('download', chunkSize => { console.log('chunk size: ' + chunkSize); console.log('total downloaded: ' + torrent.downloaded); console.log('download speed: ' + torrent.downloadSpeed); @@ -50,16 +50,16 @@ client.add(magnetURI, {}, function(torrent) { console.log('======'); }); - torrent.on('wire', function(wire, addr) { + torrent.on('wire', (wire, addr) => { console.log('connected to peer with address ' + addr); }); }); -client.seed('./file.txt', {}, function(torrent) { +client.seed('./file.txt', {}, torrent => { console.log('Client is seeding:', torrent.infoHash); }); -client.add(magnetURI, function(torrent) { +client.add(magnetURI, torrent => { // create HTTP server for this torrent var server = torrent.createServer(); server.listen(1234); // start the server listening to a port diff --git a/xrm/index.d.ts b/xrm/index.d.ts index bd70a6098d..b84405b24c 100644 --- a/xrm/index.d.ts +++ b/xrm/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft Dynamics xRM API v8.2 +// Type definitions for Microsoft Dynamics xRM API 8.2 // Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567 // Definitions by: David Berry , Matt Ngan , Markus Mauch , Daryl LaBar , Tully H // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -243,12 +243,12 @@ declare namespace Xrm * Client Types for Xrm.Page.context.getClient(). */ export type Client = "Web" | "Outlook" | "Mobile"; - + /** * Client States for Xrm.Page.context.getClientState(). */ export type ClientState = "Online" | "Offline"; - + /** * Themes for Xrm.Page.context.getCurrentTheme(). */ @@ -391,7 +391,7 @@ declare namespace Xrm /** * Defines save options to control how appointment, recurring appointment, or service activity records are processed. - * + * * @see {@link https://msdn.microsoft.com/en-us/library/dn481607.aspx#Anchor_2} for details. */ export interface SaveOptions @@ -402,7 +402,7 @@ declare namespace Xrm */ UseSchedulingEngine?: boolean; } - + /** * Interface for the Xrm.Page.data object. */ @@ -423,7 +423,7 @@ declare namespace Xrm * @return {Async.XrmPromise} Returns an asynchronous promise. */ save(): Async.XrmPromise; - + /** * Asynchronously saves the record with the option to set callback functions to be executed after the save operation is completed. * @@ -465,7 +465,7 @@ declare namespace Xrm * INFO Notification will use the system info icon. */ setFormNotification( message: string, level: Page.ui.FormNotificationLevel, uniqueId: string ): boolean; - + /** * Clears the form notification described by uniqueId. * @@ -548,7 +548,7 @@ declare namespace Xrm * A reference to the collection of tabs on the form. */ tabs: Collection.ItemCollection; - + /** * A collection of all the quick view controls on a form using the new form rendering engine (also called "turbo forms"). */ @@ -680,7 +680,7 @@ declare namespace Xrm * Called when the operation is successful. */ export type SuccessCallbackDelegate = () => void; - + /** * Called when the operation fails. * @@ -696,7 +696,7 @@ declare namespace Xrm * @see {Xrm.Utility.openQuickCreate} */ export type QuickCreateSuccessCallbackDelegate = ( record: OpenQuickCreateSuccessCallbackObject ) => void; - + /** * Called when the offline operation is successful. * @@ -713,7 +713,7 @@ declare namespace Xrm * * @see {Xrm.Mobile.offline.retrieveMultipleRecords} */ - export type OfflineRetrieveMultipleSuccessCallbackDelegate = (resultSet: { [key: string]: any }[]) => void; + export type OfflineRetrieveMultipleSuccessCallbackDelegate = (resultSet: Array<{ [key: string]: any }>) => void; /** * Called when the operation fails. @@ -766,7 +766,7 @@ declare namespace Xrm */ logicalName: string; } - + /** * Object passed to OfflineErrorCallbackDelegate. */ @@ -905,17 +905,17 @@ declare namespace Xrm * Requirement Level for Xrm.Page.Attribute.getRequiredLevel() and Xrm.Page.Attribute.setRequiredLevel(). */ export type RequirementLevel = "none" | "recommended" | "required"; - + /** * Save Modes for Xrm.Page.Entity.save(). */ export type SaveMode = "saveandclose" | "saveandnew"; - + /** * Status for Xrm.Page.Stage.getStatus(). */ export type Status = "active" | "inactive"; - + /** * Submit Mode for Xrm.Page.Attribute.getSubmitMode() and Xrm.Page.Attribute.setSubmitMode(). */ @@ -925,7 +925,7 @@ declare namespace Xrm * Control type for Xrm.Page.ui.QuickForm.getControlType(). */ export type ControlQuickFormType = "quickform"; - + /** * Control types for Xrm.Page.Control.getControlType(). */ @@ -960,7 +960,7 @@ declare namespace Xrm * Attribute formats for Xrm.Page.Attribute.getFormat(). */ export type AttributeFormat = DateAttributeFormat | IntegerAttributeFormat | OptionSetAttributeFormat | StringAttributeFormat; - + /** * Interface for a CRM Business Process Flow instance. */ @@ -1161,7 +1161,7 @@ declare namespace Xrm * @return The label. */ getLabel(): string; - + /** * Sets the label. * @@ -1182,7 +1182,7 @@ declare namespace Xrm */ getVisible(): boolean; } - + /** * Base interface for standard UI elements. */ @@ -1206,7 +1206,7 @@ declare namespace Xrm */ setFocus(): void; } - + /** * Interface for controls which methods provide immediate feedback or take actions as user types in a control. * Contains methods which can be used to perform data validations in a control even before the user commits (saves) the value in a form. @@ -1390,7 +1390,7 @@ declare namespace Xrm * string */ getAttributeType(): string; - + /** * Gets the attribute format. * @@ -1484,7 +1484,7 @@ declare namespace Xrm * A collection of all the controls on the form that interface with this attribute. */ controls: Collection.ItemCollection; - + /** * Gets the value. * @@ -1516,7 +1516,7 @@ declare namespace Xrm * none */ getFormat(): IntegerAttributeFormat; - + /** * Gets the maximum value allowed. * @@ -1553,7 +1553,7 @@ declare namespace Xrm * @remarks Attributes on Quick Create Forms will not save values set with this method. */ setValue( value: number ): void; - + /** * A collection of all the controls on the form that interface with this attribute. */ @@ -1580,7 +1580,7 @@ declare namespace Xrm * url */ getFormat(): StringAttributeFormat; - + /** * Gets maximum length allowed. * @@ -1671,7 +1671,7 @@ declare namespace Xrm * datetime */ getFormat(): DateAttributeFormat; - + /** * Gets the value. * @@ -1687,7 +1687,7 @@ declare namespace Xrm * @remarks Attributes on Quick Create Forms will not save values set with this method. */ setValue( value: Date ): void; - + /** * A collection of all the controls on the form that interface with this attribute. */ @@ -1710,7 +1710,7 @@ declare namespace Xrm * timezone */ getFormat(): OptionSetAttributeFormat; - + /** * Gets the option matching a value. * @@ -1768,7 +1768,7 @@ declare namespace Xrm * with this method. */ setValue( value: number ): void; - + /** * A collection of all the controls on the form that interface with this attribute. */ @@ -1804,7 +1804,7 @@ declare namespace Xrm * @remarks Attributes on Quick Create Forms will not save values set with this method. */ setValue( value: LookupValue[] ): void; - + /** * A collection of all the controls on the form that interface with this attribute. */ @@ -1993,7 +1993,7 @@ declare namespace Xrm * Use this method to asynchronously retrieve the enabled business process flows that the user can switch to for an * entity. * - * @param {Function} callbackFunction The callback function must accept a parameter that contains an object with + * @param {Function} callbackFunction The callback function must accept a parameter that contains an object with * dictionary properties where the name of the property is the Id of the * business process flow and the value of the property is the name of the * business process flow. @@ -2031,7 +2031,7 @@ declare namespace Xrm * @param {ContextSensitiveHandler} handler The function will be added to the bottom of the event * handler pipeline. The execution context is automatically * set to be the first parameter passed to the event handler. - * + * * Use a reference to a named function rather than an * anonymous function if you may later want to remove the * event handler. @@ -2088,9 +2088,9 @@ declare namespace Xrm /** * Represents a key-value pair, where the key is the Process Flow's ID, and the value is the name thereof. */ - export type ProcessDictionary = { [index: string]: string }; + export interface ProcessDictionary { [index: string]: string; } } - + /** * Interface for Xrm.Page.ui controls. * @@ -2117,7 +2117,7 @@ declare namespace Xrm * customsubgrid: . (A custom dataset control for mobile phone and tablet clients). */ getControlType(): ControlType | string; - + /** * Gets the name of the control on the form. * @@ -2143,7 +2143,7 @@ declare namespace Xrm */ getParent(): Section; } - + /** * Interface for a standard control. * @@ -2161,14 +2161,14 @@ declare namespace Xrm * @remarks If the uniqueId parameter is not used, the current notification shown will be removed. */ clearNotification( uniqueId?: string ): boolean; - + /** * Gets a boolean value, indicating whether the control is disabled. * * @return true if it is disabled, otherwise false. */ getDisabled(): boolean; - + /** * Sets the state of the control to either enabled, or disabled. * @@ -2211,7 +2211,7 @@ declare namespace Xrm * This is not an Entity Lookup, but a control that supports AutoComplete / KeyPress Events (Text or Number) * * @remarks This interface is not supported for CRM mobile clients (phones or tablets) and the interactive service hub. It is only available for Updated entities. - * + * * @sa StandardControl */ export interface AutoLookupControl extends StandardControl, UiKeyPressable @@ -2228,11 +2228,11 @@ declare namespace Xrm * Hides the auto-completion drop-down list configured for a specific text field */ hideAutoComplete(): void; - + /** * Shows upt to 10 matching strings in a drop-down list as users press keys to type charactrer in a specific text field. * On selecting an item in the drop-down list, the value in the text field changes to the selected item, the drop-down list disappears, and the OnChange event for the text field is invoked - * @param resultSet + * @param resultSet */ showAutoComplete(resultSet: AutoCompleteResultSet): void; } @@ -2841,7 +2841,7 @@ declare namespace Xrm * @remarks Constituent controls in a quick view control are read only. */ getControl( controlName: string ): Page.Control; - + /** * Gets a control by index. * @@ -2853,7 +2853,7 @@ declare namespace Xrm * @remarks Constituent controls in a quick view control are read only. */ getControl( index: number ): T; - + /** * Gets a control by index. * @@ -2974,13 +2974,13 @@ declare namespace Xrm /** * Command Bar Display options for Xrm.Url.FormOpenParameters.cmdbar, Xrm.Url.ViewOpenParameters.cmdbar, and Xrm.Utility.FormOpenParameters.cmdbar. */ - + export type CmdBarDisplay = "true" | "false"; /** * Navigation Bar Display options for Xrm.Url.FormOpenParameters.navbar, Xrm.Url.ViewOpenParameters.navbar, and Xrm.Utility.FormOpenParameters.navbar. */ export type NavBarDisplay = "entity" | "off" | "on"; - + /** * Report Open Action options for Xrm.Url.ReportOpenParameters.actions. */ diff --git a/xrm/tslint.json b/xrm/tslint.json index 12ee4f5938..aa4e1cf7ea 100644 --- a/xrm/tslint.json +++ b/xrm/tslint.json @@ -1,6 +1,10 @@ { "extends": "../tslint.json", "rules": { + // TODOs + "callable-types": false, + "unified-signatures": false, + "class-name": true, "comment-format": [ true, diff --git a/xsd-schema-validator/xsd-schema-validator-tests.ts b/xsd-schema-validator/xsd-schema-validator-tests.ts index f210198ade..d66148d219 100644 --- a/xsd-schema-validator/xsd-schema-validator-tests.ts +++ b/xsd-schema-validator/xsd-schema-validator-tests.ts @@ -2,7 +2,7 @@ import fs = require("fs"); import validator = require("xsd-schema-validator"); -validator.validateXML("", 'resources/foo.xsd', function(err, result) { +validator.validateXML("", 'resources/foo.xsd', (err, result) => { if (err) { throw err; } else return result.valid; diff --git a/yeoman-generator/yeoman-generator-tests.ts b/yeoman-generator/yeoman-generator-tests.ts index 11fdd2d989..22882e02d4 100644 --- a/yeoman-generator/yeoman-generator-tests.ts +++ b/yeoman-generator/yeoman-generator-tests.ts @@ -52,7 +52,7 @@ generator.installDependencies(); generator.installDependencies({ bower: true, npm: true, - callback: function () { + callback() { console.log('Everything is ready!'); } });