Skip to content

Commit

Permalink
prepare 2.7.3 release (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Nov 9, 2018
1 parent 5567117 commit 47db0f2
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 48 deletions.
60 changes: 57 additions & 3 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,105 @@ extends:
env:
es6: true
node: true
browser: true
plugins:
- babel
- prettier
globals:
VERSION: true
describe: true
it: true
expect: true
jest: true
beforeEach: true
afterEach: true
window: true
document: true
rules:
# https://github.com/prettier/eslint-plugin-prettier
prettier/prettier:
- error

# https://github.com/babel/eslint-plugin-babel
babel/semi: error

# https://eslint.org/docs/rules/array-callback-return
array-callback-return: error

# https://eslint.org/docs/rules/curly
curly:
- error
- all

# https://eslint.org/docs/rules/no-implicit-coercion
no-implicit-coercion:
- 'off'
- boolean: false
number: true
string: true
allow: []

# https://eslint.org/docs/rules/no-eval
no-eval: error

# https://eslint.org/docs/rules/no-implied-eval
no-implied-eval: error

# https://eslint.org/docs/rules/no-param-reassign
no-param-reassign:
- error
- props: true

# https://eslint.org/docs/rules/no-return-assign
no-return-assign: error

# https://eslint.org/docs/rules/no-self-compare
no-self-compare: error

# https://eslint.org/docs/rules/radix
radix: error

# https://eslint.org/docs/rules/no-array-constructor
no-array-constructor: error

# https://eslint.org/docs/rules/no-new-wrappers
no-new-wrappers: error

# https://eslint.org/docs/rules/no-cond-assign
no-cond-assign: error

# https://eslint.org/docs/rules/no-use-before-define
no-use-before-define:
- error
- functions: false

# https://eslint.org/docs/rules/eqeqeq
eqeqeq: error

# Deprecations are required to turn enforce this
camelcase: warn


# https://eslint.org/docs/rules/no-new-object
no-new-object: error

# https://eslint.org/docs/rules/no-nested-ternary
no-nested-ternary: error

# https://eslint.org/docs/rules/no-unused-vars
no-unused-vars: error

# https://eslint.org/docs/rules/no-var
no-var: error

# https://eslint.org/docs/rules/prefer-const
prefer-const: error

# https://eslint.org/docs/rules/prefer-arrow-callback
prefer-arrow-callback: error

# https://eslint.org/docs/rules/arrow-body-style
arrow-body-style:
- error
- as-needed
babel/semi: error

# https://eslint.org/docs/rules/no-undef
no-undef: error
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org).

