Skip to content

Commit 35c4560

Browse files
authored
Update dependencies (#575)
* docs: Update typedoc to 0.22 * chore: Update typescript to 4.4 * fix(bundle): Validate error type in try..catch * chore: Add .vscode to .gitignore * test(react): Update jest to 27, dropping now-unneeded prettier * fix(react): Drop dependency on prop-types; rely on TS types * chore(react): Update dev-dependency on react to 17 * chore: Update dev-dependency on gh-pages to 3 (no breaking changes) * chore(dom): Update dev-dependency on jsdom to 17 * test(dom): Silence console logging during tests * test(bundle): Update sinon to 11 * chore: Update rollup to 2 * chore(react/example): Refresh lockfile with `npm update` * chore: Refresh lockfile with `npm update` * chore: Move sinon dev dependency from bundle to root
1 parent 3526567 commit 35c4560

23 files changed

+9489
-18903
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
html
3+
.vscode
34

45
# Test coverage
56
.nyc_output

fluent-bundle/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"npm": ">=7.0.0"
5050
},
5151
"devDependencies": {
52-
"@fluent/dedent": "file:../fluent-dedent",
53-
"sinon": "^4.2.2"
52+
"@fluent/dedent": "file:../fluent-dedent"
5453
}
5554
}

fluent-bundle/src/bundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export class FluentBundle {
196196
let value = resolveComplexPattern(scope, pattern);
197197
return value.toString(scope);
198198
} catch (err) {
199-
if (scope.errors) {
199+
if (scope.errors && err instanceof Error) {
200200
scope.errors.push(err);
201201
return new FluentNone().toString(scope);
202202
}

fluent-bundle/src/scope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export class Scope {
2727
this.args = args;
2828
}
2929

30-
reportError(error: Error): void {
31-
if (!this.errors) {
30+
reportError(error: unknown): void {
31+
if (!this.errors || !(error instanceof Error)) {
3232
throw error;
3333
}
3434
this.errors.push(error);

fluent-bundle/test/constructor_test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import {FluentBundle} from '../esm/bundle.js';
88
import {FluentResource} from '../esm/resource.js';
99

1010
suite('FluentBundle constructor', function() {
11-
setup(function() {
12-
this.nf = sinon.spy(Intl, 'NumberFormat');
11+
let nfSpy;
12+
setup(() => {
13+
nfSpy = sinon.spy(Intl, 'NumberFormat');
1314
});
1415

15-
teardown(function() {
16-
this.nf.restore();
16+
teardown(() => {
17+
nfSpy.restore();
1718
});
1819

1920
test('accepts a single locale string', function() {
@@ -29,7 +30,7 @@ suite('FluentBundle constructor', function() {
2930
assert.strictEqual(val, 'Foo 1');
3031
assert.strictEqual(errs.length, 0);
3132

32-
const locale = this.nf.getCall(0).args[0];
33+
const locale = nfSpy.lastCall.args[0];
3334
assert.deepEqual(locale, ['en-US']);
3435
});
3536

@@ -46,7 +47,7 @@ suite('FluentBundle constructor', function() {
4647
assert.strictEqual(val, 'Foo 1');
4748
assert.strictEqual(errs.length, 0);
4849

49-
const locales = this.nf.getCall(0).args[0];
50+
const locales = nfSpy.lastCall.args[0];
5051
assert.deepEqual(locales, ['de', 'en-US']);
5152
});
5253
});

fluent-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"devDependencies": {
4747
"@fluent/bundle": "file:../fluent-bundle",
48-
"jsdom": "^15.1.0"
48+
"jsdom": "^17.0.0"
4949
},
5050
"dependencies": {
5151
"cached-iterable": "^0.3"

fluent-dom/test/dom_localization_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from "assert";
2+
import sinon from "sinon";
23
import { FluentBundle, FluentResource } from "@fluent/bundle";
34
import DOMLocalization from "../esm/dom_localization.js";
45

@@ -10,6 +11,9 @@ async function* mockGenerateMessages(resourceIds) {
1011
}
1112

1213
suite("translateFragment", function() {
14+
setup(() => sinon.stub(console, "warn"));
15+
teardown(() => console.warn.restore());
16+
1317
test("translates a node", async function() {
1418
const domLoc = new DOMLocalization(["test.ftl"], mockGenerateMessages);
1519

fluent-dom/test/extra_text_markup_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import assert from 'assert';
2+
import sinon from 'sinon';
23
import translateElement from '../esm/overlay.js';
34
import {elem} from './util.js';
45

56
suite('Localized text markup', function() {
7+
setup(() => sinon.stub(console, 'warn'));
8+
teardown(() => console.warn.restore());
9+
610
test('allowed element', function() {
711
const element = elem('div')`Foo`;
812
const translation = {

fluent-dom/test/localization_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from "assert";
2+
import sinon from "sinon";
23
import { FluentBundle, FluentResource } from "@fluent/bundle";
34
import Localization from "../esm/localization.js";
45

@@ -10,6 +11,9 @@ async function* mockGenerateMessages(resourceIds) {
1011
}
1112

1213
suite("formatMessages", function() {
14+
setup(() => sinon.stub(console, "warn"));
15+
teardown(() => console.warn.restore());
16+
1317
test("returns a translation", async function() {
1418
const loc = new Localization(["test.ftl"], mockGenerateMessages);
1519
const translations = await loc.formatMessages([{id: "key1"}]);

fluent-dom/test/overlay_functional_children_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import assert from 'assert';
2+
import sinon from 'sinon';
23
import translateElement from '../esm/overlay.js';
34
import {elem} from './util.js';
45

56
suite('Child without name', function() {
7+
setup(() => sinon.stub(console, 'warn'));
8+
teardown(() => console.warn.restore());
9+
610
test('in source', function() {
711
const element = elem('div')`
812
<button>Foo</button>`;
@@ -49,6 +53,9 @@ suite('Child without name', function() {
4953
});
5054

5155
suite('Child with name', function() {
56+
setup(() => sinon.stub(console, 'warn'));
57+
teardown(() => console.warn.restore());
58+
5259
test('in source', function() {
5360
const element = elem('div')`
5461
<button data-l10n-name="foo">Foo</button>`;

0 commit comments

Comments
 (0)