diff --git a/.eslintrc.js b/.eslintrc.js index 36889035daf..4fef0e87008 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1 +1,2 @@ +require("@rushstack/eslint-patch/modern-module-resolution"); module.exports = require('kolibri-tools/.eslintrc'); diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000..e7598d0e860 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,8 @@ +# Run this command to always ignore formatting commits in `git blame` +# git config blame.ignoreRevsFile .git-blame-ignore-revs + +# Applied black to the codebase +7dadc107cebd3ab4597f1aa4f159940872466dec + +# Reformatted all frontend code using prettier v3 +42efde27bac137734f05057278c4827168d119f2 diff --git a/.htmlhintrc.js b/.htmlhintrc.js deleted file mode 100644 index 5748ea4fce3..00000000000 --- a/.htmlhintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('kolibri-tools/.htmlhintrc'); diff --git a/docs/frontend_architecture/conventions.rst b/docs/frontend_architecture/conventions.rst index 4de26fb3c97..e892779e212 100644 --- a/docs/frontend_architecture/conventions.rst +++ b/docs/frontend_architecture/conventions.rst @@ -8,7 +8,7 @@ For design conventions, see the `Kolibri Design System `__, `ESLint Vue plugin `__, `stylelint `__, and `HTMLHint `__. The enforced rules are located in the ``.eslintrc.js``, ``.stylelintrc.js``, and ``.htmlhintrc`` files located at the root of the project. +Many of our conventions are enforced through various linters including `ESLint `__, `ESLint Vue plugin `__, `stylelint `__, and `HTMLHint `__. The enforced rules are located in the ``eslint.config.js``, ``.stylelintrc.js``, and files located at the root of the project. Also available are options and tools that enable auto-formatting of ``.vue``, ``.js``, ``.scss``, and ``.py`` files to conform to code conventions. To facilitate this, we use `Black `__ to auto-format ``.py`` files, and `Prettier `__ to auto-format the others. Auto-formatting runs by default while running the dev server, otherwise be sure to run the dev server with ``-warn`` as described in :doc:`/getting_started` to prevent it from auto-formatting. diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 58ccf67a53f..351777bd9e2 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -47,6 +47,12 @@ Next, initialize Git LFS: cd kolibri # Enter the Kolibri directory git lfs install +To make git blame more informative, we keep track of commits that make a lot of changes to the codebase but are not directly related to the code itself, like large scale automatic code formatting. To prevent these commits appearing in the blame output, run: + +.. code-block:: bash + + git config blame.ignoreRevsFile .git-blame-ignore-revs + Finally, add the Learning Equality repo as a remote called `upstream`. That way you can keep your local checkout updated with the most recent changes: diff --git a/kolibri/core/assets/src/api-resource.js b/kolibri/core/assets/src/api-resource.js index b091d5e8fd2..802e69078ec 100644 --- a/kolibri/core/assets/src/api-resource.js +++ b/kolibri/core/assets/src/api-resource.js @@ -86,13 +86,13 @@ export class Model { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); } }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -164,13 +164,13 @@ export class Model { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); } }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -214,13 +214,13 @@ export class Model { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); } }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -340,13 +340,13 @@ export class Collection { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); } }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -399,12 +399,12 @@ export class Collection { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -450,13 +450,13 @@ export class Collection { reject(response); // Clean up the reference to this promise this.promises.splice(this.promises.indexOf(promise), 1); - } + }, ); } }, reason => { reject(reason); - } + }, ); }); this.promises.push(promise); @@ -602,8 +602,8 @@ export class Resource { .sort() .map(paramKey => ({ [paramKey]: paramKey === this.idKey ? String(allParams[paramKey]) : allParams[paramKey], - })) - ) + })), + ), ); } @@ -926,7 +926,7 @@ export class Resource { create(params = {}, multipart = false) { return this.accessListEndpoint('post', 'list', params, multipart).then( - response => response.data + response => response.data, ); } @@ -1038,7 +1038,7 @@ export class Resource { `%cRequest error: ${err.response.statusText}, ${ err.response.status } for ${err.config.method.toUpperCase()} to ${err.config.url} - open for more info`, - 'color: red' + 'color: red', ); console.log(`Error occured for ${this.name} resource on page ${window.location.href}`); if (store?.state?.route) { diff --git a/kolibri/core/assets/src/api-resources/contentNode.js b/kolibri/core/assets/src/api-resources/contentNode.js index 11690ae3dc7..67e52fa43b0 100644 --- a/kolibri/core/assets/src/api-resources/contentNode.js +++ b/kolibri/core/assets/src/api-resources/contentNode.js @@ -139,7 +139,7 @@ export default new Resource({ if (data[this.idKey]) { this.cache[data[this.idKey]] = Object.assign( this.cache[data[this.idKey]] || {}, - cloneDeep(data) + cloneDeep(data), ); if (data.children) { this.cacheData(data.children); diff --git a/kolibri/core/assets/src/composables/useMinimumKolibriVersion.js b/kolibri/core/assets/src/composables/useMinimumKolibriVersion.js index bb9c22064f8..daea571ad88 100644 --- a/kolibri/core/assets/src/composables/useMinimumKolibriVersion.js +++ b/kolibri/core/assets/src/composables/useMinimumKolibriVersion.js @@ -19,7 +19,7 @@ const logging = logger.getLogger(__filename); export default function useMinimumKolibriVersion( majorVersion = 0, minorVersion = 15, - revisionVersion = null + revisionVersion = null, ) { const isMinimumKolibriVersion = useMemoize(version => { if (!version) { diff --git a/kolibri/core/assets/src/composables/useUserSyncStatus.js b/kolibri/core/assets/src/composables/useUserSyncStatus.js index 503ad479c07..b30f0beabf3 100644 --- a/kolibri/core/assets/src/composables/useUserSyncStatus.js +++ b/kolibri/core/assets/src/composables/useUserSyncStatus.js @@ -33,7 +33,7 @@ export function fetchUserSyncStatus(params) { error => { store.dispatch('handleApiError', { error }); return error; - } + }, ); } diff --git a/kolibri/core/assets/src/core-app/__tests__/pluginMediator.spec.js b/kolibri/core/assets/src/core-app/__tests__/pluginMediator.spec.js index 9367ad9a8d8..0e5ad8f4ecf 100644 --- a/kolibri/core/assets/src/core-app/__tests__/pluginMediator.spec.js +++ b/kolibri/core/assets/src/core-app/__tests__/pluginMediator.spec.js @@ -6,66 +6,66 @@ if (!Object.prototype.hasOwnProperty.call(global, 'Intl')) { require('intl/locale-data/jsonp/en.js'); } -describe('Mediator', function() { +describe('Mediator', function () { let mediator, kolibriModule, facade; const kolibriModuleName = 'test'; - beforeEach(function() { + beforeEach(function () { facade = {}; mediator = mediatorFactory({ Vue, facade }); }); - afterEach(function() { + afterEach(function () { mediator = undefined; facade = undefined; }); - describe('kolibriModule registry', function() { - it('should be empty', function() { + describe('kolibriModule registry', function () { + it('should be empty', function () { expect(mediator._kolibriModuleRegistry).toEqual({}); }); }); - describe('callback buffer', function() { - it('should be empty', function() { + describe('callback buffer', function () { + it('should be empty', function () { expect(mediator._callbackBuffer).toEqual({}); }); }); - describe('callback registry', function() { - it('should be empty', function() { + describe('callback registry', function () { + it('should be empty', function () { expect(mediator._callbackRegistry).toEqual({}); }); }); - describe('async callback registry', function() { - it('should be empty', function() { + describe('async callback registry', function () { + it('should be empty', function () { expect(mediator._asyncCallbackRegistry).toEqual({}); }); }); - describe('event dispatcher', function() { - it('should be a Vue object', function() { + describe('event dispatcher', function () { + it('should be a Vue object', function () { expect(mediator._eventDispatcher.$on).toBeInstanceOf(Function); expect(mediator._eventDispatcher.$emit).toBeInstanceOf(Function); expect(mediator._eventDispatcher.$once).toBeInstanceOf(Function); expect(mediator._eventDispatcher.$off).toBeInstanceOf(Function); }); }); - describe('language asset registry', function() { - it('should be empty', function() { + describe('language asset registry', function () { + it('should be empty', function () { expect(mediator._languageAssetRegistry).toEqual({}); }); }); - describe('registerKolibriModuleSync method', function() { + describe('registerKolibriModuleSync method', function () { let _registerMultipleEvents, _registerOneTimeEvents, emit, _executeCallbackBuffer; - beforeEach(function() { + beforeEach(function () { _registerMultipleEvents = jest.spyOn(mediator, '_registerMultipleEvents'); _registerOneTimeEvents = jest.spyOn(mediator, '_registerOneTimeEvents'); emit = jest.spyOn(mediator, 'emit'); _executeCallbackBuffer = jest.spyOn(mediator, '_executeCallbackBuffer'); }); - afterEach(function() { + afterEach(function () { mediator._kolibriModuleRegistry = {}; _registerMultipleEvents.mockRestore(); _registerOneTimeEvents.mockRestore(); emit.mockRestore(); _executeCallbackBuffer.mockRestore(); }); - describe('called with valid input', function() { + describe('called with valid input', function () { let consoleMock; beforeAll(() => { consoleMock = jest.spyOn(console, 'info').mockImplementation(); @@ -73,77 +73,77 @@ describe('Mediator', function() { afterAll(() => { consoleMock.mockRestore(); }); - beforeEach(function() { + beforeEach(function () { kolibriModule = { name: 'test', ready: () => {} }; mediator.registerKolibriModuleSync(kolibriModule); }); - it('should call the _registerMultipleEvents method', function() { + it('should call the _registerMultipleEvents method', function () { expect(_registerMultipleEvents).toHaveBeenCalled(); }); - it('should pass the kolibriModule to the _registerMultipleEvents method', function() { + it('should pass the kolibriModule to the _registerMultipleEvents method', function () { expect(_registerMultipleEvents).toHaveBeenCalledWith(kolibriModule); }); - it('should call the _registerOneTimeEvents method', function() { + it('should call the _registerOneTimeEvents method', function () { expect(_registerOneTimeEvents).toHaveBeenCalled(); }); - it('should pass the kolibriModule to the _registerOneTimeEvents method', function() { + it('should pass the kolibriModule to the _registerOneTimeEvents method', function () { expect(_registerOneTimeEvents).toHaveBeenCalledWith(kolibriModule); }); - it('should call the emit method', function() { + it('should call the emit method', function () { expect(emit).toHaveBeenCalled(); }); - it('should pass the kolibriModule to the emit method', function() { + it('should pass the kolibriModule to the emit method', function () { expect(emit).toHaveBeenCalledWith('kolibri_register', kolibriModule); }); - it('should call the _executeCallbackBuffer method', function() { + it('should call the _executeCallbackBuffer method', function () { expect(_executeCallbackBuffer).toHaveBeenCalled(); }); - it('should call pass the kolibriModule to the _executeCallbackBuffer method', function() { + it('should call pass the kolibriModule to the _executeCallbackBuffer method', function () { expect(_executeCallbackBuffer).toHaveBeenCalledWith(kolibriModule); }); - it('should put the kolibriModule into the kolibriModule registry', function() { + it('should put the kolibriModule into the kolibriModule registry', function () { expect(mediator._kolibriModuleRegistry[kolibriModule.name]).toEqual(kolibriModule); }); }); - describe('called with invalid input', function() { - beforeEach(function() { + describe('called with invalid input', function () { + beforeEach(function () { kolibriModule = undefined; try { mediator.registerKolibriModuleSync(kolibriModule); } catch (e) {} // eslint-disable-line no-empty }); - it('should raise an error', function() { + it('should raise an error', function () { function testCall() { mediator.registerKolibriModuleSync(kolibriModule); } expect(testCall).toThrow(TypeError); }); - it('should call the _registerMultipleEvents method', function() { + it('should call the _registerMultipleEvents method', function () { expect(_registerMultipleEvents).toHaveBeenCalled(); }); - it('should pass the kolibriModule to the _registerMultipleEvents method', function() { + it('should pass the kolibriModule to the _registerMultipleEvents method', function () { expect(_registerMultipleEvents).toHaveBeenCalledWith(kolibriModule); }); // _registerOneTimeEvents is not being called - xit('should call the _registerOneTimeEvents method', function() { + xit('should call the _registerOneTimeEvents method', function () { expect(_registerOneTimeEvents).toHaveBeenCalled(); }); - xit('should pass the kolibriModule to the _registerOneTimeEvents method', function() { + xit('should pass the kolibriModule to the _registerOneTimeEvents method', function () { expect(_registerOneTimeEvents).toHaveBeenCalledWith(kolibriModule); }); - it('should not call the trigger method', function() { + it('should not call the trigger method', function () { expect(emit).not.toHaveBeenCalled(); }); - it('should not call the _executeCallbackBuffer method', function() { + it('should not call the _executeCallbackBuffer method', function () { expect(_executeCallbackBuffer).not.toHaveBeenCalled(); }); - it('should leave the kolibriModule registry empty', function() { + it('should leave the kolibriModule registry empty', function () { expect(mediator._kolibriModuleRegistry).toEqual({}); }); }); }); - describe('_registerEvents method', function() { - it('should not throw a TypeError due to incorrect assignment of this when the eventListenerMethod is called', function() { + describe('_registerEvents method', function () { + it('should not throw a TypeError due to incorrect assignment of this when the eventListenerMethod is called', function () { function testCall() { mediator._registerEvents( { @@ -153,33 +153,33 @@ describe('Mediator', function() { }, }, 'events', - mediator._registerRepeatedEventListener + mediator._registerRepeatedEventListener, ); } expect(testCall).not.toThrow(); }); }); - describe('_registerMultipleEvents method', function() { + describe('_registerMultipleEvents method', function () { let _registerRepeatedEventListener; - beforeEach(function() { + beforeEach(function () { _registerRepeatedEventListener = jest.spyOn(mediator, '_registerRepeatedEventListener'); }); - afterEach(function() { + afterEach(function () { _registerRepeatedEventListener.mockRestore(); }); - describe('called with valid but empty input', function() { - beforeEach(function() { + describe('called with valid but empty input', function () { + beforeEach(function () { kolibriModule = { name: 'test', }; mediator._registerMultipleEvents(kolibriModule); }); - it('should not call listener registration', function() { + it('should not call listener registration', function () { expect(_registerRepeatedEventListener).not.toHaveBeenCalled(); }); }); - describe('called with valid input with event object', function() { - beforeEach(function() { + describe('called with valid input with event object', function () { + beforeEach(function () { kolibriModule = { name: 'test', events: { @@ -188,44 +188,44 @@ describe('Mediator', function() { }; mediator._registerMultipleEvents(kolibriModule); }); - afterEach(function() { + afterEach(function () { kolibriModule = undefined; }); - it('should call listener registration', function() { + it('should call listener registration', function () { expect(_registerRepeatedEventListener).toHaveBeenCalled(); }); - it('should pass event, kolibriModule, and method to listener registration', function() { + it('should pass event, kolibriModule, and method to listener registration', function () { expect(_registerRepeatedEventListener).toHaveBeenCalledWith( 'event', kolibriModule, - 'method' + 'method', ); }); }); - describe('called with valid input with event ', function() { - beforeEach(function() { + describe('called with valid input with event ', function () { + beforeEach(function () { kolibriModule = { name: 'test', events: () => ({ event: 'method' }), }; mediator._registerMultipleEvents(kolibriModule); }); - afterEach(function() { + afterEach(function () { kolibriModule = undefined; }); - it('should call listener registration', function() { + it('should call listener registration', function () { expect(_registerRepeatedEventListener).toHaveBeenCalled(); }); - it('should pass event, kolibriModule, and method to listener registration', function() { + it('should pass event, kolibriModule, and method to listener registration', function () { expect(_registerRepeatedEventListener).toHaveBeenCalledWith( 'event', kolibriModule, - 'method' + 'method', ); }); }); - describe('called with invalid input', function() { - it('should throw a TypeError', function() { + describe('called with invalid input', function () { + it('should throw a TypeError', function () { function testCall() { mediator._registerMultipleEvents(undefined); } @@ -233,49 +233,49 @@ describe('Mediator', function() { }); }); }); - describe('_registerOneTimeEvents method', function() { + describe('_registerOneTimeEvents method', function () { let _registerOneTimeEventListener; - beforeEach(function() { + beforeEach(function () { _registerOneTimeEventListener = jest.spyOn(mediator, '_registerOneTimeEventListener'); }); - afterEach(function() { + afterEach(function () { _registerOneTimeEventListener.mockRestore(); }); - describe('called with valid but empty input', function() { - beforeEach(function() { + describe('called with valid but empty input', function () { + beforeEach(function () { kolibriModule = { name: 'test', }; mediator._registerOneTimeEvents(kolibriModule); }); - it('should not call listener registration', function() { + it('should not call listener registration', function () { expect(_registerOneTimeEventListener).not.toHaveBeenCalled(); }); }); - describe('called with valid input with event object', function() { - beforeEach(function() { + describe('called with valid input with event object', function () { + beforeEach(function () { kolibriModule = { name: 'test', once: () => ({ event: 'method' }), }; mediator._registerOneTimeEvents(kolibriModule); }); - afterEach(function() { + afterEach(function () { kolibriModule = undefined; }); - it('should call listener registration', function() { + it('should call listener registration', function () { expect(_registerOneTimeEventListener).toHaveBeenCalled(); }); - it('should pass event, kolibriModule, and method to listener registration', function() { + it('should pass event, kolibriModule, and method to listener registration', function () { expect(_registerOneTimeEventListener).toHaveBeenCalledWith( 'event', kolibriModule, - 'method' + 'method', ); }); }); - describe('called with valid input with event ', function() { - beforeEach(function() { + describe('called with valid input with event ', function () { + beforeEach(function () { kolibriModule = { name: 'test', once: { @@ -284,22 +284,22 @@ describe('Mediator', function() { }; mediator._registerOneTimeEvents(kolibriModule); }); - afterEach(function() { + afterEach(function () { kolibriModule = undefined; }); - it('should call listener registration', function() { + it('should call listener registration', function () { expect(_registerOneTimeEventListener).toHaveBeenCalled(); }); - it('should pass event, kolibriModule, and method to listener registration', function() { + it('should pass event, kolibriModule, and method to listener registration', function () { expect(_registerOneTimeEventListener).toHaveBeenCalledWith( 'event', kolibriModule, - 'method' + 'method', ); }); }); - describe('called with invalid input', function() { - it('should throw a TypeError', function() { + describe('called with invalid input', function () { + it('should throw a TypeError', function () { function testCall() { mediator._registerOneTimeEvents(undefined); } @@ -307,114 +307,114 @@ describe('Mediator', function() { }); }); }); - describe('_registerRepeatedEventListener method', function() { + describe('_registerRepeatedEventListener method', function () { let stub, event, method; - beforeEach(function() { + beforeEach(function () { stub = jest.spyOn(mediator, '_registerEventListener'); event = 'event'; kolibriModule = { name: 'test' }; method = 'method'; mediator._registerRepeatedEventListener(event, kolibriModule, method); }); - afterEach(function() { + afterEach(function () { stub.mockRestore(); }); - it('should call _registerEventListener method', function() { + it('should call _registerEventListener method', function () { expect(stub).toHaveBeenCalled(); }); - it('should pass three args to _registerEventListener method', function() { + it('should pass three args to _registerEventListener method', function () { expect(stub).toHaveBeenCalledWith(event, kolibriModule, method, expect.any(Function)); }); }); - describe('_registerOneTimeEventListener method', function() { + describe('_registerOneTimeEventListener method', function () { let stub, event, method; - beforeEach(function() { + beforeEach(function () { event = 'event'; kolibriModule = { name: 'test' }; method = 'method'; }); - afterEach(function() { + afterEach(function () { stub.mockRestore(); }); - it('should call _registerEventListener method', function() { + it('should call _registerEventListener method', function () { stub = jest.spyOn(mediator, '_registerEventListener'); mediator._registerOneTimeEventListener(event, kolibriModule, method); expect(stub).toHaveBeenCalled(); }); - it('should pass three args to _registerEventListener method', function() { + it('should pass three args to _registerEventListener method', function () { stub = jest.spyOn(mediator, '_registerEventListener'); mediator._registerOneTimeEventListener(event, kolibriModule, method); expect(stub).toHaveBeenCalledWith(event, kolibriModule, method, expect.any(Function)); }); - it('should properly invoke the listenToOnce with this set to the Mediator event object', function() { + it('should properly invoke the listenToOnce with this set to the Mediator event object', function () { function testCall() { mediator._registerOneTimeEventListener(event, kolibriModule, method); } expect(testCall).not.toThrow(); }); }); - describe('_registerEventListener method', function() { + describe('_registerEventListener method', function () { let spy, event, method; - beforeEach(function() { + beforeEach(function () { spy = jest.fn(); event = 'event'; kolibriModule = { name: 'test' }; method = 'method'; mediator._registerEventListener(event, kolibriModule, method, spy); }); - it('should put a callback in the callback registry', function() { + it('should put a callback in the callback registry', function () { expect(mediator._callbackRegistry.test.event.method).toBeInstanceOf(Function); }); - it('should call listen method', function() { + it('should call listen method', function () { expect(spy).toHaveBeenCalled(); }); - it('should pass at least one arg to listen method', function() { + it('should pass at least one arg to listen method', function () { expect(spy).toHaveBeenCalledWith(event, expect.any(Function)); }); }); - describe('stopListening method', function() { + describe('stopListening method', function () { let stub, event, method; - beforeEach(function() { + beforeEach(function () { stub = jest.spyOn(mediator._eventDispatcher, '$off'); event = 'event'; kolibriModule = { name: 'test' }; method = 'method'; }); - afterEach(function() { + afterEach(function () { stub.mockRestore(); }); - describe('when no callback registered', function() { - it('should not call stopListening when no callback registered', function() { + describe('when no callback registered', function () { + it('should not call stopListening when no callback registered', function () { mediator.stopListening(event, kolibriModule, method); expect(stub).not.toHaveBeenCalled(); }); }); - describe('when callback is registered', function() { + describe('when callback is registered', function () { let callback; - beforeEach(function() { - callback = function() {}; + beforeEach(function () { + callback = function () {}; const obj = {}; mediator._callbackRegistry[kolibriModule.name] = obj; obj[event] = {}; obj[event][method] = callback; mediator.stopListening(event, kolibriModule, method); }); - it('should call $off', function() { + it('should call $off', function () { expect(stub).toHaveBeenCalled(); }); - it('should pass two args to $off method', function() { + it('should pass two args to $off method', function () { expect(stub).toHaveBeenCalledWith(event, callback); }); - it('should remove the callback from the registry', function() { + it('should remove the callback from the registry', function () { const registry = mediator._callbackRegistry; const callback = registry[kolibriModule.name][event][method]; expect(typeof callback === 'undefined').toEqual(true); }); }); }); - describe('_executeCallbackBuffer method', function() { + describe('_executeCallbackBuffer method', function () { let spy, args; - beforeEach(function() { + beforeEach(function () { spy = jest.fn(); kolibriModule = { name: 'test', @@ -429,19 +429,19 @@ describe('Mediator', function() { ]; mediator._executeCallbackBuffer(kolibriModule); }); - it('should call the callback ', function() { + it('should call the callback ', function () { expect(spy).toHaveBeenCalled(); }); - it('should pass the args to the callback ', function() { + it('should pass the args to the callback ', function () { expect(spy).toHaveBeenLastCalledWith(...args); }); - it('should remove the entry from callback registry', function() { + it('should remove the entry from callback registry', function () { expect(typeof mediator._callbackBuffer.test === 'undefined').toEqual(true); }); }); - describe('registerKolibriModuleAsync method', function() { + describe('registerKolibriModuleAsync method', function () { let stub; - beforeEach(function() { + beforeEach(function () { const kolibriModuleUrls = ['test.js', 'test1.js']; const events = { event: 'method', @@ -452,49 +452,49 @@ describe('Mediator', function() { stub = jest.spyOn(mediator._eventDispatcher, '$on'); mediator.registerKolibriModuleAsync(kolibriModuleName, kolibriModuleUrls, events, once); }); - afterEach(function() { + afterEach(function () { stub.mockRestore(); }); - it('should add create a callback buffer for the kolibriModule', function() { + it('should add create a callback buffer for the kolibriModule', function () { expect(typeof mediator._callbackBuffer[kolibriModuleName] !== 'undefined').toEqual(true); }); - it('should put two entries in the async callback registry', function() { + it('should put two entries in the async callback registry', function () { expect(mediator._asyncCallbackRegistry[kolibriModuleName].length).toEqual(2); }); - it('should put a callback in each entry in the async callback registry', function() { + it('should put a callback in each entry in the async callback registry', function () { const registry = mediator._asyncCallbackRegistry; expect(registry[kolibriModuleName][0].callback).toBeInstanceOf(Function); expect(registry[kolibriModuleName][1].callback).toBeInstanceOf(Function); }); - it('should call $on twice', function() { + it('should call $on twice', function () { expect(stub).toHaveBeenCalledTimes(2); }); - it('should pass both events to $on', function() { + it('should pass both events to $on', function () { expect(stub).toHaveBeenCalledWith('event', expect.any(Function)); expect(stub).toHaveBeenCalledWith('once', expect.any(Function)); }); - describe('async callbacks', function() { + describe('async callbacks', function () { let args; - beforeEach(function() { + beforeEach(function () { args = ['this', 'that']; mediator._asyncCallbackRegistry[kolibriModuleName][0].callback(...args); }); - it('should add an entry to the callback buffer when called', function() { + it('should add an entry to the callback buffer when called', function () { expect(mediator._callbackBuffer[kolibriModuleName].length).toEqual(1); }); - it('should add args in the callback buffer when called', function() { + it('should add args in the callback buffer when called', function () { expect(mediator._callbackBuffer[kolibriModuleName][0].args).toEqual(args); }); }); }); - describe('_clearAsyncCallbacks method', function() { + describe('_clearAsyncCallbacks method', function () { let event, stub, callback; - beforeEach(function() { + beforeEach(function () { kolibriModule = { name: 'test', }; event = 'event'; - callback = function() {}; + callback = function () {}; mediator._asyncCallbackRegistry[kolibriModule.name] = [ { event: event, @@ -504,34 +504,34 @@ describe('Mediator', function() { stub = jest.spyOn(mediator._eventDispatcher, '$off'); mediator._clearAsyncCallbacks(kolibriModule); }); - afterEach(function() { + afterEach(function () { stub.mockRestore(); }); - it('should clear the callbacks', function() { + it('should clear the callbacks', function () { expect(typeof mediator._asyncCallbackRegistry[kolibriModule.name] === 'undefined').toEqual( - true + true, ); }); - it('should call $off once', function() { + it('should call $off once', function () { expect(stub).toHaveBeenCalledTimes(1); }); - it('should call $off with two args', function() { + it('should call $off with two args', function () { expect(stub).toHaveBeenCalledWith(event, callback); }); }); - describe('emit method', function() { + describe('emit method', function () { let stub; - beforeEach(function() { + beforeEach(function () { stub = jest.spyOn(mediator._eventDispatcher, '$emit'); }); - afterEach(function() { + afterEach(function () { mediator._eventDispatcher.$emit.mockRestore(); }); - it('should call the event dispatcher $emit', function() { + it('should call the event dispatcher $emit', function () { mediator.emit('yo'); expect(stub).toHaveBeenCalled(); }); - it('should proxy all arguments to the event dispatcher $emit', function() { + it('should proxy all arguments to the event dispatcher $emit', function () { const arg1 = 'this'; const arg2 = 'that'; const arg3 = ['four']; @@ -539,25 +539,25 @@ describe('Mediator', function() { expect(stub).toHaveBeenCalledWith(arg1, arg2, arg3); }); }); - describe('registerLanguageAssets method', function() { + describe('registerLanguageAssets method', function () { const moduleName = 'test'; const language = 'test_lang'; const messageMap = { test: 'test message', }; let spy; - beforeEach(function() { + beforeEach(function () { Vue.registerMessages = jest.fn(); spy = Vue.registerMessages; }); - afterEach(function() { + afterEach(function () { spy.mockRestore(); }); - it('should call Vue.registerMessages once', function() { + it('should call Vue.registerMessages once', function () { mediator.registerLanguageAssets(moduleName, language, messageMap); expect(spy).toHaveBeenCalledTimes(1); }); - it('should call Vue.registerMessages with arguments language and messageMap', function() { + it('should call Vue.registerMessages with arguments language and messageMap', function () { mediator.registerLanguageAssets(moduleName, language, messageMap); expect(spy).toHaveBeenCalledWith(language, messageMap); }); diff --git a/kolibri/core/assets/src/core-app/baseClient.js b/kolibri/core/assets/src/core-app/baseClient.js index 27b92c6a940..cd654951481 100644 --- a/kolibri/core/assets/src/core-app/baseClient.js +++ b/kolibri/core/assets/src/core-app/baseClient.js @@ -11,7 +11,7 @@ export default function clientFactory(options) { xsrfCookieName: 'kolibri_csrftoken', xsrfHeaderName: 'X-CSRFToken', paramsSerializer: { - serialize: function(params) { + serialize: function (params) { // Do custom querystring stingifying to comma separate array params return qs.stringify(params, { arrayFormat: 'comma' }); }, @@ -20,7 +20,7 @@ export default function clientFactory(options) { }); client.interceptors.response.use( response => response, - function(error) { + function (error) { if (!error) { error = {}; } @@ -30,7 +30,7 @@ export default function clientFactory(options) { }; } return Promise.reject(error); - } + }, ); return client; } diff --git a/kolibri/core/assets/src/core-app/client.js b/kolibri/core/assets/src/core-app/client.js index 7515e6b8ca1..3355258c4f5 100644 --- a/kolibri/core/assets/src/core-app/client.js +++ b/kolibri/core/assets/src/core-app/client.js @@ -15,7 +15,7 @@ export const logging = logger.getLogger(__filename); const baseClient = clientFactory(); // Disconnection handler interceptor -baseClient.interceptors.request.use(function(config) { +baseClient.interceptors.request.use(function (config) { if (!store.getters.connected) { // If the vuex state records that we are not currently connected then cancel all // outgoing requests. @@ -29,7 +29,7 @@ baseClient.interceptors.request.use(function(config) { // Login timeout detection interceptor and disconnection monitoring baseClient.interceptors.response.use( response => response, - function(error) { + function (error) { // If we receive a 403 response from the server, it is possible that the user // is attempting to access information they are not allowed to see. // However, more likely, it is because their login has timed out, but the frontend @@ -55,7 +55,7 @@ baseClient.interceptors.response.use( } } return Promise.reject(error); - } + }, ); const client = options => { @@ -80,14 +80,14 @@ const client = options => { if (typeof options === 'string') { options = { url: options }; logging.warn( - 'passing the URL as the only argument is deprecated, please use url option instead' + 'passing the URL as the only argument is deprecated, please use url option instead', ); } const headers = { ...(options.headers || {}), 'X-Requested-With': 'XMLHttpRequest' }; if (options.multipart) { headers['Content-Type'] = 'multipart/form-data'; - options.transformRequest = function(data) { + options.transformRequest = function (data) { const fd = new FormData(); Object.keys(data).forEach(item => { fd.append(item, data[item]); @@ -104,7 +104,7 @@ const client = options => { Object.defineProperty(response, 'entity', { get() { logging.warn( - 'entity is deprecated for accessing response data, please use the data key instead' + 'entity is deprecated for accessing response data, please use the data key instead', ); return response.data; }, diff --git a/kolibri/core/assets/src/core-app/index.js b/kolibri/core/assets/src/core-app/index.js index 10e451939c4..c3f76a9d965 100644 --- a/kolibri/core/assets/src/core-app/index.js +++ b/kolibri/core/assets/src/core-app/index.js @@ -49,7 +49,7 @@ setupPluginMediator(coreApp); initializeTheme(); // monitor page visibility -document.addEventListener('visibilitychange', function() { +document.addEventListener('visibilitychange', function () { store.dispatch('setPageVisibility'); }); diff --git a/kolibri/core/assets/src/core-app/pluginMediator.js b/kolibri/core/assets/src/core-app/pluginMediator.js index 7dbfa0fdbc6..abba184b664 100644 --- a/kolibri/core/assets/src/core-app/pluginMediator.js +++ b/kolibri/core/assets/src/core-app/pluginMediator.js @@ -464,7 +464,7 @@ export default function pluginMediatorFactory(facade) { url.includes(languageDirections.RTL)) || (languageDirection === languageDirections.LTR && !url.includes(languageDirections.RTL)) || - !url.endsWith('css') + !url.endsWith('css'), ); Promise.all(urls.map(scriptLoader)) // Load all the urls that we just filtered (all the javascript @@ -486,7 +486,7 @@ export default function pluginMediatorFactory(facade) { if (this._kolibriModuleRegistry[kolibriModuleName]) { storeTags(this._kolibriModuleRegistry[kolibriModuleName]); resolve( - mergeMixin(this._kolibriModuleRegistry[kolibriModuleName].rendererComponent) + mergeMixin(this._kolibriModuleRegistry[kolibriModuleName].rendererComponent), ); } else { // Or wait until the module has been registered @@ -494,7 +494,7 @@ export default function pluginMediatorFactory(facade) { if (moduleName === kolibriModuleName) { storeTags(this._kolibriModuleRegistry[kolibriModuleName]); resolve( - mergeMixin(this._kolibriModuleRegistry[kolibriModuleName].rendererComponent) + mergeMixin(this._kolibriModuleRegistry[kolibriModuleName].rendererComponent), ); } }); @@ -528,7 +528,7 @@ export default function pluginMediatorFactory(facade) { (direction === languageDirections.RTL && url.includes(languageDirections.RTL)) || (direction === languageDirections.LTR && !url.includes(languageDirections.RTL) && - url.endsWith('css')) + url.endsWith('css')), ); // Find the URL for the direction not specified const otherCssUrl = urls.find( @@ -536,7 +536,7 @@ export default function pluginMediatorFactory(facade) { (direction !== languageDirections.RTL && url.includes(languageDirections.RTL)) || (direction !== languageDirections.LTR && !url.includes(languageDirections.RTL) && - url.endsWith('css')) + url.endsWith('css')), ); if (!cssUrl || contentRendererModule.urlTags[cssUrl]) { // There is no css file to try to load or diff --git a/kolibri/core/assets/src/exams/utils.js b/kolibri/core/assets/src/exams/utils.js index 0a164939e04..3ce86f6da7f 100644 --- a/kolibri/core/assets/src/exams/utils.js +++ b/kolibri/core/assets/src/exams/utils.js @@ -41,9 +41,9 @@ function convertExamQuestionSourcesV0V2(questionSources, seed, questionIds) { exercise_id: val.exercise_id, title: val.title, questionNumber, - })) + })), ), - [] + [], ); const shuffledExamQuestions = seededShuffle(examQuestions, seed); const shuffledExerciseQuestions = {}; @@ -56,7 +56,7 @@ function convertExamQuestionSourcesV0V2(questionSources, seed, questionIds) { title: question.title, counter_in_exercise: questionIds[question.exercise_id].findIndex( - id => id === shuffledExerciseQuestions[question.exercise_id][question.questionNumber] + id => id === shuffledExerciseQuestions[question.exercise_id][question.questionNumber], ) + 1, })); } @@ -151,7 +151,7 @@ export async function convertExamQuestionSources(exam) { exam.question_sources = convertExamQuestionSourcesV0V2( exam.question_sources, exam.seed, - questionIds + questionIds, ); // v1 -> v2 only updates the `counter_in_exercise` field if it's in camelCase // so we can set the data_model_version to 2 here to skip that code @@ -187,7 +187,7 @@ export async function fetchExamWithContent(exam) { exam.question_sources.reduce((acc, section) => { acc = [...acc, ...section.questions.map(item => item.exercise_id)]; return acc; - }, []) + }, []), ); return ContentNodeResource.fetchCollection({ diff --git a/kolibri/core/assets/src/heartbeat.js b/kolibri/core/assets/src/heartbeat.js index 7f1171df6be..9c78fe954c8 100644 --- a/kolibri/core/assets/src/heartbeat.js +++ b/kolibri/core/assets/src/heartbeat.js @@ -55,7 +55,7 @@ export class HeartBeat { this._client = clientFactory(); // Define an interceptor to monitor the response that gets returned. this._client.interceptors.response.use( - function(response) { + function (response) { // If the response does not have one of the disconnect error codes // then we have reconnected. if (!store.getters.connected && !errorCodes.includes(response.status)) { @@ -65,7 +65,7 @@ export class HeartBeat { } return response; }, - function(error) { + function (error) { const { connected, reconnectTime } = store.getters; if (!connected) { // If the response does not have one of the disconnect error codes @@ -84,12 +84,12 @@ export class HeartBeat { store.commit( 'CORE_SET_RECONNECT_TIME', // Multiply the previous interval by our multiplier, but max out at a high interval. - Math.min(RECONNECT_MULTIPLIER * reconnect, MAX_RECONNECT_TIME) + Math.min(RECONNECT_MULTIPLIER * reconnect, MAX_RECONNECT_TIME), ); createDisconnectedSnackbar(store, heartbeat.pollSessionEndPoint); } return Promise.reject(error); - } + }, ); } startPolling() { diff --git a/kolibri/core/assets/src/kolibri_app.js b/kolibri/core/assets/src/kolibri_app.js index 44f60b9bd9f..70ec3c7eb17 100644 --- a/kolibri/core/assets/src/kolibri_app.js +++ b/kolibri/core/assets/src/kolibri_app.js @@ -96,8 +96,8 @@ export default class KolibriApp extends KolibriModule { store: store, router: router.initRoutes(this.routes), }, - this.RootVue - ) + this.RootVue, + ), ); } diff --git a/kolibri/core/assets/src/logging.js b/kolibri/core/assets/src/logging.js index 801a1bdc4f4..902174e19d1 100644 --- a/kolibri/core/assets/src/logging.js +++ b/kolibri/core/assets/src/logging.js @@ -23,9 +23,9 @@ class Logger { setMessagePrefix() { var originalFactory = this.logger.methodFactory; - this.logger.methodFactory = function(methodName, logLevel, loggerName) { + this.logger.methodFactory = function (methodName, logLevel, loggerName) { var rawMethod = originalFactory(methodName, logLevel, loggerName); - return function(message) { + return function (message) { rawMethod(`[${methodName.toUpperCase()}: ${loggerName}] ` + message); }; }; @@ -75,7 +75,7 @@ class Logging { if (!loggerName) { loglevel[methodName](...args); Object.keys(this.registeredLoggers).forEach(name => - this.registeredLoggers[name][methodName](...args) + this.registeredLoggers[name][methodName](...args), ); } else { this.registeredLoggers[loggerName][methodName](...args); diff --git a/kolibri/core/assets/src/mixins/__test__/notificationStrings.spec.js b/kolibri/core/assets/src/mixins/__test__/notificationStrings.spec.js index 48b0c57e661..f0db1b66c67 100644 --- a/kolibri/core/assets/src/mixins/__test__/notificationStrings.spec.js +++ b/kolibri/core/assets/src/mixins/__test__/notificationStrings.spec.js @@ -19,7 +19,7 @@ describe('Coach Notification Strings', () => { (key, expectedPlural, expectedSingular) => { expect(NotificationStrings.$tr(key, { count: 10 })).toEqual(expectedPlural); expect(NotificationStrings.$tr(key, { count: 1 })).toEqual(expectedSingular); - } + }, ); // Test that the rest of the messages don't need paramaters diff --git a/kolibri/core/assets/src/mixins/commonCoreStrings.js b/kolibri/core/assets/src/mixins/commonCoreStrings.js index a13fff1b6e7..a05091a5154 100644 --- a/kolibri/core/assets/src/mixins/commonCoreStrings.js +++ b/kolibri/core/assets/src/mixins/commonCoreStrings.js @@ -1567,8 +1567,8 @@ const MetadataLookup = invert( METADATA.ContentLevels, METADATA.ContentNodeResourceType, METADATA.LearningActivities, - METADATA.ResourcesNeededTypes - ) + METADATA.ResourcesNeededTypes, + ), ); /** diff --git a/kolibri/core/assets/src/router.js b/kolibri/core/assets/src/router.js index 62c6df4010d..4c1a1c5d281 100644 --- a/kolibri/core/assets/src/router.js +++ b/kolibri/core/assets/src/router.js @@ -27,7 +27,7 @@ class Router { nextCalled = true; } else { logging.warn( - 'next() called multiple times - this may happen if you are invoking next() in an asynchronous handler' + 'next() called multiple times - this may happen if you are invoking next() in an asynchronous handler', ); } }; diff --git a/kolibri/core/assets/src/state/modules/core/actions.js b/kolibri/core/assets/src/state/modules/core/actions.js index 3eaf813ae48..c7a07b3fb02 100644 --- a/kolibri/core/assets/src/state/modules/core/actions.js +++ b/kolibri/core/assets/src/state/modules/core/actions.js @@ -261,7 +261,7 @@ export function setChannelInfo(store) { error => { store.dispatch('handleApiError', { error }); return error; - } + }, ); } @@ -314,7 +314,7 @@ export function fetchUserSyncStatus(store, params) { error => { store.dispatch('handleApiError', { error }); return error; - } + }, ); } // for fetching an individual user @@ -329,7 +329,7 @@ export function fetchUserSyncStatus(store, params) { error => { store.dispatch('handleApiError', { error }); return error; - } + }, ); } } diff --git a/kolibri/core/assets/src/utils/__test__/generateNavRoutes.spec.js b/kolibri/core/assets/src/utils/__test__/generateNavRoutes.spec.js index 0b7a04a7e77..5a82c483ea9 100644 --- a/kolibri/core/assets/src/utils/__test__/generateNavRoutes.spec.js +++ b/kolibri/core/assets/src/utils/__test__/generateNavRoutes.spec.js @@ -3,37 +3,37 @@ import { generateNavRoute } from '../generateNavRoutes'; describe('generateNavRoutes utility', () => { it('formats correctly for path with 1 required param', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id/classes', { facility_id: 109000000 }) + generateNavRoute('/en/facility/', '/:facility_id/classes', { facility_id: 109000000 }), ).toEqual('/en/facility/#/109000000/classes'); }); it('formats correctly for path with required param not provided', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id/classes', { facility_id: undefined }) + generateNavRoute('/en/facility/', '/:facility_id/classes', { facility_id: undefined }), ).toEqual('/en/facility/'); }); it('formats correctly for path with 1 optional param', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id?/classes', { facility_id: 109099999 }) + generateNavRoute('/en/facility/', '/:facility_id?/classes', { facility_id: 109099999 }), ).toEqual('/en/facility/#/109099999/classes'); }); it('formats correctly for path with optional param not provided', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id?/classes', { facility_id: undefined }) + generateNavRoute('/en/facility/', '/:facility_id?/classes', { facility_id: undefined }), ).toEqual('/en/facility/#/classes'); }); it('formats correctly for path with required param when wrong param provided', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id/classes', { device_id: 900034 }) + generateNavRoute('/en/facility/', '/:facility_id/classes', { device_id: 900034 }), ).toEqual('/en/facility/'); }); it('formats correctly for path with optional param when wrong param provided', () => { expect( - generateNavRoute('/en/facility/', '/:facility_id?/classes', { device_id: 900034 }) + generateNavRoute('/en/facility/', '/:facility_id?/classes', { device_id: 900034 }), ).toEqual('/en/facility/#/classes'); }); }); diff --git a/kolibri/core/assets/src/utils/i18n.js b/kolibri/core/assets/src/utils/i18n.js index 0e577f14546..d6a227eac09 100644 --- a/kolibri/core/assets/src/utils/i18n.js +++ b/kolibri/core/assets/src/utils/i18n.js @@ -165,7 +165,7 @@ class Translator { this._defaultMessages, Vue.prototype.$formatMessage, messageId, - args + args, ); } // For convenience, also proxy all vue intl translation methods on this object @@ -255,7 +255,7 @@ export function i18nSetup(skipPolyfill = false) { require => { res(() => require('intl')); }, - 'intl' + 'intl', ); }), importIntlLocale(currentLanguage), @@ -271,7 +271,7 @@ export function i18nSetup(skipPolyfill = false) { logging.error(error); logging.error('An error occurred trying to setup Internationalization', error); reject(); - } + }, ); } }); diff --git a/kolibri/core/assets/src/utils/intl-locale-data.js b/kolibri/core/assets/src/utils/intl-locale-data.js index acc96761de5..48252e82924 100644 --- a/kolibri/core/assets/src/utils/intl-locale-data.js +++ b/kolibri/core/assets/src/utils/intl-locale-data.js @@ -8,203 +8,203 @@ * * vue-intl and intl npm packages must both be installed for this module to function. */ -module.exports = function(locale) { +module.exports = function (locale) { switch (locale) { case 'ar': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ar.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ar.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ar.js')); }); }); case 'bg-bg': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/bg-BG.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/bg-BG.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/bg-BG.js')); }); }); case 'bn-bd': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/bn-BD.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/bn-BD.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/bn-BD.js')); }); }); case 'de': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/de.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/de.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/de.js')); }); }); case 'el': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/el.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/el.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/el.js')); }); }); case 'en': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/en.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/en.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/en.js')); }); }); case 'es-es': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/es-ES.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/es-ES.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/es-ES.js')); }); }); case 'es-419': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/es-419.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/es-419.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/es-419.js')); }); }); case 'fa': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/fa.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/fa.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/fa.js')); }); }); case 'fr-fr': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/fr-FR.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/fr-FR.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/fr-FR.js')); }); }); case 'ff-cm': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ff-CM.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ff-CM.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ff-CM.js')); }); }); case 'gu-in': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/gu-IN.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/gu-IN.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/gu-IN.js')); }); }); case 'ha': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ha.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ha.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ha.js')); }); }); case 'hi-in': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/hi-IN.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/hi-IN.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/hi-IN.js')); }); }); case 'ht': - return new Promise(function(resolve) { - require.ensure(['kolibri-tools/lib/i18n/locale-data/intl/ht.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['kolibri-tools/lib/i18n/locale-data/intl/ht.js'], function (require) { resolve(() => require('kolibri-tools/lib/i18n/locale-data/intl/ht.js')); }); }); case 'id': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/id.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/id.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/id.js')); }); }); case 'it': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/it.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/it.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/it.js')); }); }); case 'ka': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ka.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ka.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ka.js')); }); }); case 'km': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/km.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/km.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/km.js')); }); }); case 'ko': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ko.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ko.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ko.js')); }); }); case 'mr': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/mr.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/mr.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/mr.js')); }); }); case 'my': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/my.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/my.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/my.js')); }); }); case 'ny': - return new Promise(function(resolve) { - require.ensure(['kolibri-tools/lib/i18n/locale-data/intl/ny.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['kolibri-tools/lib/i18n/locale-data/intl/ny.js'], function (require) { resolve(() => require('kolibri-tools/lib/i18n/locale-data/intl/ny.js')); }); }); case 'pt-br': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/pt-BR.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/pt-BR.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/pt-BR.js')); }); }); case 'pt-mz': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/pt-MZ.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/pt-MZ.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/pt-MZ.js')); }); }); case 'sw-tz': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/sw-TZ.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/sw-TZ.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/sw-TZ.js')); }); }); case 'te': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/te.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/te.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/te.js')); }); }); case 'uk': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/uk.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/uk.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/uk.js')); }); }); case 'ur-pk': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/ur-PK.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/ur-PK.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/ur-PK.js')); }); }); case 'vi': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/vi.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/vi.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/vi.js')); }); }); case 'yo': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/yo.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/yo.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/yo.js')); }); }); case 'zh-hans': - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/zh-Hans.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/zh-Hans.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/zh-Hans.js')); }); }); default: - return new Promise(function(resolve) { - require.ensure(['intl/locale-data/jsonp/en.js'], function(require) { + return new Promise(function (resolve) { + require.ensure(['intl/locale-data/jsonp/en.js'], function (require) { resolve(() => require('intl/locale-data/jsonp/en.js')); }); }); diff --git a/kolibri/core/assets/src/utils/licenseTranslations.js b/kolibri/core/assets/src/utils/licenseTranslations.js index 5f3af8a1cf1..d6114b875fe 100644 --- a/kolibri/core/assets/src/utils/licenseTranslations.js +++ b/kolibri/core/assets/src/utils/licenseTranslations.js @@ -211,11 +211,11 @@ const shortNameTranslator = createTranslator('ShortLicenseNames', licenseShortNa const longNameTranslator = createTranslator('LongLicenseNames', licenseLongNameStrings); const creatorDescriptionTranslator = createTranslator( 'LicenseDescriptionsForCreators', - licenseDescriptionCreatorStrings + licenseDescriptionCreatorStrings, ); const consumerDescriptionTranslator = createTranslator( 'LicenseDescriptionsForConsumers', - licenseDescriptionConsumerStrings + licenseDescriptionConsumerStrings, ); // Translated short-form license names diff --git a/kolibri/core/assets/src/utils/setupAndLoadFonts.js b/kolibri/core/assets/src/utils/setupAndLoadFonts.js index 1380acd28cc..25702caa65e 100644 --- a/kolibri/core/assets/src/utils/setupAndLoadFonts.js +++ b/kolibri/core/assets/src/utils/setupAndLoadFonts.js @@ -61,12 +61,12 @@ function loadFullFontsProgressively() { // passing the language name to 'load' for its glyphs, not its value per se const string = availableLanguages[currentLanguage].lang_name; Promise.all([uiNormal.load(string, 20000), uiBold.load(string, 20000)]) - .then(function() { + .then(function () { htmlEl.classList.remove(PARTIAL_FONTS); htmlEl.classList.add(FULL_FONTS); logging.debug(`Loaded full font for '${currentLanguage}'`); }) - .catch(function() { + .catch(function () { logging.warn(`Could not load full font for '${currentLanguage}'`); }); } diff --git a/kolibri/core/assets/src/utils/shuffled.js b/kolibri/core/assets/src/utils/shuffled.js index 4df5ec8e1a1..c1aa4812ade 100644 --- a/kolibri/core/assets/src/utils/shuffled.js +++ b/kolibri/core/assets/src/utils/shuffled.js @@ -2,7 +2,7 @@ import shuffle from 'knuth-shuffle-seeded'; // Returns a shuffled copy of the array. // If no seed is given, chooses one randomly. -export default function(arr, seed = undefined) { +export default function (arr, seed = undefined) { if (seed === undefined) { return shuffle(arr.slice(0), Math.random()); } diff --git a/kolibri/core/assets/src/utils/syncTaskUtils.js b/kolibri/core/assets/src/utils/syncTaskUtils.js index 3cf3dea0748..048484db604 100644 --- a/kolibri/core/assets/src/utils/syncTaskUtils.js +++ b/kolibri/core/assets/src/utils/syncTaskUtils.js @@ -121,7 +121,7 @@ export function syncFacilityTaskDisplayInfo(task) { } else if (task.extra_metadata.device_name) { deviceNameMsg = formatNameWithId( task.extra_metadata.device_name, - task.extra_metadata.device_id + task.extra_metadata.device_id, ); } const syncStep = syncTaskStatusToStepMap[task.extra_metadata.sync_state]; @@ -177,7 +177,7 @@ export const removeStatusToDescriptionMap = { export function removeFacilityTaskDisplayInfo(task) { const facilityName = formatNameWithId( task.extra_metadata.facility_name, - task.extra_metadata.facility + task.extra_metadata.facility, ); const statusDescription = removeStatusToDescriptionMap[task.status]() || getTaskString('taskUnknownStatus'); diff --git a/kolibri/core/assets/src/utils/vue-intl-locale-data.js b/kolibri/core/assets/src/utils/vue-intl-locale-data.js index 52af39d846e..3293ca18506 100644 --- a/kolibri/core/assets/src/utils/vue-intl-locale-data.js +++ b/kolibri/core/assets/src/utils/vue-intl-locale-data.js @@ -8,7 +8,7 @@ * * vue-intl and intl npm packages must both be installed for this module to function. */ -module.exports = function() { +module.exports = function () { const data = []; data.push(require('vue-intl/locale-data/ar.js')); data.push(require('vue-intl/locale-data/bg.js')); diff --git a/kolibri/core/assets/src/views/AppBar.vue b/kolibri/core/assets/src/views/AppBar.vue index d6dc1cc6a72..d379b5c5903 100644 --- a/kolibri/core/assets/src/views/AppBar.vue +++ b/kolibri/core/assets/src/views/AppBar.vue @@ -4,7 +4,6 @@ v-show="!$isPrint" :style="{ backgroundColor: $themeTokens.appBar }" > -
@@ -67,7 +66,10 @@ :ariaLabel="$tr('pointsAriaLabel')" :color="$themeTokens.primary" /> -
+
{{ $formatNumber(totalPoints) }}
-
diff --git a/kolibri/core/assets/src/views/AttemptLogItem.vue b/kolibri/core/assets/src/views/AttemptLogItem.vue index 745f55a3f50..e61b7179733 100644 --- a/kolibri/core/assets/src/views/AttemptLogItem.vue +++ b/kolibri/core/assets/src/views/AttemptLogItem.vue @@ -1,12 +1,11 @@