## [2.7.3] - 2018-11-09
### Fixed:
- The TypeScript definitions were incorrectly restricting the possible values for event types in `on()` and `off()`. Also, added documentation for event types which were not documented before. ([#122](https://github.com/launchdarkly/js-client/issues/122))

## [2.7.2] - 2018-10-17
### Fixed:
- Disconnecting from the stream does not close the browser tab anymore.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ldclient-js",
"version": "2.7.2",
"version": "2.7.3",
"description": "LaunchDarkly SDK for JavaScript",
"author": "LaunchDarkly <[email protected]>",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/EventProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function EventProcessor(eventsUrl, environmentId, options = {}, e
samplingInterval = options.samplingInterval || 0;
}

if (options.flushInterval !== undefined && (isNan(options.flushInterval) || options.flushInterval < 2000)) {
if (options.flushInterval !== undefined && (isNaN(options.flushInterval) || options.flushInterval < 2000)) {
flushInterval = 2000;
reportArgumentError('Invalid flush interval configured. Must be an integer >= 2000 (milliseconds).');
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/EventSender.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function EventSender(eventsUrl, environmentId, forceHasCors, imag
const sender = {};

function loadUrlUsingImage(src, onDone) {
const img = new Image();
const img = new window.Image();
if (onDone) {
img.addEventListener('load', onDone);
}
Expand All @@ -34,7 +34,7 @@ export default function EventSender(eventsUrl, environmentId, forceHasCors, imag
const jsonBody = JSON.stringify(events);
const send = onDone => {
function createRequest(canRetry) {
const xhr = new XMLHttpRequest();
const xhr = new window.XMLHttpRequest();
xhr.open('POST', postUrl, !sync);
utils.addLDHeaders(xhr);
xhr.setRequestHeader('Content-Type', 'application/json');
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function EventSender(eventsUrl, environmentId, forceHasCors, imag
// Detect browser support for CORS (can be overridden by tests)
if (hasCors === undefined) {
if (forceHasCors === undefined) {
hasCors = 'withCredentials' in new XMLHttpRequest();
hasCors = 'withCredentials' in new window.XMLHttpRequest();
} else {
hasCors = forceHasCors;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GoalTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function GoalTracker(goals, onEvent) {
const urls = goal.urls || [];

for (let j = 0; j < urls.length; j++) {
if (doesUrlMatch(urls[j], location.href, location.search, location.hash)) {
if (doesUrlMatch(urls[j], window.location.href, window.location.search, window.location.hash)) {
if (goal.kind === 'pageview') {
onEvent('pageview', goal);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as messages from './messages';
const json = 'application/json';

function fetchJSON(endpoint, body, callback, sendLDHeaders) {
const xhr = new XMLHttpRequest();
const xhr = new window.XMLHttpRequest();
let data = undefined;

xhr.addEventListener('load', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Store(environment, hash, ident) {
const key = getFlagsKey();
let dataStr, data;
try {
dataStr = localStorage.getItem(key);
dataStr = window.localStorage.getItem(key);
} catch (ex) {
console.warn(messages.localStorageUnavailable());
return null;
Expand All @@ -41,7 +41,7 @@ export default function Store(environment, hash, ident) {
const key = getFlagsKey();
const data = utils.extend({}, flags, { $schema: 1 });
try {
localStorage.setItem(key, JSON.stringify(data));
window.localStorage.setItem(key, JSON.stringify(data));
} catch (ex) {
console.warn(messages.localStorageUnavailable());
}
Expand All @@ -50,7 +50,7 @@ export default function Store(environment, hash, ident) {
store.clearFlags = function() {
const key = getFlagsKey();
try {
localStorage.removeItem(key);
window.localStorage.removeItem(key);
} catch (ex) {}
};

Expand Down
4 changes: 2 additions & 2 deletions src/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Stream(baseUrl, environment, hash, config) {
};

stream.isConnected = function() {
return es && (es.readyState === EventSource.OPEN || es.readyState === EventSource.CONNECTING);
return es && (es.readyState === window.EventSource.OPEN || es.readyState === window.EventSource.CONNECTING);
};

function reconnect() {
Expand All @@ -45,7 +45,7 @@ export default function Stream(baseUrl, environment, hash, config) {
function openConnection() {
let url;
let query = '';
if (typeof EventSource !== 'undefined') {
if (typeof window.EventSource !== 'undefined') {
if (useReport) {
// we don't yet have an EventSource implementation that supports REPORT, so
// fall back to the old ping-based stream
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/EventSource-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function EventSource(url) {
}
}

function mockOpen() {
function mockOpen(error) {
if (this.readyState === EventSource.CONNECTING) {
this.readyState = EventSource.OPEN;
this.onopen && this.onopen(error);
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/LDClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('LDClient', () => {
// sandbox.restore(window.localStorage.__proto__, 'getItem');
// sandbox.stub(window.localStorage.__proto__, 'getItem').throws();

localStorage.getItem.mockImplementationOnce(() => {
window.localStorage.getItem.mockImplementationOnce(() => {
throw new Error();
});

Expand All @@ -256,7 +256,7 @@ describe('LDClient', () => {
});

it('should handle localStorage setItem throwing an exception', done => {
localStorage.setItem.mockImplementationOnce(() => {
window.localStorage.setItem.mockImplementationOnce(() => {
throw new Error();
});

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/Store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Store', () => {

it('should handle localStorage getItem throwing an exception', () => {
const store = Store('env', 'hash', ident);
const getItemSpy = jest.spyOn(localStorage, 'getItem').mockImplementation(() => {
const getItemSpy = jest.spyOn(window.localStorage, 'getItem').mockImplementation(() => {
throw new Error('localstorage getitem error');
});

Expand All @@ -22,7 +22,7 @@ describe('Store', () => {

it('should handle localStorage setItem throwing an exception', () => {
const store = Store('env', 'hash', ident);
const setItemSpy = jest.spyOn(localStorage, 'setItem').mockImplementation(() => {
const setItemSpy = jest.spyOn(window.localStorage, 'setItem').mockImplementation(() => {
throw new Error('localstorage getitem error');
});

Expand Down
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ export function initialize(env, user, options = {}) {

function doNotTrack() {
let flag;
if (navigator && navigator.doNotTrack !== undefined) {
flag = navigator.doNotTrack; // FF, Chrome
} else if (navigator && navigator.msDoNotTrack !== undefined) {
flag = navigator.msDoNotTrack; // IE 9/10
if (window.navigator && window.navigator.doNotTrack !== undefined) {
flag = window.navigator.doNotTrack; // FF, Chrome
} else if (window.navigator && window.navigator.msDoNotTrack !== undefined) {
flag = window.navigator.msDoNotTrack; // IE 9/10
} else {
flag = window.doNotTrack; // IE 11+, Safari
}
Expand Down Expand Up @@ -460,7 +460,7 @@ export function initialize(env, user, options = {}) {
} else if (
typeof options.bootstrap === 'string' &&
options.bootstrap.toUpperCase() === 'LOCALSTORAGE' &&
!!localStorage
!!window.localStorage
) {
useLocalStorage = true;

Expand Down Expand Up @@ -520,11 +520,11 @@ export function initialize(env, user, options = {}) {
}

function watchLocation(interval, callback) {
let previousUrl = location.href;
let previousUrl = window.location.href;
let currentUrl;

function checkUrl() {
currentUrl = location.href;
currentUrl = window.location.href;

if (currentUrl !== previousUrl) {
previousUrl = currentUrl;
Expand All @@ -541,7 +541,7 @@ export function initialize(env, user, options = {}) {

poll(checkUrl, interval);

if (!!(window.history && history.pushState)) {
if (!!(window.history && window.history.pushState)) {
window.addEventListener('popstate', checkUrl);
} else {
window.addEventListener('hashchange', checkUrl);
Expand Down
2 changes: 2 additions & 0 deletions src/messages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as errors from './errors';

const docLink =
' Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.';

Expand Down
Loading

0 comments on commit 47db0f2

Please sign in to comment.