Skip to content

Commit

Permalink
fix: Update to eslint9
Browse files Browse the repository at this point in the history
  • Loading branch information
GZolla authored Nov 25, 2024
2 parents 688a0fd + 02500ee commit 8bf1041
Show file tree
Hide file tree
Showing 8 changed files with 1,027 additions and 589 deletions.
21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { addExtensions, browserConfig, setDirectoryConfigs, testingConfig } from 'eslint-config-brightspace';

export default [
...addExtensions(setDirectoryConfigs(
browserConfig,
{
'test': testingConfig
}
), ['js']),
{
files: ['helpers/getLocalizeResources.js'],

rules: {
'no-console': 0,
},
},
{
files: ['lang/*.js'],
rules: {
'quotes': 0
}
}
];
2 changes: 1 addition & 1 deletion helpers/getLocalizeResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async function shouldUseBatchFetch() {
// subsequent page navigation.

return Boolean(documentLocaleSettings.oslo.batch) && 'CacheStorage' in window;
} catch (err) {
} catch {
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/PluralRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ class PluralRules extends Intl.PluralRules {
this.#localeData = localeData[this.#locale];
}
}

resolvedOptions() {
return { ...super.resolvedOptions(), ...this.#localeData?.options[this.#type] };
}

select(n) {
if (this.#localeData) {
return this.#localeData.select(n, this.#type === 'ordinal');
Expand Down
2 changes: 1 addition & 1 deletion lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class DocumentLocaleSettings {
if (this._htmlElem.hasAttribute(attrName)) {
try {
return JSON.parse(this._htmlElem.getAttribute(attrName));
} catch (e) {
} catch {
// swallow exception
}
}
Expand Down
7 changes: 0 additions & 7 deletions lib/localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const noAllowedTagsRegex = getDisallowedTagsRegex([]);
export const getLocalizeClass = (superclass = class {}) => class LocalizeClass extends superclass {

static documentLocaleSettings = getDocumentLocaleSettings();

static setLocalizeMarkup(localizeMarkup) {
this.#localizeMarkup ??= localizeMarkup;
}
Expand All @@ -48,12 +47,10 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
this.#connected = true;
this.#localeChangeCallback();
}

disconnect() {
LocalizeClass.documentLocaleSettings.removeChangeListener(this.#localeChangeCallback);
this.#connected = false;
}

localize(name, replacements) {

const { language, value } = this.localize.resources?.[name] ?? {};
Expand Down Expand Up @@ -132,7 +129,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
#resourcesPromise;

__resourcesLoadedPromise = new Promise(r => this.#resolveResourcesLoaded = r);

static _generatePossibleLanguages(config) {

if (config?.useBrowserLangs) return navigator.languages.map(e => e.toLowerCase()).concat('en');
Expand All @@ -145,7 +141,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e

return Array.from(new Set([ ...langs, 'en-us', 'en' ]));
}

static _getAllLocalizeResources(config = this.localizeConfig) {
const resourcesLoadedPromises = [];
const superCtor = Object.getPrototypeOf(this);
Expand All @@ -172,7 +167,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
}
return Promise.all(resourcesLoadedPromises);
}

static async _getLocalizeResources(langs, { importFunc, osloCollection, useBrowserLangs }) {

if (importFunc === undefined) return;
Expand Down Expand Up @@ -203,7 +197,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
}
}
}

_hasResources() {
if (this.constructor.localizeConfig) {
return this.constructor.localizeConfig !== undefined ||
Expand Down
Loading

0 comments on commit 8bf1041

Please sign in to comment.