Skip to content

Commit 259ce15

Browse files
authored
Merge branch 'integration/typescript' into PLAT-13697-callback-runner
2 parents 8ef69af + dda5029 commit 259ce15

7 files changed

Lines changed: 9 additions & 29 deletions

File tree

packages/core/src/config.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import isArray from './lib/es-utils/is-array'
21
import includes from './lib/es-utils/includes'
32
import intRange from './lib/validators/int-range'
43
import stringWithLength from './lib/validators/string-with-length'
@@ -210,7 +209,7 @@ const schema: Schema = {
210209
enabledReleaseStages: {
211210
defaultValue: () => null,
212211
message: 'should be an array of strings',
213-
validate: (value: unknown) => value === null || (isArray(value) && value.filter(f => typeof f === 'string').length === value.length)
212+
validate: (value: unknown) => value === null || (Array.isArray(value) && value.filter(f => typeof f === 'string').length === value.length)
214213
},
215214
releaseStage: {
216215
defaultValue: () => 'production',
@@ -225,7 +224,7 @@ const schema: Schema = {
225224
enabledBreadcrumbTypes: {
226225
defaultValue: () => BREADCRUMB_TYPES,
227226
message: `should be null or a list of available breadcrumb types (${BREADCRUMB_TYPES.join(',')})`,
228-
validate: (value: unknown) => value === null || (isArray(value) && value.reduce((accum, maybeType) => {
227+
validate: (value: unknown) => value === null || (Array.isArray(value) && value.reduce((accum, maybeType) => {
229228
if (accum === false) return accum
230229
// TS doesn't like passing a readonly to a function that might mutate an array
231230
return includes(BREADCRUMB_TYPES as unknown as any[], maybeType)
@@ -266,23 +265,23 @@ const schema: Schema = {
266265
defaultValue: () => ['password'],
267266
message: 'should be an array of strings|regexes',
268267
validate: (value: unknown) =>
269-
isArray(value) && value.length === value.filter(s =>
268+
Array.isArray(value) && value.length === value.filter(s =>
270269
(typeof s === 'string' || (s && typeof s.test === 'function'))
271270
).length
272271
},
273272
plugins: {
274273
defaultValue: () => ([]),
275274
message: 'should be an array of plugin objects',
276275
validate: (value: unknown) =>
277-
isArray(value) && value.length === value.filter(p =>
276+
Array.isArray(value) && value.length === value.filter(p =>
278277
(p && typeof p === 'object' && typeof p.load === 'function')
279278
).length
280279
},
281280
featureFlags: {
282281
defaultValue: () => [],
283282
message: 'should be an array of objects that have a "name" property',
284283
validate: (value: unknown) =>
285-
isArray(value) && value.length === value.filter(feature =>
284+
Array.isArray(value) && value.length === value.filter(feature =>
286285
feature && typeof feature === 'object' && typeof feature.name === 'string'
287286
).length
288287
},

packages/core/src/lib/derecursify.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const isArray = require('./es-utils/is-array')
2-
31
const isSafeLiteral = (obj) => (
42
typeof obj === 'string' || obj instanceof String ||
53
typeof obj === 'number' || obj instanceof Number ||
@@ -53,7 +51,7 @@ module.exports = function (data) {
5351
}
5452

5553
// handle arrays, and all iterable non-array types (such as Set)
56-
if (isArray(obj) || obj[Symbol.iterator]) {
54+
if (Array.isArray(obj) || obj[Symbol.iterator]) {
5755
seen.push(obj)
5856
const safeArray = []
5957
try {

packages/core/src/lib/es-utils/is-array.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/core/src/lib/es-utils/is-array.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/core/src/lib/feature-flag-delegate.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import isArray from './es-utils/is-array'
21
import jsonStringify from '@bugsnag/safe-json-stringify'
3-
import {FeatureFlag} from "../common";
2+
import type { FeatureFlag } from "../common";
43

54
type FeatureFlagEventApi = {
65
featureFlag: string
@@ -41,7 +40,7 @@ const featureFlagDelegate: FeatureFlagDelegate = {
4140
},
4241

4342
merge: (existingFeatures, newFeatures, existingFeatureKeys) => {
44-
if (!isArray(newFeatures)) {
43+
if (!Array.isArray(newFeatures)) {
4544
return
4645
}
4746

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import isArray from '../es-utils/is-array'
2-
3-
const listOfFunctions = (value: unknown): boolean => typeof value === 'function' || (isArray(value) && value.filter(f => typeof f === 'function').length === value.length)
1+
const listOfFunctions = (value: unknown): boolean => typeof value === 'function' || (Array.isArray(value) && value.filter(f => typeof f === 'function').length === value.length)
42

53
export default listOfFunctions

packages/core/test/lib/es-utils.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
import isArray from '../../src/lib/es-utils/is-array'
21
import includes from '../../src/lib/es-utils/includes'
32

43
describe('es-utils', () => {
5-
describe('isArray(obj)', () => {
6-
it('works with a variety of examples', () => {
7-
expect(isArray([])).toBe(true)
8-
expect(isArray('[object Array]')).toBe(false)
9-
expect(isArray(0)).toBe(false)
10-
expect(isArray(1)).toBe(false)
11-
expect(isArray({})).toBe(false)
12-
})
13-
})
14-
154
describe('includes(arr, item)', () => {
165
it('works with a variety of examples', () => {
176
expect(includes(['a', 'b', 'c'], 'a')).toBe(true)

0 commit comments

Comments
 (0)